From e672e0d456e016d12fce489940d88220ee5e2b9a Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Fri, 23 Dec 2016 14:47:45 +0100 Subject: [PATCH 001/116] Turn "label: goto label;" or "while(cond);" into assume This pattern occurs in some SV-COMP benchmarks, but may also appear as busy-wait loops in realistic systems. --- src/goto-symex/symex_goto.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/goto-symex/symex_goto.cpp b/src/goto-symex/symex_goto.cpp index 17149677965..dd31349024c 100644 --- a/src/goto-symex/symex_goto.cpp +++ b/src/goto-symex/symex_goto.cpp @@ -68,6 +68,27 @@ void goto_symext::symex_goto(statet &state) if(!forward) // backwards? { + // is it label: goto label; or while(cond); - popular in SV-COMP + if(goto_target==state.source.pc || + (instruction.incoming_edges.size()==1 && + *instruction.incoming_edges.begin()==goto_target)) + { + // generate assume(false) or a suitable negation if this + // instruction is a conditional goto + exprt negated_cond; + + if(new_guard.is_true()) + negated_cond=false_exprt(); + else + negated_cond=not_exprt(new_guard); + + symex_assume(state, negated_cond); + + // next instruction + state.source.pc++; + return; + } + unsigned &unwind= frame.loop_iterations[goto_programt::loop_id(state.source.pc)].count; unwind++; From 27ba5d5b8f456a46dd3790dbeaa50f97bacc87b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20G=C3=BCdemann?= Date: Wed, 15 Mar 2017 12:57:13 +0100 Subject: [PATCH 002/116] support class file loading limit in classpath --- src/java_bytecode/Makefile | 2 +- src/java_bytecode/jar_file.cpp | 40 ++------- src/java_bytecode/jar_file.h | 17 ++-- src/java_bytecode/java_bytecode_language.cpp | 9 ++- src/java_bytecode/java_class_loader.cpp | 52 +++++++++--- src/java_bytecode/java_class_loader.h | 17 ++-- src/java_bytecode/java_class_loader_limit.cpp | 81 +++++++++++++++++++ src/java_bytecode/java_class_loader_limit.h | 38 +++++++++ 8 files changed, 188 insertions(+), 68 deletions(-) create mode 100644 src/java_bytecode/java_class_loader_limit.cpp create mode 100644 src/java_bytecode/java_class_loader_limit.h diff --git a/src/java_bytecode/Makefile b/src/java_bytecode/Makefile index 20958a3ede3..d5d427747c2 100644 --- a/src/java_bytecode/Makefile +++ b/src/java_bytecode/Makefile @@ -6,7 +6,7 @@ SRC = java_bytecode_language.cpp java_bytecode_parse_tree.cpp \ java_root_class.cpp java_bytecode_parser.cpp bytecode_info.cpp \ java_class_loader.cpp jar_file.cpp java_object_factory.cpp \ java_bytecode_convert_method.cpp java_local_variable_table.cpp \ - java_pointer_casts.cpp java_utils.cpp + java_pointer_casts.cpp java_utils.cpp java_class_loader_limit.cpp INCLUDES= -I .. diff --git a/src/java_bytecode/jar_file.cpp b/src/java_bytecode/jar_file.cpp index 07d7719e500..ee08a50838a 100644 --- a/src/java_bytecode/jar_file.cpp +++ b/src/java_bytecode/jar_file.cpp @@ -12,7 +12,9 @@ Author: Daniel Kroening, kroening@kroening.com #include #include + #include "jar_file.h" + /*******************************************************************\ Function: jar_filet::open @@ -26,7 +28,7 @@ Function: jar_filet::open \*******************************************************************/ void jar_filet::open( - std::string &java_cp_include_files, + java_class_loader_limitt &class_loader_limit, const std::string &filename) { if(!mz_ok) @@ -38,34 +40,6 @@ void jar_filet::open( if(mz_ok) { - // '@' signals file reading with list of class files to load - bool regex_match=java_cp_include_files[0]!='@'; - std::regex regex_matcher; - std::smatch string_matcher; - std::unordered_set set_matcher; - jsont json_cp_config; - if(regex_match) - regex_matcher=std::regex(java_cp_include_files); - else - { - assert(java_cp_include_files.length()>1); - if(parse_json( - java_cp_include_files.substr(1), - get_message_handler(), - json_cp_config)) - throw "cannot read JSON input configuration for JAR loading"; - if(!json_cp_config.is_object()) - throw "the JSON file has a wrong format"; - jsont include_files=json_cp_config["classFiles"]; - if(!include_files.is_array()) - throw "the JSON file has a wrong format"; - for(const jsont &file_entry : include_files.array) - { - assert(file_entry.is_string()); - set_matcher.insert(file_entry.value); - } - } - std::size_t number_of_files= mz_zip_reader_get_num_files(&zip); @@ -80,12 +54,8 @@ void jar_filet::open( // non-class files are loaded in any case bool add_file=!has_suffix(file_name, ".class"); - // load .class file only if they match regex - if(regex_match) - add_file|=std::regex_match(file_name, string_matcher, regex_matcher); - // load .class file only if it is in the match set - else - add_file|=set_matcher.find(file_name)!=set_matcher.end(); + // load .class file only if they match regex / are in match set + add_file|=class_loader_limit.load_class_file(file_name); if(add_file) { if(has_suffix(file_name, ".class")) diff --git a/src/java_bytecode/jar_file.h b/src/java_bytecode/jar_file.h index 9407e711128..3ecdfc80d0f 100644 --- a/src/java_bytecode/jar_file.h +++ b/src/java_bytecode/jar_file.h @@ -18,6 +18,8 @@ Author: Daniel Kroening, kroening@kroening.com #include #include +#include "java_class_loader_limit.h" + class jar_filet:public messaget { public: @@ -25,7 +27,7 @@ class jar_filet:public messaget ~jar_filet(); - void open(std::string &java_cp_include_files, const std::string &); + void open(java_class_loader_limitt &, const std::string &); // Test for error; 'true' means we are good. explicit operator bool() const { return mz_ok; } @@ -47,21 +49,16 @@ class jar_filet:public messaget class jar_poolt:public messaget { public: - void set_java_cp_include_files(std::string &_java_cp_include_files) - { - java_cp_include_files=_java_cp_include_files; - } - - jar_filet &operator()(const std::string &file_name) + jar_filet &operator()( + java_class_loader_limitt &class_loader_limit, + const std::string &file_name) { - if(java_cp_include_files.empty()) - throw "class regexp cannot be empty"; file_mapt::iterator it=file_map.find(file_name); if(it==file_map.end()) { jar_filet &jar_file=file_map[file_name]; jar_file.set_message_handler(get_message_handler()); - jar_file.open(java_cp_include_files, file_name); + jar_file.open(class_loader_limit, file_name); return jar_file; } else diff --git a/src/java_bytecode/java_bytecode_language.cpp b/src/java_bytecode/java_bytecode_language.cpp index 0e2eb25d0ec..e1259a5e985 100644 --- a/src/java_bytecode/java_bytecode_language.cpp +++ b/src/java_bytecode/java_bytecode_language.cpp @@ -170,11 +170,14 @@ bool java_bytecode_languaget::parse( } else if(has_suffix(path, ".jar")) { + java_class_loader_limitt class_loader_limit( + get_message_handler(), + java_cp_include_files); if(config.java.main_class.empty()) { // Does it have a main class set in the manifest? jar_filet::manifestt manifest= - java_class_loader.jar_pool(path).get_manifest(); + java_class_loader.jar_pool(class_loader_limit, path).get_manifest(); std::string manifest_main_class=manifest["Main-Class"]; if(manifest_main_class!="") @@ -186,8 +189,8 @@ bool java_bytecode_languaget::parse( // Do we have one now? if(main_class.empty()) { - status() << "JAR file without entry point: loading it all" << eom; - java_class_loader.load_entire_jar(path); + status() << "JAR file without entry point: loading class files" << eom; + java_class_loader.load_entire_jar(class_loader_limit, path); for(const auto &kv : java_class_loader.jar_map.at(path).entries) main_jar_classes.push_back(kv.first); } diff --git a/src/java_bytecode/java_class_loader.cpp b/src/java_bytecode/java_class_loader.cpp index db5f63b08b9..fdd37c4b312 100644 --- a/src/java_bytecode/java_class_loader.cpp +++ b/src/java_bytecode/java_class_loader.cpp @@ -44,6 +44,9 @@ java_bytecode_parse_treet &java_class_loadert::operator()( queue.push("java.lang.Class"); queue.push(class_name); + java_class_loader_limitt class_loader_limit( + get_message_handler(), java_cp_include_files); + while(!queue.empty()) { irep_idt c=queue.top(); @@ -56,7 +59,7 @@ java_bytecode_parse_treet &java_class_loadert::operator()( debug() << "Reading class " << c << eom; java_bytecode_parse_treet &parse_tree= - get_parse_tree(c); + get_parse_tree(class_loader_limit, c); // add any dependencies to queue for(java_bytecode_parse_treet::class_refst::const_iterator @@ -71,6 +74,25 @@ java_bytecode_parse_treet &java_class_loadert::operator()( /*******************************************************************\ +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) +{ + java_cp_include_files=_java_cp_include_files; + jar_pool.set_message_handler(get_message_handler()); +} + +/*******************************************************************\ + Function: java_class_loadert::get_parse_tree Inputs: @@ -82,6 +104,7 @@ Function: java_class_loadert::get_parse_tree \*******************************************************************/ java_bytecode_parse_treet &java_class_loadert::get_parse_tree( + java_class_loader_limitt &class_loader_limit, const irep_idt &class_name) { java_bytecode_parse_treet &parse_tree=class_map[class_name]; @@ -89,7 +112,7 @@ java_bytecode_parse_treet &java_class_loadert::get_parse_tree( // First check given JAR files for(const auto &jf : jar_files) { - read_jar_file(jf); + read_jar_file(class_loader_limit, jf); const auto &jm=jar_map[jf]; @@ -100,7 +123,8 @@ java_bytecode_parse_treet &java_class_loadert::get_parse_tree( debug() << "Getting class `" << class_name << "' from JAR " << jf << eom; - std::string data=jar_pool(jf).get_entry(jm_it->second.class_file_name); + std::string data=jar_pool(class_loader_limit, jf) + .get_entry(jm_it->second.class_file_name); std::istringstream istream(data); @@ -114,13 +138,12 @@ java_bytecode_parse_treet &java_class_loadert::get_parse_tree( } // See if we can find it in the class path - for(const auto &cp : config.java.classpath) { // in a JAR? if(has_suffix(cp, ".jar")) { - read_jar_file(cp); + read_jar_file(class_loader_limit, cp); const auto &jm=jar_map[cp]; @@ -131,7 +154,8 @@ java_bytecode_parse_treet &java_class_loadert::get_parse_tree( debug() << "Getting class `" << class_name << "' from JAR " << cp << eom; - std::string data=jar_pool(cp).get_entry(jm_it->second.class_file_name); + std::string data=jar_pool(class_loader_limit, cp) + .get_entry(jm_it->second.class_file_name); std::istringstream istream(data); @@ -153,7 +177,9 @@ java_bytecode_parse_treet &java_class_loadert::get_parse_tree( cp+'/'+class_name_to_file(class_name); #endif - if(std::ifstream(full_path)) + // full class path starts with './' + if(class_loader_limit.load_class_file(full_path.substr(2)) && + std::ifstream(full_path)) { if(!java_bytecode_parse( full_path, @@ -182,9 +208,11 @@ Function: java_class_loadert::load_entire_jar \*******************************************************************/ -void java_class_loadert::load_entire_jar(const std::string &file) +void java_class_loadert::load_entire_jar( + java_class_loader_limitt &class_loader_limit, + const std::string &file) { - read_jar_file(file); + read_jar_file(class_loader_limit, file); const auto &jm=jar_map[file]; @@ -208,13 +236,15 @@ Function: java_class_loadert::read_jar_file \*******************************************************************/ -void java_class_loadert::read_jar_file(const irep_idt &file) +void java_class_loadert::read_jar_file( + java_class_loader_limitt &class_loader_limit, + const irep_idt &file) { // done already? if(jar_map.find(file)!=jar_map.end()) return; - jar_filet &jar_file=jar_pool(id2string(file)); + jar_filet &jar_file=jar_pool(class_loader_limit, id2string(file)); if(!jar_file) { diff --git a/src/java_bytecode/java_class_loader.h b/src/java_bytecode/java_class_loader.h index 7a8f6da2b5c..c4676ff31f0 100644 --- a/src/java_bytecode/java_class_loader.h +++ b/src/java_bytecode/java_class_loader.h @@ -10,10 +10,13 @@ Author: Daniel Kroening, kroening@kroening.com #define CPROVER_JAVA_BYTECODE_JAVA_CLASS_LOADER_H #include +#include +#include #include #include "java_bytecode_parse_tree.h" +#include "java_class_loader_limit.h" #include "jar_file.h" class java_class_loadert:public messaget @@ -21,11 +24,7 @@ class java_class_loadert:public messaget public: java_bytecode_parse_treet &operator()(const irep_idt &); - void set_java_cp_include_files(std::string &java_cp_include_files) - { - jar_pool.set_java_cp_include_files(java_cp_include_files); - jar_pool.set_message_handler(get_message_handler()); - } + void set_java_cp_include_files(std::string &); // maps class names to the parse trees typedef std::map class_mapt; @@ -39,7 +38,7 @@ class java_class_loadert:public messaget jar_files.push_back(f); } - void load_entire_jar(const std::string &f); + void load_entire_jar(java_class_loader_limitt &, const std::string &f); jar_poolt jar_pool; @@ -60,12 +59,14 @@ class java_class_loadert:public messaget typedef std::map jar_mapt; jar_mapt jar_map; - void read_jar_file(const irep_idt &); + void read_jar_file(java_class_loader_limitt &, const irep_idt &); // get a parse tree for given class - java_bytecode_parse_treet &get_parse_tree(const irep_idt &); + java_bytecode_parse_treet &get_parse_tree( + java_class_loader_limitt &, const irep_idt &); std::list jar_files; + std::string java_cp_include_files; }; #endif // CPROVER_JAVA_BYTECODE_JAVA_CLASS_LOADER_H diff --git a/src/java_bytecode/java_class_loader_limit.cpp b/src/java_bytecode/java_class_loader_limit.cpp new file mode 100644 index 00000000000..3a9ed66d3d5 --- /dev/null +++ b/src/java_bytecode/java_class_loader_limit.cpp @@ -0,0 +1,81 @@ +/*******************************************************************\ + +Module: limit class path loading + +Author: Daniel Kroening, kroening@kroening.com + +\*******************************************************************/ + +#include + +#include "java_class_loader_limit.h" + +/*******************************************************************\ + +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) +{ + if(java_cp_include_files.empty()) + throw "class regexp cannot be empty"; + + // '@' signals file reading with list of class files to load + regex_match=java_cp_include_files[0]!='@'; + if(regex_match) + regex_matcher=std::regex(java_cp_include_files); + else + { + assert(java_cp_include_files.length()>1); + jsont json_cp_config; + if(parse_json( + java_cp_include_files.substr(1), + get_message_handler(), + json_cp_config)) + throw "cannot read JSON input configuration for JAR loading"; + if(!json_cp_config.is_object()) + throw "the JSON file has a wrong format"; + jsont include_files=json_cp_config["classFiles"]; + if(!include_files.is_null() && !include_files.is_array()) + throw "the JSON file has a wrong format"; + for(const jsont &file_entry : include_files.array) + { + assert(file_entry.is_string()); + set_matcher.insert(file_entry.value); + } + } +} + +/*******************************************************************\ + +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) + { + return std::regex_match( + id2string(file_name), + string_matcher, + regex_matcher); + } + // load .class file only if it is in the match set + else + return set_matcher.find(id2string(file_name))!=set_matcher.end(); +} diff --git a/src/java_bytecode/java_class_loader_limit.h b/src/java_bytecode/java_class_loader_limit.h new file mode 100644 index 00000000000..fa5e21ffd95 --- /dev/null +++ b/src/java_bytecode/java_class_loader_limit.h @@ -0,0 +1,38 @@ +/*******************************************************************\ + +Module: limit class path loading + +Author: Daniel Kroening, kroening@kroening.com + +\*******************************************************************/ + +#ifndef CPROVER_JAVA_BYTECODE_JAVA_CLASS_LOADER_LIMIT_H +#define CPROVER_JAVA_BYTECODE_JAVA_CLASS_LOADER_LIMIT_H + +#include +#include + +#include +#include + +class java_class_loader_limitt:public messaget +{ + std::regex regex_matcher; + std::set set_matcher; + bool regex_match; + std::smatch string_matcher; + + void setup_class_load_limit(std::string &); + public: + explicit java_class_loader_limitt( + message_handlert &_message_handler, + std::string &java_cp_include_files) : + messaget(_message_handler), + regex_match(false) + { + setup_class_load_limit(java_cp_include_files); + } + bool load_class_file(const irep_idt &class_file_name); +}; + +#endif From a963d0f6db8e8ca57dfc6c04ccbdf9c140e84c05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20G=C3=BCdemann?= Date: Wed, 15 Mar 2017 13:45:16 +0100 Subject: [PATCH 003/116] add regression test for class path load limit --- .../cbmc-java/classpath2/jarfile3$A.class | Bin 0 -> 337 bytes .../cbmc-java/classpath2/jarfile3$B.class | Bin 0 -> 337 bytes .../cbmc-java/classpath2/jarfile3.class | Bin 0 -> 709 bytes regression/cbmc-java/classpath2/jarfile3.java | 19 ++++++++++++++++++ regression/cbmc-java/classpath2/test.desc | 10 +++++++++ 5 files changed, 29 insertions(+) create mode 100644 regression/cbmc-java/classpath2/jarfile3$A.class create mode 100644 regression/cbmc-java/classpath2/jarfile3$B.class create mode 100644 regression/cbmc-java/classpath2/jarfile3.class create mode 100644 regression/cbmc-java/classpath2/jarfile3.java create mode 100644 regression/cbmc-java/classpath2/test.desc diff --git a/regression/cbmc-java/classpath2/jarfile3$A.class b/regression/cbmc-java/classpath2/jarfile3$A.class new file mode 100644 index 0000000000000000000000000000000000000000..22a9c4c39f936764b999d23fd07c8c881b3842bc GIT binary patch literal 337 zcmYLE%}T>y5S-0V)5g@K{_9QXp{CFZ_NE9@5DG;PiuW(|QxjqeNh-dUha!0J0emQN z5(pl4*`1x4-TnFf`UWt;Q3nHJxyl#%ng&!gR-;6{DGzOQJh(XU z(1PROko1Ppzv3MXZIpx_Hg+L@P9-@> literal 0 HcmV?d00001 diff --git a/regression/cbmc-java/classpath2/jarfile3$B.class b/regression/cbmc-java/classpath2/jarfile3$B.class new file mode 100644 index 0000000000000000000000000000000000000000..11284e5ebe112d9c40029bf057aad81336dbe4b0 GIT binary patch literal 337 zcmYLEO-sX25S&fZz9yz7et+DA9%>4$pf|;X1))&%pm=|&Pfds^B&qnfJQTr$KfoU) zP6ENhF1xccv%5dPU*7=EaOl8B;G&I!T+2nB97;D0Nt^6S3f9x1R80Y+(oT2T)fz AQvd(} literal 0 HcmV?d00001 diff --git a/regression/cbmc-java/classpath2/jarfile3.class b/regression/cbmc-java/classpath2/jarfile3.class new file mode 100644 index 0000000000000000000000000000000000000000..ececc4cc3057d71a26d614fed6c32b64d2261195 GIT binary patch literal 709 zcmYjPT~8B16g{)ucDo;yLZQ|V#7fZxfttvh1TCmZ6Fwd=Ch)dx2eY+q&Ft3bU*W|^ zpH(7>P4wOWr18w^QXY2Z&bepqIrr}T`t$t*qD`b> zVaY)e3pQaM?mD;!-@>wh*cR~GQ6$yQAc$ib6KV-m8v3A;a2Ul;!#L;+WRIC+fx>1O zg~^sc&R>2hVD1ciQebK~jO704O-HI1noRBqlYU!sN{30%eZ3dFO;dD9g963P?%;nZ z=WsYuUHLrJ7fby>oiKX1-Vfdd9x9j>a5Avb(#XnXWZT0uW<1=-sz6O&Y7Tnodff+LLjpWbZ>m54>t}e>{e9 zM0##-3{waB{Vyn-qOy7h%lrs;jN;Kb?4SS8wKF)EQ7vMmB30xWUxAG&IxEAc!!1VF zh$h>;!i_n;nVT1mH&ScB^o;ur-YF$N!OVR{VNy7AuM6d2cuxcs=TqHV)B-gO Mw&GG-XIyHFzoIF8asU7T literal 0 HcmV?d00001 diff --git a/regression/cbmc-java/classpath2/jarfile3.java b/regression/cbmc-java/classpath2/jarfile3.java new file mode 100644 index 00000000000..c9c0cff46d1 --- /dev/null +++ b/regression/cbmc-java/classpath2/jarfile3.java @@ -0,0 +1,19 @@ +public class jarfile3 +{ + public class A + { + int x=1; + } + public class B + { + int x=1; + } + + void f(int i) + { + A a=new A(); + B b=new B(); + assert(a.x==1); + assert(b.x==1); + } +} diff --git a/regression/cbmc-java/classpath2/test.desc b/regression/cbmc-java/classpath2/test.desc new file mode 100644 index 00000000000..ba3ea35b785 --- /dev/null +++ b/regression/cbmc-java/classpath2/test.desc @@ -0,0 +1,10 @@ +CORE +jarfile3.class +--function jarfile3.f --java-cp-include-files "jarfile3\.class" +^EXIT=10$ +^SIGNAL=0$ +.*SUCCESS$ +.*FAILURE$ +^VERIFICATION FAILED +-- +^warning: ignoring From 73712653a70c9021f8ecd44986910abc496e8322 Mon Sep 17 00:00:00 2001 From: Chris Smowton Date: Wed, 30 Nov 2016 11:01:25 +0000 Subject: [PATCH 004/116] Call get_language_options from get_goto_model This allows language frontends to consume command-line options, which were previously left uninitialised when using goto-analyzer or symex frontends. --- src/goto-analyzer/goto_analyzer_parse_options.cpp | 2 +- src/goto-programs/get_goto_model.cpp | 4 +++- src/goto-programs/get_goto_model.h | 3 ++- src/symex/symex_parse_options.cpp | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/goto-analyzer/goto_analyzer_parse_options.cpp b/src/goto-analyzer/goto_analyzer_parse_options.cpp index e462740c1cc..160501e5a12 100644 --- a/src/goto-analyzer/goto_analyzer_parse_options.cpp +++ b/src/goto-analyzer/goto_analyzer_parse_options.cpp @@ -216,7 +216,7 @@ int goto_analyzer_parse_optionst::doit() goto_model.set_message_handler(get_message_handler()); - if(goto_model(cmdline.args)) + if(goto_model(cmdline)) return 6; if(process_goto_program(options)) diff --git a/src/goto-programs/get_goto_model.cpp b/src/goto-programs/get_goto_model.cpp index 02aae876030..9e594b37865 100644 --- a/src/goto-programs/get_goto_model.cpp +++ b/src/goto-programs/get_goto_model.cpp @@ -32,8 +32,9 @@ Function: get_goto_modelt::operator() \*******************************************************************/ -bool get_goto_modelt::operator()(const std::vector &files) +bool get_goto_modelt::operator()(const cmdlinet &_cmdline) { + const std::vector &files=_cmdline.args; if(files.empty()) { error() << "Please provide a program" << eom; @@ -92,6 +93,7 @@ bool get_goto_modelt::operator()(const std::vector &files) languaget &language=*lf.language; language.set_message_handler(get_message_handler()); + language.get_language_options(_cmdline); status() << "Parsing " << filename << eom; diff --git a/src/goto-programs/get_goto_model.h b/src/goto-programs/get_goto_model.h index 84c6c00c7a5..c2c8cfd1230 100644 --- a/src/goto-programs/get_goto_model.h +++ b/src/goto-programs/get_goto_model.h @@ -10,13 +10,14 @@ Author: Daniel Kroening, kroening@kroening.com #define CPROVER_GOTO_PROGRAMS_GET_GOTO_MODEL_H #include +#include #include "goto_model.h" class get_goto_modelt:public goto_modelt, public messaget { public: - bool operator()(const std::vector &); + bool operator()(const cmdlinet &); }; #endif // CPROVER_GOTO_PROGRAMS_GET_GOTO_MODEL_H diff --git a/src/symex/symex_parse_options.cpp b/src/symex/symex_parse_options.cpp index 54aa9382759..8342f000531 100644 --- a/src/symex/symex_parse_options.cpp +++ b/src/symex/symex_parse_options.cpp @@ -178,7 +178,7 @@ int symex_parse_optionst::doit() goto_model.set_message_handler(get_message_handler()); - if(goto_model(cmdline.args)) + if(goto_model(cmdline)) return 6; if(process_goto_program(options)) From 89562ca5955df4d5ad76ecbd9419e48a21ebb98a Mon Sep 17 00:00:00 2001 From: thk123 Date: Fri, 13 Jan 2017 11:32:34 +0000 Subject: [PATCH 005/116] Adding tests for function pointer removal These tests demonstrate the different ways in which we could easily do better in function pointer resolution. At the moment, each example thinks the function pointer could be any of the 9 functions but in all cases can do much better (either know exactly the function or subset of functions) Added const to arrays that aren't modified which will then be used to determine arrays whose contents can be known. Added test for arrays that are not constant and are in fact modified. Adding test for when FP array declared as a pointer The function pointer optimsation can be further improved by dealing with things like structs and pointers to function pointers. More detail is outlined in https://github.com/diffblue/cbmc/issues/476 Added test for nullptr terminated arrays Adding const struct regression tests FPs may not always be assigned into a const FP and instead may be called in place (e.g. directly from the array). This modifies the exprt structure that must be unpacked. These tests demonstrate the different ways that can be done. Adding and correcting tests for pointers to FPs --- regression/goto-analyzer/fp-removal1/main.c | 27 +++++++ .../goto-analyzer/fp-removal1/test.desc | 8 ++ regression/goto-analyzer/fp-removal10/main.c | 31 ++++++++ .../goto-analyzer/fp-removal10/test.desc | 17 +++++ regression/goto-analyzer/fp-removal11/main.c | 31 ++++++++ .../goto-analyzer/fp-removal11/test.desc | 17 +++++ regression/goto-analyzer/fp-removal12/main.c | 38 ++++++++++ .../goto-analyzer/fp-removal12/test.desc | 15 ++++ regression/goto-analyzer/fp-removal13/main.c | 41 +++++++++++ .../goto-analyzer/fp-removal13/test.desc | 15 ++++ regression/goto-analyzer/fp-removal14/main.c | 32 ++++++++ .../goto-analyzer/fp-removal14/test.desc | 15 ++++ regression/goto-analyzer/fp-removal15/main.c | 28 +++++++ .../goto-analyzer/fp-removal15/test.desc | 17 +++++ regression/goto-analyzer/fp-removal16/main.c | 31 ++++++++ .../goto-analyzer/fp-removal16/test.desc | 16 ++++ regression/goto-analyzer/fp-removal17/main.c | 29 ++++++++ .../goto-analyzer/fp-removal17/test.desc | 8 ++ regression/goto-analyzer/fp-removal19/main.c | 35 +++++++++ .../goto-analyzer/fp-removal19/test.desc | 11 +++ regression/goto-analyzer/fp-removal2/main.c | 29 ++++++++ .../goto-analyzer/fp-removal2/test.desc | 8 ++ regression/goto-analyzer/fp-removal20/main.c | 73 +++++++++++++++++++ .../goto-analyzer/fp-removal20/test.desc | 11 +++ regression/goto-analyzer/fp-removal21/main.c | 46 ++++++++++++ .../goto-analyzer/fp-removal21/test.desc | 11 +++ regression/goto-analyzer/fp-removal22/main.c | 28 +++++++ .../goto-analyzer/fp-removal22/test.desc | 11 +++ regression/goto-analyzer/fp-removal23/main.c | 35 +++++++++ .../goto-analyzer/fp-removal23/test.desc | 9 +++ regression/goto-analyzer/fp-removal24/main.c | 43 +++++++++++ .../goto-analyzer/fp-removal24/test.desc | 9 +++ regression/goto-analyzer/fp-removal25/main.c | 45 ++++++++++++ .../goto-analyzer/fp-removal25/test.desc | 11 +++ regression/goto-analyzer/fp-removal26/main.c | 41 +++++++++++ .../goto-analyzer/fp-removal26/test.desc | 11 +++ regression/goto-analyzer/fp-removal27/main.c | 30 ++++++++ .../goto-analyzer/fp-removal27/test.desc | 16 ++++ regression/goto-analyzer/fp-removal28/main.c | 38 ++++++++++ .../goto-analyzer/fp-removal28/test.desc | 11 +++ regression/goto-analyzer/fp-removal29/main.c | 37 ++++++++++ .../goto-analyzer/fp-removal29/test.desc | 17 +++++ regression/goto-analyzer/fp-removal3/main.c | 29 ++++++++ .../goto-analyzer/fp-removal3/test.desc | 8 ++ regression/goto-analyzer/fp-removal30/main.c | 34 +++++++++ .../goto-analyzer/fp-removal30/test.desc | 9 +++ regression/goto-analyzer/fp-removal31/main.c | 27 +++++++ .../goto-analyzer/fp-removal31/test.desc | 15 ++++ regression/goto-analyzer/fp-removal32/main.c | 36 +++++++++ .../goto-analyzer/fp-removal32/test.desc | 9 +++ regression/goto-analyzer/fp-removal33/main.c | 28 +++++++ .../goto-analyzer/fp-removal33/test.desc | 8 ++ regression/goto-analyzer/fp-removal34/main.c | 27 +++++++ .../goto-analyzer/fp-removal34/test.desc | 11 +++ regression/goto-analyzer/fp-removal35/main.c | 29 ++++++++ .../goto-analyzer/fp-removal35/test.desc | 11 +++ regression/goto-analyzer/fp-removal36/main.c | 43 +++++++++++ .../goto-analyzer/fp-removal36/test.desc | 20 +++++ regression/goto-analyzer/fp-removal37/main.c | 46 ++++++++++++ .../goto-analyzer/fp-removal37/test.desc | 9 +++ regression/goto-analyzer/fp-removal38/main.c | 33 +++++++++ .../goto-analyzer/fp-removal38/test.desc | 15 ++++ regression/goto-analyzer/fp-removal39/main.c | 37 ++++++++++ .../goto-analyzer/fp-removal39/test.desc | 23 ++++++ regression/goto-analyzer/fp-removal4/main.c | 30 ++++++++ .../goto-analyzer/fp-removal4/test.desc | 8 ++ regression/goto-analyzer/fp-removal40/main.c | 25 +++++++ .../goto-analyzer/fp-removal40/test.desc | 17 +++++ regression/goto-analyzer/fp-removal41/main.c | 29 ++++++++ .../goto-analyzer/fp-removal41/test.desc | 17 +++++ regression/goto-analyzer/fp-removal5/main.c | 28 +++++++ .../goto-analyzer/fp-removal5/test.desc | 11 +++ regression/goto-analyzer/fp-removal6/main.c | 27 +++++++ .../goto-analyzer/fp-removal6/test.desc | 17 +++++ regression/goto-analyzer/fp-removal7/main.c | 25 +++++++ .../goto-analyzer/fp-removal7/test.desc | 17 +++++ regression/goto-analyzer/fp-removal8/main.c | 33 +++++++++ .../goto-analyzer/fp-removal8/test.desc | 17 +++++ 78 files changed, 1840 insertions(+) create mode 100644 regression/goto-analyzer/fp-removal1/main.c create mode 100644 regression/goto-analyzer/fp-removal1/test.desc create mode 100644 regression/goto-analyzer/fp-removal10/main.c create mode 100644 regression/goto-analyzer/fp-removal10/test.desc create mode 100644 regression/goto-analyzer/fp-removal11/main.c create mode 100644 regression/goto-analyzer/fp-removal11/test.desc create mode 100644 regression/goto-analyzer/fp-removal12/main.c create mode 100644 regression/goto-analyzer/fp-removal12/test.desc create mode 100644 regression/goto-analyzer/fp-removal13/main.c create mode 100644 regression/goto-analyzer/fp-removal13/test.desc create mode 100644 regression/goto-analyzer/fp-removal14/main.c create mode 100644 regression/goto-analyzer/fp-removal14/test.desc create mode 100644 regression/goto-analyzer/fp-removal15/main.c create mode 100644 regression/goto-analyzer/fp-removal15/test.desc create mode 100644 regression/goto-analyzer/fp-removal16/main.c create mode 100644 regression/goto-analyzer/fp-removal16/test.desc create mode 100644 regression/goto-analyzer/fp-removal17/main.c create mode 100644 regression/goto-analyzer/fp-removal17/test.desc create mode 100644 regression/goto-analyzer/fp-removal19/main.c create mode 100644 regression/goto-analyzer/fp-removal19/test.desc create mode 100644 regression/goto-analyzer/fp-removal2/main.c create mode 100644 regression/goto-analyzer/fp-removal2/test.desc create mode 100644 regression/goto-analyzer/fp-removal20/main.c create mode 100644 regression/goto-analyzer/fp-removal20/test.desc create mode 100644 regression/goto-analyzer/fp-removal21/main.c create mode 100644 regression/goto-analyzer/fp-removal21/test.desc create mode 100644 regression/goto-analyzer/fp-removal22/main.c create mode 100644 regression/goto-analyzer/fp-removal22/test.desc create mode 100644 regression/goto-analyzer/fp-removal23/main.c create mode 100644 regression/goto-analyzer/fp-removal23/test.desc create mode 100644 regression/goto-analyzer/fp-removal24/main.c create mode 100644 regression/goto-analyzer/fp-removal24/test.desc create mode 100644 regression/goto-analyzer/fp-removal25/main.c create mode 100644 regression/goto-analyzer/fp-removal25/test.desc create mode 100644 regression/goto-analyzer/fp-removal26/main.c create mode 100644 regression/goto-analyzer/fp-removal26/test.desc create mode 100644 regression/goto-analyzer/fp-removal27/main.c create mode 100644 regression/goto-analyzer/fp-removal27/test.desc create mode 100644 regression/goto-analyzer/fp-removal28/main.c create mode 100644 regression/goto-analyzer/fp-removal28/test.desc create mode 100644 regression/goto-analyzer/fp-removal29/main.c create mode 100644 regression/goto-analyzer/fp-removal29/test.desc create mode 100644 regression/goto-analyzer/fp-removal3/main.c create mode 100644 regression/goto-analyzer/fp-removal3/test.desc create mode 100644 regression/goto-analyzer/fp-removal30/main.c create mode 100644 regression/goto-analyzer/fp-removal30/test.desc create mode 100644 regression/goto-analyzer/fp-removal31/main.c create mode 100644 regression/goto-analyzer/fp-removal31/test.desc create mode 100644 regression/goto-analyzer/fp-removal32/main.c create mode 100644 regression/goto-analyzer/fp-removal32/test.desc create mode 100644 regression/goto-analyzer/fp-removal33/main.c create mode 100644 regression/goto-analyzer/fp-removal33/test.desc create mode 100644 regression/goto-analyzer/fp-removal34/main.c create mode 100644 regression/goto-analyzer/fp-removal34/test.desc create mode 100644 regression/goto-analyzer/fp-removal35/main.c create mode 100644 regression/goto-analyzer/fp-removal35/test.desc create mode 100644 regression/goto-analyzer/fp-removal36/main.c create mode 100644 regression/goto-analyzer/fp-removal36/test.desc create mode 100644 regression/goto-analyzer/fp-removal37/main.c create mode 100644 regression/goto-analyzer/fp-removal37/test.desc create mode 100644 regression/goto-analyzer/fp-removal38/main.c create mode 100644 regression/goto-analyzer/fp-removal38/test.desc create mode 100644 regression/goto-analyzer/fp-removal39/main.c create mode 100644 regression/goto-analyzer/fp-removal39/test.desc create mode 100644 regression/goto-analyzer/fp-removal4/main.c create mode 100644 regression/goto-analyzer/fp-removal4/test.desc create mode 100644 regression/goto-analyzer/fp-removal40/main.c create mode 100644 regression/goto-analyzer/fp-removal40/test.desc create mode 100644 regression/goto-analyzer/fp-removal41/main.c create mode 100644 regression/goto-analyzer/fp-removal41/test.desc create mode 100644 regression/goto-analyzer/fp-removal5/main.c create mode 100644 regression/goto-analyzer/fp-removal5/test.desc create mode 100644 regression/goto-analyzer/fp-removal6/main.c create mode 100644 regression/goto-analyzer/fp-removal6/test.desc create mode 100644 regression/goto-analyzer/fp-removal7/main.c create mode 100644 regression/goto-analyzer/fp-removal7/test.desc create mode 100644 regression/goto-analyzer/fp-removal8/main.c create mode 100644 regression/goto-analyzer/fp-removal8/test.desc diff --git a/regression/goto-analyzer/fp-removal1/main.c b/regression/goto-analyzer/fp-removal1/main.c new file mode 100644 index 00000000000..f9b5908bce2 --- /dev/null +++ b/regression/goto-analyzer/fp-removal1/main.c @@ -0,0 +1,27 @@ +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp = f2; + fp(); +} + +void main(){ + func(); +} diff --git a/regression/goto-analyzer/fp-removal1/test.desc b/regression/goto-analyzer/fp-removal1/test.desc new file mode 100644 index 00000000000..c3065239e49 --- /dev/null +++ b/regression/goto-analyzer/fp-removal1/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions + +^Removing function pointers and virtual functions$ +^\s*f2(); +-- +^warning: ignoring diff --git a/regression/goto-analyzer/fp-removal10/main.c b/regression/goto-analyzer/fp-removal10/main.c new file mode 100644 index 00000000000..56729ff428a --- /dev/null +++ b/regression/goto-analyzer/fp-removal10/main.c @@ -0,0 +1,31 @@ +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +void_fp fp_tbl[] = {f2, f3, f4}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(void_fp fp, int i){ + fp_tbl[2] = fp; + const void_fp fp2 = fp_tbl[2]; + fp2(); +} + +void main(){ + for(int i=0;i<3;i++){ + func(fp_all[i+3], i); + } +} diff --git a/regression/goto-analyzer/fp-removal10/test.desc b/regression/goto-analyzer/fp-removal10/test.desc new file mode 100644 index 00000000000..7f4fb53760e --- /dev/null +++ b/regression/goto-analyzer/fp-removal10/test.desc @@ -0,0 +1,17 @@ +CORE +main.c +--show-goto-functions + +^Removing function pointers and virtual functions$ +^\s*IF fp2 == f1 THEN GOTO 1$ +^\s*IF fp2 == f2 THEN GOTO 2$ +^\s*IF fp2 == f3 THEN GOTO 3$ +^\s*IF fp2 == f4 THEN GOTO 4$ +^\s*IF fp2 == f5 THEN GOTO 5$ +^\s*IF fp2 == f6 THEN GOTO 6$ +^\s*IF fp2 == f7 THEN GOTO 7$ +^\s*IF fp2 == f8 THEN GOTO 8$ +^\s*IF fp2 == f9 THEN GOTO 9$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/fp-removal11/main.c b/regression/goto-analyzer/fp-removal11/main.c new file mode 100644 index 00000000000..19988eaf32a --- /dev/null +++ b/regression/goto-analyzer/fp-removal11/main.c @@ -0,0 +1,31 @@ +#include +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(){ + void_fp * const fp_tbl= malloc(sizeof(void_fp) * 3); + fp_tbl[0]=f2; + fp_tbl[1]=f3; + fp_tbl[2]=f4; + const void_fp fp = fp_tbl[1]; + fp(); +} + +void main(){ + func(); +} diff --git a/regression/goto-analyzer/fp-removal11/test.desc b/regression/goto-analyzer/fp-removal11/test.desc new file mode 100644 index 00000000000..3c735d48a55 --- /dev/null +++ b/regression/goto-analyzer/fp-removal11/test.desc @@ -0,0 +1,17 @@ +CORE +main.c +--show-goto-functions + +^Removing function pointers and virtual functions$ +^\s*IF fp == f1 THEN GOTO 1$ +^\s*IF fp == f2 THEN GOTO 2$ +^\s*IF fp == f3 THEN GOTO 3$ +^\s*IF fp == f4 THEN GOTO 4$ +^\s*IF fp == f5 THEN GOTO 5$ +^\s*IF fp == f6 THEN GOTO 6$ +^\s*IF fp == f7 THEN GOTO 7$ +^\s*IF fp == f8 THEN GOTO 8$ +^\s*IF fp == f9 THEN GOTO 9$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/fp-removal12/main.c b/regression/goto-analyzer/fp-removal12/main.c new file mode 100644 index 00000000000..be398e7f255 --- /dev/null +++ b/regression/goto-analyzer/fp-removal12/main.c @@ -0,0 +1,38 @@ +#include +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +typedef struct fp_container +{ + const void_fp fp_tbl[3]; +} fp_container; + + + +void func(){ + fp_container container = { .fp_tbl = {f2 ,f3, f4} }; + fp_container container2 = { .fp_tbl = {f5 ,f6, f7} }; + // Illegal: + // container = container2; + const void_fp fp = container.fp_tbl[1]; + fp(); +} + +void main(){ + func(); +} diff --git a/regression/goto-analyzer/fp-removal12/test.desc b/regression/goto-analyzer/fp-removal12/test.desc new file mode 100644 index 00000000000..63ff819792f --- /dev/null +++ b/regression/goto-analyzer/fp-removal12/test.desc @@ -0,0 +1,15 @@ +KNOWNBUG +main.c +--show-goto-functions + +^Removing function pointers and virtual functions$ +^\s*f3();$ +^SIGNAL=0$ +-- +^warning: ignoring +-- +This test is marked as a KNOWNBUG as it is possible for the function +pointer to be optimized away. Currently goto-analyzer falls back to +assuming it could be any type compatible function. + +Issue: https://github.com/diffblue/cbmc/issues/476 diff --git a/regression/goto-analyzer/fp-removal13/main.c b/regression/goto-analyzer/fp-removal13/main.c new file mode 100644 index 00000000000..a64ca581ae5 --- /dev/null +++ b/regression/goto-analyzer/fp-removal13/main.c @@ -0,0 +1,41 @@ +#include +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +typedef struct fp_container +{ + void_fp fp_tbl[3]; +} fp_container; + + + +void func(){ + const fp_container container = { .fp_tbl = {f2 ,f3, f4} }; + fp_container container2 = { .fp_tbl = {f5 ,f6, f7} }; + const void_fp alternatate_fp_tbl[] = {f5 ,f6, f7}; + // Illegal: + // container = container2; + // container.fp_tbl = alternatate_fp_tbl; + // container.fp_tbl[1] = f4; + const void_fp fp = container.fp_tbl[1]; + fp(); +} + +void main(){ + func(); +} diff --git a/regression/goto-analyzer/fp-removal13/test.desc b/regression/goto-analyzer/fp-removal13/test.desc new file mode 100644 index 00000000000..649ba6fbedd --- /dev/null +++ b/regression/goto-analyzer/fp-removal13/test.desc @@ -0,0 +1,15 @@ +CORE +main.c +--show-goto-functions --verbosity 10 + +^Removing function pointers and virtual functions$ +^\s*f3();$ +^SIGNAL=0$ +-- +^warning: ignoring +-- +This test is marked as a KNOWNBUG as it is possible for the function +pointer to be optimized away. Currently goto-analyzer falls back to +assuming it could be any type compatible function. + +Issue: https://github.com/diffblue/cbmc/issues/476 diff --git a/regression/goto-analyzer/fp-removal14/main.c b/regression/goto-analyzer/fp-removal14/main.c new file mode 100644 index 00000000000..b5599183e11 --- /dev/null +++ b/regression/goto-analyzer/fp-removal14/main.c @@ -0,0 +1,32 @@ +#include +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(){ + const void_fp fp = f3; + const void_fp fp2 = f4; + const void_fp* const p2fp = &fp; + // Illegal: + //p2fp = &fp2; + //fp = f5; + (*p2fp)(); +} + +void main(){ + func(); +} diff --git a/regression/goto-analyzer/fp-removal14/test.desc b/regression/goto-analyzer/fp-removal14/test.desc new file mode 100644 index 00000000000..63ff819792f --- /dev/null +++ b/regression/goto-analyzer/fp-removal14/test.desc @@ -0,0 +1,15 @@ +KNOWNBUG +main.c +--show-goto-functions + +^Removing function pointers and virtual functions$ +^\s*f3();$ +^SIGNAL=0$ +-- +^warning: ignoring +-- +This test is marked as a KNOWNBUG as it is possible for the function +pointer to be optimized away. Currently goto-analyzer falls back to +assuming it could be any type compatible function. + +Issue: https://github.com/diffblue/cbmc/issues/476 diff --git a/regression/goto-analyzer/fp-removal15/main.c b/regression/goto-analyzer/fp-removal15/main.c new file mode 100644 index 00000000000..4b81bffdb30 --- /dev/null +++ b/regression/goto-analyzer/fp-removal15/main.c @@ -0,0 +1,28 @@ +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + void_fp fp = f2; + fp = f3; + fp(); +} + +void main(){ + func(); +} diff --git a/regression/goto-analyzer/fp-removal15/test.desc b/regression/goto-analyzer/fp-removal15/test.desc new file mode 100644 index 00000000000..3c735d48a55 --- /dev/null +++ b/regression/goto-analyzer/fp-removal15/test.desc @@ -0,0 +1,17 @@ +CORE +main.c +--show-goto-functions + +^Removing function pointers and virtual functions$ +^\s*IF fp == f1 THEN GOTO 1$ +^\s*IF fp == f2 THEN GOTO 2$ +^\s*IF fp == f3 THEN GOTO 3$ +^\s*IF fp == f4 THEN GOTO 4$ +^\s*IF fp == f5 THEN GOTO 5$ +^\s*IF fp == f6 THEN GOTO 6$ +^\s*IF fp == f7 THEN GOTO 7$ +^\s*IF fp == f8 THEN GOTO 8$ +^\s*IF fp == f9 THEN GOTO 9$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/fp-removal16/main.c b/regression/goto-analyzer/fp-removal16/main.c new file mode 100644 index 00000000000..f1d35373e15 --- /dev/null +++ b/regression/goto-analyzer/fp-removal16/main.c @@ -0,0 +1,31 @@ +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp = f2; + const void_fp fp3 = f4; + void_fp fp2 = fp; + fp2 = fp3; + fp2(); +} + +void main() +{ + func(); +} diff --git a/regression/goto-analyzer/fp-removal16/test.desc b/regression/goto-analyzer/fp-removal16/test.desc new file mode 100644 index 00000000000..9ea2dfbbc29 --- /dev/null +++ b/regression/goto-analyzer/fp-removal16/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions +^Removing function pointers and virtual functions$ +^\s*IF fp2 == f1 THEN GOTO 1$ +^\s*IF fp2 == f2 THEN GOTO 2$ +^\s*IF fp2 == f3 THEN GOTO 3$ +^\s*IF fp2 == f4 THEN GOTO 4$ +^\s*IF fp2 == f5 THEN GOTO 5$ +^\s*IF fp2 == f6 THEN GOTO 6$ +^\s*IF fp2 == f7 THEN GOTO 7$ +^\s*IF fp2 == f8 THEN GOTO 8$ +^\s*IF fp2 == f9 THEN GOTO 9$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/fp-removal17/main.c b/regression/goto-analyzer/fp-removal17/main.c new file mode 100644 index 00000000000..16df50eeb11 --- /dev/null +++ b/regression/goto-analyzer/fp-removal17/main.c @@ -0,0 +1,29 @@ +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + // There isn't an obvious reason to write this code, but perhaps some + // code can get transformed into this so we should still handle it. + (*(&f2))(); +} + +void main() +{ + func(); +} diff --git a/regression/goto-analyzer/fp-removal17/test.desc b/regression/goto-analyzer/fp-removal17/test.desc new file mode 100644 index 00000000000..c3065239e49 --- /dev/null +++ b/regression/goto-analyzer/fp-removal17/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions + +^Removing function pointers and virtual functions$ +^\s*f2(); +-- +^warning: ignoring diff --git a/regression/goto-analyzer/fp-removal19/main.c b/regression/goto-analyzer/fp-removal19/main.c new file mode 100644 index 00000000000..45865b9599e --- /dev/null +++ b/regression/goto-analyzer/fp-removal19/main.c @@ -0,0 +1,35 @@ +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void(* const fp_tbl[3])(void) = { + (void(*)())f2, + (void(*)())f3, + (void(*)())f4, +}; + + +void func(int i){ + const void_fp fp = fp_tbl[i]; + fp(); +} + +void main(){ + for(int i=0;i<3;i++){ + func(i); + } +} diff --git a/regression/goto-analyzer/fp-removal19/test.desc b/regression/goto-analyzer/fp-removal19/test.desc new file mode 100644 index 00000000000..15840e69fe3 --- /dev/null +++ b/regression/goto-analyzer/fp-removal19/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-goto-functions + +^Removing function pointers and virtual functions$ +^\s*IF fp == f2 THEN GOTO 1$ +^\s*IF fp == f3 THEN GOTO 2$ +^\s*IF fp == f4 THEN GOTO 3$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/fp-removal2/main.c b/regression/goto-analyzer/fp-removal2/main.c new file mode 100644 index 00000000000..85f6fc5b79e --- /dev/null +++ b/regression/goto-analyzer/fp-removal2/main.c @@ -0,0 +1,29 @@ +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp = f2; + const void_fp fp2 = fp; + fp2(); +} + +void main() +{ + func(); +} diff --git a/regression/goto-analyzer/fp-removal2/test.desc b/regression/goto-analyzer/fp-removal2/test.desc new file mode 100644 index 00000000000..9ba26c84989 --- /dev/null +++ b/regression/goto-analyzer/fp-removal2/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions +^Removing function pointers and virtual functions$ +^\s*f2();$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/fp-removal20/main.c b/regression/goto-analyzer/fp-removal20/main.c new file mode 100644 index 00000000000..0abcd656db1 --- /dev/null +++ b/regression/goto-analyzer/fp-removal20/main.c @@ -0,0 +1,73 @@ +#include + +int f1 (void) +{ + printf("%i", 1); + return 1; +} +int f2 (void) +{ + printf("%i", 2); + return 2; +} +int f3 (void) +{ + printf("%i", 3); + return 3; +} +int f4 (void) +{ + printf("%i", 4); + return 4; +} +int f5 (void) +{ + printf("%i", 5); + return 5; +} +int f6 (void) +{ + printf("%i", 6); + return 6; +} +int f7 (void) +{ + printf("%i", 7); + return 7; +} +int f8 (void) +{ + printf("%i", 8); + return 8; +} +int f9 (void) +{ + printf("%i", 9); + return 9; +} + +typedef void(*void_fp)(void); +typedef int(*int_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const int_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void(* const fp_tbl[3])(void) = { + (void(*)())f2, + (void(*)())f3, + (void(*)())f4, +}; + + +void func(int i){ + const void_fp fp = fp_tbl[i]; + fp(); +} + +int main(){ + for(int i=0;i<3;i++){ + func(i); + } + return 0; +} diff --git a/regression/goto-analyzer/fp-removal20/test.desc b/regression/goto-analyzer/fp-removal20/test.desc new file mode 100644 index 00000000000..f1dc8590822 --- /dev/null +++ b/regression/goto-analyzer/fp-removal20/test.desc @@ -0,0 +1,11 @@ +KNOWNBUG +main.c +--show-goto-functions + +^Removing function pointers and virtual functions$ +^\s*IF fp == f2 THEN GOTO 1$ +^\s*IF fp == f3 THEN GOTO 2$ +^\s*IF fp == f4 THEN GOTO 3$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/fp-removal21/main.c b/regression/goto-analyzer/fp-removal21/main.c new file mode 100644 index 00000000000..1e9deb388c1 --- /dev/null +++ b/regression/goto-analyzer/fp-removal21/main.c @@ -0,0 +1,46 @@ +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +struct stable { + int x; + void (*fp)(void); +}; + +const struct stable stable_table [3] = { + { 1, f2 }, + { 2, f3 }, + { 3, f4 } +}; + +const struct stable another_table = { 4, f5 }; + + +void func(int i){ + const void_fp fp = stable_table[i].fp; + + // Illegal + // stable_table[1] = another_table; + fp(); +} + +int main(){ + for(int i=0;i<3;i++){ + func(i); + } + return 0; +} diff --git a/regression/goto-analyzer/fp-removal21/test.desc b/regression/goto-analyzer/fp-removal21/test.desc new file mode 100644 index 00000000000..4f3168057fa --- /dev/null +++ b/regression/goto-analyzer/fp-removal21/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-goto-functions --verbosity 10 + +^Removing function pointers and virtual functions$ +^\s*IF fp == f2 THEN GOTO 1$ +^\s*IF fp == f3 THEN GOTO 2$ +^\s*IF fp == f4 THEN GOTO 3$ +^SIGNAL=0$ +-- +^warning: ignoring \ No newline at end of file diff --git a/regression/goto-analyzer/fp-removal22/main.c b/regression/goto-analyzer/fp-removal22/main.c new file mode 100644 index 00000000000..7bbfed5fd8b --- /dev/null +++ b/regression/goto-analyzer/fp-removal22/main.c @@ -0,0 +1,28 @@ +void f1 (void) { int tk = 1; } +void f2 (void) { int tk = 2; } +void f3 (void) { int tk = 3; } +void f4 (void) { int tk = 4; } +void f5 (void) { int tk = 5; } +void f6 (void) { int tk = 6; } +void f7 (void) { int tk = 7; } +void f8 (void) { int tk = 8; } +void f9 (void) { int tk = 9; } + +typedef void(*void_fp)(void); + +const void_fp fp_tbl[] = {f2, f3 ,f4, 0}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i){ + const void_fp fp = fp_tbl[i]; + fp(); +} + +void main(){ + for(int i=0;i<3;i++){ + func(i); + } +} diff --git a/regression/goto-analyzer/fp-removal22/test.desc b/regression/goto-analyzer/fp-removal22/test.desc new file mode 100644 index 00000000000..15840e69fe3 --- /dev/null +++ b/regression/goto-analyzer/fp-removal22/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-goto-functions + +^Removing function pointers and virtual functions$ +^\s*IF fp == f2 THEN GOTO 1$ +^\s*IF fp == f3 THEN GOTO 2$ +^\s*IF fp == f4 THEN GOTO 3$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/fp-removal23/main.c b/regression/goto-analyzer/fp-removal23/main.c new file mode 100644 index 00000000000..09937213470 --- /dev/null +++ b/regression/goto-analyzer/fp-removal23/main.c @@ -0,0 +1,35 @@ +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +struct action +{ + void_fp fun; +}; + +const struct action rec = { .fun = f2 }; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i){ + const void_fp fp = rec.fun; + fp(); +} + +void main(){ + for(int i=0;i<3;i++){ + func(i); + } +} diff --git a/regression/goto-analyzer/fp-removal23/test.desc b/regression/goto-analyzer/fp-removal23/test.desc new file mode 100644 index 00000000000..c78b9efabd8 --- /dev/null +++ b/regression/goto-analyzer/fp-removal23/test.desc @@ -0,0 +1,9 @@ +CORE +main.c +--show-goto-functions --verbosity 10 + +^Removing function pointers and virtual functions$ +^\s*f2(); +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/fp-removal24/main.c b/regression/goto-analyzer/fp-removal24/main.c new file mode 100644 index 00000000000..6cf0b7ee3ce --- /dev/null +++ b/regression/goto-analyzer/fp-removal24/main.c @@ -0,0 +1,43 @@ +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +struct action +{ + void_fp fun; +}; + +const struct action rec = { .fun = f2 }; + +const struct action * const action_list[4] = +{ + &rec, + &rec, + &rec, + &rec +}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i){ + const void_fp fp = action_list[i]->fun; + fp(); +} + +void main(){ + for(int i=0;i<4;i++){ + func(i); + } +} diff --git a/regression/goto-analyzer/fp-removal24/test.desc b/regression/goto-analyzer/fp-removal24/test.desc new file mode 100644 index 00000000000..c78b9efabd8 --- /dev/null +++ b/regression/goto-analyzer/fp-removal24/test.desc @@ -0,0 +1,9 @@ +CORE +main.c +--show-goto-functions --verbosity 10 + +^Removing function pointers and virtual functions$ +^\s*f2(); +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/fp-removal25/main.c b/regression/goto-analyzer/fp-removal25/main.c new file mode 100644 index 00000000000..51f8de1de9e --- /dev/null +++ b/regression/goto-analyzer/fp-removal25/main.c @@ -0,0 +1,45 @@ +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +struct action +{ + void_fp fun; +}; + +const struct action rec = { .fun = f2 }; +const struct action rec2 = { .fun = f3 }; +const struct action rec3 = { .fun = f4 }; + +const struct action * const action_list[4] = +{ + &rec, + &rec2, + &rec3, + &rec +}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i){ + const void_fp fp = action_list[i]->fun; + fp(); +} + +void main(){ + for(int i=0;i<3;i++){ + func(i); + } +} diff --git a/regression/goto-analyzer/fp-removal25/test.desc b/regression/goto-analyzer/fp-removal25/test.desc new file mode 100644 index 00000000000..05b7ce7e581 --- /dev/null +++ b/regression/goto-analyzer/fp-removal25/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-goto-functions --verbosity 10 + +^Removing function pointers and virtual functions$ +^\s*IF fp == f2 THEN GOTO 1$ +^\s*IF fp == f3 THEN GOTO 2$ +^\s*IF fp == f4 THEN GOTO 3$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/fp-removal26/main.c b/regression/goto-analyzer/fp-removal26/main.c new file mode 100644 index 00000000000..66b03305547 --- /dev/null +++ b/regression/goto-analyzer/fp-removal26/main.c @@ -0,0 +1,41 @@ +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +struct state +{ + int x; // Mutable! + const void_fp go; +}; +struct state thing = {0, &f2}; +struct state other_thing = {0, &f4}; +struct state * const pts = &thing; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i){ + // Illegal + //pts=&other_thing; + // thing.go=&f6; + const void_fp fp = pts->go; + + fp(); +} + +void main(){ + for(int i=0;i<3;i++){ + func(i); + } +} diff --git a/regression/goto-analyzer/fp-removal26/test.desc b/regression/goto-analyzer/fp-removal26/test.desc new file mode 100644 index 00000000000..656246683a5 --- /dev/null +++ b/regression/goto-analyzer/fp-removal26/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-goto-functions --verbosity 10 + +^Removing function pointers and virtual functions$ +^\s*f2();$ +^SIGNAL=0$ +-- +^warning: ignoring +-- +Mutable struct but const pointer inside it, not yet supported diff --git a/regression/goto-analyzer/fp-removal27/main.c b/regression/goto-analyzer/fp-removal27/main.c new file mode 100644 index 00000000000..1ed1a4c6511 --- /dev/null +++ b/regression/goto-analyzer/fp-removal27/main.c @@ -0,0 +1,30 @@ +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + void_fp fp = f2; + fp = f3; + const void_fp fp2 = fp; + fp2(); +} + +void main() +{ + func(); +} diff --git a/regression/goto-analyzer/fp-removal27/test.desc b/regression/goto-analyzer/fp-removal27/test.desc new file mode 100644 index 00000000000..9ea2dfbbc29 --- /dev/null +++ b/regression/goto-analyzer/fp-removal27/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions +^Removing function pointers and virtual functions$ +^\s*IF fp2 == f1 THEN GOTO 1$ +^\s*IF fp2 == f2 THEN GOTO 2$ +^\s*IF fp2 == f3 THEN GOTO 3$ +^\s*IF fp2 == f4 THEN GOTO 4$ +^\s*IF fp2 == f5 THEN GOTO 5$ +^\s*IF fp2 == f6 THEN GOTO 6$ +^\s*IF fp2 == f7 THEN GOTO 7$ +^\s*IF fp2 == f8 THEN GOTO 8$ +^\s*IF fp2 == f9 THEN GOTO 9$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/fp-removal28/main.c b/regression/goto-analyzer/fp-removal28/main.c new file mode 100644 index 00000000000..cba5ae9bfc7 --- /dev/null +++ b/regression/goto-analyzer/fp-removal28/main.c @@ -0,0 +1,38 @@ +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +struct state +{ + int x; // Mutable! + const void_fp go; +}; +struct state thing = {0, &f2}; + +struct state other_thing = {0, &f4}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i){ + thing = other_thing; + const void_fp fp = thing.go; + fp(); +} + +void main(){ + for(int i=0;i<3;i++){ + func(i); + } +} diff --git a/regression/goto-analyzer/fp-removal28/test.desc b/regression/goto-analyzer/fp-removal28/test.desc new file mode 100644 index 00000000000..656246683a5 --- /dev/null +++ b/regression/goto-analyzer/fp-removal28/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-goto-functions --verbosity 10 + +^Removing function pointers and virtual functions$ +^\s*f2();$ +^SIGNAL=0$ +-- +^warning: ignoring +-- +Mutable struct but const pointer inside it, not yet supported diff --git a/regression/goto-analyzer/fp-removal29/main.c b/regression/goto-analyzer/fp-removal29/main.c new file mode 100644 index 00000000000..87e79cdb5d9 --- /dev/null +++ b/regression/goto-analyzer/fp-removal29/main.c @@ -0,0 +1,37 @@ +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +struct action +{ + void_fp fun; +}; + +struct action rec = { .fun = f2 }; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i){ + // Can mutate + rec.fun=f4; + const void_fp fp = rec.fun; + fp(); +} + +void main(){ + for(int i=0;i<3;i++){ + func(i); + } +} diff --git a/regression/goto-analyzer/fp-removal29/test.desc b/regression/goto-analyzer/fp-removal29/test.desc new file mode 100644 index 00000000000..deda28d213f --- /dev/null +++ b/regression/goto-analyzer/fp-removal29/test.desc @@ -0,0 +1,17 @@ +CORE +main.c +--show-goto-functions --verbosity 10 + +^Removing function pointers and virtual functions$ +^\s*IF fp == f1 THEN GOTO 1$ +^\s*IF fp == f2 THEN GOTO 2$ +^\s*IF fp == f3 THEN GOTO 3$ +^\s*IF fp == f4 THEN GOTO 4$ +^\s*IF fp == f5 THEN GOTO 5$ +^\s*IF fp == f6 THEN GOTO 6$ +^\s*IF fp == f7 THEN GOTO 7$ +^\s*IF fp == f8 THEN GOTO 8$ +^\s*IF fp == f9 THEN GOTO 9$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/fp-removal3/main.c b/regression/goto-analyzer/fp-removal3/main.c new file mode 100644 index 00000000000..4d057be3a08 --- /dev/null +++ b/regression/goto-analyzer/fp-removal3/main.c @@ -0,0 +1,29 @@ +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +const void_fp fp_tbl[] = {f2, f3 ,f4}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp = fp_tbl[1]; + fp(); +} + +void main(){ + func(); +} diff --git a/regression/goto-analyzer/fp-removal3/test.desc b/regression/goto-analyzer/fp-removal3/test.desc new file mode 100644 index 00000000000..a36fb208c69 --- /dev/null +++ b/regression/goto-analyzer/fp-removal3/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions +^Removing function pointers and virtual functions$ +^\s*f3();$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/fp-removal30/main.c b/regression/goto-analyzer/fp-removal30/main.c new file mode 100644 index 00000000000..8fbd4796975 --- /dev/null +++ b/regression/goto-analyzer/fp-removal30/main.c @@ -0,0 +1,34 @@ +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +struct action +{ + void_fp fun; +}; + +const struct action rec = { .fun = f2 }; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i){ + rec.fun(); +} + +void main(){ + for(int i=0;i<3;i++){ + func(i); + } +} diff --git a/regression/goto-analyzer/fp-removal30/test.desc b/regression/goto-analyzer/fp-removal30/test.desc new file mode 100644 index 00000000000..c78b9efabd8 --- /dev/null +++ b/regression/goto-analyzer/fp-removal30/test.desc @@ -0,0 +1,9 @@ +CORE +main.c +--show-goto-functions --verbosity 10 + +^Removing function pointers and virtual functions$ +^\s*f2(); +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/fp-removal31/main.c b/regression/goto-analyzer/fp-removal31/main.c new file mode 100644 index 00000000000..e27d618cea9 --- /dev/null +++ b/regression/goto-analyzer/fp-removal31/main.c @@ -0,0 +1,27 @@ +#include +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(){ + const void_fp fp = f3; + (*(&fp))(); +} + +void main(){ + func(); +} diff --git a/regression/goto-analyzer/fp-removal31/test.desc b/regression/goto-analyzer/fp-removal31/test.desc new file mode 100644 index 00000000000..649ba6fbedd --- /dev/null +++ b/regression/goto-analyzer/fp-removal31/test.desc @@ -0,0 +1,15 @@ +CORE +main.c +--show-goto-functions --verbosity 10 + +^Removing function pointers and virtual functions$ +^\s*f3();$ +^SIGNAL=0$ +-- +^warning: ignoring +-- +This test is marked as a KNOWNBUG as it is possible for the function +pointer to be optimized away. Currently goto-analyzer falls back to +assuming it could be any type compatible function. + +Issue: https://github.com/diffblue/cbmc/issues/476 diff --git a/regression/goto-analyzer/fp-removal32/main.c b/regression/goto-analyzer/fp-removal32/main.c new file mode 100644 index 00000000000..6076e1f12be --- /dev/null +++ b/regression/goto-analyzer/fp-removal32/main.c @@ -0,0 +1,36 @@ +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +struct state +{ + int x; // Mutable! + const void_fp go; +}; +struct state thing = {0, &f2}; +struct state const * const pts = &thing; + + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i){ + pts->go(); +} + +void main(){ + for(int i=0;i<3;i++){ + func(i); + } +} diff --git a/regression/goto-analyzer/fp-removal32/test.desc b/regression/goto-analyzer/fp-removal32/test.desc new file mode 100644 index 00000000000..0c27e7670ac --- /dev/null +++ b/regression/goto-analyzer/fp-removal32/test.desc @@ -0,0 +1,9 @@ +CORE +main.c +--show-goto-functions --verbosity 10 + +^Removing function pointers and virtual functions$ +^\s*f2();$ +^SIGNAL=0$ +-- +^warning: ignoring \ No newline at end of file diff --git a/regression/goto-analyzer/fp-removal33/main.c b/regression/goto-analyzer/fp-removal33/main.c new file mode 100644 index 00000000000..bd650bd01ae --- /dev/null +++ b/regression/goto-analyzer/fp-removal33/main.c @@ -0,0 +1,28 @@ +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +const void_fp fp_tbl[] = {f2, f3 ,f4}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + fp_tbl[1](); +} + +void main(){ + func(); +} diff --git a/regression/goto-analyzer/fp-removal33/test.desc b/regression/goto-analyzer/fp-removal33/test.desc new file mode 100644 index 00000000000..a36fb208c69 --- /dev/null +++ b/regression/goto-analyzer/fp-removal33/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions +^Removing function pointers and virtual functions$ +^\s*f3();$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/fp-removal34/main.c b/regression/goto-analyzer/fp-removal34/main.c new file mode 100644 index 00000000000..8fc4036e201 --- /dev/null +++ b/regression/goto-analyzer/fp-removal34/main.c @@ -0,0 +1,27 @@ +void f1 (void) { int tk = 1; } +void f2 (void) { int tk = 2; } +void f3 (void) { int tk = 3; } +void f4 (void) { int tk = 4; } +void f5 (void) { int tk = 5; } +void f6 (void) { int tk = 6; } +void f7 (void) { int tk = 7; } +void f8 (void) { int tk = 8; } +void f9 (void) { int tk = 9; } + +typedef void(*void_fp)(void); + +const void_fp fp_tbl[] = {f2, f3 ,f4}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i){ + fp_tbl[i](); +} + +void main(){ + for(int i=0;i<3;i++){ + func(i); + } +} diff --git a/regression/goto-analyzer/fp-removal34/test.desc b/regression/goto-analyzer/fp-removal34/test.desc new file mode 100644 index 00000000000..cf845be0316 --- /dev/null +++ b/regression/goto-analyzer/fp-removal34/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-goto-functions + +^Removing function pointers and virtual functions$ +^\s*IF fp_tbl\[(signed long int)i\] == f2 THEN GOTO 1$ +^\s*IF fp_tbl\[(signed long int)i\] == f3 THEN GOTO 2$ +^\s*IF fp_tbl\[(signed long int)i\] == f4 THEN GOTO 3$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/fp-removal35/main.c b/regression/goto-analyzer/fp-removal35/main.c new file mode 100644 index 00000000000..cbe9e504df2 --- /dev/null +++ b/regression/goto-analyzer/fp-removal35/main.c @@ -0,0 +1,29 @@ +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +const void_fp fp_tbl[] = {f2, f3 ,f4}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const short short_const_variable=1; + fp_tbl[(signed long int)((signed int)short_const_variable & 0x1)](); +} + +void main(){ + func(); +} diff --git a/regression/goto-analyzer/fp-removal35/test.desc b/regression/goto-analyzer/fp-removal35/test.desc new file mode 100644 index 00000000000..5b566c321ca --- /dev/null +++ b/regression/goto-analyzer/fp-removal35/test.desc @@ -0,0 +1,11 @@ +KNOWNBUG +main.c +--show-goto-functions +^Removing function pointers and virtual functions$ +^\s*f3();$ +^SIGNAL=0$ +-- +^warning: ignoring +-- +Fails because of the non-trivial index expression can be evaluated +constantly but isn't \ No newline at end of file diff --git a/regression/goto-analyzer/fp-removal36/main.c b/regression/goto-analyzer/fp-removal36/main.c new file mode 100644 index 00000000000..2f828e830ce --- /dev/null +++ b/regression/goto-analyzer/fp-removal36/main.c @@ -0,0 +1,43 @@ +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +struct state +{ + int x; // Mutable! + const void_fp go; +}; +struct state thing = {0, &f2}; +struct state other_thing = {0, &f4}; + +// This shouldn't work +struct state * pts = &thing; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i) +{ + // This shouldn't work since + pts = &other_thing; + const void_fp fp = pts->go; + fp(); +} + + +void main(){ + for(int i=0;i<3;i++){ + func(i); + } +} diff --git a/regression/goto-analyzer/fp-removal36/test.desc b/regression/goto-analyzer/fp-removal36/test.desc new file mode 100644 index 00000000000..b31b9aedfa1 --- /dev/null +++ b/regression/goto-analyzer/fp-removal36/test.desc @@ -0,0 +1,20 @@ +CORE +main.c +--show-goto-functions --verbosity 10 + +^Removing function pointers and virtual functions$ +^\s*IF fp == f1 THEN GOTO 1$ +^\s*IF fp == f2 THEN GOTO 2$ +^\s*IF fp == f3 THEN GOTO 3$ +^\s*IF fp == f4 THEN GOTO 4$ +^\s*IF fp == f5 THEN GOTO 5$ +^\s*IF fp == f6 THEN GOTO 6$ +^\s*IF fp == f7 THEN GOTO 7$ +^\s*IF fp == f8 THEN GOTO 8$ +^\s*IF fp == f9 THEN GOTO 9$ +^SIGNAL=0$ +-- +^warning: ignoring +-- +This shouldn't work because the pointer can be assigned to a different +struct after initial assignment. diff --git a/regression/goto-analyzer/fp-removal37/main.c b/regression/goto-analyzer/fp-removal37/main.c new file mode 100644 index 00000000000..7e50789f2ad --- /dev/null +++ b/regression/goto-analyzer/fp-removal37/main.c @@ -0,0 +1,46 @@ +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +struct stable { + int x; + void (*fp)(void); +}; + +const struct stable stable_table [3] = { + { 1, f2 }, + { 2, f3 }, + { 3, f4 } +}; + +const struct stable another_table = { 4, f5 }; + + +void func(int i){ + const void_fp fp = stable_table[1].fp; + + // Illegal + // stable_table[1] = another_table; + fp(); +} + +int main(){ + for(int i=0;i<3;i++){ + func(i); + } + return 0; +} diff --git a/regression/goto-analyzer/fp-removal37/test.desc b/regression/goto-analyzer/fp-removal37/test.desc new file mode 100644 index 00000000000..bfc412d2705 --- /dev/null +++ b/regression/goto-analyzer/fp-removal37/test.desc @@ -0,0 +1,9 @@ +CORE +main.c +--show-goto-functions --verbosity 10 + +^Removing function pointers and virtual functions$ +^\s*f3();$ +^SIGNAL=0$ +-- +^warning: ignoring \ No newline at end of file diff --git a/regression/goto-analyzer/fp-removal38/main.c b/regression/goto-analyzer/fp-removal38/main.c new file mode 100644 index 00000000000..c90c9bb9585 --- /dev/null +++ b/regression/goto-analyzer/fp-removal38/main.c @@ -0,0 +1,33 @@ +#include +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(){ + const void_fp fp = f3; + const void_fp fp2 = f4; + const void_fp* const p2fp = &fp; + // Illegal: + //p2fp = &fp2; + //fp = f5; + const void_fp final_fp=*p2fp; + final_fp(); +} + +void main(){ + func(); +} diff --git a/regression/goto-analyzer/fp-removal38/test.desc b/regression/goto-analyzer/fp-removal38/test.desc new file mode 100644 index 00000000000..649ba6fbedd --- /dev/null +++ b/regression/goto-analyzer/fp-removal38/test.desc @@ -0,0 +1,15 @@ +CORE +main.c +--show-goto-functions --verbosity 10 + +^Removing function pointers and virtual functions$ +^\s*f3();$ +^SIGNAL=0$ +-- +^warning: ignoring +-- +This test is marked as a KNOWNBUG as it is possible for the function +pointer to be optimized away. Currently goto-analyzer falls back to +assuming it could be any type compatible function. + +Issue: https://github.com/diffblue/cbmc/issues/476 diff --git a/regression/goto-analyzer/fp-removal39/main.c b/regression/goto-analyzer/fp-removal39/main.c new file mode 100644 index 00000000000..1510abceb69 --- /dev/null +++ b/regression/goto-analyzer/fp-removal39/main.c @@ -0,0 +1,37 @@ +#include +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(){ + const void_fp fp = f3; + const void_fp fp2 = f4; + const void_fp* p2fp = &fp; + + + // Illegal: + //fp = f5; + + // legal: + p2fp = &fp2; + const void_fp final_fp=*p2fp; + final_fp(); +} + +void main(){ + func(); +} diff --git a/regression/goto-analyzer/fp-removal39/test.desc b/regression/goto-analyzer/fp-removal39/test.desc new file mode 100644 index 00000000000..c60094eebd3 --- /dev/null +++ b/regression/goto-analyzer/fp-removal39/test.desc @@ -0,0 +1,23 @@ +CORE +main.c +--show-goto-functions --verbosity 10 + +^Removing function pointers and virtual functions$ +^\s*IF final_fp == f1 THEN GOTO 1$ +^\s*IF final_fp == f2 THEN GOTO 2$ +^\s*IF final_fp == f3 THEN GOTO 3$ +^\s*IF final_fp == f4 THEN GOTO 4$ +^\s*IF final_fp == f5 THEN GOTO 5$ +^\s*IF final_fp == f6 THEN GOTO 6$ +^\s*IF final_fp == f7 THEN GOTO 7$ +^\s*IF final_fp == f8 THEN GOTO 8$ +^\s*IF final_fp == f9 THEN GOTO 9$ +^SIGNAL=0$ +-- +^warning: ignoring +-- +This test is marked as a KNOWNBUG as it is possible for the function +pointer to be optimized away. Currently goto-analyzer falls back to +assuming it could be any type compatible function. + +Issue: https://github.com/diffblue/cbmc/issues/476 diff --git a/regression/goto-analyzer/fp-removal4/main.c b/regression/goto-analyzer/fp-removal4/main.c new file mode 100644 index 00000000000..fbbd4f34259 --- /dev/null +++ b/regression/goto-analyzer/fp-removal4/main.c @@ -0,0 +1,30 @@ +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +const void_fp fp_tbl[] = {f2, f3 ,f4}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const int x = 1; + const void_fp fp = fp_tbl[x]; + fp(); +} + +void main(){ + func(); +} diff --git a/regression/goto-analyzer/fp-removal4/test.desc b/regression/goto-analyzer/fp-removal4/test.desc new file mode 100644 index 00000000000..a36fb208c69 --- /dev/null +++ b/regression/goto-analyzer/fp-removal4/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions +^Removing function pointers and virtual functions$ +^\s*f3();$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/fp-removal40/main.c b/regression/goto-analyzer/fp-removal40/main.c new file mode 100644 index 00000000000..080f1affcc8 --- /dev/null +++ b/regression/goto-analyzer/fp-removal40/main.c @@ -0,0 +1,25 @@ +void f1 (void) { int tk = 1; } +void f2 (void) { int tk = 2; } +void f3 (void) { int tk = 3; } +void f4 (void) { int tk = 4; } +void f5 (void) { int tk = 5; } +void f6 (void) { int tk = 6; } +void f7 (void) { int tk = 7; } +void f8 (void) { int tk = 8; } +void f9 (void) { int tk = 9; } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(const void_fp fp){ + fp(); +} + +void main(){ + for(int i=0;i<3;i++){ + func(fp_all[i]); + } +} diff --git a/regression/goto-analyzer/fp-removal40/test.desc b/regression/goto-analyzer/fp-removal40/test.desc new file mode 100644 index 00000000000..3c735d48a55 --- /dev/null +++ b/regression/goto-analyzer/fp-removal40/test.desc @@ -0,0 +1,17 @@ +CORE +main.c +--show-goto-functions + +^Removing function pointers and virtual functions$ +^\s*IF fp == f1 THEN GOTO 1$ +^\s*IF fp == f2 THEN GOTO 2$ +^\s*IF fp == f3 THEN GOTO 3$ +^\s*IF fp == f4 THEN GOTO 4$ +^\s*IF fp == f5 THEN GOTO 5$ +^\s*IF fp == f6 THEN GOTO 6$ +^\s*IF fp == f7 THEN GOTO 7$ +^\s*IF fp == f8 THEN GOTO 8$ +^\s*IF fp == f9 THEN GOTO 9$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/fp-removal41/main.c b/regression/goto-analyzer/fp-removal41/main.c new file mode 100644 index 00000000000..fd73934e83c --- /dev/null +++ b/regression/goto-analyzer/fp-removal41/main.c @@ -0,0 +1,29 @@ +void f1 (void) { int tk = 1; } +void f2 (void) { int tk = 2; } +void f3 (void) { int tk = 3; } +void f4 (void) { int tk = 4; } +void f5 (void) { int tk = 5; } +void f6 (void) { int tk = 6; } +void f7 (void) { int tk = 7; } +void f8 (void) { int tk = 8; } +void f9 (void) { int tk = 9; } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i, int j){ + const void_fp fp_tbl[] = {fp_all[i*2], fp_all[j+1]}; + // Illegal: + //fp_tbl[1] = f4; + const void_fp fp = fp_tbl[1]; + fp(); +} + +void main(){ + for(int i=0;i<3;i++){ + func(i,0); + } +} diff --git a/regression/goto-analyzer/fp-removal41/test.desc b/regression/goto-analyzer/fp-removal41/test.desc new file mode 100644 index 00000000000..3c735d48a55 --- /dev/null +++ b/regression/goto-analyzer/fp-removal41/test.desc @@ -0,0 +1,17 @@ +CORE +main.c +--show-goto-functions + +^Removing function pointers and virtual functions$ +^\s*IF fp == f1 THEN GOTO 1$ +^\s*IF fp == f2 THEN GOTO 2$ +^\s*IF fp == f3 THEN GOTO 3$ +^\s*IF fp == f4 THEN GOTO 4$ +^\s*IF fp == f5 THEN GOTO 5$ +^\s*IF fp == f6 THEN GOTO 6$ +^\s*IF fp == f7 THEN GOTO 7$ +^\s*IF fp == f8 THEN GOTO 8$ +^\s*IF fp == f9 THEN GOTO 9$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/fp-removal5/main.c b/regression/goto-analyzer/fp-removal5/main.c new file mode 100644 index 00000000000..20cf98fb59a --- /dev/null +++ b/regression/goto-analyzer/fp-removal5/main.c @@ -0,0 +1,28 @@ +void f1 (void) { int tk = 1; } +void f2 (void) { int tk = 2; } +void f3 (void) { int tk = 3; } +void f4 (void) { int tk = 4; } +void f5 (void) { int tk = 5; } +void f6 (void) { int tk = 6; } +void f7 (void) { int tk = 7; } +void f8 (void) { int tk = 8; } +void f9 (void) { int tk = 9; } + +typedef void(*void_fp)(void); + +const void_fp fp_tbl[] = {f2, f3 ,f4}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i){ + const void_fp fp = fp_tbl[i]; + fp(); +} + +void main(){ + for(int i=0;i<3;i++){ + func(i); + } +} diff --git a/regression/goto-analyzer/fp-removal5/test.desc b/regression/goto-analyzer/fp-removal5/test.desc new file mode 100644 index 00000000000..15840e69fe3 --- /dev/null +++ b/regression/goto-analyzer/fp-removal5/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-goto-functions + +^Removing function pointers and virtual functions$ +^\s*IF fp == f2 THEN GOTO 1$ +^\s*IF fp == f3 THEN GOTO 2$ +^\s*IF fp == f4 THEN GOTO 3$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/fp-removal6/main.c b/regression/goto-analyzer/fp-removal6/main.c new file mode 100644 index 00000000000..68ddffa073e --- /dev/null +++ b/regression/goto-analyzer/fp-removal6/main.c @@ -0,0 +1,27 @@ +void f1 (void) { int tk = 1; } +void f2 (void) { int tk = 2; } +void f3 (void) { int tk = 3; } +void f4 (void) { int tk = 4; } +void f5 (void) { int tk = 5; } +void f6 (void) { int tk = 6; } +void f7 (void) { int tk = 7; } +void f8 (void) { int tk = 8; } +void f9 (void) { int tk = 9; } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i, int j){ + void_fp fp_tbl[] = {fp_all[i*2], fp_all[j+1]}; + const void_fp fp = fp_tbl[1]; + fp(); +} + +void main(){ + for(int i=0;i<3;i++){ + func(i,0); + } +} diff --git a/regression/goto-analyzer/fp-removal6/test.desc b/regression/goto-analyzer/fp-removal6/test.desc new file mode 100644 index 00000000000..3c735d48a55 --- /dev/null +++ b/regression/goto-analyzer/fp-removal6/test.desc @@ -0,0 +1,17 @@ +CORE +main.c +--show-goto-functions + +^Removing function pointers and virtual functions$ +^\s*IF fp == f1 THEN GOTO 1$ +^\s*IF fp == f2 THEN GOTO 2$ +^\s*IF fp == f3 THEN GOTO 3$ +^\s*IF fp == f4 THEN GOTO 4$ +^\s*IF fp == f5 THEN GOTO 5$ +^\s*IF fp == f6 THEN GOTO 6$ +^\s*IF fp == f7 THEN GOTO 7$ +^\s*IF fp == f8 THEN GOTO 8$ +^\s*IF fp == f9 THEN GOTO 9$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/fp-removal7/main.c b/regression/goto-analyzer/fp-removal7/main.c new file mode 100644 index 00000000000..8bbd6ee15d6 --- /dev/null +++ b/regression/goto-analyzer/fp-removal7/main.c @@ -0,0 +1,25 @@ +void f1 (void) { int tk = 1; } +void f2 (void) { int tk = 2; } +void f3 (void) { int tk = 3; } +void f4 (void) { int tk = 4; } +void f5 (void) { int tk = 5; } +void f6 (void) { int tk = 6; } +void f7 (void) { int tk = 7; } +void f8 (void) { int tk = 8; } +void f9 (void) { int tk = 9; } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(void_fp fp){ + fp(); +} + +void main(){ + for(int i=0;i<3;i++){ + func(fp_all[i]); + } +} diff --git a/regression/goto-analyzer/fp-removal7/test.desc b/regression/goto-analyzer/fp-removal7/test.desc new file mode 100644 index 00000000000..3c735d48a55 --- /dev/null +++ b/regression/goto-analyzer/fp-removal7/test.desc @@ -0,0 +1,17 @@ +CORE +main.c +--show-goto-functions + +^Removing function pointers and virtual functions$ +^\s*IF fp == f1 THEN GOTO 1$ +^\s*IF fp == f2 THEN GOTO 2$ +^\s*IF fp == f3 THEN GOTO 3$ +^\s*IF fp == f4 THEN GOTO 4$ +^\s*IF fp == f5 THEN GOTO 5$ +^\s*IF fp == f6 THEN GOTO 6$ +^\s*IF fp == f7 THEN GOTO 7$ +^\s*IF fp == f8 THEN GOTO 8$ +^\s*IF fp == f9 THEN GOTO 9$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/fp-removal8/main.c b/regression/goto-analyzer/fp-removal8/main.c new file mode 100644 index 00000000000..26d09257aaf --- /dev/null +++ b/regression/goto-analyzer/fp-removal8/main.c @@ -0,0 +1,33 @@ +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +void_fp fp_tbl[] = {f2, f3, f4}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(void_fp fp, int i){ + // It is concievable this could be checked and seen the first value + // of the array is unchanged but is kind of a weird edge case. + fp_tbl[2] = fp; + const void_fp fp2 = fp_tbl[1]; + fp2(); +} + +void main(){ + for(int i=0;i<3;i++){ + func(fp_all[i+3], i); + } +} diff --git a/regression/goto-analyzer/fp-removal8/test.desc b/regression/goto-analyzer/fp-removal8/test.desc new file mode 100644 index 00000000000..7f4fb53760e --- /dev/null +++ b/regression/goto-analyzer/fp-removal8/test.desc @@ -0,0 +1,17 @@ +CORE +main.c +--show-goto-functions + +^Removing function pointers and virtual functions$ +^\s*IF fp2 == f1 THEN GOTO 1$ +^\s*IF fp2 == f2 THEN GOTO 2$ +^\s*IF fp2 == f3 THEN GOTO 3$ +^\s*IF fp2 == f4 THEN GOTO 4$ +^\s*IF fp2 == f5 THEN GOTO 5$ +^\s*IF fp2 == f6 THEN GOTO 6$ +^\s*IF fp2 == f7 THEN GOTO 7$ +^\s*IF fp2 == f8 THEN GOTO 8$ +^\s*IF fp2 == f9 THEN GOTO 9$ +^SIGNAL=0$ +-- +^warning: ignoring From 995f5045c28ccc30aeebb2d7205ef415b00ca843 Mon Sep 17 00:00:00 2001 From: thk123 Date: Mon, 30 Jan 2017 14:16:01 +0000 Subject: [PATCH 006/116] Made remove_function_pointers inherit from messaget This will allow for the logging to be done through the debug() channel and hence turned on and off. --- src/cbmc/cbmc_parse_options.cpp | 1 + .../goto_analyzer_parse_options.cpp | 3 ++- src/goto-diff/goto_diff_parse_options.cpp | 1 + .../goto_instrument_parse_options.cpp | 1 + src/goto-programs/remove_function_pointers.cpp | 17 +++++++++++++---- src/goto-programs/remove_function_pointers.h | 3 +++ 6 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/cbmc/cbmc_parse_options.cpp b/src/cbmc/cbmc_parse_options.cpp index 657e4531429..8bbdb8ce89e 100644 --- a/src/cbmc/cbmc_parse_options.cpp +++ b/src/cbmc/cbmc_parse_options.cpp @@ -877,6 +877,7 @@ bool cbmc_parse_optionst::process_goto_program( // remove function pointers status() << "Removal of function pointers and virtual functions" << eom; remove_function_pointers( + get_message_handler(), symbol_table, goto_functions, cmdline.isset("pointer-check")); diff --git a/src/goto-analyzer/goto_analyzer_parse_options.cpp b/src/goto-analyzer/goto_analyzer_parse_options.cpp index e462740c1cc..10fb9d8d6d9 100644 --- a/src/goto-analyzer/goto_analyzer_parse_options.cpp +++ b/src/goto-analyzer/goto_analyzer_parse_options.cpp @@ -385,7 +385,8 @@ bool goto_analyzer_parse_optionst::process_goto_program( // remove function pointers status() << "Removing function pointers and virtual functions" << eom; - remove_function_pointers(goto_model, cmdline.isset("pointer-check")); + remove_function_pointers( + get_message_handler(), goto_model, cmdline.isset("pointer-check")); // Java virtual functions -> explicit dispatch tables: remove_virtual_functions(goto_model); // remove Java throw and catch diff --git a/src/goto-diff/goto_diff_parse_options.cpp b/src/goto-diff/goto_diff_parse_options.cpp index a405178652f..b86eee9fea1 100644 --- a/src/goto-diff/goto_diff_parse_options.cpp +++ b/src/goto-diff/goto_diff_parse_options.cpp @@ -487,6 +487,7 @@ bool goto_diff_parse_optionst::process_goto_program( // remove function pointers status() << "Function Pointer Removal" << eom; remove_function_pointers( + get_message_handler(), symbol_table, goto_functions, cmdline.isset("pointer-check")); diff --git a/src/goto-instrument/goto_instrument_parse_options.cpp b/src/goto-instrument/goto_instrument_parse_options.cpp index b5486355277..3e923bd5103 100644 --- a/src/goto-instrument/goto_instrument_parse_options.cpp +++ b/src/goto-instrument/goto_instrument_parse_options.cpp @@ -806,6 +806,7 @@ void goto_instrument_parse_optionst::do_indirect_call_and_rtti_removal( status() << "Function Pointer Removal" << eom; remove_function_pointers( + get_message_handler(), symbol_table, goto_functions, cmdline.isset("pointer-check")); diff --git a/src/goto-programs/remove_function_pointers.cpp b/src/goto-programs/remove_function_pointers.cpp index 3893729a1e1..aee2dcae89b 100644 --- a/src/goto-programs/remove_function_pointers.cpp +++ b/src/goto-programs/remove_function_pointers.cpp @@ -14,6 +14,7 @@ Author: Daniel Kroening, kroening@kroening.com #include #include #include +#include #include @@ -29,10 +30,11 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -class remove_function_pointerst +class remove_function_pointerst:public messaget { public: remove_function_pointerst( + message_handlert &_message_handler, symbol_tablet &_symbol_table, bool _add_safety_assertion, const goto_functionst &goto_functions); @@ -92,9 +94,11 @@ Function: remove_function_pointerst::remove_function_pointerst \*******************************************************************/ remove_function_pointerst::remove_function_pointerst( + message_handlert &_message_handler, symbol_tablet &_symbol_table, bool _add_safety_assertion, const goto_functionst &goto_functions): + messaget(_message_handler), ns(_symbol_table), symbol_table(_symbol_table), add_safety_assertion(_add_safety_assertion) @@ -540,13 +544,14 @@ Function: remove_function_pointers \*******************************************************************/ bool remove_function_pointers( + message_handlert &_message_handler, symbol_tablet &symbol_table, const goto_functionst &goto_functions, goto_programt &goto_program, bool add_safety_assertion) { remove_function_pointerst - rfp(symbol_table, add_safety_assertion, goto_functions); + rfp(_message_handler, symbol_table, add_safety_assertion, goto_functions); return rfp.remove_function_pointers(goto_program); } @@ -564,12 +569,13 @@ Function: remove_function_pointers \*******************************************************************/ void remove_function_pointers( + message_handlert &_message_handler, symbol_tablet &symbol_table, goto_functionst &goto_functions, bool add_safety_assertion) { remove_function_pointerst - rfp(symbol_table, add_safety_assertion, goto_functions); + rfp(_message_handler, symbol_table, add_safety_assertion, goto_functions); rfp(goto_functions); } @@ -587,10 +593,13 @@ Function: remove_function_pointers \*******************************************************************/ void remove_function_pointers( + message_handlert &_message_handler, goto_modelt &goto_model, bool add_safety_assertion) { remove_function_pointers( - goto_model.symbol_table, goto_model.goto_functions, + _message_handler, + goto_model.symbol_table, + goto_model.goto_functions, add_safety_assertion); } diff --git a/src/goto-programs/remove_function_pointers.h b/src/goto-programs/remove_function_pointers.h index 6f1f26984df..125cda131e1 100644 --- a/src/goto-programs/remove_function_pointers.h +++ b/src/goto-programs/remove_function_pointers.h @@ -16,15 +16,18 @@ Date: June 2003 // remove indirect function calls // and replace by case-split void remove_function_pointers( + message_handlert &_message_handler, goto_modelt &goto_model, bool add_safety_assertion); void remove_function_pointers( + message_handlert &_message_handler, symbol_tablet &symbol_table, goto_functionst &goto_functions, bool add_safety_assertion); bool remove_function_pointers( + message_handlert &_message_handler, symbol_tablet &symbol_table, const goto_functionst &goto_functions, goto_programt &goto_program, From 563a3519f24b1f248a01a0e23fb76689d19886e5 Mon Sep 17 00:00:00 2001 From: thk123 Date: Thu, 2 Feb 2017 14:23:27 +0000 Subject: [PATCH 007/116] First implemention of the new approach --- src/goto-programs/Makefile | 4 +- .../remove_const_function_pointers.cpp | 500 ++++++++++++++++++ .../remove_const_function_pointers.h | 62 +++ .../remove_function_pointers.cpp | 57 +- 4 files changed, 598 insertions(+), 25 deletions(-) create mode 100644 src/goto-programs/remove_const_function_pointers.cpp create mode 100644 src/goto-programs/remove_const_function_pointers.h diff --git a/src/goto-programs/Makefile b/src/goto-programs/Makefile index d5cc5ea25eb..bf6abb39ab6 100644 --- a/src/goto-programs/Makefile +++ b/src/goto-programs/Makefile @@ -20,7 +20,9 @@ SRC = goto_convert.cpp goto_convert_function_call.cpp \ slice_global_inits.cpp goto_inline_class.cpp class_identifier.cpp \ show_goto_functions_json.cpp \ show_goto_functions_xml.cpp \ - remove_static_init_loops.cpp remove_instanceof.cpp + remove_static_init_loops.cpp remove_instanceof.cpp \ + remove_const_function_pointers.cpp \ + # Empty last line INCLUDES= -I .. diff --git a/src/goto-programs/remove_const_function_pointers.cpp b/src/goto-programs/remove_const_function_pointers.cpp new file mode 100644 index 00000000000..ebf6840ecbc --- /dev/null +++ b/src/goto-programs/remove_const_function_pointers.cpp @@ -0,0 +1,500 @@ +/*******************************************************************\ + +Module: Goto Programs + +Author: Thomas Kiley, thomas.kiley@diffblue.com + +\*******************************************************************/ + +#include +#include +#include + +#include "remove_const_function_pointers.h" + +remove_const_function_pointerst::remove_const_function_pointerst( + message_handlert &message_handler, + const exprt &base_expression, + const namespacet &ns, + const symbol_tablet &symbol_table): + messaget(message_handler), + original_expression(base_expression), + ns(ns), + symbol_table(symbol_table) +{} + +bool remove_const_function_pointerst::operator()( + functionst &out_functions) +{ + return try_resolve_function_call(original_expression, out_functions); +} + +exprt remove_const_function_pointerst::resolve_symbol( + const symbol_exprt &symbol_expr) const +{ + const symbolt &symbol= + symbol_table.lookup(symbol_expr.get_identifier()); + return symbol.value; +} + +bool remove_const_function_pointerst::try_resolve_function_call( + const exprt &expr, remove_const_function_pointerst::functionst &out_functions) +{ + const exprt &simplified_expr=simplify_expr(expr, ns); + if(simplified_expr.id()==ID_index) + { + const index_exprt &index_expr=to_index_expr(simplified_expr); + return try_resolve_index_of_function_call(index_expr, out_functions); + } + else if(simplified_expr.id()==ID_member) + { + const member_exprt &member_expr=to_member_expr(simplified_expr); + const exprt &owner_expr=member_expr.compound(); + // Squash the struct + expressionst out_expressions; + bool is_const=false; + bool resolved=try_resolve_expression(owner_expr, out_expressions, is_const); + if(resolved) + { + for(const exprt &expression:out_expressions) + { + if(expression.id()!=ID_struct) + { + return false; + } + else + { + struct_exprt struct_expr=to_struct_expr(expression); + const exprt &component_value= + struct_expr.operands()[member_expr.get_component_number()]; + // TODO: copy into out_functions rather than supply direct like + bool resolved= + try_resolve_function_call(component_value, out_functions); + if(!resolved) + { + return false; + } + } + } + + return true; + + } + else + { + return false; + } + } + else if(simplified_expr.id()==ID_address_of) + { + address_of_exprt address_expr=to_address_of_expr(simplified_expr); + return try_resolve_function_call(address_expr.object(), out_functions); + } + else if(simplified_expr.id()==ID_symbol) + { + if(simplified_expr.type().id()==ID_code) + { + out_functions.insert(simplified_expr); + return true; + } + else + { + const c_qualifierst pointer_qualifers(simplified_expr.type()); + if(!pointer_qualifers.is_constant) + { + debug() << "Can't optimize FP since symbol " + << simplified_expr.get(ID_identifier) << " is not const" << eom; + return false; + } + + const exprt &symbol_value=resolve_symbol(to_symbol_expr(simplified_expr)); + return try_resolve_function_call(symbol_value, out_functions); + } + } + else + { + return false; + } +} + +// Take an index of, squash its array and squash its index +// If we can get a precise number, 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) +{ + // Get the array(s) it belongs to + expressionst potential_array_exprs; + bool is_const=false; + bool resolved_array= + try_resolve_expression(index_expr.array(), potential_array_exprs, is_const); + if(resolved_array) + { + for(const exprt &potential_array_expr : potential_array_exprs) + { + if(potential_array_expr.id()==ID_array) + { + // We require either the type of the values of the array or + // the array itself to be constant. + const typet &array_type=potential_array_expr.type(); + const typet &array_contents_type=array_type.subtype(); + c_qualifierst array_qaulifiers; + array_qaulifiers.read(array_contents_type); + + if(array_qaulifiers.is_constant || is_const) + { + // Get the index if we can + mp_integer value; + if(try_resolve_index_value(index_expr.index(), value)) + { + functionst array_out_functions; + const exprt &func_expr= + potential_array_expr.operands()[integer2size_t(value)]; + bool resolved_value= + try_resolve_function_call(func_expr, array_out_functions); + + if(resolved_value) + { + out_functions.insert( + array_out_functions.begin(), + array_out_functions.end()); + } + } + else + { + // We don't know what index it is, + // but we know the value is from the array + for(const exprt &array_entry : potential_array_expr.operands()) + { + functionst potential_functions; + bool resolved_value= + try_resolve_function_call(array_entry, potential_functions); + + if(resolved_value) + { + for(const exprt &potential_function : potential_functions) + { + if(potential_function.is_zero()) + { + continue; + } + else + { + out_functions.insert( + potential_functions.begin(), + potential_functions.end()); + } + } + } + else + { + return false; + } + } + } + } + else + { + return false; + } + } + else + { + return false; + } + } + + return true; + } + else + { + return false; + } +} + +bool remove_const_function_pointerst::try_resolve_expression( + const exprt &expr, expressionst &out_resolved_expression, bool &out_is_const) +{ + const exprt &simplified_expr=simplify_expr(expr, ns); + if(simplified_expr.id()==ID_index) + { + const index_exprt &index_expr=to_index_expr(simplified_expr); + expressionst out_array_expressions; + bool resolved_array= + try_resolve_index_of(index_expr, out_array_expressions, out_is_const); + if(resolved_array) + { + out_resolved_expression.insert( + out_resolved_expression.end(), + out_array_expressions.begin(), + out_array_expressions.end()); + } + + return resolved_array; + } + else if(simplified_expr.id()==ID_member) + { + // Get the component it belongs to + const member_exprt &member_expr=to_member_expr(simplified_expr); + + expressionst potential_structs; + bool is_struct_const; + try_resolve_expression( + member_expr.compound(), potential_structs, is_struct_const); + + bool all_components_const=true; + for(const exprt &potential_struct : potential_structs) + { + if(potential_struct.id()==ID_struct) + { + struct_exprt struct_expr=to_struct_expr(potential_struct); + const exprt &component_value= + struct_expr.operands()[member_expr.get_component_number()]; + expressionst out_expressions; + bool component_const=false; + bool resolved= + try_resolve_expression( + component_value, out_expressions, component_const); + if(resolved) + { + out_resolved_expression.insert( + out_resolved_expression.end(), + out_expressions.begin(), + out_expressions.end()); + + all_components_const= + all_components_const && component_const; + } + else + { + return false; + } + } + else + { + return false; + } + } + out_is_const=all_components_const||is_struct_const; + return true; + } + else if(simplified_expr.id()==ID_dereference) + { + // We had a pointer, we need to check both the pointer + // type can't be changed, and what it what pointing to + // can't be changed + const dereference_exprt &deref=to_dereference_expr(simplified_expr); + expressionst pointer_values; + bool pointer_const; + bool resolved= + try_resolve_expression(deref.pointer(), pointer_values, pointer_const); + if(resolved) + { + for(const exprt &pointer_val : pointer_values) + { + if(pointer_val.id()==ID_address_of) + { + address_of_exprt address_expr=to_address_of_expr(pointer_val); + bool object_const=false; + expressionst out_object_values; + bool resolved= + try_resolve_expression( + address_expr.object(), out_object_values, object_const); + + if(resolved) + { + out_resolved_expression.insert( + out_resolved_expression.end(), + out_object_values.begin(), + out_object_values.end()); + } + } + else + { + return false; + } + } + out_is_const=is_expression_const(deref) && pointer_const; + return true; + } + else + { + return false; + } + } + else if(simplified_expr.id()==ID_symbol) + { + const exprt &symbol_value=resolve_symbol(to_symbol_expr(simplified_expr)); + bool is_symbol_const=is_expression_const(simplified_expr); + bool is_symbol_value_const=false; + bool resolved_expression= + try_resolve_expression( + symbol_value, + out_resolved_expression, + is_symbol_value_const); + + // If we have a symbol, it is only const if the value it is assigned + // is const and it is in fact const. + out_is_const=is_symbol_const && is_symbol_const; + return resolved_expression; + } + // TOOD: probably need to do something with pointers or address_of + // and const since a const pointer to a non-const value is useless + else + { + out_is_const=is_expression_const(expr); + out_resolved_expression.push_back(expr); + return true; + } +} + +bool remove_const_function_pointerst::try_resolve_index_value( + const exprt &expr, mp_integer &out_array_index) +{ + expressionst index_value_expressions; + bool is_const=false; + bool resolved=try_resolve_expression(expr, index_value_expressions, is_const); + if(resolved) + { + if(index_value_expressions.size()==1 && + index_value_expressions.front().id()==ID_constant) + { + const constant_exprt &constant_expr= + to_constant_expr(index_value_expressions.front()); + mp_integer array_index; + bool errors=to_integer(constant_expr, array_index); + if(!errors) + { + out_array_index=array_index; + } + return !errors; + } + else + { + return false; + } + } + else + { + return false; + } +} + + +// Takes an index of, squashes its array and index +// if index is resolvable +bool remove_const_function_pointerst::try_resolve_index_of( + const index_exprt &index_expr, + expressionst &out_expressions, + bool &out_is_const) +{ + // Get the array(s) it belongs to + expressionst potential_array_exprs; + bool array_const=false; + bool resolved_array= + try_resolve_expression( + index_expr.array(), + potential_array_exprs, + array_const); + + if(resolved_array) + { + bool all_possible_const=true; + for(const exprt &potential_array_expr : potential_array_exprs) + { + all_possible_const= + all_possible_const && + is_type_const(potential_array_expr.type().subtype()); + + if(potential_array_expr.id()==ID_array) + { + // Get the index if we can + mp_integer value; + if(try_resolve_index_value(index_expr.index(), value)) + { + expressionst array_out_functions; + const exprt &func_expr= + potential_array_expr.operands()[integer2size_t(value)]; + bool value_const=false; + bool resolved_value= + try_resolve_expression(func_expr, array_out_functions, value_const); + + if(resolved_value) + { + out_expressions.insert( + out_expressions.end(), + array_out_functions.begin(), + array_out_functions.end()); + } + else + { + return false; + } + } + else + { + // We don't know what index it is, + // but we know the value is from the array + for(const exprt &array_entry : potential_array_expr.operands()) + { + expressionst array_contents; + bool is_entry_const; + bool resolved_value= + try_resolve_expression( + array_entry, array_contents, is_entry_const); + + if(resolved_value) + { + for(const exprt &resolved_array_entry : array_contents) + { + if(resolved_array_entry .is_zero()) + { + continue; + } + else + { + out_expressions.push_back(resolved_array_entry); + } + } + } + else + { + return false; + } + } + } + } + else + { + return false; + } + } + + out_is_const=all_possible_const || array_const; + return true; + } + else + { + return false; + } +} + +bool remove_const_function_pointerst::is_expression_const( + const exprt &expression) const +{ + return is_type_const(expression.type()); +} + +bool remove_const_function_pointerst::is_type_const(const typet &type) const +{ + c_qualifierst qualifers(type); + if(type.id()==ID_array) + { + c_qualifierst array_type_qualifers(type.subtype()); + return qualifers.is_constant || array_type_qualifers.is_constant; + } + else + { + return qualifers.is_constant; + } +} diff --git a/src/goto-programs/remove_const_function_pointers.h b/src/goto-programs/remove_const_function_pointers.h new file mode 100644 index 00000000000..cf7e85ca9a2 --- /dev/null +++ b/src/goto-programs/remove_const_function_pointers.h @@ -0,0 +1,62 @@ +/*******************************************************************\ + +Module: Goto Programs + +Author: Thomas Kiley, thomas.kiley@diffblue.com + +\*******************************************************************/ + +#ifndef CPROVER_GOTO_PROGRAMS_REMOVE_CONST_FUNCTION_POINTERS_H +#define CPROVER_GOTO_PROGRAMS_REMOVE_CONST_FUNCTION_POINTERS_H + +#include "goto_model.h" +#include +#include +#include + + +class remove_const_function_pointerst:public messaget +{ +public: + typedef std::set functionst; + typedef std::list expressionst; + remove_const_function_pointerst( + message_handlert &message_handler, + const exprt &base_expression, + const namespacet &ns, + const symbol_tablet &symbol_table); + + bool operator()(functionst &out_functions); + +private: + exprt resolve_symbol(const symbol_exprt &symbol_expr) const; + + // recursive functions for dealing with the function pointer + bool try_resolve_function_call(const exprt &expr, functionst &out_functions); + + bool try_resolve_index_of_function_call( + const index_exprt &index_expr, functionst &out_functions); + + // recursive functions for dealing with the auxiliary elements + bool try_resolve_expression( + const exprt &expr, + expressionst &out_resolved_expression, + bool &out_is_const); + + bool try_resolve_index_value( + const exprt &index_value_expr, mp_integer &out_array_index); + + bool try_resolve_index_of( + const index_exprt &index_expr, + expressionst &out_expressions, + bool &out_is_const); + + bool is_expression_const(const exprt &expression) const; + bool is_type_const(const typet &type) const; + + const exprt original_expression; + const namespacet &ns; + const symbol_tablet &symbol_table; +}; + +#endif // CPROVER_GOTO_PROGRAMS_REMOVE_CONST_FUNCTION_POINTERS_H diff --git a/src/goto-programs/remove_function_pointers.cpp b/src/goto-programs/remove_function_pointers.cpp index aee2dcae89b..1e63b25a9a6 100644 --- a/src/goto-programs/remove_function_pointers.cpp +++ b/src/goto-programs/remove_function_pointers.cpp @@ -21,6 +21,7 @@ Author: Daniel Kroening, kroening@kroening.com #include "remove_skip.h" #include "remove_function_pointers.h" #include "compute_called_functions.h" +#include "remove_const_function_pointers.h" /*******************************************************************\ @@ -343,40 +344,48 @@ void remove_function_pointerst::remove_function_pointer( assert(function.operands().size()==1); const exprt &pointer=function.op0(); + remove_const_function_pointerst::functionst functions; + remove_const_function_pointerst fpr( + get_message_handler(), pointer, ns, symbol_table); - // Is this simple? - if(pointer.id()==ID_address_of && - to_address_of_expr(pointer).object().id()==ID_symbol) + bool found_functions=fpr(functions); + + if(functions.size()==1) { - to_code_function_call(target->code).function()= - to_address_of_expr(pointer).object(); + to_code_function_call(target->code).function()=*functions.cbegin(); return; } - typedef std::list functionst; - functionst functions; + if(!found_functions) + { + debug() << "Failed to optimize away the function pointer\n" + << "The type was " << pointer.id() << " " + << "irep dump:\n" + << pointer.pretty() + << eom; - bool return_value_used=code.lhs().is_not_nil(); + bool return_value_used=code.lhs().is_not_nil(); - // get all type-compatible functions - // whose address is ever taken - for(const auto &t : type_map) - { - // address taken? - if(address_taken.find(t.first)==address_taken.end()) - continue; + // get all type-compatible functions + // whose address is ever taken + for(const auto &t : type_map) + { + // address taken? + if(address_taken.find(t.first)==address_taken.end()) + continue; - // type-compatible? - if(!is_type_compatible(return_value_used, call_type, t.second)) - continue; + // type-compatible? + if(!is_type_compatible(return_value_used, call_type, t.second)) + continue; - if(t.first=="pthread_mutex_cleanup") - continue; + if(t.first=="pthread_mutex_cleanup") + continue; - symbol_exprt expr; - expr.type()=t.second; - expr.set_identifier(t.first); - functions.push_back(expr); + symbol_exprt expr; + expr.type()=t.second; + expr.set_identifier(t.first); + functions.insert(expr); + } } // the final target is a skip From 3b3acd641cca38e77e31571acb4ed6af0a915a0b Mon Sep 17 00:00:00 2001 From: thk123 Date: Thu, 2 Feb 2017 14:53:37 +0000 Subject: [PATCH 008/116] Support for removing the typecast --- .../remove_const_function_pointers.cpp | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/goto-programs/remove_const_function_pointers.cpp b/src/goto-programs/remove_const_function_pointers.cpp index ebf6840ecbc..b5537365d0a 100644 --- a/src/goto-programs/remove_const_function_pointers.cpp +++ b/src/goto-programs/remove_const_function_pointers.cpp @@ -322,6 +322,33 @@ bool remove_const_function_pointerst::try_resolve_expression( return false; } } + else if(simplified_expr.id()==ID_typecast) + { + // We simply ignore typecasts and assume they are valid + // I thought simplify_expr would deal with this, but for example + // a cast from a 32 bit width int to a 64bit width int it doesn't seem + // to allow + typecast_exprt typecast_expr=to_typecast_expr(simplified_expr); + expressionst typecast_values; + bool typecast_const; + bool resolved= + try_resolve_expression( + typecast_expr.op(), typecast_values, typecast_const); + + if(resolved) + { + out_resolved_expression.insert( + out_resolved_expression.end(), + typecast_values.begin(), + typecast_values.end()); + out_is_const=typecast_const; + return true; + } + else + { + return false; + } + } else if(simplified_expr.id()==ID_symbol) { const exprt &symbol_value=resolve_symbol(to_symbol_expr(simplified_expr)); @@ -342,8 +369,8 @@ bool remove_const_function_pointerst::try_resolve_expression( // and const since a const pointer to a non-const value is useless else { - out_is_const=is_expression_const(expr); - out_resolved_expression.push_back(expr); + out_is_const=is_expression_const(simplified_expr); + out_resolved_expression.push_back(simplified_expr); return true; } } From e4829ebd7c8f5d70734713f7a8ebf6322a55f8e0 Mon Sep 17 00:00:00 2001 From: thk123 Date: Thu, 2 Feb 2017 15:25:03 +0000 Subject: [PATCH 009/116] Adding support for top level pointers and typecasts --- .../goto-analyzer/fp-removal12/test.desc | 11 ++-- .../goto-analyzer/fp-removal14/test.desc | 4 +- .../goto-analyzer/fp-removal20/test.desc | 8 +-- .../remove_const_function_pointers.cpp | 66 +++++++++++++++++++ 4 files changed, 76 insertions(+), 13 deletions(-) diff --git a/regression/goto-analyzer/fp-removal12/test.desc b/regression/goto-analyzer/fp-removal12/test.desc index 63ff819792f..701da09802e 100644 --- a/regression/goto-analyzer/fp-removal12/test.desc +++ b/regression/goto-analyzer/fp-removal12/test.desc @@ -1,6 +1,6 @@ -KNOWNBUG +CORE main.c ---show-goto-functions +--show-goto-functions --verbosity 10 ^Removing function pointers and virtual functions$ ^\s*f3();$ @@ -8,8 +8,5 @@ main.c -- ^warning: ignoring -- -This test is marked as a KNOWNBUG as it is possible for the function -pointer to be optimized away. Currently goto-analyzer falls back to -assuming it could be any type compatible function. - -Issue: https://github.com/diffblue/cbmc/issues/476 +This is currently failing because the const is being ignored inside +the struct diff --git a/regression/goto-analyzer/fp-removal14/test.desc b/regression/goto-analyzer/fp-removal14/test.desc index 63ff819792f..649ba6fbedd 100644 --- a/regression/goto-analyzer/fp-removal14/test.desc +++ b/regression/goto-analyzer/fp-removal14/test.desc @@ -1,6 +1,6 @@ -KNOWNBUG +CORE main.c ---show-goto-functions +--show-goto-functions --verbosity 10 ^Removing function pointers and virtual functions$ ^\s*f3();$ diff --git a/regression/goto-analyzer/fp-removal20/test.desc b/regression/goto-analyzer/fp-removal20/test.desc index f1dc8590822..81db0db6f9f 100644 --- a/regression/goto-analyzer/fp-removal20/test.desc +++ b/regression/goto-analyzer/fp-removal20/test.desc @@ -1,11 +1,11 @@ -KNOWNBUG +CORE main.c --show-goto-functions ^Removing function pointers and virtual functions$ -^\s*IF fp == f2 THEN GOTO 1$ -^\s*IF fp == f3 THEN GOTO 2$ -^\s*IF fp == f4 THEN GOTO 3$ +^\s*IF fp == (void (\*)(void))f2 THEN GOTO 1$ +^\s*IF fp == (void (\*)(void))f3 THEN GOTO 2$ +^\s*IF fp == (void (\*)(void))f4 THEN GOTO 3$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/src/goto-programs/remove_const_function_pointers.cpp b/src/goto-programs/remove_const_function_pointers.cpp index b5537365d0a..8eb406eecf0 100644 --- a/src/goto-programs/remove_const_function_pointers.cpp +++ b/src/goto-programs/remove_const_function_pointers.cpp @@ -90,6 +90,72 @@ bool remove_const_function_pointerst::try_resolve_function_call( address_of_exprt address_expr=to_address_of_expr(simplified_expr); return try_resolve_function_call(address_expr.object(), out_functions); } + else if(simplified_expr.id()==ID_dereference) + { + // We had a pointer, we need to check both the pointer + // type can't be changed, and what it what pointing to + // can't be changed + const dereference_exprt &deref=to_dereference_expr(simplified_expr); + expressionst pointer_values; + bool pointer_const; + bool resolved= + try_resolve_expression(deref.pointer(), pointer_values, pointer_const); + if(resolved && is_expression_const(deref)) + { + for(const exprt &pointer_val : pointer_values) + { + if(pointer_val.id()==ID_address_of) + { + address_of_exprt address_expr=to_address_of_expr(pointer_val); + functionst out_object_values; + bool resolved= + try_resolve_function_call( + address_expr.object(), out_object_values); + + if(resolved) + { + out_functions.insert( + out_object_values.begin(), + out_object_values.end()); + } + else + { + return false; + } + } + else + { + return false; + } + } + return true; + } + else + { + return false; + } + } + else if(simplified_expr.id()==ID_typecast) + { + // We simply ignore typecasts and assume they are valid + // I thought simplify_expr would deal with this, but for example + // a cast from a 32 bit width int to a 64bit width int it doesn't seem + // to allow + typecast_exprt typecast_expr=to_typecast_expr(simplified_expr); + functionst typecast_values; + bool resolved= + try_resolve_function_call(typecast_expr.op(), typecast_values); + + if(resolved) + { + out_functions.insert(typecast_values.begin(), typecast_values.end()); + return true; + } + else + { + return false; + } + } else if(simplified_expr.id()==ID_symbol) { if(simplified_expr.type().id()==ID_code) From 11f15eeaea0a7361bf232997c8b77002c16d9cb5 Mon Sep 17 00:00:00 2001 From: thk123 Date: Thu, 2 Feb 2017 15:44:13 +0000 Subject: [PATCH 010/116] Fixing arrays containing null pointers --- .../remove_const_function_pointers.cpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/goto-programs/remove_const_function_pointers.cpp b/src/goto-programs/remove_const_function_pointers.cpp index 8eb406eecf0..2c51a3e96ca 100644 --- a/src/goto-programs/remove_const_function_pointers.cpp +++ b/src/goto-programs/remove_const_function_pointers.cpp @@ -232,25 +232,18 @@ bool remove_const_function_pointerst::try_resolve_index_of_function_call( // but we know the value is from the array for(const exprt &array_entry : potential_array_expr.operands()) { + if(array_entry.is_zero()) + { + continue; + } functionst potential_functions; bool resolved_value= try_resolve_function_call(array_entry, potential_functions); if(resolved_value) { - for(const exprt &potential_function : potential_functions) - { - if(potential_function.is_zero()) - { - continue; - } - else - { - out_functions.insert( - potential_functions.begin(), - potential_functions.end()); - } - } + out_functions.insert( + potential_functions.begin(), potential_functions.end()); } else { From a479c98a055f209e0d67fc06d496a8f9b3d70e3d Mon Sep 17 00:00:00 2001 From: thk123 Date: Thu, 2 Feb 2017 15:45:30 +0000 Subject: [PATCH 011/116] Correctly deal with const structures --- .../remove_const_function_pointers.cpp | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/goto-programs/remove_const_function_pointers.cpp b/src/goto-programs/remove_const_function_pointers.cpp index 2c51a3e96ca..8cd32ed35a0 100644 --- a/src/goto-programs/remove_const_function_pointers.cpp +++ b/src/goto-programs/remove_const_function_pointers.cpp @@ -52,8 +52,9 @@ bool remove_const_function_pointerst::try_resolve_function_call( const exprt &owner_expr=member_expr.compound(); // Squash the struct expressionst out_expressions; - bool is_const=false; - bool resolved=try_resolve_expression(owner_expr, out_expressions, is_const); + bool struct_is_const=false; + bool resolved= + try_resolve_expression(owner_expr, out_expressions, struct_is_const); if(resolved) { for(const exprt &expression:out_expressions) @@ -68,9 +69,18 @@ bool remove_const_function_pointerst::try_resolve_function_call( const exprt &component_value= struct_expr.operands()[member_expr.get_component_number()]; // TODO: copy into out_functions rather than supply direct like - bool resolved= - try_resolve_function_call(component_value, out_functions); - if(!resolved) + bool component_const=is_expression_const(component_value); + + if(component_const || struct_is_const) + { + bool resolved= + try_resolve_function_call(component_value, out_functions); + if(!resolved) + { + return false; + } + } + else { return false; } From 921f0b7af08ebc85f6a558cc7753b292a236b5e8 Mon Sep 17 00:00:00 2001 From: thk123 Date: Thu, 2 Feb 2017 18:01:05 +0000 Subject: [PATCH 012/116] Fixing component access and const access --- .../remove_const_function_pointers.cpp | 42 ++++++++++++------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/src/goto-programs/remove_const_function_pointers.cpp b/src/goto-programs/remove_const_function_pointers.cpp index 8cd32ed35a0..bd49163817d 100644 --- a/src/goto-programs/remove_const_function_pointers.cpp +++ b/src/goto-programs/remove_const_function_pointers.cpp @@ -65,9 +65,14 @@ bool remove_const_function_pointerst::try_resolve_function_call( } else { - struct_exprt struct_expr=to_struct_expr(expression); + + struct_typet struct_type=to_struct_type(ns.follow(expression.type())); + size_t component_number= + struct_type.component_number(member_expr.get_component_name()); + + const struct_exprt &struct_expr=to_struct_expr(expression); const exprt &component_value= - struct_expr.operands()[member_expr.get_component_number()]; + struct_expr.operands()[component_number]; // TODO: copy into out_functions rather than supply direct like bool component_const=is_expression_const(component_value); @@ -383,7 +388,7 @@ bool remove_const_function_pointerst::try_resolve_expression( return false; } } - out_is_const=is_expression_const(deref) && pointer_const; + out_is_const=pointer_const; return true; } else @@ -422,17 +427,26 @@ bool remove_const_function_pointerst::try_resolve_expression( { const exprt &symbol_value=resolve_symbol(to_symbol_expr(simplified_expr)); bool is_symbol_const=is_expression_const(simplified_expr); - bool is_symbol_value_const=false; - bool resolved_expression= - try_resolve_expression( - symbol_value, - out_resolved_expression, - is_symbol_value_const); - - // If we have a symbol, it is only const if the value it is assigned - // is const and it is in fact const. - out_is_const=is_symbol_const && is_symbol_const; - return resolved_expression; + //if(is_symbol_const) + { + bool is_symbol_value_const=false; + bool resolved_expression= + try_resolve_expression( + symbol_value, + out_resolved_expression, + is_symbol_value_const); + + // If we have a symbol, it is only const if the value it is assigned + // is const and it is in fact const. + out_is_const=is_symbol_value_const && is_symbol_const; + return resolved_expression; + } + /*else + { + // If the symbol isn't const, we can't know what its value is so + // we carry on + return false; + }*/ } // TOOD: probably need to do something with pointers or address_of // and const since a const pointer to a non-const value is useless From b814d65ece0d793d04153ff9ec7b67afa2fc16d8 Mon Sep 17 00:00:00 2001 From: thk123 Date: Mon, 6 Feb 2017 15:23:29 +0000 Subject: [PATCH 013/116] Fixing todo to use separate array When trying to resolve the functions of a component, we don't use the array directly in case the step fails and therefore we shouldn't add them to our list. --- src/goto-programs/remove_const_function_pointers.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/goto-programs/remove_const_function_pointers.cpp b/src/goto-programs/remove_const_function_pointers.cpp index bd49163817d..0804c273d0c 100644 --- a/src/goto-programs/remove_const_function_pointers.cpp +++ b/src/goto-programs/remove_const_function_pointers.cpp @@ -73,14 +73,19 @@ bool remove_const_function_pointerst::try_resolve_function_call( const struct_exprt &struct_expr=to_struct_expr(expression); const exprt &component_value= struct_expr.operands()[component_number]; - // TODO: copy into out_functions rather than supply direct like bool component_const=is_expression_const(component_value); if(component_const || struct_is_const) { + functionst component_functions; bool resolved= - try_resolve_function_call(component_value, out_functions); - if(!resolved) + try_resolve_function_call(component_value, component_functions); + if(resolved) + { + out_functions.insert( + component_functions.begin(), component_functions.end()); + } + else { return false; } From 22ca113d456dd11db53eaf32dd6597d89d1f002e Mon Sep 17 00:00:00 2001 From: thk123 Date: Tue, 7 Feb 2017 13:47:05 +0000 Subject: [PATCH 014/116] Corrected const-ness for components We require either the struct to be const, or the type of the component to be const (not the value the component is assigned, which will rarely be const). --- src/goto-programs/remove_const_function_pointers.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/goto-programs/remove_const_function_pointers.cpp b/src/goto-programs/remove_const_function_pointers.cpp index 0804c273d0c..77fcf22f07c 100644 --- a/src/goto-programs/remove_const_function_pointers.cpp +++ b/src/goto-programs/remove_const_function_pointers.cpp @@ -73,7 +73,12 @@ bool remove_const_function_pointerst::try_resolve_function_call( const struct_exprt &struct_expr=to_struct_expr(expression); const exprt &component_value= struct_expr.operands()[component_number]; - bool component_const=is_expression_const(component_value); + + // Find out if the component is constant + struct_union_typet::componentt component= + struct_type.components()[component_number]; + + bool component_const=is_type_const(component.type()); if(component_const || struct_is_const) { From d87dffdd827a9d67a6c29a9acad299428085e1bf Mon Sep 17 00:00:00 2001 From: thk123 Date: Tue, 7 Feb 2017 13:48:13 +0000 Subject: [PATCH 015/116] Handle failure to squash the value when getting out of an array --- src/goto-programs/remove_const_function_pointers.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/goto-programs/remove_const_function_pointers.cpp b/src/goto-programs/remove_const_function_pointers.cpp index 77fcf22f07c..47e2be1f40c 100644 --- a/src/goto-programs/remove_const_function_pointers.cpp +++ b/src/goto-programs/remove_const_function_pointers.cpp @@ -250,6 +250,10 @@ bool remove_const_function_pointerst::try_resolve_index_of_function_call( array_out_functions.begin(), array_out_functions.end()); } + else + { + return false; + } } else { From f51b2524d1afdffe88b3e57662551e7759b3f654 Mon Sep 17 00:00:00 2001 From: thk123 Date: Tue, 7 Feb 2017 13:50:00 +0000 Subject: [PATCH 016/116] Correcting const check for pointers --- .../remove_const_function_pointers.cpp | 38 ++++++++----------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/src/goto-programs/remove_const_function_pointers.cpp b/src/goto-programs/remove_const_function_pointers.cpp index 47e2be1f40c..4e7dd10928b 100644 --- a/src/goto-programs/remove_const_function_pointers.cpp +++ b/src/goto-programs/remove_const_function_pointers.cpp @@ -376,8 +376,9 @@ bool remove_const_function_pointerst::try_resolve_expression( bool pointer_const; bool resolved= try_resolve_expression(deref.pointer(), pointer_values, pointer_const); - if(resolved) + if(resolved && pointer_const) { + bool all_objects_const=true; for(const exprt &pointer_val : pointer_values) { if(pointer_val.id()==ID_address_of) @@ -395,6 +396,8 @@ bool remove_const_function_pointerst::try_resolve_expression( out_resolved_expression.end(), out_object_values.begin(), out_object_values.end()); + + all_objects_const&=object_const; } } else @@ -402,7 +405,7 @@ bool remove_const_function_pointerst::try_resolve_expression( return false; } } - out_is_const=pointer_const; + out_is_const=all_objects_const; return true; } else @@ -441,26 +444,17 @@ bool remove_const_function_pointerst::try_resolve_expression( { const exprt &symbol_value=resolve_symbol(to_symbol_expr(simplified_expr)); bool is_symbol_const=is_expression_const(simplified_expr); - //if(is_symbol_const) - { - bool is_symbol_value_const=false; - bool resolved_expression= - try_resolve_expression( - symbol_value, - out_resolved_expression, - is_symbol_value_const); - - // If we have a symbol, it is only const if the value it is assigned - // is const and it is in fact const. - out_is_const=is_symbol_value_const && is_symbol_const; - return resolved_expression; - } - /*else - { - // If the symbol isn't const, we can't know what its value is so - // we carry on - return false; - }*/ + bool is_symbol_value_const=false; + bool resolved_expression= + try_resolve_expression( + symbol_value, + out_resolved_expression, + is_symbol_value_const); + + // If we have a symbol, it is only const if the value it is assigned + // is const and it is in fact const. + out_is_const=is_symbol_const; + return resolved_expression; } // TOOD: probably need to do something with pointers or address_of // and const since a const pointer to a non-const value is useless From 1fbfbbc410ccaf54a72c265d3ac97610baf2c787 Mon Sep 17 00:00:00 2001 From: thk123 Date: Tue, 7 Feb 2017 13:50:27 +0000 Subject: [PATCH 017/116] Adding examples to tests of what the const prevents --- regression/goto-analyzer/fp-removal11/main.c | 4 ++++ regression/goto-analyzer/fp-removal23/main.c | 3 +++ 2 files changed, 7 insertions(+) diff --git a/regression/goto-analyzer/fp-removal11/main.c b/regression/goto-analyzer/fp-removal11/main.c index 19988eaf32a..3f90a10ab65 100644 --- a/regression/goto-analyzer/fp-removal11/main.c +++ b/regression/goto-analyzer/fp-removal11/main.c @@ -22,6 +22,10 @@ void func(){ fp_tbl[0]=f2; fp_tbl[1]=f3; fp_tbl[2]=f4; + + // Illegal + //fp_tbl = malloc(sizeof(void_fp) * 10); + const void_fp fp = fp_tbl[1]; fp(); } diff --git a/regression/goto-analyzer/fp-removal23/main.c b/regression/goto-analyzer/fp-removal23/main.c index 09937213470..e4f1ee8c491 100644 --- a/regression/goto-analyzer/fp-removal23/main.c +++ b/regression/goto-analyzer/fp-removal23/main.c @@ -24,6 +24,9 @@ const struct action rec = { .fun = f2 }; const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; void func(int i){ + + // Illegal: + //rec.fun = &f5; const void_fp fp = rec.fun; fp(); } From 5ab672ad3b906cbfb5a81ad9382bb978e3c5e268 Mon Sep 17 00:00:00 2001 From: thk123 Date: Tue, 7 Feb 2017 14:38:26 +0000 Subject: [PATCH 018/116] Corrected const check for no FP pointers --- src/goto-programs/remove_const_function_pointers.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/goto-programs/remove_const_function_pointers.cpp b/src/goto-programs/remove_const_function_pointers.cpp index 4e7dd10928b..cd3cf0dc91c 100644 --- a/src/goto-programs/remove_const_function_pointers.cpp +++ b/src/goto-programs/remove_const_function_pointers.cpp @@ -125,7 +125,11 @@ bool remove_const_function_pointerst::try_resolve_function_call( bool pointer_const; bool resolved= try_resolve_expression(deref.pointer(), pointer_values, pointer_const); - if(resolved && is_expression_const(deref)) + + // Here we require that the value we are dereferencing is const + // The actual type doesn't matter since we are on the RHS so what matters + // is where this gets stored, but the value stored matters + if(resolved && pointer_const) { for(const exprt &pointer_val : pointer_values) { From 0499b4400b1b3d9ed42f9ecaceb0e915216bcaa5 Mon Sep 17 00:00:00 2001 From: thk123 Date: Tue, 7 Feb 2017 17:48:01 +0000 Subject: [PATCH 019/116] Added tests to cover a couple of missed lines 42 also demonstrates a bug that this commit fixes with index accessed function calls that fail to resolve the array. Specifically, if squashing the struct failed, we still returned true. That happens in this instance as the pointer to the struct is not constant. --- regression/goto-analyzer/fp-removal42/main.c | 41 +++++++++++++ .../goto-analyzer/fp-removal42/test.desc | 17 ++++++ regression/goto-analyzer/fp-removal43/main.c | 50 ++++++++++++++++ .../goto-analyzer/fp-removal43/test.desc | 17 ++++++ .../remove_const_function_pointers.cpp | 60 +++++++++++-------- 5 files changed, 159 insertions(+), 26 deletions(-) create mode 100644 regression/goto-analyzer/fp-removal42/main.c create mode 100644 regression/goto-analyzer/fp-removal42/test.desc create mode 100644 regression/goto-analyzer/fp-removal43/main.c create mode 100644 regression/goto-analyzer/fp-removal43/test.desc diff --git a/regression/goto-analyzer/fp-removal42/main.c b/regression/goto-analyzer/fp-removal42/main.c new file mode 100644 index 00000000000..bd46ce92484 --- /dev/null +++ b/regression/goto-analyzer/fp-removal42/main.c @@ -0,0 +1,41 @@ +#include +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +typedef struct fp_container +{ + void_fp fp_tbl[3]; +} fp_container; + + + +void func(){ + const fp_container container = { .fp_tbl = {f2 ,f3, f4} }; + const void_fp alternatate_fp_tbl[] = {f5 ,f6, f7}; + const fp_container container2 = { .fp_tbl = {f5 ,f6, f7} }; + // Illegal: + // container.fp_tbl = alternatate_fp_tbl; + // container.fp_tbl[1] = f4; + const fp_container *container_ptr=&container; + container_ptr=&container2; + container_ptr->fp_tbl[1](); +} + +int main(){ + func(); +} diff --git a/regression/goto-analyzer/fp-removal42/test.desc b/regression/goto-analyzer/fp-removal42/test.desc new file mode 100644 index 00000000000..b53053f12a4 --- /dev/null +++ b/regression/goto-analyzer/fp-removal42/test.desc @@ -0,0 +1,17 @@ +CORE +main.c +--show-goto-functions --verbosity 10 + +^Removing function pointers and virtual functions$ +^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f1 THEN GOTO 1$ +^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f2 THEN GOTO 2$ +^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f3 THEN GOTO 3$ +^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f4 THEN GOTO 4$ +^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f5 THEN GOTO 5$ +^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f6 THEN GOTO 6$ +^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f7 THEN GOTO 7$ +^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f8 THEN GOTO 8$ +^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f9 THEN GOTO 9$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/fp-removal43/main.c b/regression/goto-analyzer/fp-removal43/main.c new file mode 100644 index 00000000000..e0b37fceb10 --- /dev/null +++ b/regression/goto-analyzer/fp-removal43/main.c @@ -0,0 +1,50 @@ +#include +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +typedef struct fp_container +{ + const void_fp* const fp_tbl[3]; +} fp_container; + + + +void func(){ + void_fp f2meta = &f2; + void_fp f3meta = &f3; + void_fp f4meta = &f4; + + void_fp f5meta = &f5; + void_fp f6meta = &f6; + void_fp f7meta = &f7; + + const fp_container container = { .fp_tbl = {&f2meta ,&f3meta, &f4meta} }; + const fp_container container2 = { .fp_tbl = {&f5meta ,&f6meta, &f7meta} }; + + f3meta = &f5; + // Illegal: + // container.fp_tbl = alternatate_fp_tbl; + // container.fp_tbl[1] = f4; + const fp_container * const container_ptr=&container; + //container_ptr=&container2; + (*container_ptr->fp_tbl[1])(); +} + +int main(){ + func(); +} diff --git a/regression/goto-analyzer/fp-removal43/test.desc b/regression/goto-analyzer/fp-removal43/test.desc new file mode 100644 index 00000000000..94f1774abb7 --- /dev/null +++ b/regression/goto-analyzer/fp-removal43/test.desc @@ -0,0 +1,17 @@ +CORE +main.c +--show-goto-functions --verbosity 10 + +^Removing function pointers and virtual functions$ +^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f1 THEN GOTO 1$ +^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f2 THEN GOTO 2$ +^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f3 THEN GOTO 3$ +^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f4 THEN GOTO 4$ +^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f5 THEN GOTO 5$ +^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f6 THEN GOTO 6$ +^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f7 THEN GOTO 7$ +^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f8 THEN GOTO 8$ +^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f9 THEN GOTO 9$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/src/goto-programs/remove_const_function_pointers.cpp b/src/goto-programs/remove_const_function_pointers.cpp index cd3cf0dc91c..c239a3f67d8 100644 --- a/src/goto-programs/remove_const_function_pointers.cpp +++ b/src/goto-programs/remove_const_function_pointers.cpp @@ -331,44 +331,52 @@ bool remove_const_function_pointerst::try_resolve_expression( expressionst potential_structs; bool is_struct_const; - try_resolve_expression( - member_expr.compound(), potential_structs, is_struct_const); + bool resolved_struct= + try_resolve_expression( + member_expr.compound(), potential_structs, is_struct_const); - bool all_components_const=true; - for(const exprt &potential_struct : potential_structs) + if(resolved_struct) { - if(potential_struct.id()==ID_struct) + bool all_components_const=true; + for(const exprt &potential_struct : potential_structs) { - struct_exprt struct_expr=to_struct_expr(potential_struct); - const exprt &component_value= - struct_expr.operands()[member_expr.get_component_number()]; - expressionst out_expressions; - bool component_const=false; - bool resolved= - try_resolve_expression( - component_value, out_expressions, component_const); - if(resolved) + if(potential_struct.id()==ID_struct) { - out_resolved_expression.insert( - out_resolved_expression.end(), - out_expressions.begin(), - out_expressions.end()); + struct_exprt struct_expr=to_struct_expr(potential_struct); + const exprt &component_value= + struct_expr.operands()[member_expr.get_component_number()]; + expressionst out_expressions; + bool component_const=false; + bool resolved= + try_resolve_expression( + component_value, out_expressions, component_const); + if(resolved) + { + out_resolved_expression.insert( + out_resolved_expression.end(), + out_expressions.begin(), + out_expressions.end()); - all_components_const= - all_components_const && component_const; + all_components_const= + all_components_const && component_const; + } + else + { + return false; + } } else { return false; } } - else - { - return false; - } + out_is_const=all_components_const||is_struct_const; + return true; + } + else + { + return false; } - out_is_const=all_components_const||is_struct_const; - return true; } else if(simplified_expr.id()==ID_dereference) { From 208ef2b91a02067aa2f53b4f2af8e3649b49cbb5 Mon Sep 17 00:00:00 2001 From: thk123 Date: Wed, 8 Feb 2017 13:30:39 +0000 Subject: [PATCH 020/116] Fixed issue with structs with other components If the component was not the top level thing (e.g., as in 44, it was a pointer to a FP) we weren't correctly resolving structs that had other components (the get_component_number does not in general work). Made the two different handlings of the ID_member behave consistently and correctly. Also would have failed on 46 where the component was const but the struct was not as was checking the type of the component value rather than the component type itself. --- regression/goto-analyzer/fp-removal44/main.c | 41 ++++++++++ .../goto-analyzer/fp-removal44/test.desc | 9 +++ regression/goto-analyzer/fp-removal45/main.c | 41 ++++++++++ .../goto-analyzer/fp-removal45/test.desc | 9 +++ regression/goto-analyzer/fp-removal46/main.c | 41 ++++++++++ .../goto-analyzer/fp-removal46/test.desc | 9 +++ .../remove_const_function_pointers.cpp | 78 +++++++++++++++---- .../remove_const_function_pointers.h | 6 ++ 8 files changed, 219 insertions(+), 15 deletions(-) create mode 100644 regression/goto-analyzer/fp-removal44/main.c create mode 100644 regression/goto-analyzer/fp-removal44/test.desc create mode 100644 regression/goto-analyzer/fp-removal45/main.c create mode 100644 regression/goto-analyzer/fp-removal45/test.desc create mode 100644 regression/goto-analyzer/fp-removal46/main.c create mode 100644 regression/goto-analyzer/fp-removal46/test.desc diff --git a/regression/goto-analyzer/fp-removal44/main.c b/regression/goto-analyzer/fp-removal44/main.c new file mode 100644 index 00000000000..c7237dee13f --- /dev/null +++ b/regression/goto-analyzer/fp-removal44/main.c @@ -0,0 +1,41 @@ +#include +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +typedef struct fp_cc +{ + int x; + const void_fp * const container; +} fp_cc; + + + +void func(){ + const void_fp meta_fp = &f3; + const fp_cc container_container = { .container = &meta_fp, .x = 4 }; + + // Illegal: + //meta_fp = &f4; + //container_container.container = &f4; + + (*container_container.container)(); +} + +int main(){ + func(); +} diff --git a/regression/goto-analyzer/fp-removal44/test.desc b/regression/goto-analyzer/fp-removal44/test.desc new file mode 100644 index 00000000000..77c3b9a93d1 --- /dev/null +++ b/regression/goto-analyzer/fp-removal44/test.desc @@ -0,0 +1,9 @@ +CORE +main.c +--show-goto-functions --verbosity 10 + +^Removing function pointers and virtual functions$ +^\s*f3();$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/fp-removal45/main.c b/regression/goto-analyzer/fp-removal45/main.c new file mode 100644 index 00000000000..7324bad0488 --- /dev/null +++ b/regression/goto-analyzer/fp-removal45/main.c @@ -0,0 +1,41 @@ +#include +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +typedef struct fp_cc +{ + int x; + const void_fp * container; +} fp_cc; + + + +void func(){ + const void_fp meta_fp = &f3; + const fp_cc container_container = { .container = &meta_fp, .x = 4 }; + + // Illegal: + //meta_fp = &f4; + //container_container.container = &f4; + + (*container_container.container)(); +} + +int main(){ + func(); +} diff --git a/regression/goto-analyzer/fp-removal45/test.desc b/regression/goto-analyzer/fp-removal45/test.desc new file mode 100644 index 00000000000..77c3b9a93d1 --- /dev/null +++ b/regression/goto-analyzer/fp-removal45/test.desc @@ -0,0 +1,9 @@ +CORE +main.c +--show-goto-functions --verbosity 10 + +^Removing function pointers and virtual functions$ +^\s*f3();$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/fp-removal46/main.c b/regression/goto-analyzer/fp-removal46/main.c new file mode 100644 index 00000000000..26770f0b1e7 --- /dev/null +++ b/regression/goto-analyzer/fp-removal46/main.c @@ -0,0 +1,41 @@ +#include +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +typedef struct fp_cc +{ + int x; + const void_fp * const container; +} fp_cc; + + + +void func(){ + const void_fp meta_fp = &f3; + fp_cc container_container = { .container = &meta_fp, .x = 4 }; + + // Illegal: + //meta_fp = &f4; + //container_container.container = &f4; + + (*container_container.container)(); +} + +int main(){ + func(); +} diff --git a/regression/goto-analyzer/fp-removal46/test.desc b/regression/goto-analyzer/fp-removal46/test.desc new file mode 100644 index 00000000000..77c3b9a93d1 --- /dev/null +++ b/regression/goto-analyzer/fp-removal46/test.desc @@ -0,0 +1,9 @@ +CORE +main.c +--show-goto-functions --verbosity 10 + +^Removing function pointers and virtual functions$ +^\s*f3();$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/src/goto-programs/remove_const_function_pointers.cpp b/src/goto-programs/remove_const_function_pointers.cpp index c239a3f67d8..1b6f0289510 100644 --- a/src/goto-programs/remove_const_function_pointers.cpp +++ b/src/goto-programs/remove_const_function_pointers.cpp @@ -65,20 +65,13 @@ bool remove_const_function_pointerst::try_resolve_function_call( } else { - - struct_typet struct_type=to_struct_type(ns.follow(expression.type())); - size_t component_number= - struct_type.component_number(member_expr.get_component_name()); - const struct_exprt &struct_expr=to_struct_expr(expression); const exprt &component_value= - struct_expr.operands()[component_number]; + get_component_value(struct_expr, member_expr); - // Find out if the component is constant - struct_union_typet::componentt component= - struct_type.components()[component_number]; - - bool component_const=is_type_const(component.type()); + const typet &component_type= + get_component_type(struct_expr, member_expr); + bool component_const=is_type_const(component_type); if(component_const || struct_is_const) { @@ -344,7 +337,12 @@ bool remove_const_function_pointerst::try_resolve_expression( { struct_exprt struct_expr=to_struct_expr(potential_struct); const exprt &component_value= - struct_expr.operands()[member_expr.get_component_number()]; + get_component_value(struct_expr, member_expr); + const typet &component_type= + get_component_type(struct_expr, member_expr); + + all_components_const&=is_type_const(component_type); + expressionst out_expressions; bool component_const=false; bool resolved= @@ -356,9 +354,6 @@ bool remove_const_function_pointerst::try_resolve_expression( out_resolved_expression.end(), out_expressions.begin(), out_expressions.end()); - - all_components_const= - all_components_const && component_const; } else { @@ -628,3 +623,56 @@ bool remove_const_function_pointerst::is_type_const(const typet &type) const return qualifers.is_constant; } } + +/*******************************************************************\ + +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) +{ + const struct_typet &struct_type=to_struct_type(ns.follow(struct_expr.type())); + size_t component_number= + struct_type.component_number(member_expr.get_component_name()); + + return struct_expr.operands()[component_number]; +} + +/*******************************************************************\ + +Function: remove_const_function_pointerst::get_component_type + + Inputs: + struct_expr - The expression of the structure being accessed + member_expr - The expression saying which component is being accessed + + Outputs: Returns the type of the component. Note this may be differenent to + the type of its value (e.g. it may be a const pointer but its value + could just be a pointer). + + Purpose: To extract the type of the specific component within a struct + +\*******************************************************************/ + +typet remove_const_function_pointerst::get_component_type( + const struct_exprt &struct_expr, const member_exprt &member_expr) +{ + const struct_typet &struct_type=to_struct_type(ns.follow(struct_expr.type())); + size_t component_number= + struct_type.component_number(member_expr.get_component_name()); + struct_union_typet::componentt component= + struct_type.components()[component_number]; + + return component.type(); +} diff --git a/src/goto-programs/remove_const_function_pointers.h b/src/goto-programs/remove_const_function_pointers.h index cf7e85ca9a2..f641b0ce7ee 100644 --- a/src/goto-programs/remove_const_function_pointers.h +++ b/src/goto-programs/remove_const_function_pointers.h @@ -54,6 +54,12 @@ class remove_const_function_pointerst:public messaget bool is_expression_const(const exprt &expression) const; bool is_type_const(const typet &type) const; + exprt get_component_value( + const struct_exprt &struct_expr, const member_exprt &member_expr); + + typet get_component_type( + const struct_exprt &struct_expr, const member_exprt &member_expr); + const exprt original_expression; const namespacet &ns; const symbol_tablet &symbol_table; From 3da26cd124ad1dbf9539136a43a4ef50ce7deb6f Mon Sep 17 00:00:00 2001 From: thk123 Date: Wed, 8 Feb 2017 14:32:32 +0000 Subject: [PATCH 021/116] Adding test for another way the previous bug could be exhibited --- regression/goto-analyzer/fp-removal47/main.c | 48 +++++++++++++++++++ .../goto-analyzer/fp-removal47/test.desc | 9 ++++ 2 files changed, 57 insertions(+) create mode 100644 regression/goto-analyzer/fp-removal47/main.c create mode 100644 regression/goto-analyzer/fp-removal47/test.desc diff --git a/regression/goto-analyzer/fp-removal47/main.c b/regression/goto-analyzer/fp-removal47/main.c new file mode 100644 index 00000000000..70b853a9dff --- /dev/null +++ b/regression/goto-analyzer/fp-removal47/main.c @@ -0,0 +1,48 @@ +#include +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +typedef struct fp_container +{ + int y; + const void_fp pointer; +} fp_container; + +typedef struct fp_cc +{ + int x; + const fp_container * const container; +} fp_cc; + + + +void func(){ + const fp_container container = {.y = 10, .pointer = f3}; + const fp_container container2 = {.y = 10, .pointer = f4}; + const fp_cc container_container = { .container = &container, .x = 4 }; + + // Illegal: + //container_container.container = &container2; + //container.pointer = f4; + + (*container_container.container).pointer(); +} + +int main(){ + func(); +} diff --git a/regression/goto-analyzer/fp-removal47/test.desc b/regression/goto-analyzer/fp-removal47/test.desc new file mode 100644 index 00000000000..77c3b9a93d1 --- /dev/null +++ b/regression/goto-analyzer/fp-removal47/test.desc @@ -0,0 +1,9 @@ +CORE +main.c +--show-goto-functions --verbosity 10 + +^Removing function pointers and virtual functions$ +^\s*f3();$ +^SIGNAL=0$ +-- +^warning: ignoring From eefba98432405be583748eb1d264da74506c5fad Mon Sep 17 00:00:00 2001 From: thk123 Date: Wed, 8 Feb 2017 14:49:59 +0000 Subject: [PATCH 022/116] Adding a test variation of 44 without the consts that fails correctly --- regression/goto-analyzer/fp-removal48/main.c | 42 +++++++++++++++++++ .../goto-analyzer/fp-removal48/test.desc | 17 ++++++++ 2 files changed, 59 insertions(+) create mode 100644 regression/goto-analyzer/fp-removal48/main.c create mode 100644 regression/goto-analyzer/fp-removal48/test.desc diff --git a/regression/goto-analyzer/fp-removal48/main.c b/regression/goto-analyzer/fp-removal48/main.c new file mode 100644 index 00000000000..12949ed8d85 --- /dev/null +++ b/regression/goto-analyzer/fp-removal48/main.c @@ -0,0 +1,42 @@ +#include +#include + +void f1 (void) { printf("%i", 1); } +void f2 (void) { printf("%i", 2); } +void f3 (void) { printf("%i", 3); } +void f4 (void) { printf("%i", 4); } +void f5 (void) { printf("%i", 5); } +void f6 (void) { printf("%i", 6); } +void f7 (void) { printf("%i", 7); } +void f8 (void) { printf("%i", 8); } +void f9 (void) { printf("%i", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +typedef struct fp_cc +{ + int x; + const void_fp * container; +} fp_cc; + + + +void func(){ + const void_fp meta_fp = &f3; + const void_fp meta_fp2 = &f4; + fp_cc container_container = { .container = &meta_fp, .x = 4 }; + + // Illegal: + //meta_fp = &f4; + container_container.container = &meta_fp2; + + (*container_container.container)(); +} + +int main(){ + func(); +} diff --git a/regression/goto-analyzer/fp-removal48/test.desc b/regression/goto-analyzer/fp-removal48/test.desc new file mode 100644 index 00000000000..0899addb26a --- /dev/null +++ b/regression/goto-analyzer/fp-removal48/test.desc @@ -0,0 +1,17 @@ +CORE +main.c +--show-goto-functions --verbosity 10 + +^Removing function pointers and virtual functions$ +^\s*IF \*container_container\.container == f1 THEN GOTO 1$ +^\s*IF \*container_container\.container == f2 THEN GOTO 2$ +^\s*IF \*container_container\.container == f3 THEN GOTO 3$ +^\s*IF \*container_container\.container == f4 THEN GOTO 4$ +^\s*IF \*container_container\.container == f5 THEN GOTO 5$ +^\s*IF \*container_container\.container == f6 THEN GOTO 6$ +^\s*IF \*container_container\.container == f7 THEN GOTO 7$ +^\s*IF \*container_container\.container == f8 THEN GOTO 8$ +^\s*IF \*container_container\.container == f9 THEN GOTO 9$ +^SIGNAL=0$ +-- +^warning: ignoring From 132801a6a853376d93218ee80f23bbba1dd0d221 Mon Sep 17 00:00:00 2001 From: thk123 Date: Wed, 8 Feb 2017 16:25:20 +0000 Subject: [PATCH 023/116] Squash constant symbols first We squash all the symbols we can before running the full squashing of everything to remove FPs. This allows for example, computation of array indicies that have operators inside them. As such, enabling the test. --- .../goto-analyzer/fp-removal35/test.desc | 2 +- .../remove_const_function_pointers.cpp | 59 ++++++++++++++++++- .../remove_const_function_pointers.h | 1 + 3 files changed, 60 insertions(+), 2 deletions(-) diff --git a/regression/goto-analyzer/fp-removal35/test.desc b/regression/goto-analyzer/fp-removal35/test.desc index 5b566c321ca..a402b60e080 100644 --- a/regression/goto-analyzer/fp-removal35/test.desc +++ b/regression/goto-analyzer/fp-removal35/test.desc @@ -1,4 +1,4 @@ -KNOWNBUG +CORE main.c --show-goto-functions ^Removing function pointers and virtual functions$ diff --git a/src/goto-programs/remove_const_function_pointers.cpp b/src/goto-programs/remove_const_function_pointers.cpp index 1b6f0289510..72b1a62e575 100644 --- a/src/goto-programs/remove_const_function_pointers.cpp +++ b/src/goto-programs/remove_const_function_pointers.cpp @@ -26,7 +26,64 @@ remove_const_function_pointerst::remove_const_function_pointerst( bool remove_const_function_pointerst::operator()( functionst &out_functions) { - return try_resolve_function_call(original_expression, out_functions); + // Replace all const symbols with their values + exprt non_symbol_expression=replace_const_symbols(original_expression); + return try_resolve_function_call(non_symbol_expression, out_functions); +} + +/*******************************************************************\ + +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 +{ + if(expression.id()==ID_symbol) + { + if(is_expression_const(expression)) + { + const symbolt &symbol= + symbol_table.lookup(expression.get(ID_identifier)); + if(symbol.type.id()!=ID_code) + { + const exprt &symbol_value=symbol.value; + return replace_const_symbols(symbol_value); + } + else + { + return expression; + } + } + else + { + return expression; + } + } + else + { + exprt const_symbol_cleared_expr=expression; + const_symbol_cleared_expr.operands().clear(); + for(const exprt &op : expression.operands()) + { + exprt const_symbol_cleared_op=replace_const_symbols(op); + const_symbol_cleared_expr.operands().push_back(const_symbol_cleared_op); + } + + return const_symbol_cleared_expr; + } } exprt remove_const_function_pointerst::resolve_symbol( diff --git a/src/goto-programs/remove_const_function_pointers.h b/src/goto-programs/remove_const_function_pointers.h index f641b0ce7ee..1d56eee552a 100644 --- a/src/goto-programs/remove_const_function_pointers.h +++ b/src/goto-programs/remove_const_function_pointers.h @@ -29,6 +29,7 @@ class remove_const_function_pointerst:public messaget bool operator()(functionst &out_functions); private: + exprt replace_const_symbols(const exprt &expression) const; exprt resolve_symbol(const symbol_exprt &symbol_expr) const; // recursive functions for dealing with the function pointer From 931b2393f2b863a5cc988d06e61d94c7459932f4 Mon Sep 17 00:00:00 2001 From: thk123 Date: Wed, 8 Feb 2017 16:42:51 +0000 Subject: [PATCH 024/116] Fixed major bug with non const structs I had misunderstood and thought that a non const struct with a const member couldn't have the value changed, so this was sufficent. However, as I demonstrate in all the failing tests (which I've fixed) you can also overwrite the entire struct. Instead, we now require when squashing member access, that the struct itself be const (we don't care whether the member is or not, since if it is and the struct isn't, it can be overwritten, and if it isn't and the struct is, its value cannot be changed). Also, all the tests that rely on this have been modified to require no pointer optimization. --- regression/goto-analyzer/fp-removal12/main.c | 8 ++-- regression/goto-analyzer/fp-removal26/main.c | 1 + .../goto-analyzer/fp-removal26/test.desc | 10 ++++- .../goto-analyzer/fp-removal28/test.desc | 10 ++++- regression/goto-analyzer/fp-removal32/main.c | 2 + .../goto-analyzer/fp-removal32/test.desc | 10 ++++- regression/goto-analyzer/fp-removal46/main.c | 4 ++ .../goto-analyzer/fp-removal46/test.desc | 10 ++++- .../remove_const_function_pointers.cpp | 41 +------------------ .../remove_const_function_pointers.h | 3 -- 10 files changed, 49 insertions(+), 50 deletions(-) diff --git a/regression/goto-analyzer/fp-removal12/main.c b/regression/goto-analyzer/fp-removal12/main.c index be398e7f255..06ccc492469 100644 --- a/regression/goto-analyzer/fp-removal12/main.c +++ b/regression/goto-analyzer/fp-removal12/main.c @@ -25,14 +25,14 @@ typedef struct fp_container void func(){ - fp_container container = { .fp_tbl = {f2 ,f3, f4} }; - fp_container container2 = { .fp_tbl = {f5 ,f6, f7} }; + const fp_container container = { .fp_tbl = {f2 ,f3, f4} }; + const fp_container container2 = { .fp_tbl = {f5 ,f6, f7} }; // Illegal: - // container = container2; + //container = container2; const void_fp fp = container.fp_tbl[1]; fp(); } -void main(){ +int main(){ func(); } diff --git a/regression/goto-analyzer/fp-removal26/main.c b/regression/goto-analyzer/fp-removal26/main.c index 66b03305547..e7b62bc8b81 100644 --- a/regression/goto-analyzer/fp-removal26/main.c +++ b/regression/goto-analyzer/fp-removal26/main.c @@ -29,6 +29,7 @@ void func(int i){ // Illegal //pts=&other_thing; // thing.go=&f6; + thing = other_thing; const void_fp fp = pts->go; fp(); diff --git a/regression/goto-analyzer/fp-removal26/test.desc b/regression/goto-analyzer/fp-removal26/test.desc index 656246683a5..889299e9a3c 100644 --- a/regression/goto-analyzer/fp-removal26/test.desc +++ b/regression/goto-analyzer/fp-removal26/test.desc @@ -3,7 +3,15 @@ main.c --show-goto-functions --verbosity 10 ^Removing function pointers and virtual functions$ -^\s*f2();$ +^\s*IF fp == f1 THEN GOTO 1$ +^\s*IF fp == f2 THEN GOTO 2$ +^\s*IF fp == f3 THEN GOTO 3$ +^\s*IF fp == f4 THEN GOTO 4$ +^\s*IF fp == f5 THEN GOTO 5$ +^\s*IF fp == f6 THEN GOTO 6$ +^\s*IF fp == f7 THEN GOTO 7$ +^\s*IF fp == f8 THEN GOTO 8$ +^\s*IF fp == f9 THEN GOTO 9$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/fp-removal28/test.desc b/regression/goto-analyzer/fp-removal28/test.desc index 656246683a5..889299e9a3c 100644 --- a/regression/goto-analyzer/fp-removal28/test.desc +++ b/regression/goto-analyzer/fp-removal28/test.desc @@ -3,7 +3,15 @@ main.c --show-goto-functions --verbosity 10 ^Removing function pointers and virtual functions$ -^\s*f2();$ +^\s*IF fp == f1 THEN GOTO 1$ +^\s*IF fp == f2 THEN GOTO 2$ +^\s*IF fp == f3 THEN GOTO 3$ +^\s*IF fp == f4 THEN GOTO 4$ +^\s*IF fp == f5 THEN GOTO 5$ +^\s*IF fp == f6 THEN GOTO 6$ +^\s*IF fp == f7 THEN GOTO 7$ +^\s*IF fp == f8 THEN GOTO 8$ +^\s*IF fp == f9 THEN GOTO 9$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/fp-removal32/main.c b/regression/goto-analyzer/fp-removal32/main.c index 6076e1f12be..210facf60bf 100644 --- a/regression/goto-analyzer/fp-removal32/main.c +++ b/regression/goto-analyzer/fp-removal32/main.c @@ -18,6 +18,7 @@ struct state const void_fp go; }; struct state thing = {0, &f2}; +struct state other_thing = {0, &f4}; struct state const * const pts = &thing; @@ -26,6 +27,7 @@ struct state const * const pts = &thing; const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; void func(int i){ + thing = other_thing; pts->go(); } diff --git a/regression/goto-analyzer/fp-removal32/test.desc b/regression/goto-analyzer/fp-removal32/test.desc index 0c27e7670ac..f199330660a 100644 --- a/regression/goto-analyzer/fp-removal32/test.desc +++ b/regression/goto-analyzer/fp-removal32/test.desc @@ -3,7 +3,15 @@ main.c --show-goto-functions --verbosity 10 ^Removing function pointers and virtual functions$ -^\s*f2();$ +^\s*IF pts->go == f1 THEN GOTO 1$ +^\s*IF pts->go == f2 THEN GOTO 2$ +^\s*IF pts->go == f3 THEN GOTO 3$ +^\s*IF pts->go == f4 THEN GOTO 4$ +^\s*IF pts->go == f5 THEN GOTO 5$ +^\s*IF pts->go == f6 THEN GOTO 6$ +^\s*IF pts->go == f7 THEN GOTO 7$ +^\s*IF pts->go == f8 THEN GOTO 8$ +^\s*IF pts->go == f9 THEN GOTO 9$ ^SIGNAL=0$ -- ^warning: ignoring \ No newline at end of file diff --git a/regression/goto-analyzer/fp-removal46/main.c b/regression/goto-analyzer/fp-removal46/main.c index 26770f0b1e7..c1f4811bad8 100644 --- a/regression/goto-analyzer/fp-removal46/main.c +++ b/regression/goto-analyzer/fp-removal46/main.c @@ -27,7 +27,11 @@ typedef struct fp_cc void func(){ const void_fp meta_fp = &f3; + const void_fp meta_fp2 = &f4; + + fp_cc container_container2 = { .container = &meta_fp2, .x = 4 }; fp_cc container_container = { .container = &meta_fp, .x = 4 }; + container_container = container_container2; // Illegal: //meta_fp = &f4; diff --git a/regression/goto-analyzer/fp-removal46/test.desc b/regression/goto-analyzer/fp-removal46/test.desc index 77c3b9a93d1..0899addb26a 100644 --- a/regression/goto-analyzer/fp-removal46/test.desc +++ b/regression/goto-analyzer/fp-removal46/test.desc @@ -3,7 +3,15 @@ main.c --show-goto-functions --verbosity 10 ^Removing function pointers and virtual functions$ -^\s*f3();$ +^\s*IF \*container_container\.container == f1 THEN GOTO 1$ +^\s*IF \*container_container\.container == f2 THEN GOTO 2$ +^\s*IF \*container_container\.container == f3 THEN GOTO 3$ +^\s*IF \*container_container\.container == f4 THEN GOTO 4$ +^\s*IF \*container_container\.container == f5 THEN GOTO 5$ +^\s*IF \*container_container\.container == f6 THEN GOTO 6$ +^\s*IF \*container_container\.container == f7 THEN GOTO 7$ +^\s*IF \*container_container\.container == f8 THEN GOTO 8$ +^\s*IF \*container_container\.container == f9 THEN GOTO 9$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/src/goto-programs/remove_const_function_pointers.cpp b/src/goto-programs/remove_const_function_pointers.cpp index 72b1a62e575..6d87765a6a0 100644 --- a/src/goto-programs/remove_const_function_pointers.cpp +++ b/src/goto-programs/remove_const_function_pointers.cpp @@ -126,11 +126,7 @@ bool remove_const_function_pointerst::try_resolve_function_call( const exprt &component_value= get_component_value(struct_expr, member_expr); - const typet &component_type= - get_component_type(struct_expr, member_expr); - bool component_const=is_type_const(component_type); - - if(component_const || struct_is_const) + if(struct_is_const) { functionst component_functions; bool resolved= @@ -387,7 +383,6 @@ bool remove_const_function_pointerst::try_resolve_expression( if(resolved_struct) { - bool all_components_const=true; for(const exprt &potential_struct : potential_structs) { if(potential_struct.id()==ID_struct) @@ -395,10 +390,6 @@ bool remove_const_function_pointerst::try_resolve_expression( struct_exprt struct_expr=to_struct_expr(potential_struct); const exprt &component_value= get_component_value(struct_expr, member_expr); - const typet &component_type= - get_component_type(struct_expr, member_expr); - - all_components_const&=is_type_const(component_type); expressionst out_expressions; bool component_const=false; @@ -422,7 +413,7 @@ bool remove_const_function_pointerst::try_resolve_expression( return false; } } - out_is_const=all_components_const||is_struct_const; + out_is_const=is_struct_const; return true; } else @@ -705,31 +696,3 @@ exprt remove_const_function_pointerst::get_component_value( return struct_expr.operands()[component_number]; } - -/*******************************************************************\ - -Function: remove_const_function_pointerst::get_component_type - - Inputs: - struct_expr - The expression of the structure being accessed - member_expr - The expression saying which component is being accessed - - Outputs: Returns the type of the component. Note this may be differenent to - the type of its value (e.g. it may be a const pointer but its value - could just be a pointer). - - Purpose: To extract the type of the specific component within a struct - -\*******************************************************************/ - -typet remove_const_function_pointerst::get_component_type( - const struct_exprt &struct_expr, const member_exprt &member_expr) -{ - const struct_typet &struct_type=to_struct_type(ns.follow(struct_expr.type())); - size_t component_number= - struct_type.component_number(member_expr.get_component_name()); - struct_union_typet::componentt component= - struct_type.components()[component_number]; - - return component.type(); -} diff --git a/src/goto-programs/remove_const_function_pointers.h b/src/goto-programs/remove_const_function_pointers.h index 1d56eee552a..e8600b9c3be 100644 --- a/src/goto-programs/remove_const_function_pointers.h +++ b/src/goto-programs/remove_const_function_pointers.h @@ -58,9 +58,6 @@ class remove_const_function_pointerst:public messaget exprt get_component_value( const struct_exprt &struct_expr, const member_exprt &member_expr); - typet get_component_type( - const struct_exprt &struct_expr, const member_exprt &member_expr); - const exprt original_expression; const namespacet &ns; const symbol_tablet &symbol_table; From 2e941258fe438458986ce4857d8b3b709eddb8df Mon Sep 17 00:00:00 2001 From: thk123 Date: Wed, 8 Feb 2017 16:49:16 +0000 Subject: [PATCH 025/116] Removing redundant code Since we now require all symbols to be const (the only exception before was structs with const components, but that is not sufficent), the preliminary sweep for symbols is sufficent to catch all valid ones. --- .../remove_const_function_pointers.cpp | 25 ++----------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/src/goto-programs/remove_const_function_pointers.cpp b/src/goto-programs/remove_const_function_pointers.cpp index 6d87765a6a0..b48c1d5de5a 100644 --- a/src/goto-programs/remove_const_function_pointers.cpp +++ b/src/goto-programs/remove_const_function_pointers.cpp @@ -240,16 +240,7 @@ bool remove_const_function_pointerst::try_resolve_function_call( } else { - const c_qualifierst pointer_qualifers(simplified_expr.type()); - if(!pointer_qualifers.is_constant) - { - debug() << "Can't optimize FP since symbol " - << simplified_expr.get(ID_identifier) << " is not const" << eom; - return false; - } - - const exprt &symbol_value=resolve_symbol(to_symbol_expr(simplified_expr)); - return try_resolve_function_call(symbol_value, out_functions); + return false; } } else @@ -497,19 +488,7 @@ bool remove_const_function_pointerst::try_resolve_expression( } else if(simplified_expr.id()==ID_symbol) { - const exprt &symbol_value=resolve_symbol(to_symbol_expr(simplified_expr)); - bool is_symbol_const=is_expression_const(simplified_expr); - bool is_symbol_value_const=false; - bool resolved_expression= - try_resolve_expression( - symbol_value, - out_resolved_expression, - is_symbol_value_const); - - // If we have a symbol, it is only const if the value it is assigned - // is const and it is in fact const. - out_is_const=is_symbol_const; - return resolved_expression; + return false; } // TOOD: probably need to do something with pointers or address_of // and const since a const pointer to a non-const value is useless From 63afb800eff369b346decd6bb16a63254a1de1c8 Mon Sep 17 00:00:00 2001 From: thk123 Date: Wed, 8 Feb 2017 17:44:29 +0000 Subject: [PATCH 026/116] Added logging for all the ways the FP removal might not complete --- .../remove_const_function_pointers.cpp | 72 ++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/src/goto-programs/remove_const_function_pointers.cpp b/src/goto-programs/remove_const_function_pointers.cpp index b48c1d5de5a..6b7eda28a0e 100644 --- a/src/goto-programs/remove_const_function_pointers.cpp +++ b/src/goto-programs/remove_const_function_pointers.cpp @@ -12,6 +12,10 @@ Author: Thomas Kiley, thomas.kiley@diffblue.com #include "remove_const_function_pointers.h" +#define LOG(message, irep) \ + debug() << "Case " << __LINE__ << " : " << message << "\n" \ + << irep.pretty() << eom; + remove_const_function_pointerst::remove_const_function_pointerst( message_handlert &message_handler, const exprt &base_expression, @@ -118,6 +122,7 @@ bool remove_const_function_pointerst::try_resolve_function_call( { if(expression.id()!=ID_struct) { + LOG("Squash of member access didn't result in a struct", expression); return false; } else @@ -138,11 +143,17 @@ bool remove_const_function_pointerst::try_resolve_function_call( } else { + LOG( + "Couldn't resolve functions call from component value", + component_value); return false; } } else { + LOG( + "Struct was not const so can't resolve values on it", + struct_expr); return false; } } @@ -153,13 +164,20 @@ bool remove_const_function_pointerst::try_resolve_function_call( } else { + LOG("Failed to squash struct member access", owner_expr); return false; } } else if(simplified_expr.id()==ID_address_of) { address_of_exprt address_expr=to_address_of_expr(simplified_expr); - return try_resolve_function_call(address_expr.object(), out_functions); + bool resolved= + try_resolve_function_call(address_expr.object(), out_functions); + if(!resolved) + { + LOG("Failed to resolve address of", address_expr); + } + return resolved; } else if(simplified_expr.id()==ID_dereference) { @@ -195,11 +213,15 @@ bool remove_const_function_pointerst::try_resolve_function_call( } else { + LOG("Failed to resolver pointers value", address_expr); return false; } } else { + LOG( + "Squashing dereference did not result in an address of", + pointer_val); return false; } } @@ -207,6 +229,14 @@ bool remove_const_function_pointerst::try_resolve_function_call( } else { + if(!resolved) + { + LOG("Failed to squash dereference", deref); + } + else if(!pointer_const) + { + LOG("Dereferenced value was not const so can't dereference", deref); + } return false; } } @@ -228,6 +258,7 @@ bool remove_const_function_pointerst::try_resolve_function_call( } else { + LOG("Failed to squash typecast", simplified_expr); return false; } } @@ -240,11 +271,13 @@ bool remove_const_function_pointerst::try_resolve_function_call( } else { + LOG("Non const symbol wasn't squashed", simplified_expr); return false; } } else { + LOG("Unrecognised expression", simplified_expr); return false; } } @@ -293,6 +326,7 @@ bool remove_const_function_pointerst::try_resolve_index_of_function_call( } else { + LOG("Could not resolve expression in array", func_expr); return false; } } @@ -317,6 +351,7 @@ bool remove_const_function_pointerst::try_resolve_index_of_function_call( } else { + LOG("Could not resolve expression in array", array_entry); return false; } } @@ -324,11 +359,13 @@ bool remove_const_function_pointerst::try_resolve_index_of_function_call( } else { + LOG("Array and its contents are not const", potential_array_expr); return false; } } else { + LOG("Squashing index did not result in an array", potential_array_expr); return false; } } @@ -337,6 +374,7 @@ bool remove_const_function_pointerst::try_resolve_index_of_function_call( } else { + LOG("Could not resolve arary", index_expr); return false; } } @@ -351,6 +389,7 @@ bool remove_const_function_pointerst::try_resolve_expression( expressionst out_array_expressions; bool resolved_array= try_resolve_index_of(index_expr, out_array_expressions, out_is_const); + if(resolved_array) { out_resolved_expression.insert( @@ -358,6 +397,10 @@ bool remove_const_function_pointerst::try_resolve_expression( out_array_expressions.begin(), out_array_expressions.end()); } + else + { + LOG("Could not resolve array", index_expr); + } return resolved_array; } @@ -396,11 +439,15 @@ bool remove_const_function_pointerst::try_resolve_expression( } else { + LOG("Could not resolve component value", component_value); return false; } } else { + LOG( + "Squashing member access did not resolve in a struct", + potential_struct); return false; } } @@ -409,6 +456,7 @@ bool remove_const_function_pointerst::try_resolve_expression( } else { + LOG("Failed to squash struct access", member_expr); return false; } } @@ -445,9 +493,15 @@ bool remove_const_function_pointerst::try_resolve_expression( all_objects_const&=object_const; } + else + { + LOG("Failed to resolve value of a dereference", address_expr); + } } else { + LOG( + "Squashing dereference did not result in an address", pointer_val); return false; } } @@ -456,6 +510,14 @@ bool remove_const_function_pointerst::try_resolve_expression( } else { + if(!resolved) + { + LOG("Failed to resolve pointer of dereference", deref); + } + else if(!pointer_const) + { + LOG("Pointer value not const so can't squash", deref); + } return false; } } @@ -483,11 +545,13 @@ bool remove_const_function_pointerst::try_resolve_expression( } else { + LOG("Could not resolve typecast value", typecast_expr); return false; } } else if(simplified_expr.id()==ID_symbol) { + LOG("Non const symbol will not be squashed", simplified_expr); return false; } // TOOD: probably need to do something with pointers or address_of @@ -580,6 +644,7 @@ bool remove_const_function_pointerst::try_resolve_index_of( } else { + LOG("Failed to resolve array value", func_expr); return false; } } @@ -611,6 +676,7 @@ bool remove_const_function_pointerst::try_resolve_index_of( } else { + LOG("Failed to resolve array value", array_entry); return false; } } @@ -618,6 +684,9 @@ bool remove_const_function_pointerst::try_resolve_index_of( } else { + LOG( + "Squashing index of did not result in an array", + potential_array_expr); return false; } } @@ -627,6 +696,7 @@ bool remove_const_function_pointerst::try_resolve_index_of( } else { + LOG("Failed to squash index of to array expression", index_expr); return false; } } From 9da5ba2f34687e9cbe0b76ed2dc44f1c9aa36ccf Mon Sep 17 00:00:00 2001 From: thk123 Date: Thu, 9 Feb 2017 11:26:19 +0000 Subject: [PATCH 027/116] Adding consistency checks for the output If the output of removing the FPs is true, then we expect at least one function to replace the call with. If it is false, then we don't expect any functions. If these fail, it probably indicates a bug in the remove_const_function_pointerst class. --- src/goto-programs/remove_function_pointers.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/goto-programs/remove_function_pointers.cpp b/src/goto-programs/remove_function_pointers.cpp index 1e63b25a9a6..4c505cdc191 100644 --- a/src/goto-programs/remove_function_pointers.cpp +++ b/src/goto-programs/remove_function_pointers.cpp @@ -350,6 +350,14 @@ void remove_function_pointerst::remove_function_pointer( bool found_functions=fpr(functions); + // Consistency checks + // Reported optimized function pointer call, but didn't find any functions + assert(!found_functions || !functions.empty()); + + // Reported didn't optimize function pointer call, but did find some + // functions to replace with + assert(found_functions || functions.empty()); + if(functions.size()==1) { to_code_function_call(target->code).function()=*functions.cbegin(); @@ -358,12 +366,6 @@ void remove_function_pointerst::remove_function_pointer( if(!found_functions) { - debug() << "Failed to optimize away the function pointer\n" - << "The type was " << pointer.id() << " " - << "irep dump:\n" - << pointer.pretty() - << eom; - bool return_value_used=code.lhs().is_not_nil(); // get all type-compatible functions From d81f6cba3a2dd469992e321c9f1a8a8d662a64de Mon Sep 17 00:00:00 2001 From: thk123 Date: Thu, 9 Feb 2017 12:14:07 +0000 Subject: [PATCH 028/116] Adding comments to remove_const_function_pointers --- .../remove_const_function_pointers.cpp | 191 +++++++++++++++++- 1 file changed, 186 insertions(+), 5 deletions(-) diff --git a/src/goto-programs/remove_const_function_pointers.cpp b/src/goto-programs/remove_const_function_pointers.cpp index 6b7eda28a0e..3e04103c964 100644 --- a/src/goto-programs/remove_const_function_pointers.cpp +++ b/src/goto-programs/remove_const_function_pointers.cpp @@ -16,6 +16,23 @@ Author: Thomas Kiley, thomas.kiley@diffblue.com debug() << "Case " << __LINE__ << " : " << message << "\n" \ << irep.pretty() << eom; +/*******************************************************************\ + +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, @@ -27,6 +44,28 @@ remove_const_function_pointerst::remove_const_function_pointerst( symbol_table(symbol_table) {} +/*******************************************************************\ + +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) { @@ -90,6 +129,19 @@ exprt remove_const_function_pointerst::replace_const_symbols( } } +/*******************************************************************\ + +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 { @@ -98,6 +150,25 @@ exprt remove_const_function_pointerst::resolve_symbol( return symbol.value; } +/*******************************************************************\ + +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, remove_const_function_pointerst::functionst &out_functions) { @@ -282,9 +353,27 @@ bool remove_const_function_pointerst::try_resolve_function_call( } } -// Take an index of, squash its array and squash its index -// If we can get a precise number, try_resolve_function_call on its value -// otherwise try_resolve_function_call on each and return the union of them all +/*******************************************************************\ + +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) { @@ -379,6 +468,33 @@ bool remove_const_function_pointerst::try_resolve_index_of_function_call( } } +/*******************************************************************\ + +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) { @@ -564,6 +680,25 @@ bool remove_const_function_pointerst::try_resolve_expression( } } +/*******************************************************************\ + +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) { @@ -596,9 +731,28 @@ bool remove_const_function_pointerst::try_resolve_index_value( } } +/*******************************************************************\ + +Function: remove_const_function_pointerst::try_resolve_index_of + + Inputs: + index_expr - The index expression to to resolve to possible function calls + out_expressions - The functions 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. + +\*******************************************************************/ -// Takes an index of, squashes its array and index -// if index is resolvable bool remove_const_function_pointerst::try_resolve_index_of( const index_exprt &index_expr, expressionst &out_expressions, @@ -701,12 +855,39 @@ bool remove_const_function_pointerst::try_resolve_index_of( } } +/*******************************************************************\ + +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_expression_const( const exprt &expression) const { return is_type_const(expression.type()); } +/*******************************************************************\ + +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_type_const(const typet &type) const { c_qualifierst qualifers(type); From 3e669c0231075a5c39abd217c4afd978bc6f9fde Mon Sep 17 00:00:00 2001 From: thk123 Date: Thu, 9 Feb 2017 15:13:04 +0000 Subject: [PATCH 029/116] Renamed all the tests Gave all the regression tests sensible names so relevant cases can be found and missing cases identified. --- .../{fp-removal34 => approx-array-variable-const-fp}/main.c | 0 .../{fp-removal34 => approx-array-variable-const-fp}/test.desc | 0 .../main.c | 0 .../test.desc | 0 .../main.c | 0 .../test.desc | 0 .../main.c | 0 .../test.desc | 0 .../main.c | 0 .../test.desc | 0 .../main.c | 0 .../test.desc | 0 .../main.c | 0 .../test.desc | 0 .../main.c | 0 .../test.desc | 0 .../main.c | 0 .../test.desc | 0 .../main.c | 0 .../test.desc | 0 .../main.c | 0 .../test.desc | 0 .../main.c | 0 .../test.desc | 0 .../main.c | 0 .../test.desc | 0 .../main.c | 0 .../test.desc | 0 .../main.c | 0 .../test.desc | 0 .../main.c | 0 .../test.desc | 0 .../main.c | 0 .../test.desc | 0 .../main.c | 0 .../test.desc | 0 .../main.c | 0 .../test.desc | 2 +- .../main.c | 0 .../test.desc | 0 .../main.c | 0 .../test.desc | 0 .../main.c | 0 .../test.desc | 0 .../main.c | 0 .../test.desc | 0 .../main.c | 0 .../test.desc | 0 .../{fp-removal15 => no-match-non-const-fp}/main.c | 0 .../{fp-removal7 => no-match-non-const-fp}/test.desc | 2 +- .../{fp-removal40 => no-match-parameter-const-fp}/main.c | 0 .../{fp-removal40 => no-match-parameter-const-fp}/test.desc | 0 .../goto-analyzer/{fp-removal7 => no-match-parameter-fp}/main.c | 0 .../{fp-removal41 => no-match-parameter-fp}/test.desc | 0 .../main.c | 0 .../test.desc | 0 .../{fp-removal35 => precise-array-calculation-const-fp}/main.c | 0 .../test.desc | 0 .../{fp-removal33 => precise-array-literal-const-fp}/main.c | 0 .../{fp-removal3 => precise-array-literal-const-fp}/test.desc | 0 .../main.c | 0 .../test.desc | 0 .../main.c | 0 .../test.desc | 0 .../main.c | 1 + .../test.desc | 0 .../{fp-removal2 => precise-const-fp-const-fp}/main.c | 0 .../{fp-removal2 => precise-const-fp-const-fp}/test.desc | 0 .../main.c | 0 .../test.desc | 0 .../main.c | 0 .../test.desc | 0 .../main.c | 0 .../test.desc | 0 .../main.c | 0 .../test.desc | 0 .../goto-analyzer/{fp-removal1 => precise-const-fp}/main.c | 0 .../goto-analyzer/{fp-removal1 => precise-const-fp}/test.desc | 0 .../{fp-removal30 => precise-const-struct-non-const-fp}/main.c | 0 .../test.desc | 0 .../main.c | 0 .../test.desc | 0 .../goto-analyzer/{fp-removal17 => precise-derefence}/main.c | 0 .../goto-analyzer/{fp-removal17 => precise-derefence}/test.desc | 0 .../main.c | 0 .../test.desc | 0 .../main.c | 0 .../test.desc | 0 .../main.c | 0 .../test.desc | 0 .../main.c | 0 .../test.desc | 0 92 files changed, 3 insertions(+), 2 deletions(-) rename regression/goto-analyzer/{fp-removal34 => approx-array-variable-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal34 => approx-array-variable-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal19 => approx-const-fp-array-variable-cast-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal19 => approx-const-fp-array-variable-cast-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal22 => approx-const-fp-array-variable-const-fp-with-null}/main.c (100%) rename regression/goto-analyzer/{fp-removal22 => approx-const-fp-array-variable-const-fp-with-null}/test.desc (100%) rename regression/goto-analyzer/{fp-removal5 => approx-const-fp-array-variable-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal5 => approx-const-fp-array-variable-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal24 => approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp1}/main.c (100%) rename regression/goto-analyzer/{fp-removal23 => approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp1}/test.desc (100%) rename regression/goto-analyzer/{fp-removal25 => approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp2}/main.c (100%) rename regression/goto-analyzer/{fp-removal25 => approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp2}/test.desc (100%) rename regression/goto-analyzer/{fp-removal21 => approx-const-fp-array-variable-const-struct-non-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal21 => approx-const-fp-array-variable-const-struct-non-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal20 => approx-const-fp-array-variable-invalid-cast-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal20 => approx-const-fp-array-variable-invalid-cast-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal41 => no-match-const-fp-array-literal-const-fp-run-time}/main.c (100%) rename regression/goto-analyzer/{fp-removal11 => no-match-const-fp-array-literal-const-fp-run-time}/test.desc (100%) rename regression/goto-analyzer/{fp-removal6 => no-match-const-fp-array-literal-non-const-fp-run-time}/main.c (100%) rename regression/goto-analyzer/{fp-removal15 => no-match-const-fp-array-literal-non-const-fp-run-time}/test.desc (100%) rename regression/goto-analyzer/{fp-removal8 => no-match-const-fp-array-literal-non-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal10 => no-match-const-fp-array-literal-non-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal10 => no-match-const-fp-array-non-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal8 => no-match-const-fp-array-non-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal26 => no-match-const-fp-const-pointer-non-const-struct-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal26 => no-match-const-fp-const-pointer-non-const-struct-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal39 => no-match-const-fp-dereference-non-const-pointer-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal39 => no-match-const-fp-dereference-non-const-pointer-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal11 => no-match-const-fp-dynamic-array-non-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal29 => no-match-const-fp-dynamic-array-non-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal27 => no-match-const-fp-non-const-fp-direct-assignment}/main.c (100%) rename regression/goto-analyzer/{fp-removal16 => no-match-const-fp-non-const-fp-direct-assignment}/test.desc (100%) rename regression/goto-analyzer/{fp-removal36 => no-match-const-fp-non-const-pointer-non-const-struct-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal36 => no-match-const-fp-non-const-pointer-non-const-struct-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal28 => no-match-const-fp-non-const-struct-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal28 => no-match-const-fp-non-const-struct-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal29 => no-match-const-fp-non-const-struct-non-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal6 => no-match-const-fp-non-const-struct-non-const-fp}/test.desc (90%) rename regression/goto-analyzer/{fp-removal32 => no-match-const-pointer-non-const-struct-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal32 => no-match-const-pointer-non-const-struct-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal43 => no-match-dereference-const-pointer-const-array-literal-pointer-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal43 => no-match-dereference-const-pointer-const-array-literal-pointer-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal46 => no-match-dereference-non-const-struct-const-pointer-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal46 => no-match-dereference-non-const-struct-const-pointer-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal48 => no-match-dereference-non-const-struct-non-const-pointer-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal48 => no-match-dereference-non-const-struct-non-const-pointer-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal16 => no-match-non-const-fp-const-fp-direct-assignment}/main.c (100%) rename regression/goto-analyzer/{fp-removal27 => no-match-non-const-fp-const-fp-direct-assignment}/test.desc (100%) rename regression/goto-analyzer/{fp-removal15 => no-match-non-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal7 => no-match-non-const-fp}/test.desc (90%) rename regression/goto-analyzer/{fp-removal40 => no-match-parameter-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal40 => no-match-parameter-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal7 => no-match-parameter-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal41 => no-match-parameter-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal42 => no-match-pointer-const-struct-array-literal-non-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal42 => no-match-pointer-const-struct-array-literal-non-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal35 => precise-array-calculation-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal35 => precise-array-calculation-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal33 => precise-array-literal-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal3 => precise-array-literal-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal4 => precise-const-fp-array-const-variable-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal33 => precise-const-fp-array-const-variable-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal3 => precise-const-fp-array-literal-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal4 => precise-const-fp-array-literal-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal37 => precise-const-fp-array-literal-const-struct-non-const-fp}/main.c (96%) rename regression/goto-analyzer/{fp-removal37 => precise-const-fp-array-literal-const-struct-non-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal2 => precise-const-fp-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal2 => precise-const-fp-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal12 => precise-const-fp-const-struct-const-array-literal-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal12 => precise-const-fp-const-struct-const-array-literal-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal13 => precise-const-fp-const-struct-non-const-array-literal-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal13 => precise-const-fp-const-struct-non-const-array-literal-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal23 => precise-const-fp-const-struct-non-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal24 => precise-const-fp-const-struct-non-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal38 => precise-const-fp-dereference-const-pointer-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal14 => precise-const-fp-dereference-const-pointer-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal1 => precise-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal1 => precise-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal30 => precise-const-struct-non-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal30 => precise-const-struct-non-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal14 => precise-derefence-const-pointer-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal31 => precise-derefence-const-pointer-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal17 => precise-derefence}/main.c (100%) rename regression/goto-analyzer/{fp-removal17 => precise-derefence}/test.desc (100%) rename regression/goto-analyzer/{fp-removal31 => precise-dereference-address-pointer-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal38 => precise-dereference-address-pointer-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal44 => precise-dereference-const-struct-const-pointer-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal44 => precise-dereference-const-struct-const-pointer-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal47 => precise-dereference-const-struct-const-pointer-const-struct-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal45 => precise-dereference-const-struct-const-pointer-const-struct-const-fp}/test.desc (100%) rename regression/goto-analyzer/{fp-removal45 => precise-dereference-const-struct-pointer-const-fp}/main.c (100%) rename regression/goto-analyzer/{fp-removal47 => precise-dereference-const-struct-pointer-const-fp}/test.desc (100%) diff --git a/regression/goto-analyzer/fp-removal34/main.c b/regression/goto-analyzer/approx-array-variable-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal34/main.c rename to regression/goto-analyzer/approx-array-variable-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal34/test.desc b/regression/goto-analyzer/approx-array-variable-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal34/test.desc rename to regression/goto-analyzer/approx-array-variable-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal19/main.c b/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal19/main.c rename to regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal19/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal19/test.desc rename to regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal22/main.c b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal22/main.c rename to regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/main.c diff --git a/regression/goto-analyzer/fp-removal22/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal22/test.desc rename to regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/test.desc diff --git a/regression/goto-analyzer/fp-removal5/main.c b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal5/main.c rename to regression/goto-analyzer/approx-const-fp-array-variable-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal5/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal5/test.desc rename to regression/goto-analyzer/approx-const-fp-array-variable-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal24/main.c b/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp1/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal24/main.c rename to regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp1/main.c diff --git a/regression/goto-analyzer/fp-removal23/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp1/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal23/test.desc rename to regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp1/test.desc diff --git a/regression/goto-analyzer/fp-removal25/main.c b/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp2/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal25/main.c rename to regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp2/main.c diff --git a/regression/goto-analyzer/fp-removal25/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp2/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal25/test.desc rename to regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp2/test.desc diff --git a/regression/goto-analyzer/fp-removal21/main.c b/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal21/main.c rename to regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal21/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal21/test.desc rename to regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal20/main.c b/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal20/main.c rename to regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal20/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal20/test.desc rename to regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal41/main.c b/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal41/main.c rename to regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/main.c diff --git a/regression/goto-analyzer/fp-removal11/test.desc b/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal11/test.desc rename to regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/test.desc diff --git a/regression/goto-analyzer/fp-removal6/main.c b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal6/main.c rename to regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/main.c diff --git a/regression/goto-analyzer/fp-removal15/test.desc b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal15/test.desc rename to regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/test.desc diff --git a/regression/goto-analyzer/fp-removal8/main.c b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal8/main.c rename to regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal10/test.desc b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal10/test.desc rename to regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal10/main.c b/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal10/main.c rename to regression/goto-analyzer/no-match-const-fp-array-non-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal8/test.desc b/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal8/test.desc rename to regression/goto-analyzer/no-match-const-fp-array-non-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal26/main.c b/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal26/main.c rename to regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal26/test.desc b/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal26/test.desc rename to regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal39/main.c b/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal39/main.c rename to regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal39/test.desc b/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal39/test.desc rename to regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal11/main.c b/regression/goto-analyzer/no-match-const-fp-dynamic-array-non-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal11/main.c rename to regression/goto-analyzer/no-match-const-fp-dynamic-array-non-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal29/test.desc b/regression/goto-analyzer/no-match-const-fp-dynamic-array-non-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal29/test.desc rename to regression/goto-analyzer/no-match-const-fp-dynamic-array-non-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal27/main.c b/regression/goto-analyzer/no-match-const-fp-non-const-fp-direct-assignment/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal27/main.c rename to regression/goto-analyzer/no-match-const-fp-non-const-fp-direct-assignment/main.c diff --git a/regression/goto-analyzer/fp-removal16/test.desc b/regression/goto-analyzer/no-match-const-fp-non-const-fp-direct-assignment/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal16/test.desc rename to regression/goto-analyzer/no-match-const-fp-non-const-fp-direct-assignment/test.desc diff --git a/regression/goto-analyzer/fp-removal36/main.c b/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal36/main.c rename to regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal36/test.desc b/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal36/test.desc rename to regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal28/main.c b/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal28/main.c rename to regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal28/test.desc b/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal28/test.desc rename to regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal29/main.c b/regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal29/main.c rename to regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal6/test.desc b/regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/test.desc similarity index 90% rename from regression/goto-analyzer/fp-removal6/test.desc rename to regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/test.desc index 3c735d48a55..deda28d213f 100644 --- a/regression/goto-analyzer/fp-removal6/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions +--show-goto-functions --verbosity 10 ^Removing function pointers and virtual functions$ ^\s*IF fp == f1 THEN GOTO 1$ diff --git a/regression/goto-analyzer/fp-removal32/main.c b/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal32/main.c rename to regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal32/test.desc b/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal32/test.desc rename to regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal43/main.c b/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal43/main.c rename to regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal43/test.desc b/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal43/test.desc rename to regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal46/main.c b/regression/goto-analyzer/no-match-dereference-non-const-struct-const-pointer-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal46/main.c rename to regression/goto-analyzer/no-match-dereference-non-const-struct-const-pointer-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal46/test.desc b/regression/goto-analyzer/no-match-dereference-non-const-struct-const-pointer-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal46/test.desc rename to regression/goto-analyzer/no-match-dereference-non-const-struct-const-pointer-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal48/main.c b/regression/goto-analyzer/no-match-dereference-non-const-struct-non-const-pointer-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal48/main.c rename to regression/goto-analyzer/no-match-dereference-non-const-struct-non-const-pointer-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal48/test.desc b/regression/goto-analyzer/no-match-dereference-non-const-struct-non-const-pointer-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal48/test.desc rename to regression/goto-analyzer/no-match-dereference-non-const-struct-non-const-pointer-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal16/main.c b/regression/goto-analyzer/no-match-non-const-fp-const-fp-direct-assignment/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal16/main.c rename to regression/goto-analyzer/no-match-non-const-fp-const-fp-direct-assignment/main.c diff --git a/regression/goto-analyzer/fp-removal27/test.desc b/regression/goto-analyzer/no-match-non-const-fp-const-fp-direct-assignment/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal27/test.desc rename to regression/goto-analyzer/no-match-non-const-fp-const-fp-direct-assignment/test.desc diff --git a/regression/goto-analyzer/fp-removal15/main.c b/regression/goto-analyzer/no-match-non-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal15/main.c rename to regression/goto-analyzer/no-match-non-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal7/test.desc b/regression/goto-analyzer/no-match-non-const-fp/test.desc similarity index 90% rename from regression/goto-analyzer/fp-removal7/test.desc rename to regression/goto-analyzer/no-match-non-const-fp/test.desc index 3c735d48a55..deda28d213f 100644 --- a/regression/goto-analyzer/fp-removal7/test.desc +++ b/regression/goto-analyzer/no-match-non-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions +--show-goto-functions --verbosity 10 ^Removing function pointers and virtual functions$ ^\s*IF fp == f1 THEN GOTO 1$ diff --git a/regression/goto-analyzer/fp-removal40/main.c b/regression/goto-analyzer/no-match-parameter-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal40/main.c rename to regression/goto-analyzer/no-match-parameter-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal40/test.desc b/regression/goto-analyzer/no-match-parameter-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal40/test.desc rename to regression/goto-analyzer/no-match-parameter-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal7/main.c b/regression/goto-analyzer/no-match-parameter-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal7/main.c rename to regression/goto-analyzer/no-match-parameter-fp/main.c diff --git a/regression/goto-analyzer/fp-removal41/test.desc b/regression/goto-analyzer/no-match-parameter-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal41/test.desc rename to regression/goto-analyzer/no-match-parameter-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal42/main.c b/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal42/main.c rename to regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal42/test.desc b/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal42/test.desc rename to regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal35/main.c b/regression/goto-analyzer/precise-array-calculation-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal35/main.c rename to regression/goto-analyzer/precise-array-calculation-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal35/test.desc b/regression/goto-analyzer/precise-array-calculation-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal35/test.desc rename to regression/goto-analyzer/precise-array-calculation-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal33/main.c b/regression/goto-analyzer/precise-array-literal-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal33/main.c rename to regression/goto-analyzer/precise-array-literal-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal3/test.desc b/regression/goto-analyzer/precise-array-literal-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal3/test.desc rename to regression/goto-analyzer/precise-array-literal-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal4/main.c b/regression/goto-analyzer/precise-const-fp-array-const-variable-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal4/main.c rename to regression/goto-analyzer/precise-const-fp-array-const-variable-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal33/test.desc b/regression/goto-analyzer/precise-const-fp-array-const-variable-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal33/test.desc rename to regression/goto-analyzer/precise-const-fp-array-const-variable-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal3/main.c b/regression/goto-analyzer/precise-const-fp-array-literal-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal3/main.c rename to regression/goto-analyzer/precise-const-fp-array-literal-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal4/test.desc b/regression/goto-analyzer/precise-const-fp-array-literal-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal4/test.desc rename to regression/goto-analyzer/precise-const-fp-array-literal-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal37/main.c b/regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/main.c similarity index 96% rename from regression/goto-analyzer/fp-removal37/main.c rename to regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/main.c index 7e50789f2ad..0c8c7e86046 100644 --- a/regression/goto-analyzer/fp-removal37/main.c +++ b/regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/main.c @@ -35,6 +35,7 @@ void func(int i){ // Illegal // stable_table[1] = another_table; + // stable_table[1].fp = f5; fp(); } diff --git a/regression/goto-analyzer/fp-removal37/test.desc b/regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal37/test.desc rename to regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal2/main.c b/regression/goto-analyzer/precise-const-fp-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal2/main.c rename to regression/goto-analyzer/precise-const-fp-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal2/test.desc b/regression/goto-analyzer/precise-const-fp-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal2/test.desc rename to regression/goto-analyzer/precise-const-fp-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal12/main.c b/regression/goto-analyzer/precise-const-fp-const-struct-const-array-literal-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal12/main.c rename to regression/goto-analyzer/precise-const-fp-const-struct-const-array-literal-fp/main.c diff --git a/regression/goto-analyzer/fp-removal12/test.desc b/regression/goto-analyzer/precise-const-fp-const-struct-const-array-literal-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal12/test.desc rename to regression/goto-analyzer/precise-const-fp-const-struct-const-array-literal-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal13/main.c b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal13/main.c rename to regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/main.c diff --git a/regression/goto-analyzer/fp-removal13/test.desc b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal13/test.desc rename to regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal23/main.c b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal23/main.c rename to regression/goto-analyzer/precise-const-fp-const-struct-non-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal24/test.desc b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal24/test.desc rename to regression/goto-analyzer/precise-const-fp-const-struct-non-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal38/main.c b/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal38/main.c rename to regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal14/test.desc b/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal14/test.desc rename to regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal1/main.c b/regression/goto-analyzer/precise-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal1/main.c rename to regression/goto-analyzer/precise-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal1/test.desc b/regression/goto-analyzer/precise-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal1/test.desc rename to regression/goto-analyzer/precise-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal30/main.c b/regression/goto-analyzer/precise-const-struct-non-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal30/main.c rename to regression/goto-analyzer/precise-const-struct-non-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal30/test.desc b/regression/goto-analyzer/precise-const-struct-non-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal30/test.desc rename to regression/goto-analyzer/precise-const-struct-non-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal14/main.c b/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal14/main.c rename to regression/goto-analyzer/precise-derefence-const-pointer-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal31/test.desc b/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal31/test.desc rename to regression/goto-analyzer/precise-derefence-const-pointer-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal17/main.c b/regression/goto-analyzer/precise-derefence/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal17/main.c rename to regression/goto-analyzer/precise-derefence/main.c diff --git a/regression/goto-analyzer/fp-removal17/test.desc b/regression/goto-analyzer/precise-derefence/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal17/test.desc rename to regression/goto-analyzer/precise-derefence/test.desc diff --git a/regression/goto-analyzer/fp-removal31/main.c b/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal31/main.c rename to regression/goto-analyzer/precise-dereference-address-pointer-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal38/test.desc b/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal38/test.desc rename to regression/goto-analyzer/precise-dereference-address-pointer-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal44/main.c b/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal44/main.c rename to regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal44/test.desc b/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal44/test.desc rename to regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal47/main.c b/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-struct-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal47/main.c rename to regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-struct-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal45/test.desc b/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-struct-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal45/test.desc rename to regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-struct-const-fp/test.desc diff --git a/regression/goto-analyzer/fp-removal45/main.c b/regression/goto-analyzer/precise-dereference-const-struct-pointer-const-fp/main.c similarity index 100% rename from regression/goto-analyzer/fp-removal45/main.c rename to regression/goto-analyzer/precise-dereference-const-struct-pointer-const-fp/main.c diff --git a/regression/goto-analyzer/fp-removal47/test.desc b/regression/goto-analyzer/precise-dereference-const-struct-pointer-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/fp-removal47/test.desc rename to regression/goto-analyzer/precise-dereference-const-struct-pointer-const-fp/test.desc From a6e71e04591e95364a7533bab16edddc89892155 Mon Sep 17 00:00:00 2001 From: thk123 Date: Fri, 10 Feb 2017 11:47:10 +0000 Subject: [PATCH 030/116] Tidied up tests Consistent indentation Consistent functions for the function pointers. Made braces appear on the next line. Made all structs include at least two components. Corrected the name of two of the tests. Remove unused imports. Made all the mains return int so they compile with clang with no warnings. Enabling debug output for all tests so can see the output Removing out of date comments from the tests Missing empty lines --- .../approx-array-variable-const-fp/main.c | 39 +++++++++------ .../approx-array-variable-const-fp/test.desc | 2 +- .../main.c | 42 +++++++++------- .../test.desc | 2 +- .../main.c | 41 +++++++++------- .../test.desc | 2 +- .../main.c | 41 +++++++++------- .../test.desc | 2 +- .../main.c | 39 ++++++++------- .../test.desc | 0 .../main.c | 43 ---------------- .../main.c | 47 ++++++++++-------- .../test.desc | 2 +- .../main.c | 40 ++++++++------- .../test.desc | 2 +- .../main.c | 37 ++++++++------ .../test.desc | 2 +- .../main.c | 37 ++++++++------ .../test.desc | 2 +- .../main.c | 35 +++++++------ .../test.desc | 2 +- .../main.c | 35 +++++++------ .../test.desc | 2 +- .../main.c | 35 +++++++------ .../test.desc | 2 - .../main.c | 31 ++++++------ .../test.desc | 6 --- .../main.c | 28 ++++++----- .../main.c | 24 ++++----- .../test.desc | 2 +- .../main.c | 28 ++++++----- .../test.desc | 3 -- .../main.c | 39 ++++++++------- .../test.desc | 2 - .../main.c | 38 ++++++++------ .../main.c | 37 ++++++++------ .../main.c | 32 ++++++------ .../main.c | 27 +++++----- .../main.c | 27 +++++----- .../main.c | 24 ++++----- .../test.desc | 2 +- .../no-match-non-const-fp/main.c | 25 +++++----- .../no-match-parameter-const-fp/main.c | 39 +++++++++------ .../no-match-parameter-const-fp/test.desc | 2 +- .../no-match-parameter-fp/main.c | 39 +++++++++------ .../no-match-parameter-fp/test.desc | 2 +- .../main.c | 27 +++++----- .../precise-array-calculation-const-fp/main.c | 25 +++++----- .../test.desc | 5 +- .../precise-array-literal-const-fp/main.c | 25 +++++----- .../precise-array-literal-const-fp/test.desc | 2 +- .../main.c | 25 +++++----- .../test.desc | 2 +- .../main.c | 25 +++++----- .../test.desc | 2 +- .../main.c | 49 ++++++++++--------- .../test.desc | 2 +- .../main.c | 49 +++++++++++++++++++ .../test.desc | 0 .../precise-const-fp-const-fp/main.c | 24 ++++----- .../precise-const-fp-const-fp/test.desc | 2 +- .../main.c | 27 +++++----- .../test.desc | 3 -- .../main.c | 36 ++++++++------ .../test.desc | 6 --- .../main.c | 42 +++++++++------- .../main.c | 29 ++++++----- .../test.desc | 6 --- .../goto-analyzer/precise-const-fp/main.c | 25 +++++----- .../goto-analyzer/precise-const-fp/test.desc | 2 +- .../precise-const-struct-non-const-fp/main.c | 40 ++++++++------- .../main.c | 29 ++++++----- .../test.desc | 6 --- .../goto-analyzer/precise-derefence/main.c | 24 ++++----- .../goto-analyzer/precise-derefence/test.desc | 2 +- .../main.c | 29 ++++++----- .../test.desc | 6 --- .../main.c | 27 +++++----- .../main.c | 27 +++++----- .../main.c | 27 +++++----- 80 files changed, 893 insertions(+), 754 deletions(-) rename regression/goto-analyzer/{approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp2 => approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp}/main.c (50%) rename regression/goto-analyzer/{approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp2 => approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp}/test.desc (100%) delete mode 100644 regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp1/main.c create mode 100644 regression/goto-analyzer/precise-const-fp-array-variable-const-pointer-const-struct-non-const-fp/main.c rename regression/goto-analyzer/{approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp1 => precise-const-fp-array-variable-const-pointer-const-struct-non-const-fp}/test.desc (100%) diff --git a/regression/goto-analyzer/approx-array-variable-const-fp/main.c b/regression/goto-analyzer/approx-array-variable-const-fp/main.c index 8fc4036e201..3fb230c83fd 100644 --- a/regression/goto-analyzer/approx-array-variable-const-fp/main.c +++ b/regression/goto-analyzer/approx-array-variable-const-fp/main.c @@ -1,12 +1,14 @@ -void f1 (void) { int tk = 1; } -void f2 (void) { int tk = 2; } -void f3 (void) { int tk = 3; } -void f4 (void) { int tk = 4; } -void f5 (void) { int tk = 5; } -void f6 (void) { int tk = 6; } -void f7 (void) { int tk = 7; } -void f8 (void) { int tk = 8; } -void f9 (void) { int tk = 9; } +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -16,12 +18,17 @@ const void_fp fp_tbl[] = {f2, f3 ,f4}; // This ensures that check can't work in this example const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; -void func(int i){ - fp_tbl[i](); +void func(int i) +{ + fp_tbl[i](); } -void main(){ - for(int i=0;i<3;i++){ - func(i); - } -} +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/approx-array-variable-const-fp/test.desc b/regression/goto-analyzer/approx-array-variable-const-fp/test.desc index cf845be0316..13cac884101 100644 --- a/regression/goto-analyzer/approx-array-variable-const-fp/test.desc +++ b/regression/goto-analyzer/approx-array-variable-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions +--show-goto-functions --verbosity 10 ^Removing function pointers and virtual functions$ ^\s*IF fp_tbl\[(signed long int)i\] == f2 THEN GOTO 1$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/main.c b/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/main.c index 45865b9599e..3d968a5e243 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/main.c +++ b/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/main.c @@ -1,14 +1,14 @@ #include -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -16,20 +16,26 @@ typedef void(*void_fp)(void); // This ensures that check can't work in this example const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; -void(* const fp_tbl[3])(void) = { +void(* const fp_tbl[3])(void) = +{ (void(*)())f2, (void(*)())f3, (void(*)())f4, }; -void func(int i){ - const void_fp fp = fp_tbl[i]; - fp(); +void func(int i) +{ + const void_fp fp = fp_tbl[i]; + fp(); } -void main(){ - for(int i=0;i<3;i++){ - func(i); - } -} +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/test.desc index 15840e69fe3..05b7ce7e581 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/test.desc +++ b/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions +--show-goto-functions --verbosity 10 ^Removing function pointers and virtual functions$ ^\s*IF fp == f2 THEN GOTO 1$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/main.c b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/main.c index 7bbfed5fd8b..a777bce3a48 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/main.c +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/main.c @@ -1,12 +1,14 @@ -void f1 (void) { int tk = 1; } -void f2 (void) { int tk = 2; } -void f3 (void) { int tk = 3; } -void f4 (void) { int tk = 4; } -void f5 (void) { int tk = 5; } -void f6 (void) { int tk = 6; } -void f7 (void) { int tk = 7; } -void f8 (void) { int tk = 8; } -void f9 (void) { int tk = 9; } +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -16,13 +18,18 @@ const void_fp fp_tbl[] = {f2, f3 ,f4, 0}; // This ensures that check can't work in this example const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; -void func(int i){ - const void_fp fp = fp_tbl[i]; - fp(); +void func(int i) +{ + const void_fp fp = fp_tbl[i]; + fp(); } -void main(){ - for(int i=0;i<3;i++){ - func(i); - } -} +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/test.desc index 15840e69fe3..05b7ce7e581 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/test.desc +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions +--show-goto-functions --verbosity 10 ^Removing function pointers and virtual functions$ ^\s*IF fp == f2 THEN GOTO 1$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/main.c b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/main.c index 20cf98fb59a..d426bba269e 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/main.c +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/main.c @@ -1,12 +1,14 @@ -void f1 (void) { int tk = 1; } -void f2 (void) { int tk = 2; } -void f3 (void) { int tk = 3; } -void f4 (void) { int tk = 4; } -void f5 (void) { int tk = 5; } -void f6 (void) { int tk = 6; } -void f7 (void) { int tk = 7; } -void f8 (void) { int tk = 8; } -void f9 (void) { int tk = 9; } +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -16,13 +18,18 @@ const void_fp fp_tbl[] = {f2, f3 ,f4}; // This ensures that check can't work in this example const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; -void func(int i){ - const void_fp fp = fp_tbl[i]; - fp(); +void func(int i) +{ + const void_fp fp = fp_tbl[i]; + fp(); } -void main(){ - for(int i=0;i<3;i++){ - func(i); - } -} +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/test.desc index 15840e69fe3..05b7ce7e581 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/test.desc +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions +--show-goto-functions --verbosity 10 ^Removing function pointers and virtual functions$ ^\s*IF fp == f2 THEN GOTO 1$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp2/main.c b/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/main.c similarity index 50% rename from regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp2/main.c rename to regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/main.c index 51f8de1de9e..c27aee68bd8 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp2/main.c +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/main.c @@ -1,14 +1,14 @@ #include -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -33,13 +33,18 @@ const struct action * const action_list[4] = // This ensures that check can't work in this example const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; -void func(int i){ - const void_fp fp = action_list[i]->fun; - fp(); +void func(int i) +{ + const void_fp fp = action_list[i]->fun; + fp(); } -void main(){ - for(int i=0;i<3;i++){ - func(i); - } -} +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp2/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp2/test.desc rename to regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp1/main.c b/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp1/main.c deleted file mode 100644 index 6cf0b7ee3ce..00000000000 --- a/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp1/main.c +++ /dev/null @@ -1,43 +0,0 @@ -#include - -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } - -typedef void(*void_fp)(void); - -struct action -{ - void_fp fun; -}; - -const struct action rec = { .fun = f2 }; - -const struct action * const action_list[4] = -{ - &rec, - &rec, - &rec, - &rec -}; - -// There is a basic check that excludes all functions that aren't used anywhere -// This ensures that check can't work in this example -const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; - -void func(int i){ - const void_fp fp = action_list[i]->fun; - fp(); -} - -void main(){ - for(int i=0;i<4;i++){ - func(i); - } -} diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/main.c b/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/main.c index 1e9deb388c1..e058e5f3c4f 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/main.c +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/main.c @@ -1,14 +1,14 @@ #include -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -16,12 +16,14 @@ typedef void(*void_fp)(void); // This ensures that check can't work in this example const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; -struct stable { +struct stable +{ int x; void (*fp)(void); }; -const struct stable stable_table [3] = { +const struct stable stable_table [3] = +{ { 1, f2 }, { 2, f3 }, { 3, f4 } @@ -30,17 +32,20 @@ const struct stable stable_table [3] = { const struct stable another_table = { 4, f5 }; -void func(int i){ - const void_fp fp = stable_table[i].fp; +void func(int i) +{ + const void_fp fp = stable_table[i].fp; - // Illegal - // stable_table[1] = another_table; - fp(); + // Illegal + // stable_table[1] = another_table; + fp(); } -int main(){ - for(int i=0;i<3;i++){ - func(i); - } - return 0; +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + return 0; } diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/test.desc index 4f3168057fa..05b7ce7e581 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/test.desc +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/test.desc @@ -8,4 +8,4 @@ main.c ^\s*IF fp == f4 THEN GOTO 3$ ^SIGNAL=0$ -- -^warning: ignoring \ No newline at end of file +^warning: ignoring diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/main.c b/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/main.c index 0abcd656db1..ca882ffd6b3 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/main.c +++ b/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/main.c @@ -2,47 +2,47 @@ int f1 (void) { - printf("%i", 1); + printf("%i\n", 1); return 1; } int f2 (void) { - printf("%i", 2); + printf("%i\n", 2); return 2; } int f3 (void) { - printf("%i", 3); + printf("%i\n", 3); return 3; } int f4 (void) { - printf("%i", 4); + printf("%i\n", 4); return 4; } int f5 (void) { - printf("%i", 5); + printf("%i\n", 5); return 5; } int f6 (void) { - printf("%i", 6); + printf("%i\n", 6); return 6; } int f7 (void) { - printf("%i", 7); + printf("%i\n", 7); return 7; } int f8 (void) { - printf("%i", 8); + printf("%i\n", 8); return 8; } int f9 (void) { - printf("%i", 9); + printf("%i\n", 9); return 9; } @@ -53,21 +53,25 @@ typedef int(*int_fp)(void); // This ensures that check can't work in this example const int_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; -void(* const fp_tbl[3])(void) = { +void(* const fp_tbl[3])(void) = +{ (void(*)())f2, (void(*)())f3, (void(*)())f4, }; -void func(int i){ - const void_fp fp = fp_tbl[i]; - fp(); +void func(int i) +{ + const void_fp fp = fp_tbl[i]; + fp(); } -int main(){ - for(int i=0;i<3;i++){ - func(i); - } - return 0; +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + return 0; } diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/test.desc index 81db0db6f9f..00cd5d6eafd 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/test.desc +++ b/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions +--show-goto-functions --verbosity 10 ^Removing function pointers and virtual functions$ ^\s*IF fp == (void (\*)(void))f2 THEN GOTO 1$ diff --git a/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/main.c b/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/main.c index fd73934e83c..16b0221e740 100644 --- a/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/main.c +++ b/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/main.c @@ -1,12 +1,14 @@ -void f1 (void) { int tk = 1; } -void f2 (void) { int tk = 2; } -void f3 (void) { int tk = 3; } -void f4 (void) { int tk = 4; } -void f5 (void) { int tk = 5; } -void f6 (void) { int tk = 6; } -void f7 (void) { int tk = 7; } -void f8 (void) { int tk = 8; } -void f9 (void) { int tk = 9; } +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -14,7 +16,8 @@ typedef void(*void_fp)(void); // This ensures that check can't work in this example const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; -void func(int i, int j){ +void func(int i, int j) +{ const void_fp fp_tbl[] = {fp_all[i*2], fp_all[j+1]}; // Illegal: //fp_tbl[1] = f4; @@ -22,8 +25,12 @@ void func(int i, int j){ fp(); } -void main(){ - for(int i=0;i<3;i++){ - func(i,0); - } -} +int main() +{ + for(int i=0;i<3;i++) + { + func(i,0); + } + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/test.desc b/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/test.desc index 3c735d48a55..deda28d213f 100644 --- a/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions +--show-goto-functions --verbosity 10 ^Removing function pointers and virtual functions$ ^\s*IF fp == f1 THEN GOTO 1$ diff --git a/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/main.c b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/main.c index 68ddffa073e..a67cf750d5e 100644 --- a/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/main.c +++ b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/main.c @@ -1,12 +1,14 @@ -void f1 (void) { int tk = 1; } -void f2 (void) { int tk = 2; } -void f3 (void) { int tk = 3; } -void f4 (void) { int tk = 4; } -void f5 (void) { int tk = 5; } -void f6 (void) { int tk = 6; } -void f7 (void) { int tk = 7; } -void f8 (void) { int tk = 8; } -void f9 (void) { int tk = 9; } +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -14,14 +16,19 @@ typedef void(*void_fp)(void); // This ensures that check can't work in this example const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; -void func(int i, int j){ +void func(int i, int j) +{ void_fp fp_tbl[] = {fp_all[i*2], fp_all[j+1]}; const void_fp fp = fp_tbl[1]; fp(); } -void main(){ - for(int i=0;i<3;i++){ - func(i,0); - } -} +int main() +{ + for(int i=0;i<3;i++) + { + func(i,0); + } + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/test.desc b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/test.desc index 3c735d48a55..deda28d213f 100644 --- a/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions +--show-goto-functions --verbosity 10 ^Removing function pointers and virtual functions$ ^\s*IF fp == f1 THEN GOTO 1$ diff --git a/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/main.c b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/main.c index 26d09257aaf..d649b1dd056 100644 --- a/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/main.c +++ b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/main.c @@ -1,14 +1,14 @@ #include -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -18,7 +18,8 @@ void_fp fp_tbl[] = {f2, f3, f4}; // This ensures that check can't work in this example const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; -void func(void_fp fp, int i){ +void func(void_fp fp, int i) +{ // It is concievable this could be checked and seen the first value // of the array is unchanged but is kind of a weird edge case. fp_tbl[2] = fp; @@ -26,8 +27,12 @@ void func(void_fp fp, int i){ fp2(); } -void main(){ - for(int i=0;i<3;i++){ - func(fp_all[i+3], i); - } -} +int main() +{ + for(int i=0;i<3;i++) + { + func(fp_all[i+3], i); + } + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/test.desc index 7f4fb53760e..1942b6b867b 100644 --- a/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions +--show-goto-functions --verbosity 10 ^Removing function pointers and virtual functions$ ^\s*IF fp2 == f1 THEN GOTO 1$ diff --git a/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/main.c b/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/main.c index 56729ff428a..189bd8c036d 100644 --- a/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/main.c +++ b/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/main.c @@ -1,14 +1,14 @@ #include -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -18,14 +18,19 @@ void_fp fp_tbl[] = {f2, f3, f4}; // This ensures that check can't work in this example const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; -void func(void_fp fp, int i){ +void func(void_fp fp, int i) +{ fp_tbl[2] = fp; const void_fp fp2 = fp_tbl[2]; fp2(); } -void main(){ - for(int i=0;i<3;i++){ - func(fp_all[i+3], i); - } -} +int main() +{ + for(int i=0;i<3;i++) + { + func(fp_all[i+3], i); + } + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/test.desc index 7f4fb53760e..1942b6b867b 100644 --- a/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions +--show-goto-functions --verbosity 10 ^Removing function pointers and virtual functions$ ^\s*IF fp2 == f1 THEN GOTO 1$ diff --git a/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/main.c b/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/main.c index e7b62bc8b81..1420490b0a6 100644 --- a/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/main.c +++ b/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/main.c @@ -1,14 +1,14 @@ #include -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -25,18 +25,23 @@ struct state * const pts = &thing; // This ensures that check can't work in this example const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; -void func(int i){ +void func(int i) +{ // Illegal //pts=&other_thing; // thing.go=&f6; thing = other_thing; - const void_fp fp = pts->go; + const void_fp fp = pts->go; - fp(); + fp(); } -void main(){ - for(int i=0;i<3;i++){ +int main() +{ + for(int i=0;i<3;i++) + { func(i); } -} + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/test.desc index 889299e9a3c..deda28d213f 100644 --- a/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/test.desc @@ -15,5 +15,3 @@ main.c ^SIGNAL=0$ -- ^warning: ignoring --- -Mutable struct but const pointer inside it, not yet supported diff --git a/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/main.c b/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/main.c index 1510abceb69..f9750966b58 100644 --- a/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/main.c +++ b/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/main.c @@ -1,15 +1,14 @@ #include -#include - -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -17,7 +16,8 @@ typedef void(*void_fp)(void); // This ensures that check can't work in this example const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; -void func(){ +void func() +{ const void_fp fp = f3; const void_fp fp2 = f4; const void_fp* p2fp = &fp; @@ -32,6 +32,9 @@ void func(){ final_fp(); } -void main(){ +int main() +{ func(); -} + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/test.desc index c60094eebd3..ff7c3cc2b07 100644 --- a/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/test.desc @@ -15,9 +15,3 @@ main.c ^SIGNAL=0$ -- ^warning: ignoring --- -This test is marked as a KNOWNBUG as it is possible for the function -pointer to be optimized away. Currently goto-analyzer falls back to -assuming it could be any type compatible function. - -Issue: https://github.com/diffblue/cbmc/issues/476 diff --git a/regression/goto-analyzer/no-match-const-fp-dynamic-array-non-const-fp/main.c b/regression/goto-analyzer/no-match-const-fp-dynamic-array-non-const-fp/main.c index 3f90a10ab65..f468113ac16 100644 --- a/regression/goto-analyzer/no-match-const-fp-dynamic-array-non-const-fp/main.c +++ b/regression/goto-analyzer/no-match-const-fp-dynamic-array-non-const-fp/main.c @@ -1,15 +1,15 @@ #include #include -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -17,7 +17,8 @@ typedef void(*void_fp)(void); // This ensures that check can't work in this example const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; -void func(){ +void func() +{ void_fp * const fp_tbl= malloc(sizeof(void_fp) * 3); fp_tbl[0]=f2; fp_tbl[1]=f3; @@ -30,6 +31,9 @@ void func(){ fp(); } -void main(){ +int main() +{ func(); -} + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/no-match-const-fp-non-const-fp-direct-assignment/main.c b/regression/goto-analyzer/no-match-const-fp-non-const-fp-direct-assignment/main.c index 1ed1a4c6511..98c7f0619b6 100644 --- a/regression/goto-analyzer/no-match-const-fp-non-const-fp-direct-assignment/main.c +++ b/regression/goto-analyzer/no-match-const-fp-non-const-fp-direct-assignment/main.c @@ -1,14 +1,14 @@ #include -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -24,7 +24,9 @@ void func() fp2(); } -void main() +int main() { func(); -} + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/no-match-const-fp-non-const-fp-direct-assignment/test.desc b/regression/goto-analyzer/no-match-const-fp-non-const-fp-direct-assignment/test.desc index 9ea2dfbbc29..722b6878ab5 100644 --- a/regression/goto-analyzer/no-match-const-fp-non-const-fp-direct-assignment/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-non-const-fp-direct-assignment/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions +--show-goto-functions --verbosity 10 ^Removing function pointers and virtual functions$ ^\s*IF fp2 == f1 THEN GOTO 1$ ^\s*IF fp2 == f2 THEN GOTO 2$ diff --git a/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/main.c b/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/main.c index 2f828e830ce..1da907916bd 100644 --- a/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/main.c +++ b/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/main.c @@ -1,14 +1,14 @@ #include -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -36,8 +36,12 @@ void func(int i) } -void main(){ - for(int i=0;i<3;i++){ +int main() +{ + for(int i=0;i<3;i++) + { func(i); } -} + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/test.desc index b31b9aedfa1..deda28d213f 100644 --- a/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/test.desc @@ -15,6 +15,3 @@ main.c ^SIGNAL=0$ -- ^warning: ignoring --- -This shouldn't work because the pointer can be assigned to a different -struct after initial assignment. diff --git a/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/main.c b/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/main.c index cba5ae9bfc7..3952169b535 100644 --- a/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/main.c +++ b/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/main.c @@ -1,14 +1,14 @@ #include -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -25,14 +25,19 @@ struct state other_thing = {0, &f4}; // This ensures that check can't work in this example const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; -void func(int i){ +void func(int i) +{ thing = other_thing; - const void_fp fp = thing.go; - fp(); + const void_fp fp = thing.go; + fp(); } -void main(){ - for(int i=0;i<3;i++){ - func(i); - } -} +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/test.desc index 889299e9a3c..deda28d213f 100644 --- a/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/test.desc @@ -15,5 +15,3 @@ main.c ^SIGNAL=0$ -- ^warning: ignoring --- -Mutable struct but const pointer inside it, not yet supported diff --git a/regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/main.c b/regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/main.c index 87e79cdb5d9..9c1af7d8d83 100644 --- a/regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/main.c +++ b/regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/main.c @@ -1,37 +1,43 @@ #include -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); struct action { + int x; void_fp fun; }; -struct action rec = { .fun = f2 }; +struct action rec = { .x = 4, .fun = f2 }; // There is a basic check that excludes all functions that aren't used anywhere // This ensures that check can't work in this example const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; -void func(int i){ +void func(int i) +{ // Can mutate rec.fun=f4; const void_fp fp = rec.fun; fp(); } -void main(){ - for(int i=0;i<3;i++){ - func(i); - } -} +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/main.c b/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/main.c index 210facf60bf..f626942ef8b 100644 --- a/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/main.c +++ b/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/main.c @@ -1,14 +1,14 @@ #include -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -26,13 +26,18 @@ struct state const * const pts = &thing; // This ensures that check can't work in this example const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; -void func(int i){ +void func(int i) +{ thing = other_thing; - pts->go(); + pts->go(); } -void main(){ - for(int i=0;i<3;i++){ - func(i); - } -} +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/main.c b/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/main.c index e0b37fceb10..5d857ffcfe7 100644 --- a/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/main.c +++ b/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/main.c @@ -1,15 +1,14 @@ #include -#include - -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -19,12 +18,14 @@ const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; typedef struct fp_container { + int x; const void_fp* const fp_tbl[3]; } fp_container; -void func(){ +void func() +{ void_fp f2meta = &f2; void_fp f3meta = &f3; void_fp f4meta = &f4; @@ -33,8 +34,8 @@ void func(){ void_fp f6meta = &f6; void_fp f7meta = &f7; - const fp_container container = { .fp_tbl = {&f2meta ,&f3meta, &f4meta} }; - const fp_container container2 = { .fp_tbl = {&f5meta ,&f6meta, &f7meta} }; + const fp_container container = { .x = 4, .fp_tbl = {&f2meta ,&f3meta, &f4meta} }; + const fp_container container2 = { .x = 5, .fp_tbl = {&f5meta ,&f6meta, &f7meta} }; f3meta = &f5; // Illegal: @@ -45,6 +46,7 @@ void func(){ (*container_ptr->fp_tbl[1])(); } -int main(){ +int main() +{ func(); } diff --git a/regression/goto-analyzer/no-match-dereference-non-const-struct-const-pointer-const-fp/main.c b/regression/goto-analyzer/no-match-dereference-non-const-struct-const-pointer-const-fp/main.c index c1f4811bad8..b0be4e4837c 100644 --- a/regression/goto-analyzer/no-match-dereference-non-const-struct-const-pointer-const-fp/main.c +++ b/regression/goto-analyzer/no-match-dereference-non-const-struct-const-pointer-const-fp/main.c @@ -1,15 +1,14 @@ #include -#include - -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -25,7 +24,8 @@ typedef struct fp_cc -void func(){ +void func() +{ const void_fp meta_fp = &f3; const void_fp meta_fp2 = &f4; @@ -40,6 +40,7 @@ void func(){ (*container_container.container)(); } -int main(){ +int main() +{ func(); } diff --git a/regression/goto-analyzer/no-match-dereference-non-const-struct-non-const-pointer-const-fp/main.c b/regression/goto-analyzer/no-match-dereference-non-const-struct-non-const-pointer-const-fp/main.c index 12949ed8d85..28110c56d01 100644 --- a/regression/goto-analyzer/no-match-dereference-non-const-struct-non-const-pointer-const-fp/main.c +++ b/regression/goto-analyzer/no-match-dereference-non-const-struct-non-const-pointer-const-fp/main.c @@ -1,15 +1,14 @@ #include -#include - -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -25,7 +24,8 @@ typedef struct fp_cc -void func(){ +void func() +{ const void_fp meta_fp = &f3; const void_fp meta_fp2 = &f4; fp_cc container_container = { .container = &meta_fp, .x = 4 }; @@ -37,6 +37,7 @@ void func(){ (*container_container.container)(); } -int main(){ +int main() +{ func(); } diff --git a/regression/goto-analyzer/no-match-non-const-fp-const-fp-direct-assignment/main.c b/regression/goto-analyzer/no-match-non-const-fp-const-fp-direct-assignment/main.c index f1d35373e15..a9a31b98a70 100644 --- a/regression/goto-analyzer/no-match-non-const-fp-const-fp-direct-assignment/main.c +++ b/regression/goto-analyzer/no-match-non-const-fp-const-fp-direct-assignment/main.c @@ -1,14 +1,14 @@ #include -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -25,7 +25,9 @@ void func() fp2(); } -void main() +int main() { func(); -} + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/no-match-non-const-fp-const-fp-direct-assignment/test.desc b/regression/goto-analyzer/no-match-non-const-fp-const-fp-direct-assignment/test.desc index 9ea2dfbbc29..722b6878ab5 100644 --- a/regression/goto-analyzer/no-match-non-const-fp-const-fp-direct-assignment/test.desc +++ b/regression/goto-analyzer/no-match-non-const-fp-const-fp-direct-assignment/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions +--show-goto-functions --verbosity 10 ^Removing function pointers and virtual functions$ ^\s*IF fp2 == f1 THEN GOTO 1$ ^\s*IF fp2 == f2 THEN GOTO 2$ diff --git a/regression/goto-analyzer/no-match-non-const-fp/main.c b/regression/goto-analyzer/no-match-non-const-fp/main.c index 4b81bffdb30..a5d81d9959d 100644 --- a/regression/goto-analyzer/no-match-non-const-fp/main.c +++ b/regression/goto-analyzer/no-match-non-const-fp/main.c @@ -1,14 +1,14 @@ #include -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -23,6 +23,9 @@ void func() fp(); } -void main(){ +int main() +{ func(); -} + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/no-match-parameter-const-fp/main.c b/regression/goto-analyzer/no-match-parameter-const-fp/main.c index 080f1affcc8..340373af407 100644 --- a/regression/goto-analyzer/no-match-parameter-const-fp/main.c +++ b/regression/goto-analyzer/no-match-parameter-const-fp/main.c @@ -1,12 +1,14 @@ -void f1 (void) { int tk = 1; } -void f2 (void) { int tk = 2; } -void f3 (void) { int tk = 3; } -void f4 (void) { int tk = 4; } -void f5 (void) { int tk = 5; } -void f6 (void) { int tk = 6; } -void f7 (void) { int tk = 7; } -void f8 (void) { int tk = 8; } -void f9 (void) { int tk = 9; } +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -14,12 +16,17 @@ typedef void(*void_fp)(void); // This ensures that check can't work in this example const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; -void func(const void_fp fp){ - fp(); +void func(const void_fp fp) +{ + fp(); } -void main(){ - for(int i=0;i<3;i++){ - func(fp_all[i]); - } -} +int main() +{ + for(int i=0;i<3;i++) + { + func(fp_all[i]); + } + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/no-match-parameter-const-fp/test.desc b/regression/goto-analyzer/no-match-parameter-const-fp/test.desc index 3c735d48a55..deda28d213f 100644 --- a/regression/goto-analyzer/no-match-parameter-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-parameter-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions +--show-goto-functions --verbosity 10 ^Removing function pointers and virtual functions$ ^\s*IF fp == f1 THEN GOTO 1$ diff --git a/regression/goto-analyzer/no-match-parameter-fp/main.c b/regression/goto-analyzer/no-match-parameter-fp/main.c index 8bbd6ee15d6..fe392e11f0e 100644 --- a/regression/goto-analyzer/no-match-parameter-fp/main.c +++ b/regression/goto-analyzer/no-match-parameter-fp/main.c @@ -1,12 +1,14 @@ -void f1 (void) { int tk = 1; } -void f2 (void) { int tk = 2; } -void f3 (void) { int tk = 3; } -void f4 (void) { int tk = 4; } -void f5 (void) { int tk = 5; } -void f6 (void) { int tk = 6; } -void f7 (void) { int tk = 7; } -void f8 (void) { int tk = 8; } -void f9 (void) { int tk = 9; } +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -14,12 +16,17 @@ typedef void(*void_fp)(void); // This ensures that check can't work in this example const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; -void func(void_fp fp){ - fp(); +void func(void_fp fp) +{ + fp(); } -void main(){ - for(int i=0;i<3;i++){ - func(fp_all[i]); - } -} +int main() +{ + for(int i=0;i<3;i++) + { + func(fp_all[i]); + } + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/no-match-parameter-fp/test.desc b/regression/goto-analyzer/no-match-parameter-fp/test.desc index 3c735d48a55..deda28d213f 100644 --- a/regression/goto-analyzer/no-match-parameter-fp/test.desc +++ b/regression/goto-analyzer/no-match-parameter-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions +--show-goto-functions --verbosity 10 ^Removing function pointers and virtual functions$ ^\s*IF fp == f1 THEN GOTO 1$ diff --git a/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/main.c b/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/main.c index bd46ce92484..c9d632f43b9 100644 --- a/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/main.c +++ b/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/main.c @@ -1,15 +1,14 @@ #include -#include - -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -24,7 +23,8 @@ typedef struct fp_container -void func(){ +void func() +{ const fp_container container = { .fp_tbl = {f2 ,f3, f4} }; const void_fp alternatate_fp_tbl[] = {f5 ,f6, f7}; const fp_container container2 = { .fp_tbl = {f5 ,f6, f7} }; @@ -36,6 +36,7 @@ void func(){ container_ptr->fp_tbl[1](); } -int main(){ +int main() +{ func(); } diff --git a/regression/goto-analyzer/precise-array-calculation-const-fp/main.c b/regression/goto-analyzer/precise-array-calculation-const-fp/main.c index cbe9e504df2..be8d02bff78 100644 --- a/regression/goto-analyzer/precise-array-calculation-const-fp/main.c +++ b/regression/goto-analyzer/precise-array-calculation-const-fp/main.c @@ -1,14 +1,14 @@ #include -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -24,6 +24,9 @@ void func() fp_tbl[(signed long int)((signed int)short_const_variable & 0x1)](); } -void main(){ +int main() +{ func(); -} + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/precise-array-calculation-const-fp/test.desc b/regression/goto-analyzer/precise-array-calculation-const-fp/test.desc index a402b60e080..3fb0a47980c 100644 --- a/regression/goto-analyzer/precise-array-calculation-const-fp/test.desc +++ b/regression/goto-analyzer/precise-array-calculation-const-fp/test.desc @@ -1,11 +1,8 @@ CORE main.c ---show-goto-functions +--show-goto-functions --verbosity 10 ^Removing function pointers and virtual functions$ ^\s*f3();$ ^SIGNAL=0$ -- ^warning: ignoring --- -Fails because of the non-trivial index expression can be evaluated -constantly but isn't \ No newline at end of file diff --git a/regression/goto-analyzer/precise-array-literal-const-fp/main.c b/regression/goto-analyzer/precise-array-literal-const-fp/main.c index bd650bd01ae..31cc52a7403 100644 --- a/regression/goto-analyzer/precise-array-literal-const-fp/main.c +++ b/regression/goto-analyzer/precise-array-literal-const-fp/main.c @@ -1,14 +1,14 @@ #include -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -23,6 +23,9 @@ void func() fp_tbl[1](); } -void main(){ +int main() +{ func(); -} + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/precise-array-literal-const-fp/test.desc b/regression/goto-analyzer/precise-array-literal-const-fp/test.desc index a36fb208c69..3fb0a47980c 100644 --- a/regression/goto-analyzer/precise-array-literal-const-fp/test.desc +++ b/regression/goto-analyzer/precise-array-literal-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions +--show-goto-functions --verbosity 10 ^Removing function pointers and virtual functions$ ^\s*f3();$ ^SIGNAL=0$ diff --git a/regression/goto-analyzer/precise-const-fp-array-const-variable-const-fp/main.c b/regression/goto-analyzer/precise-const-fp-array-const-variable-const-fp/main.c index fbbd4f34259..a43a189f96f 100644 --- a/regression/goto-analyzer/precise-const-fp-array-const-variable-const-fp/main.c +++ b/regression/goto-analyzer/precise-const-fp-array-const-variable-const-fp/main.c @@ -1,14 +1,14 @@ #include -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -25,6 +25,9 @@ void func() fp(); } -void main(){ +int main() +{ func(); -} + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/precise-const-fp-array-const-variable-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp-array-const-variable-const-fp/test.desc index a36fb208c69..3fb0a47980c 100644 --- a/regression/goto-analyzer/precise-const-fp-array-const-variable-const-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-array-const-variable-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions +--show-goto-functions --verbosity 10 ^Removing function pointers and virtual functions$ ^\s*f3();$ ^SIGNAL=0$ diff --git a/regression/goto-analyzer/precise-const-fp-array-literal-const-fp/main.c b/regression/goto-analyzer/precise-const-fp-array-literal-const-fp/main.c index 4d057be3a08..d061734174f 100644 --- a/regression/goto-analyzer/precise-const-fp-array-literal-const-fp/main.c +++ b/regression/goto-analyzer/precise-const-fp-array-literal-const-fp/main.c @@ -1,14 +1,14 @@ #include -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -24,6 +24,9 @@ void func() fp(); } -void main(){ +int main() +{ func(); -} + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/precise-const-fp-array-literal-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp-array-literal-const-fp/test.desc index a36fb208c69..3fb0a47980c 100644 --- a/regression/goto-analyzer/precise-const-fp-array-literal-const-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-array-literal-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions +--show-goto-functions --verbosity 10 ^Removing function pointers and virtual functions$ ^\s*f3();$ ^SIGNAL=0$ diff --git a/regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/main.c b/regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/main.c index 0c8c7e86046..26f13fc4c28 100644 --- a/regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/main.c +++ b/regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/main.c @@ -1,14 +1,14 @@ #include -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -16,12 +16,14 @@ typedef void(*void_fp)(void); // This ensures that check can't work in this example const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; -struct stable { +struct stable +{ int x; void (*fp)(void); }; -const struct stable stable_table [3] = { +const struct stable stable_table [3] = +{ { 1, f2 }, { 2, f3 }, { 3, f4 } @@ -30,18 +32,21 @@ const struct stable stable_table [3] = { const struct stable another_table = { 4, f5 }; -void func(int i){ - const void_fp fp = stable_table[1].fp; +void func(int i) +{ + const void_fp fp = stable_table[1].fp; - // Illegal - // stable_table[1] = another_table; - // stable_table[1].fp = f5; - fp(); + // Illegal + // stable_table[1] = another_table; + // stable_table[1].fp = f5; + fp(); } -int main(){ - for(int i=0;i<3;i++){ - func(i); - } - return 0; +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + return 0; } diff --git a/regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/test.desc index bfc412d2705..77c3b9a93d1 100644 --- a/regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/test.desc @@ -6,4 +6,4 @@ main.c ^\s*f3();$ ^SIGNAL=0$ -- -^warning: ignoring \ No newline at end of file +^warning: ignoring diff --git a/regression/goto-analyzer/precise-const-fp-array-variable-const-pointer-const-struct-non-const-fp/main.c b/regression/goto-analyzer/precise-const-fp-array-variable-const-pointer-const-struct-non-const-fp/main.c new file mode 100644 index 00000000000..c1bcb0dc951 --- /dev/null +++ b/regression/goto-analyzer/precise-const-fp-array-variable-const-pointer-const-struct-non-const-fp/main.c @@ -0,0 +1,49 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +struct action +{ + int x; + void_fp fun; +}; + +const struct action rec = { .x = 4, .fun = f2 }; + +const struct action * const action_list[4] = +{ + &rec, + &rec, + &rec, + &rec +}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i) +{ + const void_fp fp = action_list[i]->fun; + fp(); +} + +int main() +{ + for(int i=0;i<4;i++) +{ + func(i); + } + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp1/test.desc b/regression/goto-analyzer/precise-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc similarity index 100% rename from regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp1/test.desc rename to regression/goto-analyzer/precise-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc diff --git a/regression/goto-analyzer/precise-const-fp-const-fp/main.c b/regression/goto-analyzer/precise-const-fp-const-fp/main.c index 85f6fc5b79e..d3a61d828e1 100644 --- a/regression/goto-analyzer/precise-const-fp-const-fp/main.c +++ b/regression/goto-analyzer/precise-const-fp-const-fp/main.c @@ -1,14 +1,14 @@ #include -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -23,7 +23,9 @@ void func() fp2(); } -void main() +int main() { func(); -} + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/precise-const-fp-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp-const-fp/test.desc index 9ba26c84989..653466e87fb 100644 --- a/regression/goto-analyzer/precise-const-fp-const-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions +--show-goto-functions --verbosity 10 ^Removing function pointers and virtual functions$ ^\s*f2();$ ^SIGNAL=0$ diff --git a/regression/goto-analyzer/precise-const-fp-const-struct-const-array-literal-fp/main.c b/regression/goto-analyzer/precise-const-fp-const-struct-const-array-literal-fp/main.c index 06ccc492469..8a05a9b7d4c 100644 --- a/regression/goto-analyzer/precise-const-fp-const-struct-const-array-literal-fp/main.c +++ b/regression/goto-analyzer/precise-const-fp-const-struct-const-array-literal-fp/main.c @@ -1,15 +1,14 @@ #include -#include - -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -24,7 +23,8 @@ typedef struct fp_container -void func(){ +void func() +{ const fp_container container = { .fp_tbl = {f2 ,f3, f4} }; const fp_container container2 = { .fp_tbl = {f5 ,f6, f7} }; // Illegal: @@ -33,6 +33,7 @@ void func(){ fp(); } -int main(){ +int main() +{ func(); } diff --git a/regression/goto-analyzer/precise-const-fp-const-struct-const-array-literal-fp/test.desc b/regression/goto-analyzer/precise-const-fp-const-struct-const-array-literal-fp/test.desc index 701da09802e..77c3b9a93d1 100644 --- a/regression/goto-analyzer/precise-const-fp-const-struct-const-array-literal-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-const-struct-const-array-literal-fp/test.desc @@ -7,6 +7,3 @@ main.c ^SIGNAL=0$ -- ^warning: ignoring --- -This is currently failing because the const is being ignored inside -the struct diff --git a/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/main.c b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/main.c index a64ca581ae5..5cf1602c854 100644 --- a/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/main.c +++ b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/main.c @@ -1,15 +1,14 @@ #include -#include - -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -19,14 +18,16 @@ const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; typedef struct fp_container { + int x; void_fp fp_tbl[3]; } fp_container; -void func(){ - const fp_container container = { .fp_tbl = {f2 ,f3, f4} }; - fp_container container2 = { .fp_tbl = {f5 ,f6, f7} }; +void func() +{ + const fp_container container = { .x = 4, .fp_tbl = {f2 ,f3, f4} }; + fp_container container2 = { .x = 5, .fp_tbl = {f5 ,f6, f7} }; const void_fp alternatate_fp_tbl[] = {f5 ,f6, f7}; // Illegal: // container = container2; @@ -36,6 +37,9 @@ void func(){ fp(); } -void main(){ +int main() +{ func(); -} + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/test.desc b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/test.desc index 649ba6fbedd..77c3b9a93d1 100644 --- a/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/test.desc @@ -7,9 +7,3 @@ main.c ^SIGNAL=0$ -- ^warning: ignoring --- -This test is marked as a KNOWNBUG as it is possible for the function -pointer to be optimized away. Currently goto-analyzer falls back to -assuming it could be any type compatible function. - -Issue: https://github.com/diffblue/cbmc/issues/476 diff --git a/regression/goto-analyzer/precise-const-fp-const-struct-non-const-fp/main.c b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-fp/main.c index e4f1ee8c491..02cbb17f851 100644 --- a/regression/goto-analyzer/precise-const-fp-const-struct-non-const-fp/main.c +++ b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-fp/main.c @@ -1,38 +1,44 @@ #include -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); struct action { + int x; void_fp fun; }; -const struct action rec = { .fun = f2 }; +const struct action rec = { .x = 4, .fun = f2 }; // There is a basic check that excludes all functions that aren't used anywhere // This ensures that check can't work in this example const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; -void func(int i){ +void func(int i) +{ // Illegal: //rec.fun = &f5; - const void_fp fp = rec.fun; - fp(); + const void_fp fp = rec.fun; + fp(); } -void main(){ - for(int i=0;i<3;i++){ - func(i); - } -} +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/main.c b/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/main.c index c90c9bb9585..c18a7fe3256 100644 --- a/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/main.c +++ b/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/main.c @@ -1,15 +1,14 @@ #include -#include -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -17,7 +16,8 @@ typedef void(*void_fp)(void); // This ensures that check can't work in this example const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; -void func(){ +void func() +{ const void_fp fp = f3; const void_fp fp2 = f4; const void_fp* const p2fp = &fp; @@ -28,6 +28,9 @@ void func(){ final_fp(); } -void main(){ +int main() +{ func(); -} + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/test.desc index 649ba6fbedd..77c3b9a93d1 100644 --- a/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/test.desc @@ -7,9 +7,3 @@ main.c ^SIGNAL=0$ -- ^warning: ignoring --- -This test is marked as a KNOWNBUG as it is possible for the function -pointer to be optimized away. Currently goto-analyzer falls back to -assuming it could be any type compatible function. - -Issue: https://github.com/diffblue/cbmc/issues/476 diff --git a/regression/goto-analyzer/precise-const-fp/main.c b/regression/goto-analyzer/precise-const-fp/main.c index f9b5908bce2..f4d21dc2588 100644 --- a/regression/goto-analyzer/precise-const-fp/main.c +++ b/regression/goto-analyzer/precise-const-fp/main.c @@ -1,14 +1,14 @@ #include -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -22,6 +22,9 @@ void func() fp(); } -void main(){ +int main() +{ func(); -} + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/precise-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp/test.desc index c3065239e49..eb4d61d9d9c 100644 --- a/regression/goto-analyzer/precise-const-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions +--show-goto-functions --verbosity 10 ^Removing function pointers and virtual functions$ ^\s*f2(); diff --git a/regression/goto-analyzer/precise-const-struct-non-const-fp/main.c b/regression/goto-analyzer/precise-const-struct-non-const-fp/main.c index 8fbd4796975..aa534a96e93 100644 --- a/regression/goto-analyzer/precise-const-struct-non-const-fp/main.c +++ b/regression/goto-analyzer/precise-const-struct-non-const-fp/main.c @@ -1,34 +1,40 @@ #include -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); struct action { + int x; void_fp fun; }; -const struct action rec = { .fun = f2 }; +const struct action rec = { .x = 4, .fun = f2 }; // There is a basic check that excludes all functions that aren't used anywhere // This ensures that check can't work in this example const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; -void func(int i){ - rec.fun(); +void func(int i) +{ + rec.fun(); } -void main(){ - for(int i=0;i<3;i++){ - func(i); - } -} +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/main.c b/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/main.c index b5599183e11..1e2fd83fd6b 100644 --- a/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/main.c +++ b/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/main.c @@ -1,15 +1,14 @@ #include -#include -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -17,7 +16,8 @@ typedef void(*void_fp)(void); // This ensures that check can't work in this example const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; -void func(){ +void func() +{ const void_fp fp = f3; const void_fp fp2 = f4; const void_fp* const p2fp = &fp; @@ -27,6 +27,9 @@ void func(){ (*p2fp)(); } -void main(){ +int main() +{ func(); -} + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/test.desc b/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/test.desc index 649ba6fbedd..77c3b9a93d1 100644 --- a/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/test.desc @@ -7,9 +7,3 @@ main.c ^SIGNAL=0$ -- ^warning: ignoring --- -This test is marked as a KNOWNBUG as it is possible for the function -pointer to be optimized away. Currently goto-analyzer falls back to -assuming it could be any type compatible function. - -Issue: https://github.com/diffblue/cbmc/issues/476 diff --git a/regression/goto-analyzer/precise-derefence/main.c b/regression/goto-analyzer/precise-derefence/main.c index 16df50eeb11..318676c712e 100644 --- a/regression/goto-analyzer/precise-derefence/main.c +++ b/regression/goto-analyzer/precise-derefence/main.c @@ -1,14 +1,14 @@ #include -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -23,7 +23,9 @@ void func() (*(&f2))(); } -void main() +int main() { func(); -} + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/precise-derefence/test.desc b/regression/goto-analyzer/precise-derefence/test.desc index c3065239e49..eb4d61d9d9c 100644 --- a/regression/goto-analyzer/precise-derefence/test.desc +++ b/regression/goto-analyzer/precise-derefence/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions +--show-goto-functions --verbosity 10 ^Removing function pointers and virtual functions$ ^\s*f2(); diff --git a/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/main.c b/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/main.c index e27d618cea9..56a7a7d7c4e 100644 --- a/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/main.c +++ b/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/main.c @@ -1,15 +1,14 @@ #include -#include -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -17,11 +16,15 @@ typedef void(*void_fp)(void); // This ensures that check can't work in this example const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; -void func(){ +void func() +{ const void_fp fp = f3; (*(&fp))(); } -void main(){ +int main() +{ func(); -} + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/test.desc b/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/test.desc index 649ba6fbedd..77c3b9a93d1 100644 --- a/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/test.desc @@ -7,9 +7,3 @@ main.c ^SIGNAL=0$ -- ^warning: ignoring --- -This test is marked as a KNOWNBUG as it is possible for the function -pointer to be optimized away. Currently goto-analyzer falls back to -assuming it could be any type compatible function. - -Issue: https://github.com/diffblue/cbmc/issues/476 diff --git a/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-fp/main.c b/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-fp/main.c index c7237dee13f..c8694d74a08 100644 --- a/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-fp/main.c +++ b/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-fp/main.c @@ -1,15 +1,14 @@ #include -#include - -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -25,7 +24,8 @@ typedef struct fp_cc -void func(){ +void func() +{ const void_fp meta_fp = &f3; const fp_cc container_container = { .container = &meta_fp, .x = 4 }; @@ -36,6 +36,7 @@ void func(){ (*container_container.container)(); } -int main(){ +int main() +{ func(); } diff --git a/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-struct-const-fp/main.c b/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-struct-const-fp/main.c index 70b853a9dff..4f00ca80765 100644 --- a/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-struct-const-fp/main.c +++ b/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-struct-const-fp/main.c @@ -1,15 +1,14 @@ #include -#include - -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -31,7 +30,8 @@ typedef struct fp_cc -void func(){ +void func() +{ const fp_container container = {.y = 10, .pointer = f3}; const fp_container container2 = {.y = 10, .pointer = f4}; const fp_cc container_container = { .container = &container, .x = 4 }; @@ -43,6 +43,7 @@ void func(){ (*container_container.container).pointer(); } -int main(){ +int main() +{ func(); } diff --git a/regression/goto-analyzer/precise-dereference-const-struct-pointer-const-fp/main.c b/regression/goto-analyzer/precise-dereference-const-struct-pointer-const-fp/main.c index 7324bad0488..1d562a42dc8 100644 --- a/regression/goto-analyzer/precise-dereference-const-struct-pointer-const-fp/main.c +++ b/regression/goto-analyzer/precise-dereference-const-struct-pointer-const-fp/main.c @@ -1,15 +1,14 @@ #include -#include - -void f1 (void) { printf("%i", 1); } -void f2 (void) { printf("%i", 2); } -void f3 (void) { printf("%i", 3); } -void f4 (void) { printf("%i", 4); } -void f5 (void) { printf("%i", 5); } -void f6 (void) { printf("%i", 6); } -void f7 (void) { printf("%i", 7); } -void f8 (void) { printf("%i", 8); } -void f9 (void) { printf("%i", 9); } + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } typedef void(*void_fp)(void); @@ -25,7 +24,8 @@ typedef struct fp_cc -void func(){ +void func() +{ const void_fp meta_fp = &f3; const fp_cc container_container = { .container = &meta_fp, .x = 4 }; @@ -36,6 +36,7 @@ void func(){ (*container_container.container)(); } -int main(){ +int main() +{ func(); } From ea5c15172235d78f1d9387cd9eb1090e9bbf6845 Mon Sep 17 00:00:00 2001 From: thk123 Date: Fri, 10 Feb 2017 11:59:38 +0000 Subject: [PATCH 031/116] Fixing compile errors for musketeer --- src/goto-programs/remove_function_pointers.h | 1 + src/musketeer/musketeer_parse_options.cpp | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/goto-programs/remove_function_pointers.h b/src/goto-programs/remove_function_pointers.h index 125cda131e1..0320a77c9a2 100644 --- a/src/goto-programs/remove_function_pointers.h +++ b/src/goto-programs/remove_function_pointers.h @@ -12,6 +12,7 @@ Date: June 2003 #define CPROVER_GOTO_PROGRAMS_REMOVE_FUNCTION_POINTERS_H #include "goto_model.h" +#include // remove indirect function calls // and replace by case-split diff --git a/src/musketeer/musketeer_parse_options.cpp b/src/musketeer/musketeer_parse_options.cpp index 707ec50bd0b..de8696d449c 100644 --- a/src/musketeer/musketeer_parse_options.cpp +++ b/src/musketeer/musketeer_parse_options.cpp @@ -215,7 +215,10 @@ void goto_fence_inserter_parse_optionst::instrument_goto_program( if(cmdline.isset("remove-function-pointers")) { status() << "remove soundly function pointers" << eom; - remove_function_pointers(symbol_table, goto_functions, + remove_function_pointers( + get_message_handler(), + symbol_table, + goto_functions, cmdline.isset("pointer-check")); } From f68ff26a3d361bcefc43d8fcaaaa852bac4f51da Mon Sep 17 00:00:00 2001 From: thk123 Date: Fri, 10 Feb 2017 15:28:36 +0000 Subject: [PATCH 032/116] Refactored resolve_index_of_function_call resolve_index_of and resolve_index_of_function_call both involved squashing down an array, the function call just made a different recurssive call at the end. Therefore it is equivalent to squash the entry and call the resolve function call on the final result. --- .../remove_const_function_pointers.cpp | 87 +++---------------- 1 file changed, 14 insertions(+), 73 deletions(-) diff --git a/src/goto-programs/remove_const_function_pointers.cpp b/src/goto-programs/remove_const_function_pointers.cpp index 3e04103c964..3c29666f86b 100644 --- a/src/goto-programs/remove_const_function_pointers.cpp +++ b/src/goto-programs/remove_const_function_pointers.cpp @@ -377,88 +377,29 @@ Function: remove_const_function_pointerst::try_resolve_index_of_function_call bool remove_const_function_pointerst::try_resolve_index_of_function_call( const index_exprt &index_expr, functionst &out_functions) { - // Get the array(s) it belongs to - expressionst potential_array_exprs; - bool is_const=false; - bool resolved_array= - try_resolve_expression(index_expr.array(), potential_array_exprs, is_const); - if(resolved_array) + expressionst potential_array_values; + bool array_const; + try_resolve_index_of(index_expr, potential_array_values, array_const); + if(array_const) { - for(const exprt &potential_array_expr : potential_array_exprs) + for(const exprt &array_value : potential_array_values) { - if(potential_array_expr.id()==ID_array) - { - // We require either the type of the values of the array or - // the array itself to be constant. - const typet &array_type=potential_array_expr.type(); - const typet &array_contents_type=array_type.subtype(); - c_qualifierst array_qaulifiers; - array_qaulifiers.read(array_contents_type); - - if(array_qaulifiers.is_constant || is_const) - { - // Get the index if we can - mp_integer value; - if(try_resolve_index_value(index_expr.index(), value)) - { - functionst array_out_functions; - const exprt &func_expr= - potential_array_expr.operands()[integer2size_t(value)]; - bool resolved_value= - try_resolve_function_call(func_expr, array_out_functions); + functionst array_out_functions; + bool resolved_value= + try_resolve_function_call(array_value, array_out_functions); - if(resolved_value) - { - out_functions.insert( - array_out_functions.begin(), - array_out_functions.end()); - } - else - { - LOG("Could not resolve expression in array", func_expr); - return false; - } - } - else - { - // We don't know what index it is, - // but we know the value is from the array - for(const exprt &array_entry : potential_array_expr.operands()) - { - if(array_entry.is_zero()) - { - continue; - } - functionst potential_functions; - bool resolved_value= - try_resolve_function_call(array_entry, potential_functions); - - if(resolved_value) - { - out_functions.insert( - potential_functions.begin(), potential_functions.end()); - } - else - { - LOG("Could not resolve expression in array", array_entry); - return false; - } - } - } - } - else - { - LOG("Array and its contents are not const", potential_array_expr); - return false; - } + if(resolved_value) + { + out_functions.insert( + array_out_functions.begin(), + array_out_functions.end()); } else { - LOG("Squashing index did not result in an array", potential_array_expr); + LOG("Could not resolve expression in array", array_value); return false; } } - return true; } else From 6298feaf6574d860141b3a001c87bd7679ed1ebc Mon Sep 17 00:00:00 2001 From: thk123 Date: Fri, 10 Feb 2017 15:39:21 +0000 Subject: [PATCH 033/116] Split out functions from try_resolve_function_call --- .../remove_const_function_pointers.cpp | 375 +++++++++++------- .../remove_const_function_pointers.h | 12 + 2 files changed, 248 insertions(+), 139 deletions(-) diff --git a/src/goto-programs/remove_const_function_pointers.cpp b/src/goto-programs/remove_const_function_pointers.cpp index 3c29666f86b..0ffff170e0b 100644 --- a/src/goto-programs/remove_const_function_pointers.cpp +++ b/src/goto-programs/remove_const_function_pointers.cpp @@ -181,157 +181,23 @@ bool remove_const_function_pointerst::try_resolve_function_call( else if(simplified_expr.id()==ID_member) { const member_exprt &member_expr=to_member_expr(simplified_expr); - const exprt &owner_expr=member_expr.compound(); - // Squash the struct - expressionst out_expressions; - bool struct_is_const=false; - bool resolved= - try_resolve_expression(owner_expr, out_expressions, struct_is_const); - if(resolved) - { - for(const exprt &expression:out_expressions) - { - if(expression.id()!=ID_struct) - { - LOG("Squash of member access didn't result in a struct", expression); - return false; - } - else - { - const struct_exprt &struct_expr=to_struct_expr(expression); - const exprt &component_value= - get_component_value(struct_expr, member_expr); - - if(struct_is_const) - { - functionst component_functions; - bool resolved= - try_resolve_function_call(component_value, component_functions); - if(resolved) - { - out_functions.insert( - component_functions.begin(), component_functions.end()); - } - else - { - LOG( - "Couldn't resolve functions call from component value", - component_value); - return false; - } - } - else - { - LOG( - "Struct was not const so can't resolve values on it", - struct_expr); - return false; - } - } - } - - return true; - - } - else - { - LOG("Failed to squash struct member access", owner_expr); - return false; - } + return try_resolve_member_function_call(member_expr, out_functions); } else if(simplified_expr.id()==ID_address_of) { address_of_exprt address_expr=to_address_of_expr(simplified_expr); - bool resolved= - try_resolve_function_call(address_expr.object(), out_functions); - if(!resolved) - { - LOG("Failed to resolve address of", address_expr); - } - return resolved; + return try_resolve_address_of_function_call( + address_expr, out_functions); } else if(simplified_expr.id()==ID_dereference) { - // We had a pointer, we need to check both the pointer - // type can't be changed, and what it what pointing to - // can't be changed const dereference_exprt &deref=to_dereference_expr(simplified_expr); - expressionst pointer_values; - bool pointer_const; - bool resolved= - try_resolve_expression(deref.pointer(), pointer_values, pointer_const); - - // Here we require that the value we are dereferencing is const - // The actual type doesn't matter since we are on the RHS so what matters - // is where this gets stored, but the value stored matters - if(resolved && pointer_const) - { - for(const exprt &pointer_val : pointer_values) - { - if(pointer_val.id()==ID_address_of) - { - address_of_exprt address_expr=to_address_of_expr(pointer_val); - functionst out_object_values; - bool resolved= - try_resolve_function_call( - address_expr.object(), out_object_values); - - if(resolved) - { - out_functions.insert( - out_object_values.begin(), - out_object_values.end()); - } - else - { - LOG("Failed to resolver pointers value", address_expr); - return false; - } - } - else - { - LOG( - "Squashing dereference did not result in an address of", - pointer_val); - return false; - } - } - return true; - } - else - { - if(!resolved) - { - LOG("Failed to squash dereference", deref); - } - else if(!pointer_const) - { - LOG("Dereferenced value was not const so can't dereference", deref); - } - return false; - } + return try_resolve_dereference_function_call(deref, out_functions); } else if(simplified_expr.id()==ID_typecast) { - // We simply ignore typecasts and assume they are valid - // I thought simplify_expr would deal with this, but for example - // a cast from a 32 bit width int to a 64bit width int it doesn't seem - // to allow typecast_exprt typecast_expr=to_typecast_expr(simplified_expr); - functionst typecast_values; - bool resolved= - try_resolve_function_call(typecast_expr.op(), typecast_values); - - if(resolved) - { - out_functions.insert(typecast_values.begin(), typecast_values.end()); - return true; - } - else - { - LOG("Failed to squash typecast", simplified_expr); - return false; - } + return try_resolve_typecast_function_call(typecast_expr, out_functions); } else if(simplified_expr.id()==ID_symbol) { @@ -411,6 +277,237 @@ bool remove_const_function_pointerst::try_resolve_index_of_function_call( /*******************************************************************\ +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) +{ + const exprt &owner_expr=member_expr.compound(); + // Squash the struct + expressionst out_expressions; + bool struct_is_const=false; + bool resolved= + try_resolve_expression(owner_expr, out_expressions, struct_is_const); + if(resolved) + { + for(const exprt &expression:out_expressions) + { + if(expression.id()!=ID_struct) + { + LOG("Squash of member access didn't result in a struct", expression); + return false; + } + else + { + const struct_exprt &struct_expr=to_struct_expr(expression); + const exprt &component_value= + get_component_value(struct_expr, member_expr); + + if(struct_is_const) + { + functionst component_functions; + bool resolved= + try_resolve_function_call(component_value, component_functions); + if(resolved) + { + out_functions.insert( + component_functions.begin(), component_functions.end()); + } + else + { + LOG( + "Couldn't resolve functions call from component value", + component_value); + return false; + } + } + else + { + LOG( + "Struct was not const so can't resolve values on it", + struct_expr); + return false; + } + } + } + + return true; + + } + else + { + LOG("Failed to squash struct member access", owner_expr); + return false; + } +} + +/*******************************************************************\ + +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_os expressions. + +\*******************************************************************/ + +bool remove_const_function_pointerst::try_resolve_address_of_function_call( + const address_of_exprt &address_expr, functionst &out_functions) +{ + bool resolved= + try_resolve_function_call(address_expr.object(), out_functions); + if(!resolved) + { + LOG("Failed to resolve address of", address_expr); + } + return resolved; +} + +/*******************************************************************\ + +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, functionst &out_functions) +{ + // We had a pointer, we need to check both the pointer + // type can't be changed, and what it what pointing to + // can't be changed + expressionst pointer_values; + bool pointer_const; + bool resolved= + try_resolve_expression(deref.pointer(), pointer_values, pointer_const); + + // Here we require that the value we are dereferencing is const + // The actual type doesn't matter since we are on the RHS so what matters + // is where this gets stored, but the value stored matters + if(resolved && pointer_const) + { + for(const exprt &pointer_val : pointer_values) + { + if(pointer_val.id()==ID_address_of) + { + address_of_exprt address_expr=to_address_of_expr(pointer_val); + functionst out_object_values; + bool resolved= + try_resolve_function_call( + address_expr.object(), out_object_values); + + if(resolved) + { + out_functions.insert( + out_object_values.begin(), + out_object_values.end()); + } + else + { + LOG("Failed to resolver pointers value", address_expr); + return false; + } + } + else + { + LOG( + "Squashing dereference did not result in an address of", + pointer_val); + return false; + } + } + return true; + } + else + { + if(!resolved) + { + LOG("Failed to squash dereference", deref); + } + else if(!pointer_const) + { + LOG("Dereferenced value was not const so can't dereference", deref); + } + return false; + } +} + +/*******************************************************************\ + +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) +{ + // We simply ignore typecasts and assume they are valid + // I thought simplify_expr would deal with this, but for example + // a cast from a 32 bit width int to a 64bit width int it doesn't seem + // to allow + functionst typecast_values; + bool resolved= + try_resolve_function_call(typecast_expr.op(), typecast_values); + + if(resolved) + { + out_functions.insert(typecast_values.begin(), typecast_values.end()); + return true; + } + else + { + LOG("Failed to squash typecast", typecast_expr); + return false; + } +} + +/*******************************************************************\ + Function: remove_const_function_pointerst::try_resolve_expression Inputs: diff --git a/src/goto-programs/remove_const_function_pointers.h b/src/goto-programs/remove_const_function_pointers.h index e8600b9c3be..be7a18badbc 100644 --- a/src/goto-programs/remove_const_function_pointers.h +++ b/src/goto-programs/remove_const_function_pointers.h @@ -38,6 +38,18 @@ class remove_const_function_pointerst:public messaget bool try_resolve_index_of_function_call( const index_exprt &index_expr, functionst &out_functions); + bool try_resolve_member_function_call( + const member_exprt &member_expr, functionst &out_functions); + + bool try_resolve_address_of_function_call( + const address_of_exprt &address_expr, functionst &out_functions); + + bool try_resolve_dereference_function_call( + const dereference_exprt &deref, functionst &out_functions); + + bool try_resolve_typecast_function_call( + const typecast_exprt &typecast_expr, functionst &out_functions); + // recursive functions for dealing with the auxiliary elements bool try_resolve_expression( const exprt &expr, From 5d33d4d576aeff79cf55543017ccb9256e7acf7b Mon Sep 17 00:00:00 2001 From: thk123 Date: Fri, 10 Feb 2017 16:14:04 +0000 Subject: [PATCH 034/116] Made the behaviour of try_resolve_function_call clearer Rather than sometimes using the array directly, other times checking it, use and having lots of exit points to the function, all steps use same interface and work in the same way with arrays. --- .../remove_const_function_pointers.cpp | 42 ++++++++++++------- .../remove_const_function_pointers.h | 2 +- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/goto-programs/remove_const_function_pointers.cpp b/src/goto-programs/remove_const_function_pointers.cpp index 0ffff170e0b..1711e0ed3fa 100644 --- a/src/goto-programs/remove_const_function_pointers.cpp +++ b/src/goto-programs/remove_const_function_pointers.cpp @@ -170,51 +170,65 @@ Function: remove_const_function_pointerst::try_resolve_function_call \*******************************************************************/ bool remove_const_function_pointerst::try_resolve_function_call( - const exprt &expr, remove_const_function_pointerst::functionst &out_functions) + const exprt &expr, functionst &out_functions) { + assert(out_functions.empty()); const exprt &simplified_expr=simplify_expr(expr, ns); + bool resolved=false; + functionst resolved_functions; if(simplified_expr.id()==ID_index) { const index_exprt &index_expr=to_index_expr(simplified_expr); - return try_resolve_index_of_function_call(index_expr, out_functions); + resolved=try_resolve_index_of_function_call(index_expr, resolved_functions); } else if(simplified_expr.id()==ID_member) { const member_exprt &member_expr=to_member_expr(simplified_expr); - return try_resolve_member_function_call(member_expr, out_functions); + resolved=try_resolve_member_function_call(member_expr, resolved_functions); } else if(simplified_expr.id()==ID_address_of) { address_of_exprt address_expr=to_address_of_expr(simplified_expr); - return try_resolve_address_of_function_call( - address_expr, out_functions); + resolved=try_resolve_address_of_function_call( + address_expr, resolved_functions); } else if(simplified_expr.id()==ID_dereference) { const dereference_exprt &deref=to_dereference_expr(simplified_expr); - return try_resolve_dereference_function_call(deref, out_functions); + resolved=try_resolve_dereference_function_call(deref, resolved_functions); } else if(simplified_expr.id()==ID_typecast) { typecast_exprt typecast_expr=to_typecast_expr(simplified_expr); - return try_resolve_typecast_function_call(typecast_expr, out_functions); + resolved= + try_resolve_typecast_function_call(typecast_expr, resolved_functions); } else if(simplified_expr.id()==ID_symbol) { if(simplified_expr.type().id()==ID_code) { - out_functions.insert(simplified_expr); - return true; + resolved_functions.insert(simplified_expr); + resolved=true; } else { LOG("Non const symbol wasn't squashed", simplified_expr); - return false; + resolved=false; } } else { LOG("Unrecognised expression", simplified_expr); + resolved=false; + } + + if(resolved) + { + out_functions.insert(resolved_functions.begin(), resolved_functions.end()); + return true; + } + else + { return false; } } @@ -404,7 +418,7 @@ Function: remove_const_function_pointerst::try_resolve_dereference_function_call \*******************************************************************/ bool remove_const_function_pointerst::try_resolve_dereference_function_call( - const dereference_exprt &deref, functionst &out_functions) + const dereference_exprt &deref_expr, functionst &out_functions) { // We had a pointer, we need to check both the pointer // type can't be changed, and what it what pointing to @@ -412,7 +426,7 @@ bool remove_const_function_pointerst::try_resolve_dereference_function_call( expressionst pointer_values; bool pointer_const; bool resolved= - try_resolve_expression(deref.pointer(), pointer_values, pointer_const); + try_resolve_expression(deref_expr.pointer(), pointer_values, pointer_const); // Here we require that the value we are dereferencing is const // The actual type doesn't matter since we are on the RHS so what matters @@ -455,11 +469,11 @@ bool remove_const_function_pointerst::try_resolve_dereference_function_call( { if(!resolved) { - LOG("Failed to squash dereference", deref); + LOG("Failed to squash dereference", deref_expr); } else if(!pointer_const) { - LOG("Dereferenced value was not const so can't dereference", deref); + LOG("Dereferenced value was not const so can't dereference", deref_expr); } return false; } diff --git a/src/goto-programs/remove_const_function_pointers.h b/src/goto-programs/remove_const_function_pointers.h index be7a18badbc..3d47e0d5f94 100644 --- a/src/goto-programs/remove_const_function_pointers.h +++ b/src/goto-programs/remove_const_function_pointers.h @@ -45,7 +45,7 @@ class remove_const_function_pointerst:public messaget const address_of_exprt &address_expr, functionst &out_functions); bool try_resolve_dereference_function_call( - const dereference_exprt &deref, functionst &out_functions); + const dereference_exprt &deref_expr, functionst &out_functions); bool try_resolve_typecast_function_call( const typecast_exprt &typecast_expr, functionst &out_functions); From a75957bf3fed937568b0ccf977c113426df2a8c4 Mon Sep 17 00:00:00 2001 From: thk123 Date: Fri, 10 Feb 2017 16:14:45 +0000 Subject: [PATCH 035/116] Split up try_resolve_expression into functions --- .../remove_const_function_pointers.cpp | 398 +++++++++++------- .../remove_const_function_pointers.h | 21 +- 2 files changed, 258 insertions(+), 161 deletions(-) diff --git a/src/goto-programs/remove_const_function_pointers.cpp b/src/goto-programs/remove_const_function_pointers.cpp index 1711e0ed3fa..0cd450a3935 100644 --- a/src/goto-programs/remove_const_function_pointers.cpp +++ b/src/goto-programs/remove_const_function_pointers.cpp @@ -383,7 +383,7 @@ Function: remove_const_function_pointerst::try_resolve_address_of_function_call contain the possible functions. Purpose: To resolve an expression to the specific function calls it can - be. Specifically, this function deals with address_os expressions. + be. Specifically, this function deals with address_of expressions. \*******************************************************************/ @@ -551,185 +551,61 @@ bool remove_const_function_pointerst::try_resolve_expression( const exprt &expr, expressionst &out_resolved_expression, bool &out_is_const) { const exprt &simplified_expr=simplify_expr(expr, ns); + bool resolved; + expressionst resolved_expressions; + bool is_resolved_expression_const; if(simplified_expr.id()==ID_index) { const index_exprt &index_expr=to_index_expr(simplified_expr); - expressionst out_array_expressions; - bool resolved_array= - try_resolve_index_of(index_expr, out_array_expressions, out_is_const); - - if(resolved_array) - { - out_resolved_expression.insert( - out_resolved_expression.end(), - out_array_expressions.begin(), - out_array_expressions.end()); - } - else - { - LOG("Could not resolve array", index_expr); - } - - return resolved_array; + resolved= + try_resolve_index_of( + index_expr, resolved_expressions, is_resolved_expression_const); } else if(simplified_expr.id()==ID_member) { - // Get the component it belongs to const member_exprt &member_expr=to_member_expr(simplified_expr); - - expressionst potential_structs; - bool is_struct_const; - bool resolved_struct= - try_resolve_expression( - member_expr.compound(), potential_structs, is_struct_const); - - if(resolved_struct) - { - for(const exprt &potential_struct : potential_structs) - { - if(potential_struct.id()==ID_struct) - { - struct_exprt struct_expr=to_struct_expr(potential_struct); - const exprt &component_value= - get_component_value(struct_expr, member_expr); - - expressionst out_expressions; - bool component_const=false; - bool resolved= - try_resolve_expression( - component_value, out_expressions, component_const); - if(resolved) - { - out_resolved_expression.insert( - out_resolved_expression.end(), - out_expressions.begin(), - out_expressions.end()); - } - else - { - LOG("Could not resolve component value", component_value); - return false; - } - } - else - { - LOG( - "Squashing member access did not resolve in a struct", - potential_struct); - return false; - } - } - out_is_const=is_struct_const; - return true; - } - else - { - LOG("Failed to squash struct access", member_expr); - return false; - } + resolved=try_resolve_member( + member_expr, resolved_expressions, is_resolved_expression_const); } else if(simplified_expr.id()==ID_dereference) { - // We had a pointer, we need to check both the pointer - // type can't be changed, and what it what pointing to - // can't be changed const dereference_exprt &deref=to_dereference_expr(simplified_expr); - expressionst pointer_values; - bool pointer_const; - bool resolved= - try_resolve_expression(deref.pointer(), pointer_values, pointer_const); - if(resolved && pointer_const) - { - bool all_objects_const=true; - for(const exprt &pointer_val : pointer_values) - { - if(pointer_val.id()==ID_address_of) - { - address_of_exprt address_expr=to_address_of_expr(pointer_val); - bool object_const=false; - expressionst out_object_values; - bool resolved= - try_resolve_expression( - address_expr.object(), out_object_values, object_const); - - if(resolved) - { - out_resolved_expression.insert( - out_resolved_expression.end(), - out_object_values.begin(), - out_object_values.end()); - - all_objects_const&=object_const; - } - else - { - LOG("Failed to resolve value of a dereference", address_expr); - } - } - else - { - LOG( - "Squashing dereference did not result in an address", pointer_val); - return false; - } - } - out_is_const=all_objects_const; - return true; - } - else - { - if(!resolved) - { - LOG("Failed to resolve pointer of dereference", deref); - } - else if(!pointer_const) - { - LOG("Pointer value not const so can't squash", deref); - } - return false; - } + resolved= + try_resolve_dereference( + deref, resolved_expressions, is_resolved_expression_const); } else if(simplified_expr.id()==ID_typecast) { - // We simply ignore typecasts and assume they are valid - // I thought simplify_expr would deal with this, but for example - // a cast from a 32 bit width int to a 64bit width int it doesn't seem - // to allow typecast_exprt typecast_expr=to_typecast_expr(simplified_expr); - expressionst typecast_values; - bool typecast_const; - bool resolved= - try_resolve_expression( - typecast_expr.op(), typecast_values, typecast_const); - - if(resolved) - { - out_resolved_expression.insert( - out_resolved_expression.end(), - typecast_values.begin(), - typecast_values.end()); - out_is_const=typecast_const; - return true; - } - else - { - LOG("Could not resolve typecast value", typecast_expr); - return false; - } + resolved= + try_resolve_typecast( + typecast_expr, resolved_expressions, is_resolved_expression_const); } else if(simplified_expr.id()==ID_symbol) { LOG("Non const symbol will not be squashed", simplified_expr); - return false; + resolved=false; } - // TOOD: probably need to do something with pointers or address_of - // and const since a const pointer to a non-const value is useless else { - out_is_const=is_expression_const(simplified_expr); - out_resolved_expression.push_back(simplified_expr); + resolved_expressions.push_back(simplified_expr); + is_resolved_expression_const=is_expression_const(simplified_expr); + resolved=true; + } + + if(resolved) + { + out_resolved_expression.insert( + out_resolved_expression.end(), + resolved_expressions.begin(), + resolved_expressions.end()); + out_is_const=is_resolved_expression_const; return true; } + else + { + return false; + } } /*******************************************************************\ @@ -788,8 +664,8 @@ bool remove_const_function_pointerst::try_resolve_index_value( Function: remove_const_function_pointerst::try_resolve_index_of Inputs: - index_expr - The index expression to to resolve to possible function calls - out_expressions - The functions this expression could be + 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 @@ -909,6 +785,212 @@ bool remove_const_function_pointerst::try_resolve_index_of( /*******************************************************************\ +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, + bool &out_is_const) +{ + expressionst potential_structs; + bool is_struct_const; + + // Get the struct it belongs to + bool resolved_struct= + try_resolve_expression( + member_expr.compound(), potential_structs, is_struct_const); + if(resolved_struct) + { + for(const exprt &potential_struct : potential_structs) + { + if(potential_struct.id()==ID_struct) + { + struct_exprt struct_expr=to_struct_expr(potential_struct); + const exprt &component_value= + get_component_value(struct_expr, member_expr); + expressionst resolved_expressions; + bool component_const=false; + bool resolved= + try_resolve_expression( + component_value, resolved_expressions, component_const); + if(resolved) + { + out_expressions.insert( + out_expressions.end(), + resolved_expressions.begin(), + resolved_expressions.end()); + } + else + { + LOG("Could not resolve component value", component_value); + return false; + } + } + else + { + LOG( + "Squashing member access did not resolve in a struct", + potential_struct); + return false; + } + } + out_is_const=is_struct_const; + return true; + } + else + { + LOG("Failed to squash struct access", member_expr); + return false; + } +} + +/*******************************************************************\ + +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, + bool &out_is_const) +{ + // We had a pointer, we need to check both the pointer + // type can't be changed, and what it what pointing to + // can't be changed + expressionst pointer_values; + bool pointer_const; + bool resolved= + try_resolve_expression(deref_expr.pointer(), pointer_values, pointer_const); + if(resolved && pointer_const) + { + bool all_objects_const=true; + for(const exprt &pointer_val : pointer_values) + { + if(pointer_val.id()==ID_address_of) + { + address_of_exprt address_expr=to_address_of_expr(pointer_val); + bool object_const=false; + expressionst out_object_values; + bool resolved= + try_resolve_expression( + address_expr.object(), out_object_values, object_const); + + if(resolved) + { + out_expressions.insert( + out_expressions.end(), + out_object_values.begin(), + out_object_values.end()); + + all_objects_const&=object_const; + } + else + { + LOG("Failed to resolve value of a dereference", address_expr); + } + } + else + { + LOG( + "Squashing dereference did not result in an address", pointer_val); + return false; + } + } + out_is_const=all_objects_const; + return true; + } + else + { + if(!resolved) + { + LOG("Failed to resolve pointer of dereference", deref_expr); + } + else if(!pointer_const) + { + LOG("Pointer value not const so can't squash", deref_expr); + } + return false; + } +} + +/*******************************************************************\ + +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, + bool &out_is_const) +{ + expressionst typecast_values; + bool typecast_const; + bool resolved= + try_resolve_expression( + typecast_expr.op(), typecast_values, typecast_const); + + if(resolved) + { + out_expressions.insert( + out_expressions.end(), + typecast_values.begin(), + typecast_values.end()); + out_is_const=typecast_const; + return true; + } + else + { + LOG("Could not resolve typecast value", typecast_expr); + return false; + } +} + +/*******************************************************************\ + Function: remove_const_function_pointerst::is_expression_const Inputs: diff --git a/src/goto-programs/remove_const_function_pointers.h b/src/goto-programs/remove_const_function_pointers.h index 3d47e0d5f94..ae212e863f1 100644 --- a/src/goto-programs/remove_const_function_pointers.h +++ b/src/goto-programs/remove_const_function_pointers.h @@ -56,17 +56,32 @@ class remove_const_function_pointerst:public messaget expressionst &out_resolved_expression, bool &out_is_const); - bool try_resolve_index_value( - const exprt &index_value_expr, mp_integer &out_array_index); - bool try_resolve_index_of( const index_exprt &index_expr, expressionst &out_expressions, bool &out_is_const); + bool try_resolve_member( + const member_exprt &member_expr, + expressionst &out_expressions, + bool &out_is_const); + + bool try_resolve_dereference( + const dereference_exprt &deref_expr, + expressionst &out_expressions, + bool &out_is_const); + + bool try_resolve_typecast( + const typecast_exprt &typecast_expr, + expressionst &out_expressions, + bool &out_is_const); + bool is_expression_const(const exprt &expression) const; bool is_type_const(const typet &type) const; + bool try_resolve_index_value( + const exprt &index_value_expr, mp_integer &out_array_index); + exprt get_component_value( const struct_exprt &struct_expr, const member_exprt &member_expr); From 37660b16674d7c7547804050523ef2ac5c862e10 Mon Sep 17 00:00:00 2001 From: thk123 Date: Fri, 10 Feb 2017 16:37:25 +0000 Subject: [PATCH 036/116] Made other try_resolve*_function_call use the normal method --- .../remove_const_function_pointers.cpp | 202 +++++++----------- 1 file changed, 82 insertions(+), 120 deletions(-) diff --git a/src/goto-programs/remove_const_function_pointers.cpp b/src/goto-programs/remove_const_function_pointers.cpp index 0cd450a3935..989dd6c57de 100644 --- a/src/goto-programs/remove_const_function_pointers.cpp +++ b/src/goto-programs/remove_const_function_pointers.cpp @@ -259,34 +259,40 @@ bool remove_const_function_pointerst::try_resolve_index_of_function_call( { expressionst potential_array_values; bool array_const; - try_resolve_index_of(index_expr, potential_array_values, array_const); - if(array_const) - { - for(const exprt &array_value : potential_array_values) - { - functionst array_out_functions; - bool resolved_value= - try_resolve_function_call(array_value, array_out_functions); + bool resolved= + try_resolve_index_of(index_expr, potential_array_values, array_const); - if(resolved_value) - { - out_functions.insert( - array_out_functions.begin(), - array_out_functions.end()); - } - else - { - LOG("Could not resolve expression in array", array_value); - return false; - } - } - return true; + if(!resolved) + { + LOG("Could not resolve array", index_expr); + return false; } - else + + if(!array_const) { - LOG("Could not resolve arary", index_expr); + LOG("Array not const", index_expr); return false; } + + for(const exprt &array_value : potential_array_values) + { + functionst array_out_functions; + bool resolved_value= + try_resolve_function_call(array_value, array_out_functions); + + if(resolved_value) + { + out_functions.insert( + array_out_functions.begin(), + array_out_functions.end()); + } + else + { + LOG("Could not resolve expression in array", array_value); + return false; + } + } + return true; } /*******************************************************************\ @@ -310,63 +316,41 @@ Function: remove_const_function_pointerst::try_resolve_member_function_call bool remove_const_function_pointerst::try_resolve_member_function_call( const member_exprt &member_expr, functionst &out_functions) { - const exprt &owner_expr=member_expr.compound(); - // Squash the struct - expressionst out_expressions; - bool struct_is_const=false; + expressionst potential_component_values; + bool struct_const; bool resolved= - try_resolve_expression(owner_expr, out_expressions, struct_is_const); - if(resolved) - { - for(const exprt &expression:out_expressions) - { - if(expression.id()!=ID_struct) - { - LOG("Squash of member access didn't result in a struct", expression); - return false; - } - else - { - const struct_exprt &struct_expr=to_struct_expr(expression); - const exprt &component_value= - get_component_value(struct_expr, member_expr); - - if(struct_is_const) - { - functionst component_functions; - bool resolved= - try_resolve_function_call(component_value, component_functions); - if(resolved) - { - out_functions.insert( - component_functions.begin(), component_functions.end()); - } - else - { - LOG( - "Couldn't resolve functions call from component value", - component_value); - return false; - } - } - else - { - LOG( - "Struct was not const so can't resolve values on it", - struct_expr); - return false; - } - } - } - - return true; + try_resolve_member(member_expr, potential_component_values, struct_const); + if(!resolved) + { + LOG("Could not resolve struct", member_expr); + return false; } - else + + if(!struct_const) { - LOG("Failed to squash struct member access", owner_expr); + LOG("Struct was not const so can't resolve values on it", member_expr); return false; } + + for(const exprt &struct_component_value : potential_component_values) + { + functionst struct_out_functions; + bool resolved_value= + try_resolve_function_call(struct_component_value, struct_out_functions); + + if(resolved_value) + { + out_functions.insert( + struct_out_functions.begin(), struct_out_functions.end()); + } + else + { + LOG("Could not resolve expression in array", struct_component_value); + return false; + } + } + return true; } /*******************************************************************\ @@ -420,63 +404,41 @@ Function: remove_const_function_pointerst::try_resolve_dereference_function_call bool remove_const_function_pointerst::try_resolve_dereference_function_call( const dereference_exprt &deref_expr, functionst &out_functions) { - // We had a pointer, we need to check both the pointer - // type can't be changed, and what it what pointing to - // can't be changed - expressionst pointer_values; - bool pointer_const; + expressionst potential_deref_values; + bool deref_const; bool resolved= - try_resolve_expression(deref_expr.pointer(), pointer_values, pointer_const); + try_resolve_dereference(deref_expr, potential_deref_values, deref_const); - // Here we require that the value we are dereferencing is const - // The actual type doesn't matter since we are on the RHS so what matters - // is where this gets stored, but the value stored matters - if(resolved && pointer_const) + if(!resolved) { - for(const exprt &pointer_val : pointer_values) - { - if(pointer_val.id()==ID_address_of) - { - address_of_exprt address_expr=to_address_of_expr(pointer_val); - functionst out_object_values; - bool resolved= - try_resolve_function_call( - address_expr.object(), out_object_values); + LOG("Failed to squash dereference", deref_expr); + return false; + } - if(resolved) - { - out_functions.insert( - out_object_values.begin(), - out_object_values.end()); - } - else - { - LOG("Failed to resolver pointers value", address_expr); - return false; - } - } - else - { - LOG( - "Squashing dereference did not result in an address of", - pointer_val); - return false; - } - } - return true; + if(!deref_const) + { + LOG("Dereferenced value was not const so can't dereference", deref_expr); + return false; } - else + + for(const exprt &deref_value : potential_deref_values) { - if(!resolved) + functionst struct_out_functions; + bool resolved_value= + try_resolve_function_call(deref_value, struct_out_functions); + + if(resolved_value) { - LOG("Failed to squash dereference", deref_expr); + out_functions.insert( + struct_out_functions.begin(), struct_out_functions.end()); } - else if(!pointer_const) + else { - LOG("Dereferenced value was not const so can't dereference", deref_expr); + LOG("Could not resolve expression after dereference", deref_value); + return false; } - return false; } + return true; } /*******************************************************************\ From 83622336d158763218e90ee547e8e91d95321f3c Mon Sep 17 00:00:00 2001 From: thk123 Date: Fri, 10 Feb 2017 16:53:06 +0000 Subject: [PATCH 037/116] Extracted element dealing with calling resolve on each result --- .../remove_const_function_pointers.cpp | 99 +++++++++---------- .../remove_const_function_pointers.h | 3 + 2 files changed, 47 insertions(+), 55 deletions(-) diff --git a/src/goto-programs/remove_const_function_pointers.cpp b/src/goto-programs/remove_const_function_pointers.cpp index 989dd6c57de..f61aa2c86e5 100644 --- a/src/goto-programs/remove_const_function_pointers.cpp +++ b/src/goto-programs/remove_const_function_pointers.cpp @@ -235,6 +235,47 @@ bool remove_const_function_pointerst::try_resolve_function_call( /*******************************************************************\ +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) +{ + for(const exprt &value : exprs) + { + functionst potential_out_functions; + bool resolved_value= + try_resolve_function_call(value, potential_out_functions); + + if(resolved_value) + { + out_functions.insert( + potential_out_functions.begin(), + potential_out_functions.end()); + } + else + { + LOG("Could not resolve expression in array", value); + return false; + } + } + return true; +} + +/*******************************************************************\ + Function: remove_const_function_pointerst::try_resolve_index_of_function_call Inputs: @@ -274,25 +315,7 @@ bool remove_const_function_pointerst::try_resolve_index_of_function_call( return false; } - for(const exprt &array_value : potential_array_values) - { - functionst array_out_functions; - bool resolved_value= - try_resolve_function_call(array_value, array_out_functions); - - if(resolved_value) - { - out_functions.insert( - array_out_functions.begin(), - array_out_functions.end()); - } - else - { - LOG("Could not resolve expression in array", array_value); - return false; - } - } - return true; + return try_resolve_function_calls(potential_array_values, out_functions); } /*******************************************************************\ @@ -333,24 +356,7 @@ bool remove_const_function_pointerst::try_resolve_member_function_call( return false; } - for(const exprt &struct_component_value : potential_component_values) - { - functionst struct_out_functions; - bool resolved_value= - try_resolve_function_call(struct_component_value, struct_out_functions); - - if(resolved_value) - { - out_functions.insert( - struct_out_functions.begin(), struct_out_functions.end()); - } - else - { - LOG("Could not resolve expression in array", struct_component_value); - return false; - } - } - return true; + return try_resolve_function_calls(potential_component_values, out_functions); } /*******************************************************************\ @@ -421,24 +427,7 @@ bool remove_const_function_pointerst::try_resolve_dereference_function_call( return false; } - for(const exprt &deref_value : potential_deref_values) - { - functionst struct_out_functions; - bool resolved_value= - try_resolve_function_call(deref_value, struct_out_functions); - - if(resolved_value) - { - out_functions.insert( - struct_out_functions.begin(), struct_out_functions.end()); - } - else - { - LOG("Could not resolve expression after dereference", deref_value); - return false; - } - } - return true; + return try_resolve_function_calls(potential_deref_values, out_functions); } /*******************************************************************\ diff --git a/src/goto-programs/remove_const_function_pointers.h b/src/goto-programs/remove_const_function_pointers.h index ae212e863f1..74b34a28e9d 100644 --- a/src/goto-programs/remove_const_function_pointers.h +++ b/src/goto-programs/remove_const_function_pointers.h @@ -35,6 +35,9 @@ class remove_const_function_pointerst:public messaget // recursive functions for dealing with the function pointer bool try_resolve_function_call(const exprt &expr, functionst &out_functions); + bool try_resolve_function_calls( + const expressionst &exprs, functionst &out_functions); + bool try_resolve_index_of_function_call( const index_exprt &index_expr, functionst &out_functions); From e57677ee603bbd877dcb5aff23c38332c8d4f293 Mon Sep 17 00:00:00 2001 From: thk123 Date: Mon, 13 Feb 2017 10:20:17 +0000 Subject: [PATCH 038/116] Adding the pointer check flag To handle the cases where the function pointer is null, we enable the pointer--check flag. This asserts that one of the branches is taken (e.g. a valid function pointer). This wasn't supported by goto-analyze so added the option to it. --- .../goto-analyzer/approx-array-variable-const-fp/test.desc | 2 +- .../approx-const-fp-array-variable-cast-const-fp/test.desc | 2 +- .../test.desc | 2 +- .../approx-const-fp-array-variable-const-fp/test.desc | 2 +- .../test.desc | 2 +- .../test.desc | 2 +- .../test.desc | 2 +- .../test.desc | 2 +- .../test.desc | 2 +- .../no-match-const-fp-array-literal-non-const-fp/test.desc | 2 +- .../no-match-const-fp-array-non-const-fp/test.desc | 2 +- .../test.desc | 2 +- .../test.desc | 2 +- .../no-match-const-fp-dynamic-array-non-const-fp/test.desc | 2 +- .../no-match-const-fp-non-const-fp-direct-assignment/test.desc | 2 +- .../test.desc | 2 +- .../no-match-const-fp-non-const-struct-const-fp/test.desc | 2 +- .../no-match-const-fp-non-const-struct-non-const-fp/test.desc | 2 +- .../no-match-const-pointer-non-const-struct-const-fp/test.desc | 2 +- .../test.desc | 2 +- .../test.desc | 2 +- .../test.desc | 2 +- .../no-match-non-const-fp-const-fp-direct-assignment/test.desc | 2 +- regression/goto-analyzer/no-match-non-const-fp/test.desc | 2 +- regression/goto-analyzer/no-match-parameter-const-fp/test.desc | 2 +- regression/goto-analyzer/no-match-parameter-fp/test.desc | 2 +- .../test.desc | 2 +- .../goto-analyzer/precise-array-calculation-const-fp/test.desc | 2 +- .../goto-analyzer/precise-array-literal-const-fp/test.desc | 2 +- .../precise-const-fp-array-const-variable-const-fp/test.desc | 2 +- .../precise-const-fp-array-literal-const-fp/test.desc | 2 +- .../test.desc | 2 +- .../test.desc | 2 +- regression/goto-analyzer/precise-const-fp-const-fp/test.desc | 2 +- .../test.desc | 2 +- .../test.desc | 2 +- .../precise-const-fp-const-struct-non-const-fp/test.desc | 2 +- .../test.desc | 2 +- regression/goto-analyzer/precise-const-fp/test.desc | 2 +- .../goto-analyzer/precise-const-struct-non-const-fp/test.desc | 2 +- .../precise-derefence-const-pointer-const-fp/test.desc | 2 +- regression/goto-analyzer/precise-derefence/test.desc | 2 +- .../precise-dereference-address-pointer-const-fp/test.desc | 2 +- .../test.desc | 2 +- .../test.desc | 2 +- .../test.desc | 2 +- src/goto-analyzer/goto_analyzer_parse_options.cpp | 3 +++ src/goto-analyzer/goto_analyzer_parse_options.h | 3 +++ 48 files changed, 52 insertions(+), 46 deletions(-) diff --git a/regression/goto-analyzer/approx-array-variable-const-fp/test.desc b/regression/goto-analyzer/approx-array-variable-const-fp/test.desc index 13cac884101..e8d2128a0d0 100644 --- a/regression/goto-analyzer/approx-array-variable-const-fp/test.desc +++ b/regression/goto-analyzer/approx-array-variable-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*IF fp_tbl\[(signed long int)i\] == f2 THEN GOTO 1$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/test.desc index 05b7ce7e581..20eb8d6a109 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/test.desc +++ b/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*IF fp == f2 THEN GOTO 1$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/test.desc index 05b7ce7e581..20eb8d6a109 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/test.desc +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*IF fp == f2 THEN GOTO 1$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/test.desc index 05b7ce7e581..20eb8d6a109 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/test.desc +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*IF fp == f2 THEN GOTO 1$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc index 05b7ce7e581..20eb8d6a109 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*IF fp == f2 THEN GOTO 1$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/test.desc index 05b7ce7e581..20eb8d6a109 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/test.desc +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*IF fp == f2 THEN GOTO 1$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/test.desc index 00cd5d6eafd..082acf9a6f2 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/test.desc +++ b/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*IF fp == (void (\*)(void))f2 THEN GOTO 1$ diff --git a/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/test.desc b/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/test.desc index deda28d213f..a90040a0f82 100644 --- a/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*IF fp == f1 THEN GOTO 1$ diff --git a/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/test.desc b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/test.desc index deda28d213f..a90040a0f82 100644 --- a/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*IF fp == f1 THEN GOTO 1$ diff --git a/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/test.desc index 1942b6b867b..328eefd5fd0 100644 --- a/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*IF fp2 == f1 THEN GOTO 1$ diff --git a/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/test.desc index 1942b6b867b..328eefd5fd0 100644 --- a/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*IF fp2 == f1 THEN GOTO 1$ diff --git a/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/test.desc index deda28d213f..a90040a0f82 100644 --- a/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*IF fp == f1 THEN GOTO 1$ diff --git a/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/test.desc index ff7c3cc2b07..a726957f5ee 100644 --- a/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*IF final_fp == f1 THEN GOTO 1$ diff --git a/regression/goto-analyzer/no-match-const-fp-dynamic-array-non-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-dynamic-array-non-const-fp/test.desc index deda28d213f..a90040a0f82 100644 --- a/regression/goto-analyzer/no-match-const-fp-dynamic-array-non-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-dynamic-array-non-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*IF fp == f1 THEN GOTO 1$ diff --git a/regression/goto-analyzer/no-match-const-fp-non-const-fp-direct-assignment/test.desc b/regression/goto-analyzer/no-match-const-fp-non-const-fp-direct-assignment/test.desc index 722b6878ab5..06f3395c5fa 100644 --- a/regression/goto-analyzer/no-match-const-fp-non-const-fp-direct-assignment/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-non-const-fp-direct-assignment/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*IF fp2 == f1 THEN GOTO 1$ ^\s*IF fp2 == f2 THEN GOTO 2$ diff --git a/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/test.desc index deda28d213f..a90040a0f82 100644 --- a/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*IF fp == f1 THEN GOTO 1$ diff --git a/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/test.desc index deda28d213f..a90040a0f82 100644 --- a/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*IF fp == f1 THEN GOTO 1$ diff --git a/regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/test.desc index deda28d213f..a90040a0f82 100644 --- a/regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*IF fp == f1 THEN GOTO 1$ diff --git a/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/test.desc b/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/test.desc index f199330660a..b038fb608e3 100644 --- a/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*IF pts->go == f1 THEN GOTO 1$ diff --git a/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/test.desc b/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/test.desc index 94f1774abb7..2fa1d08dd26 100644 --- a/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f1 THEN GOTO 1$ diff --git a/regression/goto-analyzer/no-match-dereference-non-const-struct-const-pointer-const-fp/test.desc b/regression/goto-analyzer/no-match-dereference-non-const-struct-const-pointer-const-fp/test.desc index 0899addb26a..1eb1dc36059 100644 --- a/regression/goto-analyzer/no-match-dereference-non-const-struct-const-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-dereference-non-const-struct-const-pointer-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*IF \*container_container\.container == f1 THEN GOTO 1$ diff --git a/regression/goto-analyzer/no-match-dereference-non-const-struct-non-const-pointer-const-fp/test.desc b/regression/goto-analyzer/no-match-dereference-non-const-struct-non-const-pointer-const-fp/test.desc index 0899addb26a..1eb1dc36059 100644 --- a/regression/goto-analyzer/no-match-dereference-non-const-struct-non-const-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-dereference-non-const-struct-non-const-pointer-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*IF \*container_container\.container == f1 THEN GOTO 1$ diff --git a/regression/goto-analyzer/no-match-non-const-fp-const-fp-direct-assignment/test.desc b/regression/goto-analyzer/no-match-non-const-fp-const-fp-direct-assignment/test.desc index 722b6878ab5..06f3395c5fa 100644 --- a/regression/goto-analyzer/no-match-non-const-fp-const-fp-direct-assignment/test.desc +++ b/regression/goto-analyzer/no-match-non-const-fp-const-fp-direct-assignment/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*IF fp2 == f1 THEN GOTO 1$ ^\s*IF fp2 == f2 THEN GOTO 2$ diff --git a/regression/goto-analyzer/no-match-non-const-fp/test.desc b/regression/goto-analyzer/no-match-non-const-fp/test.desc index deda28d213f..a90040a0f82 100644 --- a/regression/goto-analyzer/no-match-non-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-non-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*IF fp == f1 THEN GOTO 1$ diff --git a/regression/goto-analyzer/no-match-parameter-const-fp/test.desc b/regression/goto-analyzer/no-match-parameter-const-fp/test.desc index deda28d213f..a90040a0f82 100644 --- a/regression/goto-analyzer/no-match-parameter-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-parameter-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*IF fp == f1 THEN GOTO 1$ diff --git a/regression/goto-analyzer/no-match-parameter-fp/test.desc b/regression/goto-analyzer/no-match-parameter-fp/test.desc index deda28d213f..a90040a0f82 100644 --- a/regression/goto-analyzer/no-match-parameter-fp/test.desc +++ b/regression/goto-analyzer/no-match-parameter-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*IF fp == f1 THEN GOTO 1$ diff --git a/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/test.desc b/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/test.desc index b53053f12a4..9ae7c264af7 100644 --- a/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f1 THEN GOTO 1$ diff --git a/regression/goto-analyzer/precise-array-calculation-const-fp/test.desc b/regression/goto-analyzer/precise-array-calculation-const-fp/test.desc index 3fb0a47980c..9716d23800e 100644 --- a/regression/goto-analyzer/precise-array-calculation-const-fp/test.desc +++ b/regression/goto-analyzer/precise-array-calculation-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*f3();$ ^SIGNAL=0$ diff --git a/regression/goto-analyzer/precise-array-literal-const-fp/test.desc b/regression/goto-analyzer/precise-array-literal-const-fp/test.desc index 3fb0a47980c..9716d23800e 100644 --- a/regression/goto-analyzer/precise-array-literal-const-fp/test.desc +++ b/regression/goto-analyzer/precise-array-literal-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*f3();$ ^SIGNAL=0$ diff --git a/regression/goto-analyzer/precise-const-fp-array-const-variable-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp-array-const-variable-const-fp/test.desc index 3fb0a47980c..9716d23800e 100644 --- a/regression/goto-analyzer/precise-const-fp-array-const-variable-const-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-array-const-variable-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*f3();$ ^SIGNAL=0$ diff --git a/regression/goto-analyzer/precise-const-fp-array-literal-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp-array-literal-const-fp/test.desc index 3fb0a47980c..9716d23800e 100644 --- a/regression/goto-analyzer/precise-const-fp-array-literal-const-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-array-literal-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*f3();$ ^SIGNAL=0$ diff --git a/regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/test.desc index 77c3b9a93d1..313435441b0 100644 --- a/regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*f3();$ diff --git a/regression/goto-analyzer/precise-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc index c78b9efabd8..5d0951328b4 100644 --- a/regression/goto-analyzer/precise-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*f2(); diff --git a/regression/goto-analyzer/precise-const-fp-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp-const-fp/test.desc index 653466e87fb..9852b6f4f36 100644 --- a/regression/goto-analyzer/precise-const-fp-const-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*f2();$ ^SIGNAL=0$ diff --git a/regression/goto-analyzer/precise-const-fp-const-struct-const-array-literal-fp/test.desc b/regression/goto-analyzer/precise-const-fp-const-struct-const-array-literal-fp/test.desc index 77c3b9a93d1..313435441b0 100644 --- a/regression/goto-analyzer/precise-const-fp-const-struct-const-array-literal-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-const-struct-const-array-literal-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*f3();$ diff --git a/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/test.desc b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/test.desc index 77c3b9a93d1..313435441b0 100644 --- a/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*f3();$ diff --git a/regression/goto-analyzer/precise-const-fp-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-fp/test.desc index c78b9efabd8..5d0951328b4 100644 --- a/regression/goto-analyzer/precise-const-fp-const-struct-non-const-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*f2(); diff --git a/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/test.desc index 77c3b9a93d1..313435441b0 100644 --- a/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*f3();$ diff --git a/regression/goto-analyzer/precise-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp/test.desc index eb4d61d9d9c..8de39dddaab 100644 --- a/regression/goto-analyzer/precise-const-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*f2(); diff --git a/regression/goto-analyzer/precise-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/precise-const-struct-non-const-fp/test.desc index c78b9efabd8..5d0951328b4 100644 --- a/regression/goto-analyzer/precise-const-struct-non-const-fp/test.desc +++ b/regression/goto-analyzer/precise-const-struct-non-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*f2(); diff --git a/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/test.desc b/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/test.desc index 77c3b9a93d1..313435441b0 100644 --- a/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*f3();$ diff --git a/regression/goto-analyzer/precise-derefence/test.desc b/regression/goto-analyzer/precise-derefence/test.desc index eb4d61d9d9c..8de39dddaab 100644 --- a/regression/goto-analyzer/precise-derefence/test.desc +++ b/regression/goto-analyzer/precise-derefence/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*f2(); diff --git a/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/test.desc b/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/test.desc index 77c3b9a93d1..313435441b0 100644 --- a/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*f3();$ diff --git a/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-fp/test.desc b/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-fp/test.desc index 77c3b9a93d1..313435441b0 100644 --- a/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*f3();$ diff --git a/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-struct-const-fp/test.desc b/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-struct-const-fp/test.desc index 77c3b9a93d1..313435441b0 100644 --- a/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-struct-const-fp/test.desc +++ b/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-struct-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*f3();$ diff --git a/regression/goto-analyzer/precise-dereference-const-struct-pointer-const-fp/test.desc b/regression/goto-analyzer/precise-dereference-const-struct-pointer-const-fp/test.desc index 77c3b9a93d1..313435441b0 100644 --- a/regression/goto-analyzer/precise-dereference-const-struct-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/precise-dereference-const-struct-pointer-const-fp/test.desc @@ -1,6 +1,6 @@ CORE main.c ---show-goto-functions --verbosity 10 +--show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ ^\s*f3();$ diff --git a/src/goto-analyzer/goto_analyzer_parse_options.cpp b/src/goto-analyzer/goto_analyzer_parse_options.cpp index 10fb9d8d6d9..9a74e27f167 100644 --- a/src/goto-analyzer/goto_analyzer_parse_options.cpp +++ b/src/goto-analyzer/goto_analyzer_parse_options.cpp @@ -541,6 +541,9 @@ void goto_analyzer_parse_optionst::help() // NOLINTNEXTLINE(whitespace/line_length) " --show-properties show the properties, but don't run analysis\n" "\n" + "Program instrumentation options:\n" + HELP_GOTO_CHECK + "\n" "Other options:\n" " --version show version and exit\n" "\n"; diff --git a/src/goto-analyzer/goto_analyzer_parse_options.h b/src/goto-analyzer/goto_analyzer_parse_options.h index 7b319c8b99b..caf95254288 100644 --- a/src/goto-analyzer/goto_analyzer_parse_options.h +++ b/src/goto-analyzer/goto_analyzer_parse_options.h @@ -17,6 +17,8 @@ Author: Daniel Kroening, kroening@kroening.com #include #include +#include + class bmct; class goto_functionst; class optionst; @@ -28,6 +30,7 @@ class optionst; "(16)(32)(64)(LP64)(ILP64)(LLP64)(ILP32)(LP32)" \ "(little-endian)(big-endian)" \ OPT_SHOW_GOTO_FUNCTIONS \ + OPT_GOTO_CHECK \ "(show-loops)" \ "(show-symbol-table)(show-parse-tree)" \ "(show-properties)(show-reachable-properties)(property):" \ From 0de6b17606a6c7092cdde65a2d3ccd5589374693 Mon Sep 17 00:00:00 2001 From: thk123 Date: Mon, 13 Feb 2017 11:59:47 +0000 Subject: [PATCH 039/116] Adding checks for NULL function pointers --- .../main.c | 31 +++++++++++++ .../test.desc | 8 ++++ .../no-match-const-fp-const-fp-null/main.c | 31 +++++++++++++ .../no-match-const-fp-const-fp-null/test.desc | 8 ++++ .../main.c | 44 +++++++++++++++++++ .../test.desc | 9 ++++ .../main.c | 36 +++++++++++++++ .../test.desc | 9 ++++ .../no-match-const-fp-null/main.c | 30 +++++++++++++ .../no-match-const-fp-null/test.desc | 8 ++++ .../main.c | 40 +++++++++++++++++ .../test.desc | 9 ++++ 12 files changed, 263 insertions(+) create mode 100644 regression/goto-analyzer/no-match-array-literal-const-fp-null/main.c create mode 100644 regression/goto-analyzer/no-match-array-literal-const-fp-null/test.desc create mode 100644 regression/goto-analyzer/no-match-const-fp-const-fp-null/main.c create mode 100644 regression/goto-analyzer/no-match-const-fp-const-fp-null/test.desc create mode 100644 regression/goto-analyzer/no-match-const-fp-const-pointer-const-struct-const-fp-null/main.c create mode 100644 regression/goto-analyzer/no-match-const-fp-const-pointer-const-struct-const-fp-null/test.desc create mode 100644 regression/goto-analyzer/no-match-const-fp-dereference-const-pointer-null/main.c create mode 100644 regression/goto-analyzer/no-match-const-fp-dereference-const-pointer-null/test.desc create mode 100644 regression/goto-analyzer/no-match-const-fp-null/main.c create mode 100644 regression/goto-analyzer/no-match-const-fp-null/test.desc create mode 100644 regression/goto-analyzer/no-match-const-struct-non-const-fp-null/main.c create mode 100644 regression/goto-analyzer/no-match-const-struct-non-const-fp-null/test.desc diff --git a/regression/goto-analyzer/no-match-array-literal-const-fp-null/main.c b/regression/goto-analyzer/no-match-array-literal-const-fp-null/main.c new file mode 100644 index 00000000000..fba4069b7a2 --- /dev/null +++ b/regression/goto-analyzer/no-match-array-literal-const-fp-null/main.c @@ -0,0 +1,31 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +const void_fp fp_tbl[] = {f2, NULL ,f4}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + fp_tbl[1](); +} + +int main() +{ + func(); + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/no-match-array-literal-const-fp-null/test.desc b/regression/goto-analyzer/no-match-array-literal-const-fp-null/test.desc new file mode 100644 index 00000000000..4786993cade --- /dev/null +++ b/regression/goto-analyzer/no-match-array-literal-const-fp-null/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*ASSERT FALSE // invalid function pointer$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-const-fp-null/main.c b/regression/goto-analyzer/no-match-const-fp-const-fp-null/main.c new file mode 100644 index 00000000000..4b8ba72dd51 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-const-fp-null/main.c @@ -0,0 +1,31 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp = NULL; + const void_fp fp2 = fp; + fp2(); +} + +int main() +{ + func(); + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/no-match-const-fp-const-fp-null/test.desc b/regression/goto-analyzer/no-match-const-fp-const-fp-null/test.desc new file mode 100644 index 00000000000..4786993cade --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-const-fp-null/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*ASSERT FALSE // invalid function pointer$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-const-pointer-const-struct-const-fp-null/main.c b/regression/goto-analyzer/no-match-const-fp-const-pointer-const-struct-const-fp-null/main.c new file mode 100644 index 00000000000..76671ef3829 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-const-pointer-const-struct-const-fp-null/main.c @@ -0,0 +1,44 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + + +typedef struct fp_container +{ + int x; + const void_fp pointer; +} fp_container; + + + +void func() +{ + const fp_container container = {.x = 10, .pointer = f3}; + const fp_container container2 = {.x = 10, .pointer = f4}; + const fp_container * const container_ptr = NULL; + + // Illegal: + //container_ptr = &container2; + //container_ptr->pointer = f4; + + container_ptr->pointer(); +} + +int main() +{ + func(); +} diff --git a/regression/goto-analyzer/no-match-const-fp-const-pointer-const-struct-const-fp-null/test.desc b/regression/goto-analyzer/no-match-const-fp-const-pointer-const-struct-const-fp-null/test.desc new file mode 100644 index 00000000000..25b505c0a0f --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-const-pointer-const-struct-const-fp-null/test.desc @@ -0,0 +1,9 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check + +^Removing function pointers and virtual functions$ +^\s*ASSERT FALSE // invalid function pointer$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-dereference-const-pointer-null/main.c b/regression/goto-analyzer/no-match-const-fp-dereference-const-pointer-null/main.c new file mode 100644 index 00000000000..b384b87bb4e --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-dereference-const-pointer-null/main.c @@ -0,0 +1,36 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp = f3; + const void_fp fp2 = f4; + const void_fp* const p2fp = NULL; + // Illegal: + //p2fp = &fp2; + //fp = f5; + const void_fp final_fp=*p2fp; + final_fp(); +} + +int main() +{ + func(); + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/no-match-const-fp-dereference-const-pointer-null/test.desc b/regression/goto-analyzer/no-match-const-fp-dereference-const-pointer-null/test.desc new file mode 100644 index 00000000000..25b505c0a0f --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-dereference-const-pointer-null/test.desc @@ -0,0 +1,9 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check + +^Removing function pointers and virtual functions$ +^\s*ASSERT FALSE // invalid function pointer$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-null/main.c b/regression/goto-analyzer/no-match-const-fp-null/main.c new file mode 100644 index 00000000000..98a0349ce37 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-null/main.c @@ -0,0 +1,30 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp = NULL; + fp(); +} + +int main() +{ + func(); + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/no-match-const-fp-null/test.desc b/regression/goto-analyzer/no-match-const-fp-null/test.desc new file mode 100644 index 00000000000..267ec2284f7 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-null/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check + +^Removing function pointers and virtual functions$ +^\s*ASSERT FALSE // invalid function pointer$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-struct-non-const-fp-null/main.c b/regression/goto-analyzer/no-match-const-struct-non-const-fp-null/main.c new file mode 100644 index 00000000000..569870b6609 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-struct-non-const-fp-null/main.c @@ -0,0 +1,40 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +struct action +{ + int x; + const void_fp fun; +}; + +const struct action rec = { .x = 4, .fun = NULL }; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i) +{ + rec.fun(); +} + +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/no-match-const-struct-non-const-fp-null/test.desc b/regression/goto-analyzer/no-match-const-struct-non-const-fp-null/test.desc new file mode 100644 index 00000000000..25b505c0a0f --- /dev/null +++ b/regression/goto-analyzer/no-match-const-struct-non-const-fp-null/test.desc @@ -0,0 +1,9 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check + +^Removing function pointers and virtual functions$ +^\s*ASSERT FALSE // invalid function pointer$ +^SIGNAL=0$ +-- +^warning: ignoring From 10a08efe8c76631d8ec5a23676bf3f84fdc81197 Mon Sep 17 00:00:00 2001 From: thk123 Date: Mon, 13 Feb 2017 12:25:43 +0000 Subject: [PATCH 040/116] Renaming functions to more consistent name --- src/goto-programs/remove_const_function_pointers.cpp | 12 ++++++------ src/goto-programs/remove_const_function_pointers.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/goto-programs/remove_const_function_pointers.cpp b/src/goto-programs/remove_const_function_pointers.cpp index f61aa2c86e5..d43ac85d62a 100644 --- a/src/goto-programs/remove_const_function_pointers.cpp +++ b/src/goto-programs/remove_const_function_pointers.cpp @@ -96,7 +96,7 @@ exprt remove_const_function_pointerst::replace_const_symbols( { if(expression.id()==ID_symbol) { - if(is_expression_const(expression)) + if(is_const_expression(expression)) { const symbolt &symbol= symbol_table.lookup(expression.get(ID_identifier)); @@ -540,7 +540,7 @@ bool remove_const_function_pointerst::try_resolve_expression( else { resolved_expressions.push_back(simplified_expr); - is_resolved_expression_const=is_expression_const(simplified_expr); + is_resolved_expression_const=is_const_expression(simplified_expr); resolved=true; } @@ -653,7 +653,7 @@ bool remove_const_function_pointerst::try_resolve_index_of( { all_possible_const= all_possible_const && - is_type_const(potential_array_expr.type().subtype()); + is_const_type(potential_array_expr.type().subtype()); if(potential_array_expr.id()==ID_array) { @@ -953,10 +953,10 @@ Function: remove_const_function_pointerst::is_expression_const \*******************************************************************/ -bool remove_const_function_pointerst::is_expression_const( +bool remove_const_function_pointerst::is_const_expression( const exprt &expression) const { - return is_type_const(expression.type()); + return is_const_type(expression.type()); } /*******************************************************************\ @@ -973,7 +973,7 @@ Function: remove_const_function_pointerst::is_type_const \*******************************************************************/ -bool remove_const_function_pointerst::is_type_const(const typet &type) const +bool remove_const_function_pointerst::is_const_type(const typet &type) const { c_qualifierst qualifers(type); if(type.id()==ID_array) diff --git a/src/goto-programs/remove_const_function_pointers.h b/src/goto-programs/remove_const_function_pointers.h index 74b34a28e9d..8b0b0c23a56 100644 --- a/src/goto-programs/remove_const_function_pointers.h +++ b/src/goto-programs/remove_const_function_pointers.h @@ -79,8 +79,8 @@ class remove_const_function_pointerst:public messaget expressionst &out_expressions, bool &out_is_const); - bool is_expression_const(const exprt &expression) const; - bool is_type_const(const typet &type) const; + bool is_const_expression(const exprt &expression) const; + bool is_const_type(const typet &type) const; bool try_resolve_index_value( const exprt &index_value_expr, mp_integer &out_array_index); From cf6a49a6b55a2c6ce9fa4e3afcfebdef8d10295a Mon Sep 17 00:00:00 2001 From: thk123 Date: Mon, 13 Feb 2017 13:38:31 +0000 Subject: [PATCH 041/116] Swap to using an unorded set Modified the tests to not assume the order of the functions. For precise tests no further changes are required since if the removal failed, there will be a label before the call to be jumped to. For the no-match tests, no further changes are required since the goto statements are being verified to be all the there. For the approx tests, we need to verify that the other case statements aren't present in the GOTO program to be sure that the FP removal has been successful. As such, the other case statements are added to the exclude section. --- .../approx-array-variable-const-fp/test.desc | 12 +++++++++--- .../test.desc | 12 +++++++++--- .../test.desc | 12 +++++++++--- .../test.desc | 12 +++++++++--- .../test.desc | 12 +++++++++--- .../test.desc | 12 +++++++++--- .../test.desc | 12 +++++++++--- .../test.desc | 18 +++++++++--------- .../test.desc | 18 +++++++++--------- .../test.desc | 18 +++++++++--------- .../test.desc | 18 +++++++++--------- .../test.desc | 18 +++++++++--------- .../test.desc | 18 +++++++++--------- .../test.desc | 18 +++++++++--------- .../test.desc | 18 +++++++++--------- .../test.desc | 18 +++++++++--------- .../test.desc | 18 +++++++++--------- .../test.desc | 18 +++++++++--------- .../test.desc | 18 +++++++++--------- .../test.desc | 18 +++++++++--------- .../test.desc | 18 +++++++++--------- .../test.desc | 18 +++++++++--------- .../test.desc | 18 +++++++++--------- .../no-match-non-const-fp/test.desc | 18 +++++++++--------- .../no-match-parameter-const-fp/test.desc | 18 +++++++++--------- .../no-match-parameter-fp/test.desc | 18 +++++++++--------- .../test.desc | 18 +++++++++--------- .../remove_const_function_pointers.h | 4 +++- 28 files changed, 246 insertions(+), 202 deletions(-) diff --git a/regression/goto-analyzer/approx-array-variable-const-fp/test.desc b/regression/goto-analyzer/approx-array-variable-const-fp/test.desc index e8d2128a0d0..28b95c5ac33 100644 --- a/regression/goto-analyzer/approx-array-variable-const-fp/test.desc +++ b/regression/goto-analyzer/approx-array-variable-const-fp/test.desc @@ -3,9 +3,15 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF fp_tbl\[(signed long int)i\] == f2 THEN GOTO 1$ -^\s*IF fp_tbl\[(signed long int)i\] == f3 THEN GOTO 2$ -^\s*IF fp_tbl\[(signed long int)i\] == f4 THEN GOTO 3$ +^\s*IF fp_tbl\[(signed long int)i\] == f2 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f3 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f4 THEN GOTO [0-9]$ ^SIGNAL=0$ -- +^\s*IF fp_tbl\[(signed long int)i\] == f1 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f5 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f6 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f7 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f8 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f9 THEN GOTO [0-9]$ ^warning: ignoring diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/test.desc index 20eb8d6a109..973fbe34127 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/test.desc +++ b/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/test.desc @@ -3,9 +3,15 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF fp == f2 THEN GOTO 1$ -^\s*IF fp == f3 THEN GOTO 2$ -^\s*IF fp == f4 THEN GOTO 3$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring +^\s*IF fp_tbl\[(signed long int)i\] == f1 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f5 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f6 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f7 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f8 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f9 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/test.desc index 20eb8d6a109..973fbe34127 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/test.desc +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/test.desc @@ -3,9 +3,15 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF fp == f2 THEN GOTO 1$ -^\s*IF fp == f3 THEN GOTO 2$ -^\s*IF fp == f4 THEN GOTO 3$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring +^\s*IF fp_tbl\[(signed long int)i\] == f1 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f5 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f6 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f7 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f8 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f9 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/test.desc index 20eb8d6a109..973fbe34127 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/test.desc +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/test.desc @@ -3,9 +3,15 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF fp == f2 THEN GOTO 1$ -^\s*IF fp == f3 THEN GOTO 2$ -^\s*IF fp == f4 THEN GOTO 3$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring +^\s*IF fp_tbl\[(signed long int)i\] == f1 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f5 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f6 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f7 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f8 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f9 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc index 20eb8d6a109..973fbe34127 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc @@ -3,9 +3,15 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF fp == f2 THEN GOTO 1$ -^\s*IF fp == f3 THEN GOTO 2$ -^\s*IF fp == f4 THEN GOTO 3$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring +^\s*IF fp_tbl\[(signed long int)i\] == f1 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f5 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f6 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f7 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f8 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f9 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/test.desc index 20eb8d6a109..973fbe34127 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/test.desc +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/test.desc @@ -3,9 +3,15 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF fp == f2 THEN GOTO 1$ -^\s*IF fp == f3 THEN GOTO 2$ -^\s*IF fp == f4 THEN GOTO 3$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring +^\s*IF fp_tbl\[(signed long int)i\] == f1 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f5 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f6 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f7 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f8 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f9 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/test.desc index 082acf9a6f2..5459b630bc9 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/test.desc +++ b/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/test.desc @@ -3,9 +3,15 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF fp == (void (\*)(void))f2 THEN GOTO 1$ -^\s*IF fp == (void (\*)(void))f3 THEN GOTO 2$ -^\s*IF fp == (void (\*)(void))f4 THEN GOTO 3$ +^\s*IF fp == (void (\*)(void))f2 THEN GOTO [0-9]$ +^\s*IF fp == (void (\*)(void))f3 THEN GOTO [0-9]$ +^\s*IF fp == (void (\*)(void))f4 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring +^\s*IF fp_tbl\[(signed long int)i\] == f1 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f5 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f6 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f7 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f8 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f9 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/test.desc b/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/test.desc index a90040a0f82..997ec886207 100644 --- a/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/test.desc @@ -3,15 +3,15 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF fp == f1 THEN GOTO 1$ -^\s*IF fp == f2 THEN GOTO 2$ -^\s*IF fp == f3 THEN GOTO 3$ -^\s*IF fp == f4 THEN GOTO 4$ -^\s*IF fp == f5 THEN GOTO 5$ -^\s*IF fp == f6 THEN GOTO 6$ -^\s*IF fp == f7 THEN GOTO 7$ -^\s*IF fp == f8 THEN GOTO 8$ -^\s*IF fp == f9 THEN GOTO 9$ +^\s*IF fp == f1 THEN GOTO [0-9]$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^\s*IF fp == f5 THEN GOTO [0-9]$ +^\s*IF fp == f6 THEN GOTO [0-9]$ +^\s*IF fp == f7 THEN GOTO [0-9]$ +^\s*IF fp == f8 THEN GOTO [0-9]$ +^\s*IF fp == f9 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/test.desc b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/test.desc index a90040a0f82..997ec886207 100644 --- a/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/test.desc @@ -3,15 +3,15 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF fp == f1 THEN GOTO 1$ -^\s*IF fp == f2 THEN GOTO 2$ -^\s*IF fp == f3 THEN GOTO 3$ -^\s*IF fp == f4 THEN GOTO 4$ -^\s*IF fp == f5 THEN GOTO 5$ -^\s*IF fp == f6 THEN GOTO 6$ -^\s*IF fp == f7 THEN GOTO 7$ -^\s*IF fp == f8 THEN GOTO 8$ -^\s*IF fp == f9 THEN GOTO 9$ +^\s*IF fp == f1 THEN GOTO [0-9]$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^\s*IF fp == f5 THEN GOTO [0-9]$ +^\s*IF fp == f6 THEN GOTO [0-9]$ +^\s*IF fp == f7 THEN GOTO [0-9]$ +^\s*IF fp == f8 THEN GOTO [0-9]$ +^\s*IF fp == f9 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/test.desc index 328eefd5fd0..9c0926c2e7a 100644 --- a/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/test.desc @@ -3,15 +3,15 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF fp2 == f1 THEN GOTO 1$ -^\s*IF fp2 == f2 THEN GOTO 2$ -^\s*IF fp2 == f3 THEN GOTO 3$ -^\s*IF fp2 == f4 THEN GOTO 4$ -^\s*IF fp2 == f5 THEN GOTO 5$ -^\s*IF fp2 == f6 THEN GOTO 6$ -^\s*IF fp2 == f7 THEN GOTO 7$ -^\s*IF fp2 == f8 THEN GOTO 8$ -^\s*IF fp2 == f9 THEN GOTO 9$ +^\s*IF fp2 == f1 THEN GOTO [0-9]$ +^\s*IF fp2 == f2 THEN GOTO [0-9]$ +^\s*IF fp2 == f3 THEN GOTO [0-9]$ +^\s*IF fp2 == f4 THEN GOTO [0-9]$ +^\s*IF fp2 == f5 THEN GOTO [0-9]$ +^\s*IF fp2 == f6 THEN GOTO [0-9]$ +^\s*IF fp2 == f7 THEN GOTO [0-9]$ +^\s*IF fp2 == f8 THEN GOTO [0-9]$ +^\s*IF fp2 == f9 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/test.desc index 328eefd5fd0..9c0926c2e7a 100644 --- a/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/test.desc @@ -3,15 +3,15 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF fp2 == f1 THEN GOTO 1$ -^\s*IF fp2 == f2 THEN GOTO 2$ -^\s*IF fp2 == f3 THEN GOTO 3$ -^\s*IF fp2 == f4 THEN GOTO 4$ -^\s*IF fp2 == f5 THEN GOTO 5$ -^\s*IF fp2 == f6 THEN GOTO 6$ -^\s*IF fp2 == f7 THEN GOTO 7$ -^\s*IF fp2 == f8 THEN GOTO 8$ -^\s*IF fp2 == f9 THEN GOTO 9$ +^\s*IF fp2 == f1 THEN GOTO [0-9]$ +^\s*IF fp2 == f2 THEN GOTO [0-9]$ +^\s*IF fp2 == f3 THEN GOTO [0-9]$ +^\s*IF fp2 == f4 THEN GOTO [0-9]$ +^\s*IF fp2 == f5 THEN GOTO [0-9]$ +^\s*IF fp2 == f6 THEN GOTO [0-9]$ +^\s*IF fp2 == f7 THEN GOTO [0-9]$ +^\s*IF fp2 == f8 THEN GOTO [0-9]$ +^\s*IF fp2 == f9 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/test.desc index a90040a0f82..997ec886207 100644 --- a/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/test.desc @@ -3,15 +3,15 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF fp == f1 THEN GOTO 1$ -^\s*IF fp == f2 THEN GOTO 2$ -^\s*IF fp == f3 THEN GOTO 3$ -^\s*IF fp == f4 THEN GOTO 4$ -^\s*IF fp == f5 THEN GOTO 5$ -^\s*IF fp == f6 THEN GOTO 6$ -^\s*IF fp == f7 THEN GOTO 7$ -^\s*IF fp == f8 THEN GOTO 8$ -^\s*IF fp == f9 THEN GOTO 9$ +^\s*IF fp == f1 THEN GOTO [0-9]$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^\s*IF fp == f5 THEN GOTO [0-9]$ +^\s*IF fp == f6 THEN GOTO [0-9]$ +^\s*IF fp == f7 THEN GOTO [0-9]$ +^\s*IF fp == f8 THEN GOTO [0-9]$ +^\s*IF fp == f9 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/test.desc index a726957f5ee..61a7ec29e6b 100644 --- a/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/test.desc @@ -3,15 +3,15 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF final_fp == f1 THEN GOTO 1$ -^\s*IF final_fp == f2 THEN GOTO 2$ -^\s*IF final_fp == f3 THEN GOTO 3$ -^\s*IF final_fp == f4 THEN GOTO 4$ -^\s*IF final_fp == f5 THEN GOTO 5$ -^\s*IF final_fp == f6 THEN GOTO 6$ -^\s*IF final_fp == f7 THEN GOTO 7$ -^\s*IF final_fp == f8 THEN GOTO 8$ -^\s*IF final_fp == f9 THEN GOTO 9$ +^\s*IF final_fp == f1 THEN GOTO [0-9]$ +^\s*IF final_fp == f2 THEN GOTO [0-9]$ +^\s*IF final_fp == f3 THEN GOTO [0-9]$ +^\s*IF final_fp == f4 THEN GOTO [0-9]$ +^\s*IF final_fp == f5 THEN GOTO [0-9]$ +^\s*IF final_fp == f6 THEN GOTO [0-9]$ +^\s*IF final_fp == f7 THEN GOTO [0-9]$ +^\s*IF final_fp == f8 THEN GOTO [0-9]$ +^\s*IF final_fp == f9 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-dynamic-array-non-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-dynamic-array-non-const-fp/test.desc index a90040a0f82..997ec886207 100644 --- a/regression/goto-analyzer/no-match-const-fp-dynamic-array-non-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-dynamic-array-non-const-fp/test.desc @@ -3,15 +3,15 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF fp == f1 THEN GOTO 1$ -^\s*IF fp == f2 THEN GOTO 2$ -^\s*IF fp == f3 THEN GOTO 3$ -^\s*IF fp == f4 THEN GOTO 4$ -^\s*IF fp == f5 THEN GOTO 5$ -^\s*IF fp == f6 THEN GOTO 6$ -^\s*IF fp == f7 THEN GOTO 7$ -^\s*IF fp == f8 THEN GOTO 8$ -^\s*IF fp == f9 THEN GOTO 9$ +^\s*IF fp == f1 THEN GOTO [0-9]$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^\s*IF fp == f5 THEN GOTO [0-9]$ +^\s*IF fp == f6 THEN GOTO [0-9]$ +^\s*IF fp == f7 THEN GOTO [0-9]$ +^\s*IF fp == f8 THEN GOTO [0-9]$ +^\s*IF fp == f9 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-non-const-fp-direct-assignment/test.desc b/regression/goto-analyzer/no-match-const-fp-non-const-fp-direct-assignment/test.desc index 06f3395c5fa..13d0c5353ce 100644 --- a/regression/goto-analyzer/no-match-const-fp-non-const-fp-direct-assignment/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-non-const-fp-direct-assignment/test.desc @@ -2,15 +2,15 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF fp2 == f1 THEN GOTO 1$ -^\s*IF fp2 == f2 THEN GOTO 2$ -^\s*IF fp2 == f3 THEN GOTO 3$ -^\s*IF fp2 == f4 THEN GOTO 4$ -^\s*IF fp2 == f5 THEN GOTO 5$ -^\s*IF fp2 == f6 THEN GOTO 6$ -^\s*IF fp2 == f7 THEN GOTO 7$ -^\s*IF fp2 == f8 THEN GOTO 8$ -^\s*IF fp2 == f9 THEN GOTO 9$ +^\s*IF fp2 == f1 THEN GOTO [0-9]$ +^\s*IF fp2 == f2 THEN GOTO [0-9]$ +^\s*IF fp2 == f3 THEN GOTO [0-9]$ +^\s*IF fp2 == f4 THEN GOTO [0-9]$ +^\s*IF fp2 == f5 THEN GOTO [0-9]$ +^\s*IF fp2 == f6 THEN GOTO [0-9]$ +^\s*IF fp2 == f7 THEN GOTO [0-9]$ +^\s*IF fp2 == f8 THEN GOTO [0-9]$ +^\s*IF fp2 == f9 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/test.desc index a90040a0f82..997ec886207 100644 --- a/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/test.desc @@ -3,15 +3,15 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF fp == f1 THEN GOTO 1$ -^\s*IF fp == f2 THEN GOTO 2$ -^\s*IF fp == f3 THEN GOTO 3$ -^\s*IF fp == f4 THEN GOTO 4$ -^\s*IF fp == f5 THEN GOTO 5$ -^\s*IF fp == f6 THEN GOTO 6$ -^\s*IF fp == f7 THEN GOTO 7$ -^\s*IF fp == f8 THEN GOTO 8$ -^\s*IF fp == f9 THEN GOTO 9$ +^\s*IF fp == f1 THEN GOTO [0-9]$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^\s*IF fp == f5 THEN GOTO [0-9]$ +^\s*IF fp == f6 THEN GOTO [0-9]$ +^\s*IF fp == f7 THEN GOTO [0-9]$ +^\s*IF fp == f8 THEN GOTO [0-9]$ +^\s*IF fp == f9 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/test.desc index a90040a0f82..997ec886207 100644 --- a/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/test.desc @@ -3,15 +3,15 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF fp == f1 THEN GOTO 1$ -^\s*IF fp == f2 THEN GOTO 2$ -^\s*IF fp == f3 THEN GOTO 3$ -^\s*IF fp == f4 THEN GOTO 4$ -^\s*IF fp == f5 THEN GOTO 5$ -^\s*IF fp == f6 THEN GOTO 6$ -^\s*IF fp == f7 THEN GOTO 7$ -^\s*IF fp == f8 THEN GOTO 8$ -^\s*IF fp == f9 THEN GOTO 9$ +^\s*IF fp == f1 THEN GOTO [0-9]$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^\s*IF fp == f5 THEN GOTO [0-9]$ +^\s*IF fp == f6 THEN GOTO [0-9]$ +^\s*IF fp == f7 THEN GOTO [0-9]$ +^\s*IF fp == f8 THEN GOTO [0-9]$ +^\s*IF fp == f9 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/test.desc index a90040a0f82..997ec886207 100644 --- a/regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/test.desc @@ -3,15 +3,15 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF fp == f1 THEN GOTO 1$ -^\s*IF fp == f2 THEN GOTO 2$ -^\s*IF fp == f3 THEN GOTO 3$ -^\s*IF fp == f4 THEN GOTO 4$ -^\s*IF fp == f5 THEN GOTO 5$ -^\s*IF fp == f6 THEN GOTO 6$ -^\s*IF fp == f7 THEN GOTO 7$ -^\s*IF fp == f8 THEN GOTO 8$ -^\s*IF fp == f9 THEN GOTO 9$ +^\s*IF fp == f1 THEN GOTO [0-9]$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^\s*IF fp == f5 THEN GOTO [0-9]$ +^\s*IF fp == f6 THEN GOTO [0-9]$ +^\s*IF fp == f7 THEN GOTO [0-9]$ +^\s*IF fp == f8 THEN GOTO [0-9]$ +^\s*IF fp == f9 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/test.desc b/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/test.desc index b038fb608e3..80169b619fa 100644 --- a/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/test.desc @@ -3,15 +3,15 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF pts->go == f1 THEN GOTO 1$ -^\s*IF pts->go == f2 THEN GOTO 2$ -^\s*IF pts->go == f3 THEN GOTO 3$ -^\s*IF pts->go == f4 THEN GOTO 4$ -^\s*IF pts->go == f5 THEN GOTO 5$ -^\s*IF pts->go == f6 THEN GOTO 6$ -^\s*IF pts->go == f7 THEN GOTO 7$ -^\s*IF pts->go == f8 THEN GOTO 8$ -^\s*IF pts->go == f9 THEN GOTO 9$ +^\s*IF pts->go == f1 THEN GOTO [0-9]$ +^\s*IF pts->go == f2 THEN GOTO [0-9]$ +^\s*IF pts->go == f3 THEN GOTO [0-9]$ +^\s*IF pts->go == f4 THEN GOTO [0-9]$ +^\s*IF pts->go == f5 THEN GOTO [0-9]$ +^\s*IF pts->go == f6 THEN GOTO [0-9]$ +^\s*IF pts->go == f7 THEN GOTO [0-9]$ +^\s*IF pts->go == f8 THEN GOTO [0-9]$ +^\s*IF pts->go == f9 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring \ No newline at end of file diff --git a/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/test.desc b/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/test.desc index 2fa1d08dd26..9abe6fde56a 100644 --- a/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/test.desc @@ -3,15 +3,15 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f1 THEN GOTO 1$ -^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f2 THEN GOTO 2$ -^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f3 THEN GOTO 3$ -^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f4 THEN GOTO 4$ -^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f5 THEN GOTO 5$ -^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f6 THEN GOTO 6$ -^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f7 THEN GOTO 7$ -^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f8 THEN GOTO 8$ -^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f9 THEN GOTO 9$ +^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f1 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f2 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f3 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f4 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f5 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f6 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f7 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f8 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f9 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/no-match-dereference-non-const-struct-const-pointer-const-fp/test.desc b/regression/goto-analyzer/no-match-dereference-non-const-struct-const-pointer-const-fp/test.desc index 1eb1dc36059..f55defde97b 100644 --- a/regression/goto-analyzer/no-match-dereference-non-const-struct-const-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-dereference-non-const-struct-const-pointer-const-fp/test.desc @@ -3,15 +3,15 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF \*container_container\.container == f1 THEN GOTO 1$ -^\s*IF \*container_container\.container == f2 THEN GOTO 2$ -^\s*IF \*container_container\.container == f3 THEN GOTO 3$ -^\s*IF \*container_container\.container == f4 THEN GOTO 4$ -^\s*IF \*container_container\.container == f5 THEN GOTO 5$ -^\s*IF \*container_container\.container == f6 THEN GOTO 6$ -^\s*IF \*container_container\.container == f7 THEN GOTO 7$ -^\s*IF \*container_container\.container == f8 THEN GOTO 8$ -^\s*IF \*container_container\.container == f9 THEN GOTO 9$ +^\s*IF \*container_container\.container == f1 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f2 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f3 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f4 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f5 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f6 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f7 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f8 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f9 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/no-match-dereference-non-const-struct-non-const-pointer-const-fp/test.desc b/regression/goto-analyzer/no-match-dereference-non-const-struct-non-const-pointer-const-fp/test.desc index 1eb1dc36059..f55defde97b 100644 --- a/regression/goto-analyzer/no-match-dereference-non-const-struct-non-const-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-dereference-non-const-struct-non-const-pointer-const-fp/test.desc @@ -3,15 +3,15 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF \*container_container\.container == f1 THEN GOTO 1$ -^\s*IF \*container_container\.container == f2 THEN GOTO 2$ -^\s*IF \*container_container\.container == f3 THEN GOTO 3$ -^\s*IF \*container_container\.container == f4 THEN GOTO 4$ -^\s*IF \*container_container\.container == f5 THEN GOTO 5$ -^\s*IF \*container_container\.container == f6 THEN GOTO 6$ -^\s*IF \*container_container\.container == f7 THEN GOTO 7$ -^\s*IF \*container_container\.container == f8 THEN GOTO 8$ -^\s*IF \*container_container\.container == f9 THEN GOTO 9$ +^\s*IF \*container_container\.container == f1 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f2 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f3 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f4 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f5 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f6 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f7 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f8 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f9 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/no-match-non-const-fp-const-fp-direct-assignment/test.desc b/regression/goto-analyzer/no-match-non-const-fp-const-fp-direct-assignment/test.desc index 06f3395c5fa..13d0c5353ce 100644 --- a/regression/goto-analyzer/no-match-non-const-fp-const-fp-direct-assignment/test.desc +++ b/regression/goto-analyzer/no-match-non-const-fp-const-fp-direct-assignment/test.desc @@ -2,15 +2,15 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF fp2 == f1 THEN GOTO 1$ -^\s*IF fp2 == f2 THEN GOTO 2$ -^\s*IF fp2 == f3 THEN GOTO 3$ -^\s*IF fp2 == f4 THEN GOTO 4$ -^\s*IF fp2 == f5 THEN GOTO 5$ -^\s*IF fp2 == f6 THEN GOTO 6$ -^\s*IF fp2 == f7 THEN GOTO 7$ -^\s*IF fp2 == f8 THEN GOTO 8$ -^\s*IF fp2 == f9 THEN GOTO 9$ +^\s*IF fp2 == f1 THEN GOTO [0-9]$ +^\s*IF fp2 == f2 THEN GOTO [0-9]$ +^\s*IF fp2 == f3 THEN GOTO [0-9]$ +^\s*IF fp2 == f4 THEN GOTO [0-9]$ +^\s*IF fp2 == f5 THEN GOTO [0-9]$ +^\s*IF fp2 == f6 THEN GOTO [0-9]$ +^\s*IF fp2 == f7 THEN GOTO [0-9]$ +^\s*IF fp2 == f8 THEN GOTO [0-9]$ +^\s*IF fp2 == f9 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/no-match-non-const-fp/test.desc b/regression/goto-analyzer/no-match-non-const-fp/test.desc index a90040a0f82..997ec886207 100644 --- a/regression/goto-analyzer/no-match-non-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-non-const-fp/test.desc @@ -3,15 +3,15 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF fp == f1 THEN GOTO 1$ -^\s*IF fp == f2 THEN GOTO 2$ -^\s*IF fp == f3 THEN GOTO 3$ -^\s*IF fp == f4 THEN GOTO 4$ -^\s*IF fp == f5 THEN GOTO 5$ -^\s*IF fp == f6 THEN GOTO 6$ -^\s*IF fp == f7 THEN GOTO 7$ -^\s*IF fp == f8 THEN GOTO 8$ -^\s*IF fp == f9 THEN GOTO 9$ +^\s*IF fp == f1 THEN GOTO [0-9]$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^\s*IF fp == f5 THEN GOTO [0-9]$ +^\s*IF fp == f6 THEN GOTO [0-9]$ +^\s*IF fp == f7 THEN GOTO [0-9]$ +^\s*IF fp == f8 THEN GOTO [0-9]$ +^\s*IF fp == f9 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/no-match-parameter-const-fp/test.desc b/regression/goto-analyzer/no-match-parameter-const-fp/test.desc index a90040a0f82..997ec886207 100644 --- a/regression/goto-analyzer/no-match-parameter-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-parameter-const-fp/test.desc @@ -3,15 +3,15 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF fp == f1 THEN GOTO 1$ -^\s*IF fp == f2 THEN GOTO 2$ -^\s*IF fp == f3 THEN GOTO 3$ -^\s*IF fp == f4 THEN GOTO 4$ -^\s*IF fp == f5 THEN GOTO 5$ -^\s*IF fp == f6 THEN GOTO 6$ -^\s*IF fp == f7 THEN GOTO 7$ -^\s*IF fp == f8 THEN GOTO 8$ -^\s*IF fp == f9 THEN GOTO 9$ +^\s*IF fp == f1 THEN GOTO [0-9]$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^\s*IF fp == f5 THEN GOTO [0-9]$ +^\s*IF fp == f6 THEN GOTO [0-9]$ +^\s*IF fp == f7 THEN GOTO [0-9]$ +^\s*IF fp == f8 THEN GOTO [0-9]$ +^\s*IF fp == f9 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/no-match-parameter-fp/test.desc b/regression/goto-analyzer/no-match-parameter-fp/test.desc index a90040a0f82..997ec886207 100644 --- a/regression/goto-analyzer/no-match-parameter-fp/test.desc +++ b/regression/goto-analyzer/no-match-parameter-fp/test.desc @@ -3,15 +3,15 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF fp == f1 THEN GOTO 1$ -^\s*IF fp == f2 THEN GOTO 2$ -^\s*IF fp == f3 THEN GOTO 3$ -^\s*IF fp == f4 THEN GOTO 4$ -^\s*IF fp == f5 THEN GOTO 5$ -^\s*IF fp == f6 THEN GOTO 6$ -^\s*IF fp == f7 THEN GOTO 7$ -^\s*IF fp == f8 THEN GOTO 8$ -^\s*IF fp == f9 THEN GOTO 9$ +^\s*IF fp == f1 THEN GOTO [0-9]$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^\s*IF fp == f5 THEN GOTO [0-9]$ +^\s*IF fp == f6 THEN GOTO [0-9]$ +^\s*IF fp == f7 THEN GOTO [0-9]$ +^\s*IF fp == f8 THEN GOTO [0-9]$ +^\s*IF fp == f9 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/test.desc b/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/test.desc index 9ae7c264af7..3f90b23b7d4 100644 --- a/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/test.desc @@ -3,15 +3,15 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f1 THEN GOTO 1$ -^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f2 THEN GOTO 2$ -^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f3 THEN GOTO 3$ -^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f4 THEN GOTO 4$ -^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f5 THEN GOTO 5$ -^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f6 THEN GOTO 6$ -^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f7 THEN GOTO 7$ -^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f8 THEN GOTO 8$ -^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f9 THEN GOTO 9$ +^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f1 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f2 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f3 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f4 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f5 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f6 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f7 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f8 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f9 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/src/goto-programs/remove_const_function_pointers.h b/src/goto-programs/remove_const_function_pointers.h index 8b0b0c23a56..1847ef56849 100644 --- a/src/goto-programs/remove_const_function_pointers.h +++ b/src/goto-programs/remove_const_function_pointers.h @@ -9,6 +9,8 @@ Author: Thomas Kiley, thomas.kiley@diffblue.com #ifndef CPROVER_GOTO_PROGRAMS_REMOVE_CONST_FUNCTION_POINTERS_H #define CPROVER_GOTO_PROGRAMS_REMOVE_CONST_FUNCTION_POINTERS_H +#include + #include "goto_model.h" #include #include @@ -18,7 +20,7 @@ Author: Thomas Kiley, thomas.kiley@diffblue.com class remove_const_function_pointerst:public messaget { public: - typedef std::set functionst; + typedef std::unordered_set functionst; typedef std::list expressionst; remove_const_function_pointerst( message_handlert &message_handler, From db11c31fc16df7e1eed7c3dd278489203d00d1be Mon Sep 17 00:00:00 2001 From: thk123 Date: Mon, 13 Feb 2017 16:20:18 +0000 Subject: [PATCH 042/116] Added flag for goto-instrument to just remove const function pointers Added a flag --remove-const-function-pointers for goto-instrument that can be used instead of --remove-function-pointers to only remove function pointers where we can resolve to something more precise that all functions with a matching signature. --- .../main.c | 34 +++++++++++ .../test.desc | 16 ++++++ .../main.c | 34 +++++++++++ .../test.desc | 16 ++++++ .../main.c | 31 ++++++++++ .../test.desc | 8 +++ .../main.c | 31 ++++++++++ .../test.desc | 16 ++++++ .../precise-const-fp-only-remove-const/main.c | 30 ++++++++++ .../test.desc | 7 +++ .../precise-const-fp-remove-all-fp/main.c | 30 ++++++++++ .../precise-const-fp-remove-all-fp/test.desc | 7 +++ .../goto_instrument_parse_options.cpp | 40 +++++++++++++ .../goto_instrument_parse_options.h | 3 + .../remove_const_function_pointers.h | 7 +++ .../remove_function_pointers.cpp | 57 +++++++++++++++---- src/goto-programs/remove_function_pointers.h | 9 ++- 17 files changed, 361 insertions(+), 15 deletions(-) create mode 100644 regression/goto-instrument/approx-array-variable-const-fp-only-remove-const/main.c create mode 100644 regression/goto-instrument/approx-array-variable-const-fp-only-remove-const/test.desc create mode 100644 regression/goto-instrument/approx-array-variable-const-fp-remove-all-fp/main.c create mode 100644 regression/goto-instrument/approx-array-variable-const-fp-remove-all-fp/test.desc create mode 100644 regression/goto-instrument/no-match-non-const-fp-only-remove-const/main.c create mode 100644 regression/goto-instrument/no-match-non-const-fp-only-remove-const/test.desc create mode 100644 regression/goto-instrument/no-match-non-const-fp-remove-all-fp/main.c create mode 100644 regression/goto-instrument/no-match-non-const-fp-remove-all-fp/test.desc create mode 100644 regression/goto-instrument/precise-const-fp-only-remove-const/main.c create mode 100644 regression/goto-instrument/precise-const-fp-only-remove-const/test.desc create mode 100644 regression/goto-instrument/precise-const-fp-remove-all-fp/main.c create mode 100644 regression/goto-instrument/precise-const-fp-remove-all-fp/test.desc diff --git a/regression/goto-instrument/approx-array-variable-const-fp-only-remove-const/main.c b/regression/goto-instrument/approx-array-variable-const-fp-only-remove-const/main.c new file mode 100644 index 00000000000..3fb230c83fd --- /dev/null +++ b/regression/goto-instrument/approx-array-variable-const-fp-only-remove-const/main.c @@ -0,0 +1,34 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +const void_fp fp_tbl[] = {f2, f3 ,f4}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i) +{ + fp_tbl[i](); +} + +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + + return 0; +} \ No newline at end of file diff --git a/regression/goto-instrument/approx-array-variable-const-fp-only-remove-const/test.desc b/regression/goto-instrument/approx-array-variable-const-fp-only-remove-const/test.desc new file mode 100644 index 00000000000..3c712e97b99 --- /dev/null +++ b/regression/goto-instrument/approx-array-variable-const-fp-only-remove-const/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--verbosity 10 --pointer-check --remove-const-function-pointers + +^\s*IF fp_tbl\[(signed long int)i\] == f2 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f3 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f4 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^\s*IF fp_tbl\[(signed long int)i\] == f1 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f5 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f6 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f7 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f8 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f9 THEN GOTO [0-9]$ +^warning: ignoring diff --git a/regression/goto-instrument/approx-array-variable-const-fp-remove-all-fp/main.c b/regression/goto-instrument/approx-array-variable-const-fp-remove-all-fp/main.c new file mode 100644 index 00000000000..7896e3402c0 --- /dev/null +++ b/regression/goto-instrument/approx-array-variable-const-fp-remove-all-fp/main.c @@ -0,0 +1,34 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +const void_fp fp_tbl[] = {f2, f3 ,f4}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i) +{ + fp_tbl[i](); +} + +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + + return 0; +} diff --git a/regression/goto-instrument/approx-array-variable-const-fp-remove-all-fp/test.desc b/regression/goto-instrument/approx-array-variable-const-fp-remove-all-fp/test.desc new file mode 100644 index 00000000000..7cd546580d7 --- /dev/null +++ b/regression/goto-instrument/approx-array-variable-const-fp-remove-all-fp/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--verbosity 10 --pointer-check --remove-function-pointers + +^\s*IF fp_tbl\[(signed long int)i\] == f2 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f3 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f4 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^\s*IF fp_tbl\[(signed long int)i\] == f1 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f5 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f6 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f7 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f8 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[(signed long int)i\] == f9 THEN GOTO [0-9]$ +^warning: ignoring diff --git a/regression/goto-instrument/no-match-non-const-fp-only-remove-const/main.c b/regression/goto-instrument/no-match-non-const-fp-only-remove-const/main.c new file mode 100644 index 00000000000..80c8c863ff5 --- /dev/null +++ b/regression/goto-instrument/no-match-non-const-fp-only-remove-const/main.c @@ -0,0 +1,31 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + void_fp fp = f2; + fp = f3; + fp(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-instrument/no-match-non-const-fp-only-remove-const/test.desc b/regression/goto-instrument/no-match-non-const-fp-only-remove-const/test.desc new file mode 100644 index 00000000000..ff5e6a916e1 --- /dev/null +++ b/regression/goto-instrument/no-match-non-const-fp-only-remove-const/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--verbosity 10 --pointer-check --remove-const-function-pointers + +^\s*fp();$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-instrument/no-match-non-const-fp-remove-all-fp/main.c b/regression/goto-instrument/no-match-non-const-fp-remove-all-fp/main.c new file mode 100644 index 00000000000..80c8c863ff5 --- /dev/null +++ b/regression/goto-instrument/no-match-non-const-fp-remove-all-fp/main.c @@ -0,0 +1,31 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + void_fp fp = f2; + fp = f3; + fp(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-instrument/no-match-non-const-fp-remove-all-fp/test.desc b/regression/goto-instrument/no-match-non-const-fp-remove-all-fp/test.desc new file mode 100644 index 00000000000..3190d348aae --- /dev/null +++ b/regression/goto-instrument/no-match-non-const-fp-remove-all-fp/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--verbosity 10 --pointer-check --remove-function-pointers + +^\s*IF fp == f1 THEN GOTO [0-9]$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^\s*IF fp == f5 THEN GOTO [0-9]$ +^\s*IF fp == f6 THEN GOTO [0-9]$ +^\s*IF fp == f7 THEN GOTO [0-9]$ +^\s*IF fp == f8 THEN GOTO [0-9]$ +^\s*IF fp == f9 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-instrument/precise-const-fp-only-remove-const/main.c b/regression/goto-instrument/precise-const-fp-only-remove-const/main.c new file mode 100644 index 00000000000..b4002c94e5e --- /dev/null +++ b/regression/goto-instrument/precise-const-fp-only-remove-const/main.c @@ -0,0 +1,30 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp = f2; + fp(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-instrument/precise-const-fp-only-remove-const/test.desc b/regression/goto-instrument/precise-const-fp-only-remove-const/test.desc new file mode 100644 index 00000000000..e125fff93f4 --- /dev/null +++ b/regression/goto-instrument/precise-const-fp-only-remove-const/test.desc @@ -0,0 +1,7 @@ +CORE +main.c +--verbosity 10 --pointer-check --remove-const-function-pointers + +^\s*f2(); +-- +^warning: ignoring diff --git a/regression/goto-instrument/precise-const-fp-remove-all-fp/main.c b/regression/goto-instrument/precise-const-fp-remove-all-fp/main.c new file mode 100644 index 00000000000..b4002c94e5e --- /dev/null +++ b/regression/goto-instrument/precise-const-fp-remove-all-fp/main.c @@ -0,0 +1,30 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp = f2; + fp(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-instrument/precise-const-fp-remove-all-fp/test.desc b/regression/goto-instrument/precise-const-fp-remove-all-fp/test.desc new file mode 100644 index 00000000000..58ccee3a018 --- /dev/null +++ b/regression/goto-instrument/precise-const-fp-remove-all-fp/test.desc @@ -0,0 +1,7 @@ +CORE +main.c +--verbosity 10 --pointer-check --remove-function-pointers + +^\s*f2(); +-- +^warning: ignoring diff --git a/src/goto-instrument/goto_instrument_parse_options.cpp b/src/goto-instrument/goto_instrument_parse_options.cpp index 3e923bd5103..7af3323d8e8 100644 --- a/src/goto-instrument/goto_instrument_parse_options.cpp +++ b/src/goto-instrument/goto_instrument_parse_options.cpp @@ -820,6 +820,39 @@ void goto_instrument_parse_optionst::do_indirect_call_and_rtti_removal( /*******************************************************************\ +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 + // removal. + if(function_pointer_removal_done) + { + return; + } + + status() << "Removing const function pointers only" << eom; + remove_function_pointers( + get_message_handler(), + symbol_table, + goto_functions, + cmdline.isset("pointer-check"), + true); // abort if we can't resolve via const pointers +} + +/*******************************************************************\ + Function: goto_instrument_parse_optionst::do_partial_inlining Inputs: @@ -1046,7 +1079,13 @@ void goto_instrument_parse_optionst::instrument_goto_program() // replace function pointers, if explicitly requested if(cmdline.isset("remove-function-pointers")) + { do_indirect_call_and_rtti_removal(); + } + else if(cmdline.isset("remove-const-function-pointers")) + { + do_remove_const_function_pointers_only(); + } if(cmdline.isset("function-inline")) { @@ -1556,6 +1595,7 @@ void goto_instrument_parse_optionst::help() " --no-caching disable caching of intermediate results during transitive function inlining\n" // NOLINT(*) " --log log in json format which code segments were inlined, use with --function-inline\n" // NOLINT(*) " --remove-function-pointers replace function pointers by case statement over function calls\n" // NOLINT(*) + HELP_REMOVE_CONST_FUNCTION_POINTERS " --add-library add models of C library functions\n" " --model-argc-argv model up to command line arguments\n" "\n" diff --git a/src/goto-instrument/goto_instrument_parse_options.h b/src/goto-instrument/goto_instrument_parse_options.h index d3efb975767..d4054b6e0a4 100644 --- a/src/goto-instrument/goto_instrument_parse_options.h +++ b/src/goto-instrument/goto_instrument_parse_options.h @@ -15,6 +15,7 @@ Author: Daniel Kroening, kroening@kroening.com #include #include #include +#include #include @@ -54,6 +55,7 @@ Author: Daniel Kroening, kroening@kroening.com "(show-uninitialized)(show-locations)" \ "(full-slice)(reachability-slice)(slice-global-inits)" \ "(inline)(partial-inline)(function-inline):(log):(no-caching)" \ + OPT_REMOVE_CONST_FUNCTION_POINTERS \ "(remove-function-pointers)" \ "(show-claims)(show-properties)(property):" \ "(show-symbol-table)(show-points-to)(show-rw-set)" \ @@ -98,6 +100,7 @@ class goto_instrument_parse_optionst: void eval_verbosity(); void do_indirect_call_and_rtti_removal(bool force=false); + void do_remove_const_function_pointers_only(); void do_partial_inlining(); void do_remove_returns(); diff --git a/src/goto-programs/remove_const_function_pointers.h b/src/goto-programs/remove_const_function_pointers.h index 1847ef56849..6516fb6ec64 100644 --- a/src/goto-programs/remove_const_function_pointers.h +++ b/src/goto-programs/remove_const_function_pointers.h @@ -95,4 +95,11 @@ class remove_const_function_pointerst:public messaget const symbol_tablet &symbol_table; }; +#define OPT_REMOVE_CONST_FUNCTION_POINTERS \ + "(remove-const-function-pointers)" + +#define HELP_REMOVE_CONST_FUNCTION_POINTERS \ + " --remove-const-function-pointers Remove function pointers that are constant or constant part of an array\n" // NOLINT(*) + + #endif // CPROVER_GOTO_PROGRAMS_REMOVE_CONST_FUNCTION_POINTERS_H diff --git a/src/goto-programs/remove_function_pointers.cpp b/src/goto-programs/remove_function_pointers.cpp index 4c505cdc191..a2500efd3ea 100644 --- a/src/goto-programs/remove_function_pointers.cpp +++ b/src/goto-programs/remove_function_pointers.cpp @@ -38,6 +38,7 @@ class remove_function_pointerst:public messaget message_handlert &_message_handler, symbol_tablet &_symbol_table, bool _add_safety_assertion, + bool only_resolve_const_fps, const goto_functionst &goto_functions); void operator()(goto_functionst &goto_functions); @@ -49,6 +50,14 @@ class remove_function_pointerst:public messaget symbol_tablet &symbol_table; bool add_safety_assertion; + // We can optionally halt the FP removal if we aren't able to use + // remove_const_function_pointerst to sucessfully narrow to a small + // subset of possible functions and just leave the function pointer + // as it is. + // This can be activated in goto-instrument using + // --remove-const-function-pointers instead of --remove-function-pointers + bool only_resolve_const_fps; + void remove_function_pointer( goto_programt &goto_program, goto_programt::targett target); @@ -97,12 +106,13 @@ Function: remove_function_pointerst::remove_function_pointerst remove_function_pointerst::remove_function_pointerst( message_handlert &_message_handler, symbol_tablet &_symbol_table, - bool _add_safety_assertion, + bool _add_safety_assertion, bool only_resolve_const_fps, const goto_functionst &goto_functions): messaget(_message_handler), ns(_symbol_table), symbol_table(_symbol_table), - add_safety_assertion(_add_safety_assertion) + add_safety_assertion(_add_safety_assertion), + only_resolve_const_fps(only_resolve_const_fps) { compute_address_taken_in_symbols(address_taken); compute_address_taken_functions(goto_functions, address_taken); @@ -366,6 +376,17 @@ void remove_function_pointerst::remove_function_pointer( if(!found_functions) { + if(only_resolve_const_fps) + { + // If this mode is enabled, we only remove function pointers + // that we can resolve either to an exact funciton, or an exact subset + // (e.g. a variable index in a constant array). + // Since we haven't found functions, we would now resort to + // replacing the function pointer with any function with a valid signature + // Since we don't want to do that, we abort. + return; + } + bool return_value_used=code.lhs().is_not_nil(); // get all type-compatible functions @@ -554,15 +575,20 @@ Function: remove_function_pointers \*******************************************************************/ -bool remove_function_pointers( - message_handlert &_message_handler, +bool remove_function_pointers(message_handlert &_message_handler, symbol_tablet &symbol_table, const goto_functionst &goto_functions, goto_programt &goto_program, - bool add_safety_assertion) + bool add_safety_assertion, + bool only_remove_const_fps) { remove_function_pointerst - rfp(_message_handler, symbol_table, add_safety_assertion, goto_functions); + rfp( + _message_handler, + symbol_table, + add_safety_assertion, + only_remove_const_fps, + goto_functions); return rfp.remove_function_pointers(goto_program); } @@ -583,10 +609,16 @@ void remove_function_pointers( message_handlert &_message_handler, symbol_tablet &symbol_table, goto_functionst &goto_functions, - bool add_safety_assertion) + bool add_safety_assertion, + bool only_remove_const_fps) { remove_function_pointerst - rfp(_message_handler, symbol_table, add_safety_assertion, goto_functions); + rfp( + _message_handler, + symbol_table, + add_safety_assertion, + only_remove_const_fps, + goto_functions); rfp(goto_functions); } @@ -603,14 +635,15 @@ Function: remove_function_pointers \*******************************************************************/ -void remove_function_pointers( - message_handlert &_message_handler, +void remove_function_pointers(message_handlert &_message_handler, goto_modelt &goto_model, - bool add_safety_assertion) + bool add_safety_assertion, + bool only_remove_const_fps) { remove_function_pointers( _message_handler, goto_model.symbol_table, goto_model.goto_functions, - add_safety_assertion); + add_safety_assertion, + only_remove_const_fps); } diff --git a/src/goto-programs/remove_function_pointers.h b/src/goto-programs/remove_function_pointers.h index 0320a77c9a2..e8eea37ea75 100644 --- a/src/goto-programs/remove_function_pointers.h +++ b/src/goto-programs/remove_function_pointers.h @@ -19,19 +19,22 @@ Date: June 2003 void remove_function_pointers( message_handlert &_message_handler, goto_modelt &goto_model, - bool add_safety_assertion); + bool add_safety_assertion, + bool only_remove_const_fps=false); void remove_function_pointers( message_handlert &_message_handler, symbol_tablet &symbol_table, goto_functionst &goto_functions, - bool add_safety_assertion); + bool add_safety_assertion, + bool only_remove_const_fps=false); bool remove_function_pointers( message_handlert &_message_handler, symbol_tablet &symbol_table, const goto_functionst &goto_functions, goto_programt &goto_program, - bool add_safety_assertion); + bool add_safety_assertion, + bool only_remove_const_fps=false); #endif // CPROVER_GOTO_PROGRAMS_REMOVE_FUNCTION_POINTERS_H From 052da5a6471dedd8b5f97ca8eaffaafb7f1730db Mon Sep 17 00:00:00 2001 From: thk123 Date: Tue, 14 Feb 2017 17:19:41 +0000 Subject: [PATCH 043/116] Check the GOTO program for loss of const Before removing const function pointers using remove_const_function_pointerst we check each instruction in the goto program for assigns where the RHS is more const than the LHS. This includes both implicit and explicit casting away of const. If this has happened to something relating to a function pointer, then our optimization is not sound, so if we find any we just abandon this optimization. This is acceptable since it is undefined behavior anyway to be modifying a const variable. --- .../no-match-const-fp-const-cast/main.c | 35 +++++ .../no-match-const-fp-const-cast/test.desc | 16 ++ .../no-match-const-fp-const-lost/main.c | 35 +++++ .../no-match-const-fp-const-lost/test.desc | 16 ++ .../main.c | 45 ++++++ .../test.desc | 17 ++ .../remove_function_pointers.cpp | 146 ++++++++++++++++-- 7 files changed, 298 insertions(+), 12 deletions(-) create mode 100644 regression/goto-analyzer/no-match-const-fp-const-cast/main.c create mode 100644 regression/goto-analyzer/no-match-const-fp-const-cast/test.desc create mode 100644 regression/goto-analyzer/no-match-const-fp-const-lost/main.c create mode 100644 regression/goto-analyzer/no-match-const-fp-const-lost/test.desc create mode 100644 regression/goto-analyzer/no-match-const-pointer-const-struct-const-fp-const-cast/main.c create mode 100644 regression/goto-analyzer/no-match-const-pointer-const-struct-const-fp-const-cast/test.desc diff --git a/regression/goto-analyzer/no-match-const-fp-const-cast/main.c b/regression/goto-analyzer/no-match-const-fp-const-cast/main.c new file mode 100644 index 00000000000..f7fa7f41b42 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-const-cast/main.c @@ -0,0 +1,35 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp = f2; + + // Warning: this loses const-ness of f2 + void_fp * p2fp = (void_fp*)&fp; + *p2fp = &f4; + + fp(); +} + +int main() +{ + func(); + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/no-match-const-fp-const-cast/test.desc b/regression/goto-analyzer/no-match-const-fp-const-cast/test.desc new file mode 100644 index 00000000000..e8357d911c6 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-const-cast/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check + +^Removing function pointers and virtual functions$ +^\s*IF fp == f1 THEN GOTO [0-9]$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^\s*IF fp == f5 THEN GOTO [0-9]$ +^\s*IF fp == f6 THEN GOTO [0-9]$ +^\s*IF fp == f7 THEN GOTO [0-9]$ +^\s*IF fp == f8 THEN GOTO [0-9]$ +^\s*IF fp == f9 THEN GOTO [0-9]$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-const-lost/main.c b/regression/goto-analyzer/no-match-const-fp-const-lost/main.c new file mode 100644 index 00000000000..edeca0d3f79 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-const-lost/main.c @@ -0,0 +1,35 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp = f2; + + // Warning: this loses const-ness of f2 + void_fp * p2fp = &fp; + *p2fp = &f4; + + fp(); +} + +int main() +{ + func(); + + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/no-match-const-fp-const-lost/test.desc b/regression/goto-analyzer/no-match-const-fp-const-lost/test.desc new file mode 100644 index 00000000000..e8357d911c6 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-const-lost/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check + +^Removing function pointers and virtual functions$ +^\s*IF fp == f1 THEN GOTO [0-9]$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^\s*IF fp == f5 THEN GOTO [0-9]$ +^\s*IF fp == f6 THEN GOTO [0-9]$ +^\s*IF fp == f7 THEN GOTO [0-9]$ +^\s*IF fp == f8 THEN GOTO [0-9]$ +^\s*IF fp == f9 THEN GOTO [0-9]$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-pointer-const-struct-const-fp-const-cast/main.c b/regression/goto-analyzer/no-match-const-pointer-const-struct-const-fp-const-cast/main.c new file mode 100644 index 00000000000..b7b9e4d2b30 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-pointer-const-struct-const-fp-const-cast/main.c @@ -0,0 +1,45 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +typedef struct fp_cc +{ + int x; + void_fp fp; +} fp_cc; + + + +void func() +{ + const fp_cc container_container = { .fp = f2, .x = 4 }; + + const fp_cc * const container_pointer = &container_container; + + fp_cc* container_pointer_modifier = (fp_cc*) container_pointer; + container_pointer_modifier->fp = f4; + + // Illegal: + // container_container.container = &f4; + + container_pointer->fp(); +} + +int main() +{ + func(); +} diff --git a/regression/goto-analyzer/no-match-const-pointer-const-struct-const-fp-const-cast/test.desc b/regression/goto-analyzer/no-match-const-pointer-const-struct-const-fp-const-cast/test.desc new file mode 100644 index 00000000000..2f4b2832b4d --- /dev/null +++ b/regression/goto-analyzer/no-match-const-pointer-const-struct-const-fp-const-cast/test.desc @@ -0,0 +1,17 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check + +^Removing function pointers and virtual functions$ +^\s*IF container_pointer->fp == f1 THEN GOTO [0-9]$ +^\s*IF container_pointer->fp == f2 THEN GOTO [0-9]$ +^\s*IF container_pointer->fp == f3 THEN GOTO [0-9]$ +^\s*IF container_pointer->fp == f4 THEN GOTO [0-9]$ +^\s*IF container_pointer->fp == f5 THEN GOTO [0-9]$ +^\s*IF container_pointer->fp == f6 THEN GOTO [0-9]$ +^\s*IF container_pointer->fp == f7 THEN GOTO [0-9]$ +^\s*IF container_pointer->fp == f8 THEN GOTO [0-9]$ +^\s*IF container_pointer->fp == f9 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/src/goto-programs/remove_function_pointers.cpp b/src/goto-programs/remove_function_pointers.cpp index a2500efd3ea..dd20bedeb6d 100644 --- a/src/goto-programs/remove_function_pointers.cpp +++ b/src/goto-programs/remove_function_pointers.cpp @@ -15,6 +15,8 @@ Author: Daniel Kroening, kroening@kroening.com #include #include #include +#include +#include #include @@ -62,6 +64,11 @@ class remove_function_pointerst:public messaget goto_programt &goto_program, goto_programt::targett target); + bool does_program_contain_const_removal_cast( + const goto_programt &goto_program); + + bool is_type_at_least_as_const_as(typet type_more_const, typet type_compare); + std::set address_taken; typedef std::map type_mapt; @@ -353,25 +360,36 @@ void remove_function_pointerst::remove_function_pointer( assert(function.id()==ID_dereference); assert(function.operands().size()==1); + bool found_functions; + const exprt &pointer=function.op0(); remove_const_function_pointerst::functionst functions; - remove_const_function_pointerst fpr( + if(does_program_contain_const_removal_cast(goto_program)) + { + warning() << "Cast from const to non-const pointer found, only worst case" + << " function pointer removal will be done." << eom; + found_functions=false; + } + else + { + remove_const_function_pointerst fpr( get_message_handler(), pointer, ns, symbol_table); - bool found_functions=fpr(functions); + found_functions=fpr(functions); - // Consistency checks - // Reported optimized function pointer call, but didn't find any functions - assert(!found_functions || !functions.empty()); + // Consistency checks + // Reported optimized function pointer call, but didn't find any functions + assert(!found_functions || !functions.empty()); - // Reported didn't optimize function pointer call, but did find some - // functions to replace with - assert(found_functions || functions.empty()); + // Reported didn't optimize function pointer call, but did find some + // functions to replace with + assert(found_functions || functions.empty()); - if(functions.size()==1) - { - to_code_function_call(target->code).function()=*functions.cbegin(); - return; + if(functions.size()==1) + { + to_code_function_call(target->code).function()=*functions.cbegin(); + return; + } } if(!found_functions) @@ -495,6 +513,110 @@ void remove_function_pointerst::remove_function_pointer( /*******************************************************************\ +Function: remove_function_pointerst::does_program_contain_const_removal_cast + + Inputs: + goto_program - the goto program to check + + Outputs: Returns true if any instruction in the code casts away either + explicitly or implicitly the const qualifier of a type. + + Purpose: A naive check to look for casts that remove const-ness from + pointers. If this is present, then our remove_const_function_pointerst + is not sound so we don't allow it. + +\*******************************************************************/ + +bool remove_function_pointerst::does_program_contain_const_removal_cast( + const goto_programt &goto_program) +{ + for(const goto_programt::instructiont &instruction : + goto_program.instructions) + { + if(instruction.is_assign()) + { + const code_assignt assign=to_code_assign(instruction.code); + typet rhs_type=assign.rhs().type(); + typet lhs_type=assign.lhs().type(); + + // Compare the types recursively for a point where the rhs is more + // const that the lhs + if(!is_type_at_least_as_const_as(lhs_type, rhs_type)) + { + return true; + } + + // see if the rhs loses const inside the expression tree + exprt rhs=assign.rhs(); + while(!rhs.operands().empty()) + { + typet &pre_op_type=rhs.type(); + typet &post_op_type=rhs.op0().type(); + + // Types equality does not check, for example, const-ness + // If this is true, then this expression only modified the + // type by some qualifier (or not at all) + if(base_type_eq(pre_op_type, post_op_type, ns)) + { + if(!is_type_at_least_as_const_as(pre_op_type, post_op_type)) + { + return true; + } + } + rhs=rhs.op0(); + } + } + } + + return false; +} + +/*******************************************************************\ + +Function: remove_function_pointerst::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 remove_function_pointerst::is_type_at_least_as_const_as( + typet type_more_const, typet type_compare) +{ + while(!type_compare.id().empty() && !type_more_const.id().empty()) + { + const c_qualifierst rhs_qualifiers(type_compare); + const c_qualifierst lhs_qualifiers(type_more_const); + if(rhs_qualifiers.is_constant && !lhs_qualifiers.is_constant) + { + return false; + } + + type_compare=type_compare.subtype(); + type_more_const=type_more_const.subtype(); + } + + // Both the types should have the same number of subtypes + assert(type_compare.id()=="" && type_more_const.id()==""); + return true; +} + +/*******************************************************************\ + Function: remove_function_pointerst::remove_function_pointers Inputs: From 6ba046908cac6647c551db1a941c28d3778d8fd7 Mon Sep 17 00:00:00 2001 From: thk123 Date: Thu, 16 Feb 2017 12:09:38 +0000 Subject: [PATCH 044/116] Added a couple of missed test cases. Added test for run time const arrays. Adding test case for pointer to struct --- .../main.c | 32 ++++++++++++++ .../test.desc | 8 ++++ .../main.c | 43 +++++++++++++++++++ .../test.desc | 9 ++++ 4 files changed, 92 insertions(+) create mode 100644 regression/goto-analyzer/precise-const-fp-array-literal-const-fp-run-time/main.c create mode 100644 regression/goto-analyzer/precise-const-fp-array-literal-const-fp-run-time/test.desc create mode 100644 regression/goto-analyzer/precise-const-pointer-const-struct-fp/main.c create mode 100644 regression/goto-analyzer/precise-const-pointer-const-struct-fp/test.desc diff --git a/regression/goto-analyzer/precise-const-fp-array-literal-const-fp-run-time/main.c b/regression/goto-analyzer/precise-const-fp-array-literal-const-fp-run-time/main.c new file mode 100644 index 00000000000..36e4da04ddf --- /dev/null +++ b/regression/goto-analyzer/precise-const-fp-array-literal-const-fp-run-time/main.c @@ -0,0 +1,32 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp_tbl[] = {f2, f3}; + // Illegal: + //fp_tbl[1] = f4; + const void_fp fp = fp_tbl[1]; + fp(); +} + +int main() +{ + func(); + return 0; +} \ No newline at end of file diff --git a/regression/goto-analyzer/precise-const-fp-array-literal-const-fp-run-time/test.desc b/regression/goto-analyzer/precise-const-fp-array-literal-const-fp-run-time/test.desc new file mode 100644 index 00000000000..0e57c1a7db3 --- /dev/null +++ b/regression/goto-analyzer/precise-const-fp-array-literal-const-fp-run-time/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check + +^Removing function pointers and virtual functions$ +^\s*f3();$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/precise-const-pointer-const-struct-fp/main.c b/regression/goto-analyzer/precise-const-pointer-const-struct-fp/main.c new file mode 100644 index 00000000000..e1671666b2b --- /dev/null +++ b/regression/goto-analyzer/precise-const-pointer-const-struct-fp/main.c @@ -0,0 +1,43 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +typedef struct fp_cc +{ + int x; + void_fp fp; +} fp_cc; + + + +void func() +{ + const fp_cc container_container = { .fp = f2, .x = 4 }; + + const fp_cc * const container_pointer = &container_container; + + // Illegal: + //meta_fp = &f4; + //container_container.container = &f4; + + container_pointer->fp(); +} + +int main() +{ + func(); +} diff --git a/regression/goto-analyzer/precise-const-pointer-const-struct-fp/test.desc b/regression/goto-analyzer/precise-const-pointer-const-struct-fp/test.desc new file mode 100644 index 00000000000..9d578669db7 --- /dev/null +++ b/regression/goto-analyzer/precise-const-pointer-const-struct-fp/test.desc @@ -0,0 +1,9 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check + +^Removing function pointers and virtual functions$ +^\s*f2();$ +^SIGNAL=0$ +-- +^warning: ignoring From 18b590778787ca3a9802a826dc6a570be4e0350a Mon Sep 17 00:00:00 2001 From: thk123 Date: Thu, 16 Feb 2017 14:04:02 +0000 Subject: [PATCH 045/116] Fixing tests to work with new test.pl The new test.pl script requrires breaks to be escaped. --- .../approx-array-variable-const-fp/test.desc | 18 +++++++++--------- .../test.desc | 12 ++++++------ .../test.desc | 12 ++++++------ .../test.desc | 12 ++++++------ .../test.desc | 12 ++++++------ .../test.desc | 12 ++++++------ .../test.desc | 18 +++++++++--------- .../test.desc | 18 +++++++++--------- .../test.desc | 18 +++++++++--------- .../test.desc | 2 +- .../precise-array-literal-const-fp/test.desc | 2 +- .../test.desc | 2 +- .../test.desc | 2 +- .../test.desc | 2 +- .../test.desc | 2 +- .../test.desc | 2 +- .../precise-const-fp-const-fp/test.desc | 2 +- .../test.desc | 2 +- .../test.desc | 2 +- .../test.desc | 2 +- .../test.desc | 2 +- .../goto-analyzer/precise-const-fp/test.desc | 2 +- .../test.desc | 2 +- .../test.desc | 2 +- .../test.desc | 2 +- .../goto-analyzer/precise-derefence/test.desc | 2 +- .../test.desc | 2 +- .../test.desc | 2 +- .../test.desc | 2 +- .../test.desc | 2 +- .../test.desc | 18 +++++++++--------- .../test.desc | 18 +++++++++--------- .../test.desc | 2 +- .../test.desc | 2 +- .../precise-const-fp-remove-all-fp/test.desc | 2 +- 35 files changed, 108 insertions(+), 108 deletions(-) diff --git a/regression/goto-analyzer/approx-array-variable-const-fp/test.desc b/regression/goto-analyzer/approx-array-variable-const-fp/test.desc index 28b95c5ac33..83a930d1c36 100644 --- a/regression/goto-analyzer/approx-array-variable-const-fp/test.desc +++ b/regression/goto-analyzer/approx-array-variable-const-fp/test.desc @@ -3,15 +3,15 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF fp_tbl\[(signed long int)i\] == f2 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f3 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f4 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f2 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f3 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f4 THEN GOTO [0-9]$ ^SIGNAL=0$ -- -^\s*IF fp_tbl\[(signed long int)i\] == f1 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f5 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f6 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f7 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f8 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f9 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f1 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f5 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f6 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f7 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f8 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f9 THEN GOTO [0-9]$ ^warning: ignoring diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/test.desc index 973fbe34127..a937e306d31 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/test.desc +++ b/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/test.desc @@ -9,9 +9,9 @@ main.c ^SIGNAL=0$ -- ^warning: ignoring -^\s*IF fp_tbl\[(signed long int)i\] == f1 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f5 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f6 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f7 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f8 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f9 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f1 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f5 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f6 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f7 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f8 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f9 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/test.desc index 973fbe34127..a937e306d31 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/test.desc +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/test.desc @@ -9,9 +9,9 @@ main.c ^SIGNAL=0$ -- ^warning: ignoring -^\s*IF fp_tbl\[(signed long int)i\] == f1 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f5 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f6 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f7 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f8 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f9 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f1 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f5 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f6 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f7 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f8 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f9 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/test.desc index 973fbe34127..a937e306d31 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/test.desc +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/test.desc @@ -9,9 +9,9 @@ main.c ^SIGNAL=0$ -- ^warning: ignoring -^\s*IF fp_tbl\[(signed long int)i\] == f1 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f5 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f6 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f7 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f8 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f9 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f1 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f5 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f6 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f7 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f8 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f9 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc index 973fbe34127..a937e306d31 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc @@ -9,9 +9,9 @@ main.c ^SIGNAL=0$ -- ^warning: ignoring -^\s*IF fp_tbl\[(signed long int)i\] == f1 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f5 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f6 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f7 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f8 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f9 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f1 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f5 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f6 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f7 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f8 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f9 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/test.desc index 973fbe34127..a937e306d31 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/test.desc +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/test.desc @@ -9,9 +9,9 @@ main.c ^SIGNAL=0$ -- ^warning: ignoring -^\s*IF fp_tbl\[(signed long int)i\] == f1 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f5 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f6 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f7 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f8 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f9 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f1 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f5 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f6 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f7 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f8 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f9 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/test.desc index 5459b630bc9..b6e93d5b677 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/test.desc +++ b/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/test.desc @@ -3,15 +3,15 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF fp == (void (\*)(void))f2 THEN GOTO [0-9]$ -^\s*IF fp == (void (\*)(void))f3 THEN GOTO [0-9]$ -^\s*IF fp == (void (\*)(void))f4 THEN GOTO [0-9]$ +^\s*IF fp == \(void \(\*\)\(void\)\)f2 THEN GOTO [0-9]$ +^\s*IF fp == \(void \(\*\)\(void\)\)f3 THEN GOTO [0-9]$ +^\s*IF fp == \(void \(\*\)\(void\)\)f4 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring -^\s*IF fp_tbl\[(signed long int)i\] == f1 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f5 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f6 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f7 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f8 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f9 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f1 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f5 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f6 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f7 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f8 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f9 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/test.desc b/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/test.desc index 9abe6fde56a..7e0aca75523 100644 --- a/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/test.desc @@ -3,15 +3,15 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f1 THEN GOTO [0-9]$ -^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f2 THEN GOTO [0-9]$ -^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f3 THEN GOTO [0-9]$ -^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f4 THEN GOTO [0-9]$ -^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f5 THEN GOTO [0-9]$ -^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f6 THEN GOTO [0-9]$ -^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f7 THEN GOTO [0-9]$ -^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f8 THEN GOTO [0-9]$ -^\s*IF \*container_ptr->fp_tbl\[(signed long int)1\] == f9 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[\(signed long int\)1\] == f1 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[\(signed long int\)1\] == f2 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[\(signed long int\)1\] == f3 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[\(signed long int\)1\] == f4 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[\(signed long int\)1\] == f5 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[\(signed long int\)1\] == f6 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[\(signed long int\)1\] == f7 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[\(signed long int\)1\] == f8 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[\(signed long int\)1\] == f9 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/test.desc b/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/test.desc index 3f90b23b7d4..83a4d98d9f4 100644 --- a/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/test.desc @@ -3,15 +3,15 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f1 THEN GOTO [0-9]$ -^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f2 THEN GOTO [0-9]$ -^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f3 THEN GOTO [0-9]$ -^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f4 THEN GOTO [0-9]$ -^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f5 THEN GOTO [0-9]$ -^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f6 THEN GOTO [0-9]$ -^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f7 THEN GOTO [0-9]$ -^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f8 THEN GOTO [0-9]$ -^\s*IF container_ptr->fp_tbl\[(signed long int)1\] == f9 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[\(signed long int\)1\] == f1 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[\(signed long int\)1\] == f2 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[\(signed long int\)1\] == f3 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[\(signed long int\)1\] == f4 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[\(signed long int\)1\] == f5 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[\(signed long int\)1\] == f6 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[\(signed long int\)1\] == f7 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[\(signed long int\)1\] == f8 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[\(signed long int\)1\] == f9 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/precise-array-calculation-const-fp/test.desc b/regression/goto-analyzer/precise-array-calculation-const-fp/test.desc index 9716d23800e..fad0e6c7a1d 100644 --- a/regression/goto-analyzer/precise-array-calculation-const-fp/test.desc +++ b/regression/goto-analyzer/precise-array-calculation-const-fp/test.desc @@ -2,7 +2,7 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*f3();$ +^\s*f3\(\);$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/precise-array-literal-const-fp/test.desc b/regression/goto-analyzer/precise-array-literal-const-fp/test.desc index 9716d23800e..fad0e6c7a1d 100644 --- a/regression/goto-analyzer/precise-array-literal-const-fp/test.desc +++ b/regression/goto-analyzer/precise-array-literal-const-fp/test.desc @@ -2,7 +2,7 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*f3();$ +^\s*f3\(\);$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/precise-const-fp-array-const-variable-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp-array-const-variable-const-fp/test.desc index 9716d23800e..fad0e6c7a1d 100644 --- a/regression/goto-analyzer/precise-const-fp-array-const-variable-const-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-array-const-variable-const-fp/test.desc @@ -2,7 +2,7 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*f3();$ +^\s*f3\(\);$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/precise-const-fp-array-literal-const-fp-run-time/test.desc b/regression/goto-analyzer/precise-const-fp-array-literal-const-fp-run-time/test.desc index 0e57c1a7db3..6c7de56a1a0 100644 --- a/regression/goto-analyzer/precise-const-fp-array-literal-const-fp-run-time/test.desc +++ b/regression/goto-analyzer/precise-const-fp-array-literal-const-fp-run-time/test.desc @@ -3,6 +3,6 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*f3();$ +^\s*f3\(\);$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/precise-const-fp-array-literal-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp-array-literal-const-fp/test.desc index 9716d23800e..fad0e6c7a1d 100644 --- a/regression/goto-analyzer/precise-const-fp-array-literal-const-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-array-literal-const-fp/test.desc @@ -2,7 +2,7 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*f3();$ +^\s*f3\(\);$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/test.desc index 313435441b0..2eff811f4bc 100644 --- a/regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/test.desc @@ -3,7 +3,7 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*f3();$ +^\s*f3\(\);$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/precise-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc index 5d0951328b4..eb1e2781ef1 100644 --- a/regression/goto-analyzer/precise-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc @@ -3,7 +3,7 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*f2(); +^\s*f2\(\); ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/precise-const-fp-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp-const-fp/test.desc index 9852b6f4f36..40361f6ccc2 100644 --- a/regression/goto-analyzer/precise-const-fp-const-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-const-fp/test.desc @@ -2,7 +2,7 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*f2();$ +^\s*f2\(\);$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/precise-const-fp-const-struct-const-array-literal-fp/test.desc b/regression/goto-analyzer/precise-const-fp-const-struct-const-array-literal-fp/test.desc index 313435441b0..2eff811f4bc 100644 --- a/regression/goto-analyzer/precise-const-fp-const-struct-const-array-literal-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-const-struct-const-array-literal-fp/test.desc @@ -3,7 +3,7 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*f3();$ +^\s*f3\(\);$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/test.desc b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/test.desc index 313435441b0..2eff811f4bc 100644 --- a/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/test.desc @@ -3,7 +3,7 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*f3();$ +^\s*f3\(\);$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/precise-const-fp-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-fp/test.desc index 5d0951328b4..eb1e2781ef1 100644 --- a/regression/goto-analyzer/precise-const-fp-const-struct-non-const-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-fp/test.desc @@ -3,7 +3,7 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*f2(); +^\s*f2\(\); ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/test.desc index 313435441b0..2eff811f4bc 100644 --- a/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/test.desc @@ -3,7 +3,7 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*f3();$ +^\s*f3\(\);$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/precise-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp/test.desc index 8de39dddaab..ef4cf690b60 100644 --- a/regression/goto-analyzer/precise-const-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp/test.desc @@ -3,6 +3,6 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*f2(); +^\s*f2\(\); -- ^warning: ignoring diff --git a/regression/goto-analyzer/precise-const-pointer-const-struct-fp/test.desc b/regression/goto-analyzer/precise-const-pointer-const-struct-fp/test.desc index 9d578669db7..0de6942ba42 100644 --- a/regression/goto-analyzer/precise-const-pointer-const-struct-fp/test.desc +++ b/regression/goto-analyzer/precise-const-pointer-const-struct-fp/test.desc @@ -3,7 +3,7 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*f2();$ +^\s*f2\(\);$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/precise-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/precise-const-struct-non-const-fp/test.desc index 5d0951328b4..eb1e2781ef1 100644 --- a/regression/goto-analyzer/precise-const-struct-non-const-fp/test.desc +++ b/regression/goto-analyzer/precise-const-struct-non-const-fp/test.desc @@ -3,7 +3,7 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*f2(); +^\s*f2\(\); ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/test.desc b/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/test.desc index 313435441b0..2eff811f4bc 100644 --- a/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/test.desc @@ -3,7 +3,7 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*f3();$ +^\s*f3\(\);$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/precise-derefence/test.desc b/regression/goto-analyzer/precise-derefence/test.desc index 8de39dddaab..ef4cf690b60 100644 --- a/regression/goto-analyzer/precise-derefence/test.desc +++ b/regression/goto-analyzer/precise-derefence/test.desc @@ -3,6 +3,6 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*f2(); +^\s*f2\(\); -- ^warning: ignoring diff --git a/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/test.desc b/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/test.desc index 313435441b0..2eff811f4bc 100644 --- a/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/test.desc @@ -3,7 +3,7 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*f3();$ +^\s*f3\(\);$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-fp/test.desc b/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-fp/test.desc index 313435441b0..2eff811f4bc 100644 --- a/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-fp/test.desc @@ -3,7 +3,7 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*f3();$ +^\s*f3\(\);$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-struct-const-fp/test.desc b/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-struct-const-fp/test.desc index 313435441b0..2eff811f4bc 100644 --- a/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-struct-const-fp/test.desc +++ b/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-struct-const-fp/test.desc @@ -3,7 +3,7 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*f3();$ +^\s*f3\(\);$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/precise-dereference-const-struct-pointer-const-fp/test.desc b/regression/goto-analyzer/precise-dereference-const-struct-pointer-const-fp/test.desc index 313435441b0..2eff811f4bc 100644 --- a/regression/goto-analyzer/precise-dereference-const-struct-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/precise-dereference-const-struct-pointer-const-fp/test.desc @@ -3,7 +3,7 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*f3();$ +^\s*f3\(\);$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-instrument/approx-array-variable-const-fp-only-remove-const/test.desc b/regression/goto-instrument/approx-array-variable-const-fp-only-remove-const/test.desc index 3c712e97b99..f58b03a58b3 100644 --- a/regression/goto-instrument/approx-array-variable-const-fp-only-remove-const/test.desc +++ b/regression/goto-instrument/approx-array-variable-const-fp-only-remove-const/test.desc @@ -2,15 +2,15 @@ CORE main.c --verbosity 10 --pointer-check --remove-const-function-pointers -^\s*IF fp_tbl\[(signed long int)i\] == f2 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f3 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f4 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f2 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f3 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f4 THEN GOTO [0-9]$ ^SIGNAL=0$ -- -^\s*IF fp_tbl\[(signed long int)i\] == f1 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f5 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f6 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f7 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f8 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f9 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f1 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f5 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f6 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f7 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f8 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f9 THEN GOTO [0-9]$ ^warning: ignoring diff --git a/regression/goto-instrument/approx-array-variable-const-fp-remove-all-fp/test.desc b/regression/goto-instrument/approx-array-variable-const-fp-remove-all-fp/test.desc index 7cd546580d7..3d065f1a742 100644 --- a/regression/goto-instrument/approx-array-variable-const-fp-remove-all-fp/test.desc +++ b/regression/goto-instrument/approx-array-variable-const-fp-remove-all-fp/test.desc @@ -2,15 +2,15 @@ CORE main.c --verbosity 10 --pointer-check --remove-function-pointers -^\s*IF fp_tbl\[(signed long int)i\] == f2 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f3 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f4 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f2 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f3 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f4 THEN GOTO [0-9]$ ^SIGNAL=0$ -- -^\s*IF fp_tbl\[(signed long int)i\] == f1 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f5 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f6 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f7 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f8 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[(signed long int)i\] == f9 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f1 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f5 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f6 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f7 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f8 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f9 THEN GOTO [0-9]$ ^warning: ignoring diff --git a/regression/goto-instrument/no-match-non-const-fp-only-remove-const/test.desc b/regression/goto-instrument/no-match-non-const-fp-only-remove-const/test.desc index ff5e6a916e1..3b016907a44 100644 --- a/regression/goto-instrument/no-match-non-const-fp-only-remove-const/test.desc +++ b/regression/goto-instrument/no-match-non-const-fp-only-remove-const/test.desc @@ -2,7 +2,7 @@ CORE main.c --verbosity 10 --pointer-check --remove-const-function-pointers -^\s*fp();$ +^\s*fp\(\);$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-instrument/precise-const-fp-only-remove-const/test.desc b/regression/goto-instrument/precise-const-fp-only-remove-const/test.desc index e125fff93f4..2304d56b239 100644 --- a/regression/goto-instrument/precise-const-fp-only-remove-const/test.desc +++ b/regression/goto-instrument/precise-const-fp-only-remove-const/test.desc @@ -2,6 +2,6 @@ CORE main.c --verbosity 10 --pointer-check --remove-const-function-pointers -^\s*f2(); +^\s*f2\(\); -- ^warning: ignoring diff --git a/regression/goto-instrument/precise-const-fp-remove-all-fp/test.desc b/regression/goto-instrument/precise-const-fp-remove-all-fp/test.desc index 58ccee3a018..dd072b1c232 100644 --- a/regression/goto-instrument/precise-const-fp-remove-all-fp/test.desc +++ b/regression/goto-instrument/precise-const-fp-remove-all-fp/test.desc @@ -2,6 +2,6 @@ CORE main.c --verbosity 10 --pointer-check --remove-function-pointers -^\s*f2(); +^\s*f2\(\); -- ^warning: ignoring From 2538f4f31fbbdce8842b8a46d3219234fb1a23ad Mon Sep 17 00:00:00 2001 From: thk123 Date: Mon, 20 Feb 2017 12:19:00 +0000 Subject: [PATCH 046/116] Fixing missing new lines --- regression/goto-analyzer/approx-array-variable-const-fp/main.c | 2 +- .../approx-const-fp-array-variable-cast-const-fp/main.c | 2 +- .../approx-const-fp-array-variable-const-fp-with-null/main.c | 2 +- .../approx-const-fp-array-variable-const-fp/main.c | 2 +- .../main.c | 2 +- .../goto-analyzer/no-match-array-literal-const-fp-null/main.c | 2 +- .../no-match-const-fp-array-literal-const-fp-run-time/main.c | 2 +- .../main.c | 2 +- .../no-match-const-fp-array-literal-non-const-fp/main.c | 2 +- .../goto-analyzer/no-match-const-fp-array-non-const-fp/main.c | 2 +- regression/goto-analyzer/no-match-const-fp-const-cast/main.c | 2 +- regression/goto-analyzer/no-match-const-fp-const-fp-null/main.c | 2 +- regression/goto-analyzer/no-match-const-fp-const-lost/main.c | 2 +- .../main.c | 2 +- .../no-match-const-fp-dereference-const-pointer-null/main.c | 2 +- .../main.c | 2 +- .../no-match-const-fp-dynamic-array-non-const-fp/main.c | 2 +- .../no-match-const-fp-non-const-fp-direct-assignment/main.c | 2 +- .../main.c | 2 +- .../no-match-const-fp-non-const-struct-const-fp/main.c | 2 +- .../no-match-const-fp-non-const-struct-non-const-fp/main.c | 2 +- regression/goto-analyzer/no-match-const-fp-null/main.c | 2 +- .../no-match-const-pointer-non-const-struct-const-fp/main.c | 2 +- .../no-match-const-pointer-non-const-struct-const-fp/test.desc | 2 +- .../no-match-const-struct-non-const-fp-null/main.c | 2 +- .../no-match-non-const-fp-const-fp-direct-assignment/main.c | 2 +- regression/goto-analyzer/no-match-non-const-fp/main.c | 2 +- regression/goto-analyzer/no-match-parameter-const-fp/main.c | 2 +- regression/goto-analyzer/no-match-parameter-fp/main.c | 2 +- .../goto-analyzer/precise-array-calculation-const-fp/main.c | 2 +- regression/goto-analyzer/precise-array-literal-const-fp/main.c | 2 +- .../precise-const-fp-array-const-variable-const-fp/main.c | 2 +- .../precise-const-fp-array-literal-const-fp-run-time/main.c | 2 +- .../precise-const-fp-array-literal-const-fp/main.c | 2 +- .../main.c | 2 +- regression/goto-analyzer/precise-const-fp-const-fp/main.c | 2 +- .../main.c | 2 +- .../precise-const-fp-const-struct-non-const-fp/main.c | 2 +- .../precise-const-fp-dereference-const-pointer-const-fp/main.c | 2 +- regression/goto-analyzer/precise-const-fp/main.c | 2 +- .../goto-analyzer/precise-const-struct-non-const-fp/main.c | 2 +- .../precise-derefence-const-pointer-const-fp/main.c | 2 +- regression/goto-analyzer/precise-derefence/main.c | 2 +- .../precise-dereference-address-pointer-const-fp/main.c | 2 +- 44 files changed, 44 insertions(+), 44 deletions(-) diff --git a/regression/goto-analyzer/approx-array-variable-const-fp/main.c b/regression/goto-analyzer/approx-array-variable-const-fp/main.c index 3fb230c83fd..7896e3402c0 100644 --- a/regression/goto-analyzer/approx-array-variable-const-fp/main.c +++ b/regression/goto-analyzer/approx-array-variable-const-fp/main.c @@ -31,4 +31,4 @@ int main() } return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/main.c b/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/main.c index 3d968a5e243..8fda2e71af4 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/main.c +++ b/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/main.c @@ -38,4 +38,4 @@ int main() } return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/main.c b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/main.c index a777bce3a48..72a600aa80c 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/main.c +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/main.c @@ -32,4 +32,4 @@ int main() } return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/main.c b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/main.c index d426bba269e..7eea22141bd 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/main.c +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/main.c @@ -32,4 +32,4 @@ int main() } return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/main.c b/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/main.c index c27aee68bd8..67d256f0c7b 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/main.c +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/main.c @@ -47,4 +47,4 @@ int main() } return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/no-match-array-literal-const-fp-null/main.c b/regression/goto-analyzer/no-match-array-literal-const-fp-null/main.c index fba4069b7a2..93ed0af0d47 100644 --- a/regression/goto-analyzer/no-match-array-literal-const-fp-null/main.c +++ b/regression/goto-analyzer/no-match-array-literal-const-fp-null/main.c @@ -28,4 +28,4 @@ int main() func(); return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/main.c b/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/main.c index 16b0221e740..ee9ba95cb57 100644 --- a/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/main.c +++ b/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/main.c @@ -33,4 +33,4 @@ int main() } return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/main.c b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/main.c index a67cf750d5e..fa1cf231a50 100644 --- a/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/main.c +++ b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/main.c @@ -31,4 +31,4 @@ int main() } return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/main.c b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/main.c index d649b1dd056..88b4edcf448 100644 --- a/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/main.c +++ b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/main.c @@ -35,4 +35,4 @@ int main() } return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/main.c b/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/main.c index 189bd8c036d..38d09cfb14e 100644 --- a/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/main.c +++ b/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/main.c @@ -33,4 +33,4 @@ int main() } return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/no-match-const-fp-const-cast/main.c b/regression/goto-analyzer/no-match-const-fp-const-cast/main.c index f7fa7f41b42..b9bd141e6f0 100644 --- a/regression/goto-analyzer/no-match-const-fp-const-cast/main.c +++ b/regression/goto-analyzer/no-match-const-fp-const-cast/main.c @@ -32,4 +32,4 @@ int main() func(); return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/no-match-const-fp-const-fp-null/main.c b/regression/goto-analyzer/no-match-const-fp-const-fp-null/main.c index 4b8ba72dd51..67c501302a6 100644 --- a/regression/goto-analyzer/no-match-const-fp-const-fp-null/main.c +++ b/regression/goto-analyzer/no-match-const-fp-const-fp-null/main.c @@ -28,4 +28,4 @@ int main() func(); return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/no-match-const-fp-const-lost/main.c b/regression/goto-analyzer/no-match-const-fp-const-lost/main.c index edeca0d3f79..d2724684066 100644 --- a/regression/goto-analyzer/no-match-const-fp-const-lost/main.c +++ b/regression/goto-analyzer/no-match-const-fp-const-lost/main.c @@ -32,4 +32,4 @@ int main() func(); return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/main.c b/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/main.c index 1420490b0a6..3f55ff255dd 100644 --- a/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/main.c +++ b/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/main.c @@ -44,4 +44,4 @@ int main() } return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/no-match-const-fp-dereference-const-pointer-null/main.c b/regression/goto-analyzer/no-match-const-fp-dereference-const-pointer-null/main.c index b384b87bb4e..e4048adb8cb 100644 --- a/regression/goto-analyzer/no-match-const-fp-dereference-const-pointer-null/main.c +++ b/regression/goto-analyzer/no-match-const-fp-dereference-const-pointer-null/main.c @@ -33,4 +33,4 @@ int main() func(); return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/main.c b/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/main.c index f9750966b58..30e4947c2d7 100644 --- a/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/main.c +++ b/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/main.c @@ -37,4 +37,4 @@ int main() func(); return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/no-match-const-fp-dynamic-array-non-const-fp/main.c b/regression/goto-analyzer/no-match-const-fp-dynamic-array-non-const-fp/main.c index f468113ac16..d7d4820d29c 100644 --- a/regression/goto-analyzer/no-match-const-fp-dynamic-array-non-const-fp/main.c +++ b/regression/goto-analyzer/no-match-const-fp-dynamic-array-non-const-fp/main.c @@ -36,4 +36,4 @@ int main() func(); return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/no-match-const-fp-non-const-fp-direct-assignment/main.c b/regression/goto-analyzer/no-match-const-fp-non-const-fp-direct-assignment/main.c index 98c7f0619b6..6c9ba5514e7 100644 --- a/regression/goto-analyzer/no-match-const-fp-non-const-fp-direct-assignment/main.c +++ b/regression/goto-analyzer/no-match-const-fp-non-const-fp-direct-assignment/main.c @@ -29,4 +29,4 @@ int main() func(); return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/main.c b/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/main.c index 1da907916bd..bb40b1a53c1 100644 --- a/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/main.c +++ b/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/main.c @@ -44,4 +44,4 @@ int main() } return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/main.c b/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/main.c index 3952169b535..ed86d4c39c6 100644 --- a/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/main.c +++ b/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/main.c @@ -40,4 +40,4 @@ int main() } return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/main.c b/regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/main.c index 9c1af7d8d83..7d8b2584388 100644 --- a/regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/main.c +++ b/regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/main.c @@ -40,4 +40,4 @@ int main() } return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/no-match-const-fp-null/main.c b/regression/goto-analyzer/no-match-const-fp-null/main.c index 98a0349ce37..16c65f9f845 100644 --- a/regression/goto-analyzer/no-match-const-fp-null/main.c +++ b/regression/goto-analyzer/no-match-const-fp-null/main.c @@ -27,4 +27,4 @@ int main() func(); return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/main.c b/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/main.c index f626942ef8b..bf4bb45d094 100644 --- a/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/main.c +++ b/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/main.c @@ -40,4 +40,4 @@ int main() } return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/test.desc b/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/test.desc index 80169b619fa..2760fadd576 100644 --- a/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/test.desc @@ -14,4 +14,4 @@ main.c ^\s*IF pts->go == f9 THEN GOTO [0-9]$ ^SIGNAL=0$ -- -^warning: ignoring \ No newline at end of file +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-struct-non-const-fp-null/main.c b/regression/goto-analyzer/no-match-const-struct-non-const-fp-null/main.c index 569870b6609..6e24a0d8d4c 100644 --- a/regression/goto-analyzer/no-match-const-struct-non-const-fp-null/main.c +++ b/regression/goto-analyzer/no-match-const-struct-non-const-fp-null/main.c @@ -37,4 +37,4 @@ int main() } return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/no-match-non-const-fp-const-fp-direct-assignment/main.c b/regression/goto-analyzer/no-match-non-const-fp-const-fp-direct-assignment/main.c index a9a31b98a70..4487db8b047 100644 --- a/regression/goto-analyzer/no-match-non-const-fp-const-fp-direct-assignment/main.c +++ b/regression/goto-analyzer/no-match-non-const-fp-const-fp-direct-assignment/main.c @@ -30,4 +30,4 @@ int main() func(); return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/no-match-non-const-fp/main.c b/regression/goto-analyzer/no-match-non-const-fp/main.c index a5d81d9959d..80c8c863ff5 100644 --- a/regression/goto-analyzer/no-match-non-const-fp/main.c +++ b/regression/goto-analyzer/no-match-non-const-fp/main.c @@ -28,4 +28,4 @@ int main() func(); return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/no-match-parameter-const-fp/main.c b/regression/goto-analyzer/no-match-parameter-const-fp/main.c index 340373af407..23e73aabdc0 100644 --- a/regression/goto-analyzer/no-match-parameter-const-fp/main.c +++ b/regression/goto-analyzer/no-match-parameter-const-fp/main.c @@ -29,4 +29,4 @@ int main() } return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/no-match-parameter-fp/main.c b/regression/goto-analyzer/no-match-parameter-fp/main.c index fe392e11f0e..332df257368 100644 --- a/regression/goto-analyzer/no-match-parameter-fp/main.c +++ b/regression/goto-analyzer/no-match-parameter-fp/main.c @@ -29,4 +29,4 @@ int main() } return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/precise-array-calculation-const-fp/main.c b/regression/goto-analyzer/precise-array-calculation-const-fp/main.c index be8d02bff78..a61d95186aa 100644 --- a/regression/goto-analyzer/precise-array-calculation-const-fp/main.c +++ b/regression/goto-analyzer/precise-array-calculation-const-fp/main.c @@ -29,4 +29,4 @@ int main() func(); return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/precise-array-literal-const-fp/main.c b/regression/goto-analyzer/precise-array-literal-const-fp/main.c index 31cc52a7403..55dab779802 100644 --- a/regression/goto-analyzer/precise-array-literal-const-fp/main.c +++ b/regression/goto-analyzer/precise-array-literal-const-fp/main.c @@ -28,4 +28,4 @@ int main() func(); return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/precise-const-fp-array-const-variable-const-fp/main.c b/regression/goto-analyzer/precise-const-fp-array-const-variable-const-fp/main.c index a43a189f96f..c2465dcb695 100644 --- a/regression/goto-analyzer/precise-const-fp-array-const-variable-const-fp/main.c +++ b/regression/goto-analyzer/precise-const-fp-array-const-variable-const-fp/main.c @@ -30,4 +30,4 @@ int main() func(); return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/precise-const-fp-array-literal-const-fp-run-time/main.c b/regression/goto-analyzer/precise-const-fp-array-literal-const-fp-run-time/main.c index 36e4da04ddf..59d51313fde 100644 --- a/regression/goto-analyzer/precise-const-fp-array-literal-const-fp-run-time/main.c +++ b/regression/goto-analyzer/precise-const-fp-array-literal-const-fp-run-time/main.c @@ -29,4 +29,4 @@ int main() { func(); return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/precise-const-fp-array-literal-const-fp/main.c b/regression/goto-analyzer/precise-const-fp-array-literal-const-fp/main.c index d061734174f..2e9cb8cc4df 100644 --- a/regression/goto-analyzer/precise-const-fp-array-literal-const-fp/main.c +++ b/regression/goto-analyzer/precise-const-fp-array-literal-const-fp/main.c @@ -29,4 +29,4 @@ int main() func(); return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/precise-const-fp-array-variable-const-pointer-const-struct-non-const-fp/main.c b/regression/goto-analyzer/precise-const-fp-array-variable-const-pointer-const-struct-non-const-fp/main.c index c1bcb0dc951..c61a7a32499 100644 --- a/regression/goto-analyzer/precise-const-fp-array-variable-const-pointer-const-struct-non-const-fp/main.c +++ b/regression/goto-analyzer/precise-const-fp-array-variable-const-pointer-const-struct-non-const-fp/main.c @@ -46,4 +46,4 @@ int main() } return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/precise-const-fp-const-fp/main.c b/regression/goto-analyzer/precise-const-fp-const-fp/main.c index d3a61d828e1..a1efb8e0934 100644 --- a/regression/goto-analyzer/precise-const-fp-const-fp/main.c +++ b/regression/goto-analyzer/precise-const-fp-const-fp/main.c @@ -28,4 +28,4 @@ int main() func(); return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/main.c b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/main.c index 5cf1602c854..bc4ffead00e 100644 --- a/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/main.c +++ b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/main.c @@ -42,4 +42,4 @@ int main() func(); return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/precise-const-fp-const-struct-non-const-fp/main.c b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-fp/main.c index 02cbb17f851..7c3bed93919 100644 --- a/regression/goto-analyzer/precise-const-fp-const-struct-non-const-fp/main.c +++ b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-fp/main.c @@ -41,4 +41,4 @@ int main() } return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/main.c b/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/main.c index c18a7fe3256..efeb3b35d80 100644 --- a/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/main.c +++ b/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/main.c @@ -33,4 +33,4 @@ int main() func(); return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/precise-const-fp/main.c b/regression/goto-analyzer/precise-const-fp/main.c index f4d21dc2588..b4002c94e5e 100644 --- a/regression/goto-analyzer/precise-const-fp/main.c +++ b/regression/goto-analyzer/precise-const-fp/main.c @@ -27,4 +27,4 @@ int main() func(); return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/precise-const-struct-non-const-fp/main.c b/regression/goto-analyzer/precise-const-struct-non-const-fp/main.c index aa534a96e93..150ea314914 100644 --- a/regression/goto-analyzer/precise-const-struct-non-const-fp/main.c +++ b/regression/goto-analyzer/precise-const-struct-non-const-fp/main.c @@ -37,4 +37,4 @@ int main() } return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/main.c b/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/main.c index 1e2fd83fd6b..78901cc6405 100644 --- a/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/main.c +++ b/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/main.c @@ -32,4 +32,4 @@ int main() func(); return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/precise-derefence/main.c b/regression/goto-analyzer/precise-derefence/main.c index 318676c712e..d3bc8a2bc35 100644 --- a/regression/goto-analyzer/precise-derefence/main.c +++ b/regression/goto-analyzer/precise-derefence/main.c @@ -28,4 +28,4 @@ int main() func(); return 0; -} \ No newline at end of file +} diff --git a/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/main.c b/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/main.c index 56a7a7d7c4e..e0246369f7b 100644 --- a/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/main.c +++ b/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/main.c @@ -27,4 +27,4 @@ int main() func(); return 0; -} \ No newline at end of file +} From 29e7e0de382778dc341bf4858e2cd1f76964d0cd Mon Sep 17 00:00:00 2001 From: thk123 Date: Mon, 20 Mar 2017 12:57:23 +0000 Subject: [PATCH 047/116] Split out the const check into own analysis Created a standalone class to check whether a prgram contains a cast that loses the const-ness of something that would allow modifying a constant value (i.e. undefinied behaviour). --- src/analyses/Makefile | 4 +- src/analyses/does_remove_const.cpp | 138 ++++++++++++++++++ src/analyses/does_remove_const.h | 29 ++++ .../remove_function_pointers.cpp | 113 +------------- 4 files changed, 173 insertions(+), 111 deletions(-) create mode 100644 src/analyses/does_remove_const.cpp create mode 100644 src/analyses/does_remove_const.h diff --git a/src/analyses/Makefile b/src/analyses/Makefile index 89f14e4f768..e05d5be0c42 100644 --- a/src/analyses/Makefile +++ b/src/analyses/Makefile @@ -6,7 +6,9 @@ SRC = natural_loops.cpp is_threaded.cpp dirty.cpp interval_analysis.cpp \ local_bitvector_analysis.cpp dependence_graph.cpp \ constant_propagator.cpp replace_symbol_ext.cpp \ flow_insensitive_analysis.cpp \ - custom_bitvector_analysis.cpp escape_analysis.cpp global_may_alias.cpp + custom_bitvector_analysis.cpp escape_analysis.cpp global_may_alias.cpp \ + does_remove_const.cpp \ + # Empty last line INCLUDES= -I .. diff --git a/src/analyses/does_remove_const.cpp b/src/analyses/does_remove_const.cpp new file mode 100644 index 00000000000..75d520b6937 --- /dev/null +++ b/src/analyses/does_remove_const.cpp @@ -0,0 +1,138 @@ +/*******************************************************************\ + + Module: Analyses + + Author: DiffBlue Limited. All rights reserved. + +\*******************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include "does_remove_const.h" + +/*******************************************************************\ + +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): + goto_program(goto_program), + ns(ns) +{} + +/*******************************************************************\ + +Function: does_remove_constt::operator() + + Inputs: + + Outputs: Returns true if the pgroam 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 : + goto_program.instructions) + { + if(instruction.is_assign()) + { + const code_assignt assign=to_code_assign(instruction.code); + const typet &rhs_type=assign.rhs().type(); + const typet &lhs_type=assign.lhs().type(); + + // Compare the types recursively for a point where the rhs is more + // const that the lhs + if(!is_type_at_least_as_const_as(lhs_type, rhs_type)) + { + return true; + } + + // see if the rhs loses const inside the expression tree + exprt rhs=assign.rhs(); + while(!rhs.operands().empty()) + { + typet &pre_op_type=rhs.type(); + typet &post_op_type=rhs.op0().type(); + + // Types equality does not check, for example, const-ness + // If this is true, then this expression only modified the + // type by some qualifier (or not at all) + if(base_type_eq(pre_op_type, post_op_type, ns)) + { + if(!is_type_at_least_as_const_as(pre_op_type, post_op_type)) + { + return true; + } + } + rhs=rhs.op0(); + } + } + } + + return false; +} + +/*******************************************************************\ + +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( + typet type_more_const, typet type_compare) const +{ + while(!type_compare.id().empty() && !type_more_const.id().empty()) + { + const c_qualifierst rhs_qualifiers(type_compare); + const c_qualifierst lhs_qualifiers(type_more_const); + if(rhs_qualifiers.is_constant && !lhs_qualifiers.is_constant) + { + return false; + } + + type_compare=type_compare.subtype(); + type_more_const=type_more_const.subtype(); + } + + // Both the types should have the same number of subtypes + assert(type_compare.id().empty() && type_more_const.id().empty()); + return true; +} diff --git a/src/analyses/does_remove_const.h b/src/analyses/does_remove_const.h new file mode 100644 index 00000000000..98a09a0eca6 --- /dev/null +++ b/src/analyses/does_remove_const.h @@ -0,0 +1,29 @@ +/*******************************************************************\ + + Module: Analyses + + Author: DiffBlue Limited. All rights reserved. + +\*******************************************************************/ +#ifndef CPROVER_ANALYSES_DOES_REMOVE_CONST_H +#define CPROVER_ANALYSES_DOES_REMOVE_CONST_H + +#include + +class goto_programt; + +class does_remove_constt +{ +public: + does_remove_constt(const goto_programt &goto_program, const namespacet &ns); + bool operator()() const; + +private: + bool is_type_at_least_as_const_as( + typet type_more_const, typet type_compare) const; + + const goto_programt &goto_program; + const namespacet &ns; +}; + +#endif // CPROVER_ANALYSES_DOES_REMOVE_CONST_H diff --git a/src/goto-programs/remove_function_pointers.cpp b/src/goto-programs/remove_function_pointers.cpp index dd20bedeb6d..021c63148be 100644 --- a/src/goto-programs/remove_function_pointers.cpp +++ b/src/goto-programs/remove_function_pointers.cpp @@ -17,6 +17,7 @@ Author: Daniel Kroening, kroening@kroening.com #include #include #include +#include #include @@ -64,11 +65,6 @@ class remove_function_pointerst:public messaget goto_programt &goto_program, goto_programt::targett target); - bool does_program_contain_const_removal_cast( - const goto_programt &goto_program); - - bool is_type_at_least_as_const_as(typet type_more_const, typet type_compare); - std::set address_taken; typedef std::map type_mapt; @@ -364,7 +360,8 @@ void remove_function_pointerst::remove_function_pointer( const exprt &pointer=function.op0(); remove_const_function_pointerst::functionst functions; - if(does_program_contain_const_removal_cast(goto_program)) + does_remove_constt const_removal_check(goto_program, ns); + if(const_removal_check()) { warning() << "Cast from const to non-const pointer found, only worst case" << " function pointer removal will be done." << eom; @@ -513,110 +510,6 @@ void remove_function_pointerst::remove_function_pointer( /*******************************************************************\ -Function: remove_function_pointerst::does_program_contain_const_removal_cast - - Inputs: - goto_program - the goto program to check - - Outputs: Returns true if any instruction in the code casts away either - explicitly or implicitly the const qualifier of a type. - - Purpose: A naive check to look for casts that remove const-ness from - pointers. If this is present, then our remove_const_function_pointerst - is not sound so we don't allow it. - -\*******************************************************************/ - -bool remove_function_pointerst::does_program_contain_const_removal_cast( - const goto_programt &goto_program) -{ - for(const goto_programt::instructiont &instruction : - goto_program.instructions) - { - if(instruction.is_assign()) - { - const code_assignt assign=to_code_assign(instruction.code); - typet rhs_type=assign.rhs().type(); - typet lhs_type=assign.lhs().type(); - - // Compare the types recursively for a point where the rhs is more - // const that the lhs - if(!is_type_at_least_as_const_as(lhs_type, rhs_type)) - { - return true; - } - - // see if the rhs loses const inside the expression tree - exprt rhs=assign.rhs(); - while(!rhs.operands().empty()) - { - typet &pre_op_type=rhs.type(); - typet &post_op_type=rhs.op0().type(); - - // Types equality does not check, for example, const-ness - // If this is true, then this expression only modified the - // type by some qualifier (or not at all) - if(base_type_eq(pre_op_type, post_op_type, ns)) - { - if(!is_type_at_least_as_const_as(pre_op_type, post_op_type)) - { - return true; - } - } - rhs=rhs.op0(); - } - } - } - - return false; -} - -/*******************************************************************\ - -Function: remove_function_pointerst::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 remove_function_pointerst::is_type_at_least_as_const_as( - typet type_more_const, typet type_compare) -{ - while(!type_compare.id().empty() && !type_more_const.id().empty()) - { - const c_qualifierst rhs_qualifiers(type_compare); - const c_qualifierst lhs_qualifiers(type_more_const); - if(rhs_qualifiers.is_constant && !lhs_qualifiers.is_constant) - { - return false; - } - - type_compare=type_compare.subtype(); - type_more_const=type_more_const.subtype(); - } - - // Both the types should have the same number of subtypes - assert(type_compare.id()=="" && type_more_const.id()==""); - return true; -} - -/*******************************************************************\ - Function: remove_function_pointerst::remove_function_pointers Inputs: From 649e0bf252e9ca1ddf8c587cc1e7c856c0b3c586 Mon Sep 17 00:00:00 2001 From: thk123 Date: Tue, 21 Mar 2017 14:25:31 +0000 Subject: [PATCH 048/116] Descend all children of the same base type When we are checking for loss of const qualifiers, we need to check all children that are the same basic type to see if their qualification is lost in their parent. --- .../main.c | 41 ++++++++++++ .../test.desc | 16 +++++ .../main.c | 35 ++++++++++ .../test.desc | 16 +++++ .../main.c | 40 ++++++++++++ .../test.desc | 16 +++++ .../no-match-const-fp-const-array-lost/main.c | 40 ++++++++++++ .../test.desc | 16 +++++ .../main.c | 36 +++++++++++ .../test.desc | 16 +++++ src/analyses/does_remove_const.cpp | 64 +++++++++++++------ src/analyses/does_remove_const.h | 2 + 12 files changed, 320 insertions(+), 18 deletions(-) create mode 100644 regression/goto-analyzer/no-match-const-array-const-pointer-const-fp-const-lost/main.c create mode 100644 regression/goto-analyzer/no-match-const-array-const-pointer-const-fp-const-lost/test.desc create mode 100644 regression/goto-analyzer/no-match-const-fp-binary-op-const-lost/main.c create mode 100644 regression/goto-analyzer/no-match-const-fp-binary-op-const-lost/test.desc create mode 100644 regression/goto-analyzer/no-match-const-fp-const-array-index-lost/main.c create mode 100644 regression/goto-analyzer/no-match-const-fp-const-array-index-lost/test.desc create mode 100644 regression/goto-analyzer/no-match-const-fp-const-array-lost/main.c create mode 100644 regression/goto-analyzer/no-match-const-fp-const-array-lost/test.desc create mode 100644 regression/goto-analyzer/no-match-const-fp-ternerary-op-const-lost/main.c create mode 100644 regression/goto-analyzer/no-match-const-fp-ternerary-op-const-lost/test.desc diff --git a/regression/goto-analyzer/no-match-const-array-const-pointer-const-fp-const-lost/main.c b/regression/goto-analyzer/no-match-const-array-const-pointer-const-fp-const-lost/main.c new file mode 100644 index 00000000000..a17acab6166 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-array-const-pointer-const-fp-const-lost/main.c @@ -0,0 +1,41 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp start_fp = f2; + const void_fp * const fp_tbl[] = { &start_fp, &start_fp, &start_fp }; + + // warning: loses const + void_fp * arr_ptr=fp_tbl[0]; + (*arr_ptr) = f5; + arr_ptr++; + (*arr_ptr) = f5; + + const void_fp * const fp = fp_tbl[1]; + + + (*fp)(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-analyzer/no-match-const-array-const-pointer-const-fp-const-lost/test.desc b/regression/goto-analyzer/no-match-const-array-const-pointer-const-fp-const-lost/test.desc new file mode 100644 index 00000000000..9ac0520abde --- /dev/null +++ b/regression/goto-analyzer/no-match-const-array-const-pointer-const-fp-const-lost/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check + +^Removing function pointers and virtual functions$ +^\s*IF \*fp == f1 THEN GOTO [0-9]$ +^\s*IF \*fp == f2 THEN GOTO [0-9]$ +^\s*IF \*fp == f3 THEN GOTO [0-9]$ +^\s*IF \*fp == f4 THEN GOTO [0-9]$ +^\s*IF \*fp == f5 THEN GOTO [0-9]$ +^\s*IF \*fp == f6 THEN GOTO [0-9]$ +^\s*IF \*fp == f7 THEN GOTO [0-9]$ +^\s*IF \*fp == f8 THEN GOTO [0-9]$ +^\s*IF \*fp == f9 THEN GOTO [0-9]$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-binary-op-const-lost/main.c b/regression/goto-analyzer/no-match-const-fp-binary-op-const-lost/main.c new file mode 100644 index 00000000000..7f5c0ea3755 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-binary-op-const-lost/main.c @@ -0,0 +1,35 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp = f2; + + // Warning: this loses const-ness of f2 + void_fp * p2fp = 0 + ((void_fp*)&fp); + *p2fp = &f4; + + fp(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-analyzer/no-match-const-fp-binary-op-const-lost/test.desc b/regression/goto-analyzer/no-match-const-fp-binary-op-const-lost/test.desc new file mode 100644 index 00000000000..e8357d911c6 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-binary-op-const-lost/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check + +^Removing function pointers and virtual functions$ +^\s*IF fp == f1 THEN GOTO [0-9]$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^\s*IF fp == f5 THEN GOTO [0-9]$ +^\s*IF fp == f6 THEN GOTO [0-9]$ +^\s*IF fp == f7 THEN GOTO [0-9]$ +^\s*IF fp == f8 THEN GOTO [0-9]$ +^\s*IF fp == f9 THEN GOTO [0-9]$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-const-array-index-lost/main.c b/regression/goto-analyzer/no-match-const-fp-const-array-index-lost/main.c new file mode 100644 index 00000000000..b3dafeff777 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-const-array-index-lost/main.c @@ -0,0 +1,40 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp_tbl[] = {f2, f3 ,f4}; + + // warning: loses const + void_fp * arr_ptr=&fp_tbl[0]; + (*arr_ptr) = f5; + arr_ptr++; + (*arr_ptr) = f5; + + const void_fp * const fp = &fp_tbl[1]; + + + (*fp)(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-analyzer/no-match-const-fp-const-array-index-lost/test.desc b/regression/goto-analyzer/no-match-const-fp-const-array-index-lost/test.desc new file mode 100644 index 00000000000..9ac0520abde --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-const-array-index-lost/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check + +^Removing function pointers and virtual functions$ +^\s*IF \*fp == f1 THEN GOTO [0-9]$ +^\s*IF \*fp == f2 THEN GOTO [0-9]$ +^\s*IF \*fp == f3 THEN GOTO [0-9]$ +^\s*IF \*fp == f4 THEN GOTO [0-9]$ +^\s*IF \*fp == f5 THEN GOTO [0-9]$ +^\s*IF \*fp == f6 THEN GOTO [0-9]$ +^\s*IF \*fp == f7 THEN GOTO [0-9]$ +^\s*IF \*fp == f8 THEN GOTO [0-9]$ +^\s*IF \*fp == f9 THEN GOTO [0-9]$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-const-array-lost/main.c b/regression/goto-analyzer/no-match-const-fp-const-array-lost/main.c new file mode 100644 index 00000000000..d27da78d0b7 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-const-array-lost/main.c @@ -0,0 +1,40 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp_tbl[] = {f2, f3 ,f4}; + + // warning: loses const + void_fp * arr_ptr=fp_tbl; + (*arr_ptr) = f5; + arr_ptr++; + (*arr_ptr) = f5; + + const void_fp * const fp = &fp_tbl[1]; + + + (*fp)(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-analyzer/no-match-const-fp-const-array-lost/test.desc b/regression/goto-analyzer/no-match-const-fp-const-array-lost/test.desc new file mode 100644 index 00000000000..9ac0520abde --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-const-array-lost/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check + +^Removing function pointers and virtual functions$ +^\s*IF \*fp == f1 THEN GOTO [0-9]$ +^\s*IF \*fp == f2 THEN GOTO [0-9]$ +^\s*IF \*fp == f3 THEN GOTO [0-9]$ +^\s*IF \*fp == f4 THEN GOTO [0-9]$ +^\s*IF \*fp == f5 THEN GOTO [0-9]$ +^\s*IF \*fp == f6 THEN GOTO [0-9]$ +^\s*IF \*fp == f7 THEN GOTO [0-9]$ +^\s*IF \*fp == f8 THEN GOTO [0-9]$ +^\s*IF \*fp == f9 THEN GOTO [0-9]$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-ternerary-op-const-lost/main.c b/regression/goto-analyzer/no-match-const-fp-ternerary-op-const-lost/main.c new file mode 100644 index 00000000000..ba5bcad694a --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-ternerary-op-const-lost/main.c @@ -0,0 +1,36 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int x) +{ + const void_fp fp = f2; + void_fp non_const_fp = f7; + + // Warning: this loses const-ness of f2 + void_fp * p2fp = x > 0 ? ((void_fp*)&fp) : &non_const_fp; + *p2fp = &f4; + + fp(); +} + +int main() +{ + func(1); + + return 0; +} diff --git a/regression/goto-analyzer/no-match-const-fp-ternerary-op-const-lost/test.desc b/regression/goto-analyzer/no-match-const-fp-ternerary-op-const-lost/test.desc new file mode 100644 index 00000000000..e8357d911c6 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-ternerary-op-const-lost/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check + +^Removing function pointers and virtual functions$ +^\s*IF fp == f1 THEN GOTO [0-9]$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^\s*IF fp == f5 THEN GOTO [0-9]$ +^\s*IF fp == f6 THEN GOTO [0-9]$ +^\s*IF fp == f7 THEN GOTO [0-9]$ +^\s*IF fp == f8 THEN GOTO [0-9]$ +^\s*IF fp == f9 THEN GOTO [0-9]$ +-- +^warning: ignoring diff --git a/src/analyses/does_remove_const.cpp b/src/analyses/does_remove_const.cpp index 75d520b6937..43c575838d3 100644 --- a/src/analyses/does_remove_const.cpp +++ b/src/analyses/does_remove_const.cpp @@ -43,7 +43,7 @@ Function: does_remove_constt::operator() Inputs: - Outputs: Returns true if the pgroam contains a const-removing cast + 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. @@ -68,24 +68,10 @@ bool does_remove_constt::operator()() const return true; } - // see if the rhs loses const inside the expression tree - exprt rhs=assign.rhs(); - while(!rhs.operands().empty()) + bool sub_expr_lose_const=does_expr_lose_const(assign.rhs()); + if(sub_expr_lose_const) { - typet &pre_op_type=rhs.type(); - typet &post_op_type=rhs.op0().type(); - - // Types equality does not check, for example, const-ness - // If this is true, then this expression only modified the - // type by some qualifier (or not at all) - if(base_type_eq(pre_op_type, post_op_type, ns)) - { - if(!is_type_at_least_as_const_as(pre_op_type, post_op_type)) - { - return true; - } - } - rhs=rhs.op0(); + return true; } } } @@ -95,6 +81,48 @@ bool does_remove_constt::operator()() const /*******************************************************************\ +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(); + + // Look in each child that has the same base type as the root + for(const exprt &op : expr.operands()) + { + const typet &op_type=op.type(); + if(base_type_eq(op_type, root_type, ns)) + { + // Is this child more const-qualified than the root + if(!is_type_at_least_as_const_as(root_type, op_type)) + { + return true; + } + } + + // Recursively check the children of this child + if(does_expr_lose_const(op)) + { + return true; + } + } + return false; +} + +/*******************************************************************\ + Function: does_remove_constt::is_type_at_least_as_const_as Inputs: diff --git a/src/analyses/does_remove_const.h b/src/analyses/does_remove_const.h index 98a09a0eca6..30add2aeee3 100644 --- a/src/analyses/does_remove_const.h +++ b/src/analyses/does_remove_const.h @@ -19,6 +19,8 @@ class does_remove_constt bool operator()() const; private: + bool does_expr_lose_const(const exprt &expr) const; + bool is_type_at_least_as_const_as( typet type_more_const, typet type_compare) const; From 4607e73e24dfd60423263c926f6c2ee6483fcbc8 Mon Sep 17 00:00:00 2001 From: thk123 Date: Wed, 22 Mar 2017 10:13:59 +0000 Subject: [PATCH 049/116] PR Feedback implementation Simplifying assert Simplify and reducing indentation by changing if branches with trivial else clauses into checking them first and bailing if condition not met. Corrected use of reference --- src/analyses/does_remove_const.cpp | 31 ++++++++++--------- .../remove_const_function_pointers.cpp | 26 ++++++---------- .../remove_function_pointers.cpp | 11 +++---- 3 files changed, 30 insertions(+), 38 deletions(-) diff --git a/src/analyses/does_remove_const.cpp b/src/analyses/does_remove_const.cpp index 43c575838d3..fc33d3dc973 100644 --- a/src/analyses/does_remove_const.cpp +++ b/src/analyses/does_remove_const.cpp @@ -55,24 +55,25 @@ bool does_remove_constt::operator()() const for(const goto_programt::instructiont &instruction : goto_program.instructions) { - if(instruction.is_assign()) + if(!instruction.is_assign()) { - const code_assignt assign=to_code_assign(instruction.code); - const typet &rhs_type=assign.rhs().type(); - const typet &lhs_type=assign.lhs().type(); + continue; + } - // Compare the types recursively for a point where the rhs is more - // const that the lhs - if(!is_type_at_least_as_const_as(lhs_type, rhs_type)) - { - return true; - } + const code_assignt &assign=to_code_assign(instruction.code); + const typet &rhs_type=assign.rhs().type(); + const typet &lhs_type=assign.lhs().type(); - bool sub_expr_lose_const=does_expr_lose_const(assign.rhs()); - if(sub_expr_lose_const) - { - return true; - } + // Compare the types recursively for a point where the rhs is more + // const that the lhs + if(!is_type_at_least_as_const_as(lhs_type, rhs_type)) + { + return true; + } + + if(does_expr_lose_const(assign.rhs())) + { + return true; } } diff --git a/src/goto-programs/remove_const_function_pointers.cpp b/src/goto-programs/remove_const_function_pointers.cpp index d43ac85d62a..c0a7d8d5380 100644 --- a/src/goto-programs/remove_const_function_pointers.cpp +++ b/src/goto-programs/remove_const_function_pointers.cpp @@ -501,7 +501,7 @@ Function: remove_const_function_pointerst::try_resolve_expression bool remove_const_function_pointerst::try_resolve_expression( const exprt &expr, expressionst &out_resolved_expression, bool &out_is_const) { - const exprt &simplified_expr=simplify_expr(expr, ns); + exprt simplified_expr=simplify_expr(expr, ns); bool resolved; expressionst resolved_expressions; bool is_resolved_expression_const; @@ -693,25 +693,19 @@ bool remove_const_function_pointerst::try_resolve_index_of( try_resolve_expression( array_entry, array_contents, is_entry_const); - if(resolved_value) - { - for(const exprt &resolved_array_entry : array_contents) - { - if(resolved_array_entry .is_zero()) - { - continue; - } - else - { - out_expressions.push_back(resolved_array_entry); - } - } - } - else + if(!resolved_value) { LOG("Failed to resolve array value", array_entry); return false; } + + for(const exprt &resolved_array_entry : array_contents) + { + if(!resolved_array_entry.is_zero()) + { + out_expressions.push_back(resolved_array_entry); + } + } } } } diff --git a/src/goto-programs/remove_function_pointers.cpp b/src/goto-programs/remove_function_pointers.cpp index 021c63148be..c67c834b2ce 100644 --- a/src/goto-programs/remove_function_pointers.cpp +++ b/src/goto-programs/remove_function_pointers.cpp @@ -374,13 +374,10 @@ void remove_function_pointerst::remove_function_pointer( found_functions=fpr(functions); - // Consistency checks - // Reported optimized function pointer call, but didn't find any functions - assert(!found_functions || !functions.empty()); - - // Reported didn't optimize function pointer call, but did find some - // functions to replace with - assert(found_functions || functions.empty()); + // Either found_functions is true therefore the functions should not + // be empty + // Or found_functions is false therefore the functions should be empty + assert(found_functions != functions.empty()); if(functions.size()==1) { From d7c15ae788f0429bbdc7f05f3750574316cd89b2 Mon Sep 17 00:00:00 2001 From: thk123 Date: Wed, 22 Mar 2017 10:27:10 +0000 Subject: [PATCH 050/116] Use pointers in is_type_at_least_as_const_as To avoid unnecessary temporary objects, use a pointer when checking for const preservation. Note we now need to compare the ID against NIL rather than the empty string since the non-const version of subtype returns a new irept with no id, but the const version returns the nil data structure. --- src/analyses/does_remove_const.cpp | 18 +++++++++--------- src/analyses/does_remove_const.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/analyses/does_remove_const.cpp b/src/analyses/does_remove_const.cpp index fc33d3dc973..fcccd8219c9 100644 --- a/src/analyses/does_remove_const.cpp +++ b/src/analyses/does_remove_const.cpp @@ -66,7 +66,7 @@ bool does_remove_constt::operator()() const // Compare the types recursively for a point where the rhs is more // const that the lhs - if(!is_type_at_least_as_const_as(lhs_type, rhs_type)) + if(!is_type_at_least_as_const_as(&lhs_type, &rhs_type)) { return true; } @@ -107,7 +107,7 @@ bool does_remove_constt::does_expr_lose_const(const exprt &expr) const if(base_type_eq(op_type, root_type, ns)) { // Is this child more const-qualified than the root - if(!is_type_at_least_as_const_as(root_type, op_type)) + if(!is_type_at_least_as_const_as(&root_type, &op_type)) { return true; } @@ -146,22 +146,22 @@ Function: does_remove_constt::is_type_at_least_as_const_as \*******************************************************************/ bool does_remove_constt::is_type_at_least_as_const_as( - typet type_more_const, typet type_compare) const + const typet *type_more_const, const typet *type_compare) const { - while(!type_compare.id().empty() && !type_more_const.id().empty()) + while(type_compare->id()!=ID_nil && type_more_const->id()!=ID_nil) { - const c_qualifierst rhs_qualifiers(type_compare); - const c_qualifierst lhs_qualifiers(type_more_const); + const c_qualifierst rhs_qualifiers(*type_compare); + const c_qualifierst lhs_qualifiers(*type_more_const); if(rhs_qualifiers.is_constant && !lhs_qualifiers.is_constant) { return false; } - type_compare=type_compare.subtype(); - type_more_const=type_more_const.subtype(); + type_compare=&type_compare->subtype(); + type_more_const=&type_more_const->subtype(); } // Both the types should have the same number of subtypes - assert(type_compare.id().empty() && type_more_const.id().empty()); + assert(type_compare->id()==ID_nil && type_more_const->id()==ID_nil); return true; } diff --git a/src/analyses/does_remove_const.h b/src/analyses/does_remove_const.h index 30add2aeee3..594682c7d50 100644 --- a/src/analyses/does_remove_const.h +++ b/src/analyses/does_remove_const.h @@ -22,7 +22,7 @@ class does_remove_constt bool does_expr_lose_const(const exprt &expr) const; bool is_type_at_least_as_const_as( - typet type_more_const, typet type_compare) const; + const typet *type_more_const, const typet *type_compare) const; const goto_programt &goto_program; const namespacet &ns; From 35356bda51458669224a54408022483d5f852151 Mon Sep 17 00:00:00 2001 From: thk123 Date: Wed, 14 Dec 2016 15:00:30 +0000 Subject: [PATCH 051/116] keep typedefs when dumping c with --use-system-headers --- src/ansi-c/ansi_c_declaration.cpp | 4 ++++ src/ansi-c/c_typecheck_type.cpp | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/ansi-c/ansi_c_declaration.cpp b/src/ansi-c/ansi_c_declaration.cpp index 4c82adc307a..6834298a40b 100644 --- a/src/ansi-c/ansi_c_declaration.cpp +++ b/src/ansi-c/ansi_c_declaration.cpp @@ -146,6 +146,10 @@ typet ansi_c_declarationt::full_type( *p=type(); + // retain typedef for dump-c + if(get_is_typedef()) + result.set(ID_typedef,declarator.get_name()); + return result; } diff --git a/src/ansi-c/c_typecheck_type.cpp b/src/ansi-c/c_typecheck_type.cpp index f875bdec7d4..909b254c611 100644 --- a/src/ansi-c/c_typecheck_type.cpp +++ b/src/ansi-c/c_typecheck_type.cpp @@ -52,6 +52,7 @@ void c_typecheck_baset::typecheck_type(typet &type) c_qualifiers+=c_qualifierst(type.subtype()); bool packed=type.get_bool(ID_C_packed); exprt alignment=static_cast(type.find(ID_C_alignment)); + irept _typedef=type.find(ID_typedef); type.swap(type.subtype()); @@ -60,6 +61,8 @@ void c_typecheck_baset::typecheck_type(typet &type) type.set(ID_C_packed, true); if(alignment.is_not_nil()) type.add(ID_C_alignment, alignment); + if(_typedef.is_not_nil()) + type.add(ID_typedef, _typedef); return; // done } From 08cf4ee55227be3959f5c34a1ba7a4c143df0d82 Mon Sep 17 00:00:00 2001 From: thk123 Date: Wed, 14 Dec 2016 17:10:50 +0000 Subject: [PATCH 052/116] Added initial collection of tests for typedef'd types Covers the basic cases of typedef-ing a normal type (int) --- regression/goto-instrument-typedef/Makefile | 31 +++++++++++++++++++ regression/goto-instrument-typedef/chain.sh | 13 ++++++++ .../typedef-type1/main.c | 8 +++++ .../typedef-type1/test.desc | 11 +++++++ .../typedef-type2/main.c | 10 ++++++ .../typedef-type2/test.desc | 12 +++++++ .../typedef-type3/main.c | 10 ++++++ .../typedef-type3/test.desc | 12 +++++++ 8 files changed, 107 insertions(+) create mode 100644 regression/goto-instrument-typedef/Makefile create mode 100755 regression/goto-instrument-typedef/chain.sh create mode 100644 regression/goto-instrument-typedef/typedef-type1/main.c create mode 100644 regression/goto-instrument-typedef/typedef-type1/test.desc create mode 100644 regression/goto-instrument-typedef/typedef-type2/main.c create mode 100644 regression/goto-instrument-typedef/typedef-type2/test.desc create mode 100644 regression/goto-instrument-typedef/typedef-type3/main.c create mode 100644 regression/goto-instrument-typedef/typedef-type3/test.desc diff --git a/regression/goto-instrument-typedef/Makefile b/regression/goto-instrument-typedef/Makefile new file mode 100644 index 00000000000..08fe97ae88c --- /dev/null +++ b/regression/goto-instrument-typedef/Makefile @@ -0,0 +1,31 @@ + +default: tests.log + +test: + @if ! ../test.pl -c ../chain.sh ; then \ + ../failed-tests-printer.pl ; \ + exit 1; \ + fi + +tests.log: + @if ! ../test.pl -c ../chain.sh ; then \ + ../failed-tests-printer.pl ; \ + exit 1; \ + fi + +show: + @for dir in *; do \ + if [ -d "$$dir" ]; then \ + vim -o "$$dir/*.c" "$$dir/*.out"; \ + fi; \ + done; + +clean: + @for dir in *; do \ + rm -f tests.log; \ + if [ -d "$$dir" ]; then \ + cd "$$dir"; \ + rm -f *.out *.gb; \ + cd ..; \ + fi \ + done diff --git a/regression/goto-instrument-typedef/chain.sh b/regression/goto-instrument-typedef/chain.sh new file mode 100755 index 00000000000..248ca155b8d --- /dev/null +++ b/regression/goto-instrument-typedef/chain.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +SRC=../../../src + +GC=$SRC/goto-cc/goto-cc +GI=$SRC/goto-instrument/goto-instrument + +OPTS=$1 +NAME=${2%.c} + +$GC $NAME.c --function fun -o $NAME.gb +echo $GI $OPTS $NAME.gb +$GI $OPTS $NAME.gb diff --git a/regression/goto-instrument-typedef/typedef-type1/main.c b/regression/goto-instrument-typedef/typedef-type1/main.c new file mode 100644 index 00000000000..43f028c7772 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-type1/main.c @@ -0,0 +1,8 @@ + +typedef int MYINT; + +void fun() +{ + int int_var = 3; + MYINT myint_var = 5; +} diff --git a/regression/goto-instrument-typedef/typedef-type1/test.desc b/regression/goto-instrument-typedef/typedef-type1/test.desc new file mode 100644 index 00000000000..7599f1759c0 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-type1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_var\nMode\.+: C\nType\.+: signed int +Base name\.+: myint_var\nMode\.+: C\nType\.+: MYINT +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-type2/main.c b/regression/goto-instrument-typedef/typedef-type2/main.c new file mode 100644 index 00000000000..acb1cce2da4 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-type2/main.c @@ -0,0 +1,10 @@ + +typedef int MYINT; +typedef int ALTINT; + +void fun() +{ + int int_var = 3; + MYINT myint_var = 5; + ALTINT altint_var = 7; +} diff --git a/regression/goto-instrument-typedef/typedef-type2/test.desc b/regression/goto-instrument-typedef/typedef-type2/test.desc new file mode 100644 index 00000000000..3cf1e50a5a5 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-type2/test.desc @@ -0,0 +1,12 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_var\nMode\.+: C\nType\.+: signed int +Base name\.+: myint_var\nMode\.+: C\nType\.+: MYINT +Base name\.+: altint_var\nMode\.+: C\nType\.+: ALTINT +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-type3/main.c b/regression/goto-instrument-typedef/typedef-type3/main.c new file mode 100644 index 00000000000..5855e0c24cb --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-type3/main.c @@ -0,0 +1,10 @@ + +typedef int MYINT; +typedef MYINT CHAINEDINT; + +void fun() +{ + int int_var = 3; + MYINT myint_var = 5; + CHAINEDINT chainedint_var = 5; +} diff --git a/regression/goto-instrument-typedef/typedef-type3/test.desc b/regression/goto-instrument-typedef/typedef-type3/test.desc new file mode 100644 index 00000000000..aca9069695c --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-type3/test.desc @@ -0,0 +1,12 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_var\nMode\.+: C\nType\.+: signed int +Base name\.+: myint_var\nMode\.+: C\nType\.+: MYINT +Base name\.+: chainedint_var\nMode\.+: C\nType\.+: CHAINEDINT +-- +warning: ignoring From 99067de178170a6ac42a2a412c859ad7e8690319 Mon Sep 17 00:00:00 2001 From: thk123 Date: Wed, 14 Dec 2016 17:12:13 +0000 Subject: [PATCH 053/116] If a type has a typedef then use that when printing the type --- src/ansi-c/expr2c.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ansi-c/expr2c.cpp b/src/ansi-c/expr2c.cpp index 86bd4183b91..4f31653d91a 100644 --- a/src/ansi-c/expr2c.cpp +++ b/src/ansi-c/expr2c.cpp @@ -232,6 +232,11 @@ std::string expr2ct::convert_rec( std::string d= declarator==""?declarator:" "+declarator; + if(src.find(ID_typedef).is_not_nil()) + { + return q+id2string(src.get(ID_typedef))+d; + } + if(src.id()==ID_bool) { return q+"_Bool"+d; From eb7e551c4b9d53f537f8733a5329febf156c55c5 Mon Sep 17 00:00:00 2001 From: thk123 Date: Thu, 15 Dec 2016 12:29:56 +0000 Subject: [PATCH 054/116] Adding tests for structs and parameters using typedefs --- .../typedef-anon-struct1/main.c | 11 ++++++++++ .../typedef-anon-struct1/test.desc | 10 ++++++++++ .../typedef-param-anon-struct1/main.c | 11 ++++++++++ .../typedef-param-anon-struct1/test.desc | 10 ++++++++++ .../typedef-param-struct1/main.c | 10 ++++++++++ .../typedef-param-struct1/test.desc | 11 ++++++++++ .../typedef-param-type1/main.c | 7 +++++++ .../typedef-param-type1/test.desc | 11 ++++++++++ .../typedef-param-type2/main.c | 8 ++++++++ .../typedef-param-type2/test.desc | 12 +++++++++++ .../typedef-param-type3/main.c | 7 +++++++ .../typedef-param-type3/test.desc | 12 +++++++++++ .../typedef-return-anon-struct1/main.c | 12 +++++++++++ .../typedef-return-anon-struct1/test.desc | 11 ++++++++++ .../typedef-return-struct1/main.c | 20 +++++++++++++++++++ .../typedef-return-struct1/test.desc | 11 ++++++++++ .../typedef-return-type1/main.c | 12 +++++++++++ .../typedef-return-type1/test.desc | 11 ++++++++++ .../typedef-return-type2/main.c | 13 ++++++++++++ .../typedef-return-type2/test.desc | 11 ++++++++++ .../typedef-return-type3/main.c | 12 +++++++++++ .../typedef-return-type3/test.desc | 10 ++++++++++ .../typedef-struct1/main.c | 12 +++++++++++ .../typedef-struct1/test.desc | 11 ++++++++++ 24 files changed, 266 insertions(+) create mode 100644 regression/goto-instrument-typedef/typedef-anon-struct1/main.c create mode 100644 regression/goto-instrument-typedef/typedef-anon-struct1/test.desc create mode 100644 regression/goto-instrument-typedef/typedef-param-anon-struct1/main.c create mode 100644 regression/goto-instrument-typedef/typedef-param-anon-struct1/test.desc create mode 100644 regression/goto-instrument-typedef/typedef-param-struct1/main.c create mode 100644 regression/goto-instrument-typedef/typedef-param-struct1/test.desc create mode 100644 regression/goto-instrument-typedef/typedef-param-type1/main.c create mode 100644 regression/goto-instrument-typedef/typedef-param-type1/test.desc create mode 100644 regression/goto-instrument-typedef/typedef-param-type2/main.c create mode 100644 regression/goto-instrument-typedef/typedef-param-type2/test.desc create mode 100644 regression/goto-instrument-typedef/typedef-param-type3/main.c create mode 100644 regression/goto-instrument-typedef/typedef-param-type3/test.desc create mode 100644 regression/goto-instrument-typedef/typedef-return-anon-struct1/main.c create mode 100644 regression/goto-instrument-typedef/typedef-return-anon-struct1/test.desc create mode 100644 regression/goto-instrument-typedef/typedef-return-struct1/main.c create mode 100644 regression/goto-instrument-typedef/typedef-return-struct1/test.desc create mode 100644 regression/goto-instrument-typedef/typedef-return-type1/main.c create mode 100644 regression/goto-instrument-typedef/typedef-return-type1/test.desc create mode 100644 regression/goto-instrument-typedef/typedef-return-type2/main.c create mode 100644 regression/goto-instrument-typedef/typedef-return-type2/test.desc create mode 100644 regression/goto-instrument-typedef/typedef-return-type3/main.c create mode 100644 regression/goto-instrument-typedef/typedef-return-type3/test.desc create mode 100644 regression/goto-instrument-typedef/typedef-struct1/main.c create mode 100644 regression/goto-instrument-typedef/typedef-struct1/test.desc diff --git a/regression/goto-instrument-typedef/typedef-anon-struct1/main.c b/regression/goto-instrument-typedef/typedef-anon-struct1/main.c new file mode 100644 index 00000000000..d1e7196a3b1 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-anon-struct1/main.c @@ -0,0 +1,11 @@ + +typedef struct +{ + int x; + float y; +} MYSTRUCT; + +void fun() +{ + MYSTRUCT mystruct_var = {.x = 3, .y = 2.1f}; +} diff --git a/regression/goto-instrument-typedef/typedef-anon-struct1/test.desc b/regression/goto-instrument-typedef/typedef-anon-struct1/test.desc new file mode 100644 index 00000000000..59aba0e01a6 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-anon-struct1/test.desc @@ -0,0 +1,10 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: mystruct_var\nMode\.+: C\nType\.+: MYSTRUCT +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-param-anon-struct1/main.c b/regression/goto-instrument-typedef/typedef-param-anon-struct1/main.c new file mode 100644 index 00000000000..e8f3fb8fd7c --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-param-anon-struct1/main.c @@ -0,0 +1,11 @@ + +typedef struct +{ + int x; + float y; +} MYSTRUCT; + +void fun(MYSTRUCT mystruct_param) +{ + +} diff --git a/regression/goto-instrument-typedef/typedef-param-anon-struct1/test.desc b/regression/goto-instrument-typedef/typedef-param-anon-struct1/test.desc new file mode 100644 index 00000000000..537526b4422 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-param-anon-struct1/test.desc @@ -0,0 +1,10 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: mystruct_param\nMode\.+: C\nType\.+: MYSTRUCT +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-param-struct1/main.c b/regression/goto-instrument-typedef/typedef-param-struct1/main.c new file mode 100644 index 00000000000..a358c15a030 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-param-struct1/main.c @@ -0,0 +1,10 @@ + +typedef struct tag_struct_name +{ + int x; + float y; +} MYSTRUCT; + +void fun(struct tag_struct_name tag_struct_param, MYSTRUCT mystruct_param) +{ +} diff --git a/regression/goto-instrument-typedef/typedef-param-struct1/test.desc b/regression/goto-instrument-typedef/typedef-param-struct1/test.desc new file mode 100644 index 00000000000..c26ee458459 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-param-struct1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_struct_param\nMode\.+: C\nType\.+: struct tag_struct_name +Base name\.+: mystruct_param\nMode\.+: C\nType\.+: MYSTRUCT +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-param-type1/main.c b/regression/goto-instrument-typedef/typedef-param-type1/main.c new file mode 100644 index 00000000000..b4c915066b6 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-param-type1/main.c @@ -0,0 +1,7 @@ + +typedef int MYINT; + +void fun(int int_param, MYINT myint_param) +{ + +} diff --git a/regression/goto-instrument-typedef/typedef-param-type1/test.desc b/regression/goto-instrument-typedef/typedef-param-type1/test.desc new file mode 100644 index 00000000000..050ac22b315 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-param-type1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_param\nMode\.+: C\nType\.+: signed int +Base name\.+: myint_param\nMode\.+: C\nType\.+: MYINT +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-param-type2/main.c b/regression/goto-instrument-typedef/typedef-param-type2/main.c new file mode 100644 index 00000000000..b5974fb6bbb --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-param-type2/main.c @@ -0,0 +1,8 @@ + +typedef int MYINT; +typedef int ALTINT; + +void fun(int int_param, MYINT myint_param, ALTINT altint_param) +{ + +} diff --git a/regression/goto-instrument-typedef/typedef-param-type2/test.desc b/regression/goto-instrument-typedef/typedef-param-type2/test.desc new file mode 100644 index 00000000000..53cdc42193e --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-param-type2/test.desc @@ -0,0 +1,12 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_param\nMode\.+: C\nType\.+: signed int +Base name\.+: myint_param\nMode\.+: C\nType\.+: MYINT +Base name\.+: altint_param\nMode\.+: C\nType\.+: ALTINT +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-param-type3/main.c b/regression/goto-instrument-typedef/typedef-param-type3/main.c new file mode 100644 index 00000000000..4d542e10c13 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-param-type3/main.c @@ -0,0 +1,7 @@ + +typedef int MYINT; +typedef MYINT CHAINEDINT; + +void fun(int int_param, MYINT myint_param, CHAINEDINT chainedint_param) +{ +} diff --git a/regression/goto-instrument-typedef/typedef-param-type3/test.desc b/regression/goto-instrument-typedef/typedef-param-type3/test.desc new file mode 100644 index 00000000000..6ba9d61f8ca --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-param-type3/test.desc @@ -0,0 +1,12 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_param\nMode\.+: C\nType\.+: signed int +Base name\.+: myint_param\nMode\.+: C\nType\.+: MYINT +Base name\.+: chainedint_param\nMode\.+: C\nType\.+: CHAINEDINT +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-return-anon-struct1/main.c b/regression/goto-instrument-typedef/typedef-return-anon-struct1/main.c new file mode 100644 index 00000000000..0195b955cdd --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-return-anon-struct1/main.c @@ -0,0 +1,12 @@ + +typedef struct +{ + int x; + float y; +} MYSTRUCT; + +MYSTRUCT fun() +{ + MYSTRUCT return_variable = {.x = 1, .y = 3.14f}; + return return_variable; +} diff --git a/regression/goto-instrument-typedef/typedef-return-anon-struct1/test.desc b/regression/goto-instrument-typedef/typedef-return-anon-struct1/test.desc new file mode 100644 index 00000000000..47964f71f66 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-return-anon-struct1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: return\nMode\.+: C\nType\.+: MYSTRUCT +Base name\.+: fun\nMode\.+: C\nType\.+: MYSTRUCT \(\) +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-return-struct1/main.c b/regression/goto-instrument-typedef/typedef-return-struct1/main.c new file mode 100644 index 00000000000..30c1323555c --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-return-struct1/main.c @@ -0,0 +1,20 @@ + +typedef struct tag_struct_name +{ + int x; + float y; +} MYSTRUCT; + +struct tag_struct_name fun() +{ + struct tag_struct_name return_variable = { .x = 1, .y = 3.14f}; + return return_variable; +} + +MYSTRUCT fun2() +{ + MYSTRUCT return_variable = { .x = 1, .y = 3.14f}; + return return_variable; +} + + diff --git a/regression/goto-instrument-typedef/typedef-return-struct1/test.desc b/regression/goto-instrument-typedef/typedef-return-struct1/test.desc new file mode 100644 index 00000000000..eade5942ac8 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-return-struct1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: fun\nMode\.+: C\nType\.+: struct tag_struct_name \(\) +Base name\.+: fun2\nMode\.+: C\nType\.+: MYSTRUCT \(\) +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-return-type1/main.c b/regression/goto-instrument-typedef/typedef-return-type1/main.c new file mode 100644 index 00000000000..1ba7f426f89 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-return-type1/main.c @@ -0,0 +1,12 @@ + +typedef int MYINT; + +int fun() +{ + return 4; +} + +MYINT fun2() +{ + return 5; +} diff --git a/regression/goto-instrument-typedef/typedef-return-type1/test.desc b/regression/goto-instrument-typedef/typedef-return-type1/test.desc new file mode 100644 index 00000000000..ba1b96ce6b6 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-return-type1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: fun\nMode\.+: C\nType\.+: signed int \(\) +Base name\.+: fun2\nMode\.+: C\nType\.+: MYINT \(\) +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-return-type2/main.c b/regression/goto-instrument-typedef/typedef-return-type2/main.c new file mode 100644 index 00000000000..0d94ab54da3 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-return-type2/main.c @@ -0,0 +1,13 @@ + +typedef int MYINT; +typedef int ALTINT; + +MYINT fun() +{ + +} + +ALTINT fun2() +{ + +} diff --git a/regression/goto-instrument-typedef/typedef-return-type2/test.desc b/regression/goto-instrument-typedef/typedef-return-type2/test.desc new file mode 100644 index 00000000000..1ecc9ea8e90 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-return-type2/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: fun\nMode\.+: C\nType\.+: MYINT \(\) +Base name\.+: fun2\nMode\.+: C\nType\.+: ALTINT \(\) +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-return-type3/main.c b/regression/goto-instrument-typedef/typedef-return-type3/main.c new file mode 100644 index 00000000000..e246757c692 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-return-type3/main.c @@ -0,0 +1,12 @@ + +typedef int MYINT; +typedef MYINT CHAINEDINT; + +MYINT fun() +{ +} + +CHAINEDINT fun2() +{ + +} \ No newline at end of file diff --git a/regression/goto-instrument-typedef/typedef-return-type3/test.desc b/regression/goto-instrument-typedef/typedef-return-type3/test.desc new file mode 100644 index 00000000000..2401af3ce8d --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-return-type3/test.desc @@ -0,0 +1,10 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +Base name\.+: fun\nMode\.+: C\nType\.+: MYINT \(\) +Base name\.+: fun2\nMode\.+: C\nType\.+: CHAINEDINT \(\) +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-struct1/main.c b/regression/goto-instrument-typedef/typedef-struct1/main.c new file mode 100644 index 00000000000..dac5abf77b8 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-struct1/main.c @@ -0,0 +1,12 @@ + +typedef struct tag_struct_name +{ + int x; + float y; +} MYSTRUCT; + +void fun() +{ + struct tag_struct_name tag_struct_var = {.x = 1, .y = 3.14f}; + MYSTRUCT mystruct_var = {.x = 3, .y = 2.1f}; +} diff --git a/regression/goto-instrument-typedef/typedef-struct1/test.desc b/regression/goto-instrument-typedef/typedef-struct1/test.desc new file mode 100644 index 00000000000..6a02f2d2174 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-struct1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_struct_var\nMode\.+: C\nType\.+: struct tag_struct_name +Base name\.+: mystruct_var\nMode\.+: C\nType\.+: MYSTRUCT +-- +warning: ignoring From 0152f671316b24217bab8f15cb53cf3e7376e1cf Mon Sep 17 00:00:00 2001 From: thk123 Date: Fri, 16 Dec 2016 10:04:08 +0000 Subject: [PATCH 055/116] Improved chain.sh to remove old .gb files first Made the first step of the chain.sh remove the generated .gb file from previous runs. This ensures that if the goto-cc step fails, misleading results are not generated. --- regression/goto-instrument-typedef/chain.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/regression/goto-instrument-typedef/chain.sh b/regression/goto-instrument-typedef/chain.sh index 248ca155b8d..9cef4ffdfa4 100755 --- a/regression/goto-instrument-typedef/chain.sh +++ b/regression/goto-instrument-typedef/chain.sh @@ -8,6 +8,7 @@ GI=$SRC/goto-instrument/goto-instrument OPTS=$1 NAME=${2%.c} +rm $NAME.gb $GC $NAME.c --function fun -o $NAME.gb echo $GI $OPTS $NAME.gb $GI $OPTS $NAME.gb From e8dbc4086de7d78deeb107d8da526a63d51dafaa Mon Sep 17 00:00:00 2001 From: thk123 Date: Fri, 16 Dec 2016 10:51:26 +0000 Subject: [PATCH 056/116] Adding tests for union typedefs --- .../typedef-param-union1/main.c | 10 ++++++++++ .../typedef-param-union1/test.desc | 11 ++++++++++ .../typedef-return-union1/main.c | 20 +++++++++++++++++++ .../typedef-return-union1/test.desc | 11 ++++++++++ .../typedef-union1/main.c | 12 +++++++++++ .../typedef-union1/test.desc | 11 ++++++++++ 6 files changed, 75 insertions(+) create mode 100644 regression/goto-instrument-typedef/typedef-param-union1/main.c create mode 100644 regression/goto-instrument-typedef/typedef-param-union1/test.desc create mode 100644 regression/goto-instrument-typedef/typedef-return-union1/main.c create mode 100644 regression/goto-instrument-typedef/typedef-return-union1/test.desc create mode 100644 regression/goto-instrument-typedef/typedef-union1/main.c create mode 100644 regression/goto-instrument-typedef/typedef-union1/test.desc diff --git a/regression/goto-instrument-typedef/typedef-param-union1/main.c b/regression/goto-instrument-typedef/typedef-param-union1/main.c new file mode 100644 index 00000000000..8f961614e5d --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-param-union1/main.c @@ -0,0 +1,10 @@ + +typedef union tag_union_name +{ + int x; + float y; +} MYUNION; + +void fun(union tag_union_name tag_union_param, MYUNION myunion_param) +{ +} diff --git a/regression/goto-instrument-typedef/typedef-param-union1/test.desc b/regression/goto-instrument-typedef/typedef-param-union1/test.desc new file mode 100644 index 00000000000..466dd76ed52 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-param-union1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_union_param\nMode\.+: C\nType\.+: union tag_union_name +Base name\.+: myunion_param\nMode\.+: C\nType\.+: MYUNION +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-return-union1/main.c b/regression/goto-instrument-typedef/typedef-return-union1/main.c new file mode 100644 index 00000000000..ad69cb04545 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-return-union1/main.c @@ -0,0 +1,20 @@ + +typedef union tag_union_name +{ + int x; + float y; +} MYUNION; + +union tag_union_name fun() +{ + union tag_union_name return_variable = {1}; + return return_variable; +} + +MYUNION fun2() +{ + MYUNION return_variable = {1}; + return return_variable; +} + + diff --git a/regression/goto-instrument-typedef/typedef-return-union1/test.desc b/regression/goto-instrument-typedef/typedef-return-union1/test.desc new file mode 100644 index 00000000000..0855b28f479 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-return-union1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: fun\nMode\.+: C\nType\.+: union tag_union_name \(\) +Base name\.+: fun2\nMode\.+: C\nType\.+: MYUNION \(\) +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-union1/main.c b/regression/goto-instrument-typedef/typedef-union1/main.c new file mode 100644 index 00000000000..6f56f3c731b --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-union1/main.c @@ -0,0 +1,12 @@ + +typedef union tag_union_name +{ + int x; + float y; +} MYUNION; + +void fun() +{ + union tag_union_name tag_union_var = {1}; + MYUNION myunion_var = {.y = 2.1f}; +} diff --git a/regression/goto-instrument-typedef/typedef-union1/test.desc b/regression/goto-instrument-typedef/typedef-union1/test.desc new file mode 100644 index 00000000000..8502d149cb1 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-union1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_union_var\nMode\.+: C\nType\.+: union tag_union_name +Base name\.+: myunion_var\nMode\.+: C\nType\.+: MYUNION +-- +warning: ignoring From 5dd0c8a63cf871e12d6f5646ce276c8138d5b4ba Mon Sep 17 00:00:00 2001 From: thk123 Date: Fri, 16 Dec 2016 12:04:07 +0000 Subject: [PATCH 057/116] Adding const variables tests The tests relating to structs and unions are marked as known bugs as they are related to #355 --- .../typedef-const-struct1/main.c | 12 ++++++++++++ .../typedef-const-struct1/test.desc | 11 +++++++++++ .../typedef-const-type1/main.c | 8 ++++++++ .../typedef-const-type1/test.desc | 11 +++++++++++ .../typedef-const-union1/main.c | 12 ++++++++++++ .../typedef-const-union1/test.desc | 11 +++++++++++ 6 files changed, 65 insertions(+) create mode 100644 regression/goto-instrument-typedef/typedef-const-struct1/main.c create mode 100644 regression/goto-instrument-typedef/typedef-const-struct1/test.desc create mode 100644 regression/goto-instrument-typedef/typedef-const-type1/main.c create mode 100644 regression/goto-instrument-typedef/typedef-const-type1/test.desc create mode 100644 regression/goto-instrument-typedef/typedef-const-union1/main.c create mode 100644 regression/goto-instrument-typedef/typedef-const-union1/test.desc diff --git a/regression/goto-instrument-typedef/typedef-const-struct1/main.c b/regression/goto-instrument-typedef/typedef-const-struct1/main.c new file mode 100644 index 00000000000..ab8137e82e4 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-const-struct1/main.c @@ -0,0 +1,12 @@ + +typedef struct tag_struct_name +{ + int x; + float y; +} MYSTRUCT; + +void fun() +{ + const struct tag_struct_name tag_struct_var = {.x = 1, .y = 3.14f}; + const MYSTRUCT mystruct_var = {.x = 3, .y = 2.1f}; +} diff --git a/regression/goto-instrument-typedef/typedef-const-struct1/test.desc b/regression/goto-instrument-typedef/typedef-const-struct1/test.desc new file mode 100644 index 00000000000..a6aad1f799a --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-const-struct1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_struct_var\nMode\.+: C\nType\.+: const struct tag_struct_name +Base name\.+: mystruct_var\nMode\.+: C\nType\.+: const MYSTRUCT +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-const-type1/main.c b/regression/goto-instrument-typedef/typedef-const-type1/main.c new file mode 100644 index 00000000000..8cd4a4346eb --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-const-type1/main.c @@ -0,0 +1,8 @@ + +typedef int MYINT; + +void fun() +{ + const int int_var = 3; + const MYINT myint_var = 5; +} diff --git a/regression/goto-instrument-typedef/typedef-const-type1/test.desc b/regression/goto-instrument-typedef/typedef-const-type1/test.desc new file mode 100644 index 00000000000..481b097653f --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-const-type1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_var\nMode\.+: C\nType\.+: const signed int +Base name\.+: myint_var\nMode\.+: C\nType\.+: const MYINT +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-const-union1/main.c b/regression/goto-instrument-typedef/typedef-const-union1/main.c new file mode 100644 index 00000000000..b8defe635a6 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-const-union1/main.c @@ -0,0 +1,12 @@ + +typedef union tag_union_name +{ + int x; + float y; +} MYUNION; + +void fun() +{ + const union tag_union_name tag_union_var = {1}; + const MYUNION myunion_var = {.y = 2.1f}; +} diff --git a/regression/goto-instrument-typedef/typedef-const-union1/test.desc b/regression/goto-instrument-typedef/typedef-const-union1/test.desc new file mode 100644 index 00000000000..cd303b85195 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-const-union1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_union_var\nMode\.+: C\nType\.+: const union tag_union_name +Base name\.+: myunion_var\nMode\.+: C\nType\.+: const MYUNION +-- +warning: ignoring From bb09401a54699cfd236aa497a6703a23d4f8297d Mon Sep 17 00:00:00 2001 From: thk123 Date: Fri, 16 Dec 2016 14:22:20 +0000 Subject: [PATCH 058/116] Adding tests for anonymous unions These mirror the tests for anonymous structs --- .../typedef-anon-union1/main.c | 11 +++++++++++ .../typedef-anon-union1/test.desc | 10 ++++++++++ .../typedef-param-anon-union1/main.c | 10 ++++++++++ .../typedef-param-anon-union1/test.desc | 10 ++++++++++ .../typedef-return-anon-union1/main.c | 15 +++++++++++++++ .../typedef-return-anon-union1/test.desc | 10 ++++++++++ 6 files changed, 66 insertions(+) create mode 100644 regression/goto-instrument-typedef/typedef-anon-union1/main.c create mode 100644 regression/goto-instrument-typedef/typedef-anon-union1/test.desc create mode 100644 regression/goto-instrument-typedef/typedef-param-anon-union1/main.c create mode 100644 regression/goto-instrument-typedef/typedef-param-anon-union1/test.desc create mode 100644 regression/goto-instrument-typedef/typedef-return-anon-union1/main.c create mode 100644 regression/goto-instrument-typedef/typedef-return-anon-union1/test.desc diff --git a/regression/goto-instrument-typedef/typedef-anon-union1/main.c b/regression/goto-instrument-typedef/typedef-anon-union1/main.c new file mode 100644 index 00000000000..9322c77cb6e --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-anon-union1/main.c @@ -0,0 +1,11 @@ + +typedef union +{ + int x; + float y; +} MYUNION; + +void fun() +{ + MYUNION myunion_var = {.y = 2.1f}; +} diff --git a/regression/goto-instrument-typedef/typedef-anon-union1/test.desc b/regression/goto-instrument-typedef/typedef-anon-union1/test.desc new file mode 100644 index 00000000000..86caf078d6a --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-anon-union1/test.desc @@ -0,0 +1,10 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: myunion_var\nMode\.+: C\nType\.+: MYUNION +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-param-anon-union1/main.c b/regression/goto-instrument-typedef/typedef-param-anon-union1/main.c new file mode 100644 index 00000000000..71791d9adfc --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-param-anon-union1/main.c @@ -0,0 +1,10 @@ + +typedef union +{ + int x; + float y; +} MYUNION; + +void fun(MYUNION myunion_param) +{ +} diff --git a/regression/goto-instrument-typedef/typedef-param-anon-union1/test.desc b/regression/goto-instrument-typedef/typedef-param-anon-union1/test.desc new file mode 100644 index 00000000000..270316982a3 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-param-anon-union1/test.desc @@ -0,0 +1,10 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: myunion_param\nMode\.+: C\nType\.+: MYUNION +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-return-anon-union1/main.c b/regression/goto-instrument-typedef/typedef-return-anon-union1/main.c new file mode 100644 index 00000000000..3bc7d19d5b7 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-return-anon-union1/main.c @@ -0,0 +1,15 @@ + +typedef union +{ + int x; + float y; +} MYUNION; + + +MYUNION fun() +{ + MYUNION return_variable = {1}; + return return_variable; +} + + diff --git a/regression/goto-instrument-typedef/typedef-return-anon-union1/test.desc b/regression/goto-instrument-typedef/typedef-return-anon-union1/test.desc new file mode 100644 index 00000000000..5a8d1b2062d --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-return-anon-union1/test.desc @@ -0,0 +1,10 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: fun\nMode\.+: C\nType\.+: MYUNION \(\) +-- +warning: ignoring From 79f1638a4b0f14a48fec81c29f1803f6a5e9058a Mon Sep 17 00:00:00 2001 From: thk123 Date: Fri, 16 Dec 2016 15:00:11 +0000 Subject: [PATCH 059/116] Adding regression tests for multiple declarations on one line This was mainly to check the declarator part of the conversion wasn't being tripped up by the typedef printing --- .../typedef-anon-struct2/main.c | 11 +++++++++++ .../typedef-anon-struct2/test.desc | 11 +++++++++++ .../typedef-anon-union2/main.c | 11 +++++++++++ .../typedef-anon-union2/test.desc | 11 +++++++++++ .../goto-instrument-typedef/typedef-struct2/main.c | 12 ++++++++++++ .../typedef-struct2/test.desc | 11 +++++++++++ .../goto-instrument-typedef/typedef-type4/main.c | 8 ++++++++ .../goto-instrument-typedef/typedef-type4/test.desc | 12 ++++++++++++ .../goto-instrument-typedef/typedef-union2/main.c | 12 ++++++++++++ .../typedef-union2/test.desc | 13 +++++++++++++ 10 files changed, 112 insertions(+) create mode 100644 regression/goto-instrument-typedef/typedef-anon-struct2/main.c create mode 100644 regression/goto-instrument-typedef/typedef-anon-struct2/test.desc create mode 100644 regression/goto-instrument-typedef/typedef-anon-union2/main.c create mode 100644 regression/goto-instrument-typedef/typedef-anon-union2/test.desc create mode 100644 regression/goto-instrument-typedef/typedef-struct2/main.c create mode 100644 regression/goto-instrument-typedef/typedef-struct2/test.desc create mode 100644 regression/goto-instrument-typedef/typedef-type4/main.c create mode 100644 regression/goto-instrument-typedef/typedef-type4/test.desc create mode 100644 regression/goto-instrument-typedef/typedef-union2/main.c create mode 100644 regression/goto-instrument-typedef/typedef-union2/test.desc diff --git a/regression/goto-instrument-typedef/typedef-anon-struct2/main.c b/regression/goto-instrument-typedef/typedef-anon-struct2/main.c new file mode 100644 index 00000000000..35475513f7d --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-anon-struct2/main.c @@ -0,0 +1,11 @@ + +typedef struct +{ + int x; + float y; +} MYSTRUCT; + +void fun() +{ + MYSTRUCT mystruct_var = {.x = 10, .y = 3.1f}, another_mystruct_var = {.x = 3, .y = 2.1f}; +} diff --git a/regression/goto-instrument-typedef/typedef-anon-struct2/test.desc b/regression/goto-instrument-typedef/typedef-anon-struct2/test.desc new file mode 100644 index 00000000000..490b6cc2623 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-anon-struct2/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: mystruct_var\nMode\.+: C\nType\.+: MYSTRUCT +Base name\.+: another_mystruct_var\nMode\.+: C\nType\.+: MYSTRUCT +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-anon-union2/main.c b/regression/goto-instrument-typedef/typedef-anon-union2/main.c new file mode 100644 index 00000000000..b2dd6594432 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-anon-union2/main.c @@ -0,0 +1,11 @@ + +typedef union +{ + int x; + float y; +} MYUNION; + +void fun() +{ + MYUNION myunion_var = {.y = 2.1f}, another_myunion_var = {.y = 2.1f}; +} diff --git a/regression/goto-instrument-typedef/typedef-anon-union2/test.desc b/regression/goto-instrument-typedef/typedef-anon-union2/test.desc new file mode 100644 index 00000000000..8d8ca64aa93 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-anon-union2/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: myunion_var\nMode\.+: C\nType\.+: MYUNION +Base name\.+: another_myunion_var\nMode\.+: C\nType\.+: MYUNION +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-struct2/main.c b/regression/goto-instrument-typedef/typedef-struct2/main.c new file mode 100644 index 00000000000..dac5abf77b8 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-struct2/main.c @@ -0,0 +1,12 @@ + +typedef struct tag_struct_name +{ + int x; + float y; +} MYSTRUCT; + +void fun() +{ + struct tag_struct_name tag_struct_var = {.x = 1, .y = 3.14f}; + MYSTRUCT mystruct_var = {.x = 3, .y = 2.1f}; +} diff --git a/regression/goto-instrument-typedef/typedef-struct2/test.desc b/regression/goto-instrument-typedef/typedef-struct2/test.desc new file mode 100644 index 00000000000..6a02f2d2174 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-struct2/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_struct_var\nMode\.+: C\nType\.+: struct tag_struct_name +Base name\.+: mystruct_var\nMode\.+: C\nType\.+: MYSTRUCT +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-type4/main.c b/regression/goto-instrument-typedef/typedef-type4/main.c new file mode 100644 index 00000000000..aa2ec9ad7fb --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-type4/main.c @@ -0,0 +1,8 @@ + +typedef int MYINT; + +void fun() +{ + int int_var = 3; + MYINT myint_var = 5, another_myint_var = 10; +} diff --git a/regression/goto-instrument-typedef/typedef-type4/test.desc b/regression/goto-instrument-typedef/typedef-type4/test.desc new file mode 100644 index 00000000000..28163714070 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-type4/test.desc @@ -0,0 +1,12 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_var\nMode\.+: C\nType\.+: signed int +Base name\.+: myint_var\nMode\.+: C\nType\.+: MYINT +Base name\.+: another_myint_var\nMode\.+: C\nType\.+: MYINT +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-union2/main.c b/regression/goto-instrument-typedef/typedef-union2/main.c new file mode 100644 index 00000000000..9ca707cf767 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-union2/main.c @@ -0,0 +1,12 @@ + +typedef union tag_union_name +{ + int x; + float y; +} MYUNION; + +void fun() +{ + union tag_union_name tag_union_var = {1}, another_tag_union_var = {1}; + MYUNION myunion_var = {.y = 2.1f}, another_myunion_var = {.y = 3.1f}; +} diff --git a/regression/goto-instrument-typedef/typedef-union2/test.desc b/regression/goto-instrument-typedef/typedef-union2/test.desc new file mode 100644 index 00000000000..0fc908a6ab5 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-union2/test.desc @@ -0,0 +1,13 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_union_var\nMode\.+: C\nType\.+: union tag_union_name +Base name\.+: another_tag_union_var\nMode\.+: C\nType\.+: union tag_union_name +Base name\.+: myunion_var\nMode\.+: C\nType\.+: MYUNION +Base name\.+: another_myunion_var\nMode\.+: C\nType\.+: MYUNION +-- +warning: ignoring From fc8d7c6e473383c5030f474a10558c950bc9d22f Mon Sep 17 00:00:00 2001 From: thk123 Date: Fri, 16 Dec 2016 15:03:54 +0000 Subject: [PATCH 060/116] Added regressions for typedefs on the source file Since there seemed to be some sublte differences in the data that was maintained whether you ran goto-cc first (independently) or directly fed the .c file into CBMC. These tests replicate the behaviour of tests found in regressions/goto-instrument-typedef/ --- regression/Makefile | 1 + regression/cbmc/typedef-anon-struct1/main.c | 11 ++++++++++ .../cbmc/typedef-anon-struct1/test.desc | 10 ++++++++++ regression/cbmc/typedef-anon-struct2/main.c | 11 ++++++++++ .../cbmc/typedef-anon-struct2/test.desc | 11 ++++++++++ regression/cbmc/typedef-anon-union1/main.c | 11 ++++++++++ regression/cbmc/typedef-anon-union1/test.desc | 10 ++++++++++ regression/cbmc/typedef-anon-union2/main.c | 11 ++++++++++ regression/cbmc/typedef-anon-union2/test.desc | 11 ++++++++++ regression/cbmc/typedef-const-struct1/main.c | 12 +++++++++++ .../cbmc/typedef-const-struct1/test.desc | 11 ++++++++++ regression/cbmc/typedef-const-type1/main.c | 8 ++++++++ regression/cbmc/typedef-const-type1/test.desc | 11 ++++++++++ regression/cbmc/typedef-const-union1/main.c | 12 +++++++++++ .../cbmc/typedef-const-union1/test.desc | 11 ++++++++++ .../cbmc/typedef-param-anon-struct1/main.c | 11 ++++++++++ .../cbmc/typedef-param-anon-struct1/test.desc | 10 ++++++++++ .../cbmc/typedef-param-anon-union1/main.c | 10 ++++++++++ .../cbmc/typedef-param-anon-union1/test.desc | 10 ++++++++++ regression/cbmc/typedef-param-struct1/main.c | 10 ++++++++++ .../cbmc/typedef-param-struct1/test.desc | 11 ++++++++++ regression/cbmc/typedef-param-type1/main.c | 7 +++++++ regression/cbmc/typedef-param-type1/test.desc | 11 ++++++++++ regression/cbmc/typedef-param-type2/main.c | 8 ++++++++ regression/cbmc/typedef-param-type2/test.desc | 12 +++++++++++ regression/cbmc/typedef-param-type3/main.c | 7 +++++++ regression/cbmc/typedef-param-type3/test.desc | 12 +++++++++++ regression/cbmc/typedef-param-union1/main.c | 10 ++++++++++ .../cbmc/typedef-param-union1/test.desc | 11 ++++++++++ .../cbmc/typedef-return-anon-struct1/main.c | 12 +++++++++++ .../typedef-return-anon-struct1/test.desc | 11 ++++++++++ .../cbmc/typedef-return-anon-union1/main.c | 15 ++++++++++++++ .../cbmc/typedef-return-anon-union1/test.desc | 10 ++++++++++ regression/cbmc/typedef-return-struct1/main.c | 20 +++++++++++++++++++ .../cbmc/typedef-return-struct1/test.desc | 11 ++++++++++ regression/cbmc/typedef-return-type1/main.c | 12 +++++++++++ .../cbmc/typedef-return-type1/test.desc | 11 ++++++++++ regression/cbmc/typedef-return-type2/main.c | 13 ++++++++++++ .../cbmc/typedef-return-type2/test.desc | 11 ++++++++++ regression/cbmc/typedef-return-type3/main.c | 12 +++++++++++ .../cbmc/typedef-return-type3/test.desc | 10 ++++++++++ regression/cbmc/typedef-return-union1/main.c | 20 +++++++++++++++++++ .../cbmc/typedef-return-union1/test.desc | 11 ++++++++++ regression/cbmc/typedef-struct1/main.c | 12 +++++++++++ regression/cbmc/typedef-struct1/test.desc | 11 ++++++++++ regression/cbmc/typedef-struct2/main.c | 12 +++++++++++ regression/cbmc/typedef-struct2/test.desc | 11 ++++++++++ regression/cbmc/typedef-type1/main.c | 8 ++++++++ regression/cbmc/typedef-type1/test.desc | 11 ++++++++++ regression/cbmc/typedef-type2/main.c | 10 ++++++++++ regression/cbmc/typedef-type2/test.desc | 12 +++++++++++ regression/cbmc/typedef-type3/main.c | 10 ++++++++++ regression/cbmc/typedef-type3/test.desc | 12 +++++++++++ regression/cbmc/typedef-type4/main.c | 8 ++++++++ regression/cbmc/typedef-type4/test.desc | 12 +++++++++++ regression/cbmc/typedef-union1/main.c | 12 +++++++++++ regression/cbmc/typedef-union1/test.desc | 11 ++++++++++ regression/cbmc/typedef-union2/main.c | 12 +++++++++++ regression/cbmc/typedef-union2/test.desc | 13 ++++++++++++ 59 files changed, 648 insertions(+) create mode 100644 regression/cbmc/typedef-anon-struct1/main.c create mode 100644 regression/cbmc/typedef-anon-struct1/test.desc create mode 100644 regression/cbmc/typedef-anon-struct2/main.c create mode 100644 regression/cbmc/typedef-anon-struct2/test.desc create mode 100644 regression/cbmc/typedef-anon-union1/main.c create mode 100644 regression/cbmc/typedef-anon-union1/test.desc create mode 100644 regression/cbmc/typedef-anon-union2/main.c create mode 100644 regression/cbmc/typedef-anon-union2/test.desc create mode 100644 regression/cbmc/typedef-const-struct1/main.c create mode 100644 regression/cbmc/typedef-const-struct1/test.desc create mode 100644 regression/cbmc/typedef-const-type1/main.c create mode 100644 regression/cbmc/typedef-const-type1/test.desc create mode 100644 regression/cbmc/typedef-const-union1/main.c create mode 100644 regression/cbmc/typedef-const-union1/test.desc create mode 100644 regression/cbmc/typedef-param-anon-struct1/main.c create mode 100644 regression/cbmc/typedef-param-anon-struct1/test.desc create mode 100644 regression/cbmc/typedef-param-anon-union1/main.c create mode 100644 regression/cbmc/typedef-param-anon-union1/test.desc create mode 100644 regression/cbmc/typedef-param-struct1/main.c create mode 100644 regression/cbmc/typedef-param-struct1/test.desc create mode 100644 regression/cbmc/typedef-param-type1/main.c create mode 100644 regression/cbmc/typedef-param-type1/test.desc create mode 100644 regression/cbmc/typedef-param-type2/main.c create mode 100644 regression/cbmc/typedef-param-type2/test.desc create mode 100644 regression/cbmc/typedef-param-type3/main.c create mode 100644 regression/cbmc/typedef-param-type3/test.desc create mode 100644 regression/cbmc/typedef-param-union1/main.c create mode 100644 regression/cbmc/typedef-param-union1/test.desc create mode 100644 regression/cbmc/typedef-return-anon-struct1/main.c create mode 100644 regression/cbmc/typedef-return-anon-struct1/test.desc create mode 100644 regression/cbmc/typedef-return-anon-union1/main.c create mode 100644 regression/cbmc/typedef-return-anon-union1/test.desc create mode 100644 regression/cbmc/typedef-return-struct1/main.c create mode 100644 regression/cbmc/typedef-return-struct1/test.desc create mode 100644 regression/cbmc/typedef-return-type1/main.c create mode 100644 regression/cbmc/typedef-return-type1/test.desc create mode 100644 regression/cbmc/typedef-return-type2/main.c create mode 100644 regression/cbmc/typedef-return-type2/test.desc create mode 100644 regression/cbmc/typedef-return-type3/main.c create mode 100644 regression/cbmc/typedef-return-type3/test.desc create mode 100644 regression/cbmc/typedef-return-union1/main.c create mode 100644 regression/cbmc/typedef-return-union1/test.desc create mode 100644 regression/cbmc/typedef-struct1/main.c create mode 100644 regression/cbmc/typedef-struct1/test.desc create mode 100644 regression/cbmc/typedef-struct2/main.c create mode 100644 regression/cbmc/typedef-struct2/test.desc create mode 100644 regression/cbmc/typedef-type1/main.c create mode 100644 regression/cbmc/typedef-type1/test.desc create mode 100644 regression/cbmc/typedef-type2/main.c create mode 100644 regression/cbmc/typedef-type2/test.desc create mode 100644 regression/cbmc/typedef-type3/main.c create mode 100644 regression/cbmc/typedef-type3/test.desc create mode 100644 regression/cbmc/typedef-type4/main.c create mode 100644 regression/cbmc/typedef-type4/test.desc create mode 100644 regression/cbmc/typedef-union1/main.c create mode 100644 regression/cbmc/typedef-union1/test.desc create mode 100644 regression/cbmc/typedef-union2/main.c create mode 100644 regression/cbmc/typedef-union2/test.desc diff --git a/regression/Makefile b/regression/Makefile index 5c59fd6e34c..296f583cc5e 100644 --- a/regression/Makefile +++ b/regression/Makefile @@ -5,6 +5,7 @@ DIRS = ansi-c \ cbmc-java \ goto-analyzer \ goto-instrument \ + goto-instrument-typedef \ test-script \ # Empty last line diff --git a/regression/cbmc/typedef-anon-struct1/main.c b/regression/cbmc/typedef-anon-struct1/main.c new file mode 100644 index 00000000000..d1e7196a3b1 --- /dev/null +++ b/regression/cbmc/typedef-anon-struct1/main.c @@ -0,0 +1,11 @@ + +typedef struct +{ + int x; + float y; +} MYSTRUCT; + +void fun() +{ + MYSTRUCT mystruct_var = {.x = 3, .y = 2.1f}; +} diff --git a/regression/cbmc/typedef-anon-struct1/test.desc b/regression/cbmc/typedef-anon-struct1/test.desc new file mode 100644 index 00000000000..d9d9769f677 --- /dev/null +++ b/regression/cbmc/typedef-anon-struct1/test.desc @@ -0,0 +1,10 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: mystruct_var\nMode\.+: C\nType\.+: MYSTRUCT +-- +warning: ignoring diff --git a/regression/cbmc/typedef-anon-struct2/main.c b/regression/cbmc/typedef-anon-struct2/main.c new file mode 100644 index 00000000000..35475513f7d --- /dev/null +++ b/regression/cbmc/typedef-anon-struct2/main.c @@ -0,0 +1,11 @@ + +typedef struct +{ + int x; + float y; +} MYSTRUCT; + +void fun() +{ + MYSTRUCT mystruct_var = {.x = 10, .y = 3.1f}, another_mystruct_var = {.x = 3, .y = 2.1f}; +} diff --git a/regression/cbmc/typedef-anon-struct2/test.desc b/regression/cbmc/typedef-anon-struct2/test.desc new file mode 100644 index 00000000000..83af4f59a9f --- /dev/null +++ b/regression/cbmc/typedef-anon-struct2/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: mystruct_var\nMode\.+: C\nType\.+: MYSTRUCT +Base name\.+: another_mystruct_var\nMode\.+: C\nType\.+: MYSTRUCT +-- +warning: ignoring diff --git a/regression/cbmc/typedef-anon-union1/main.c b/regression/cbmc/typedef-anon-union1/main.c new file mode 100644 index 00000000000..9322c77cb6e --- /dev/null +++ b/regression/cbmc/typedef-anon-union1/main.c @@ -0,0 +1,11 @@ + +typedef union +{ + int x; + float y; +} MYUNION; + +void fun() +{ + MYUNION myunion_var = {.y = 2.1f}; +} diff --git a/regression/cbmc/typedef-anon-union1/test.desc b/regression/cbmc/typedef-anon-union1/test.desc new file mode 100644 index 00000000000..6f74f9f5574 --- /dev/null +++ b/regression/cbmc/typedef-anon-union1/test.desc @@ -0,0 +1,10 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: myunion_var\nMode\.+: C\nType\.+: MYUNION +-- +warning: ignoring diff --git a/regression/cbmc/typedef-anon-union2/main.c b/regression/cbmc/typedef-anon-union2/main.c new file mode 100644 index 00000000000..b2dd6594432 --- /dev/null +++ b/regression/cbmc/typedef-anon-union2/main.c @@ -0,0 +1,11 @@ + +typedef union +{ + int x; + float y; +} MYUNION; + +void fun() +{ + MYUNION myunion_var = {.y = 2.1f}, another_myunion_var = {.y = 2.1f}; +} diff --git a/regression/cbmc/typedef-anon-union2/test.desc b/regression/cbmc/typedef-anon-union2/test.desc new file mode 100644 index 00000000000..f5242dc7ac7 --- /dev/null +++ b/regression/cbmc/typedef-anon-union2/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: myunion_var\nMode\.+: C\nType\.+: MYUNION +Base name\.+: another_myunion_var\nMode\.+: C\nType\.+: MYUNION +-- +warning: ignoring diff --git a/regression/cbmc/typedef-const-struct1/main.c b/regression/cbmc/typedef-const-struct1/main.c new file mode 100644 index 00000000000..ab8137e82e4 --- /dev/null +++ b/regression/cbmc/typedef-const-struct1/main.c @@ -0,0 +1,12 @@ + +typedef struct tag_struct_name +{ + int x; + float y; +} MYSTRUCT; + +void fun() +{ + const struct tag_struct_name tag_struct_var = {.x = 1, .y = 3.14f}; + const MYSTRUCT mystruct_var = {.x = 3, .y = 2.1f}; +} diff --git a/regression/cbmc/typedef-const-struct1/test.desc b/regression/cbmc/typedef-const-struct1/test.desc new file mode 100644 index 00000000000..f6c2d8e4b48 --- /dev/null +++ b/regression/cbmc/typedef-const-struct1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_struct_var\nMode\.+: C\nType\.+: const struct tag_struct_name +Base name\.+: mystruct_var\nMode\.+: C\nType\.+: const MYSTRUCT +-- +warning: ignoring diff --git a/regression/cbmc/typedef-const-type1/main.c b/regression/cbmc/typedef-const-type1/main.c new file mode 100644 index 00000000000..8cd4a4346eb --- /dev/null +++ b/regression/cbmc/typedef-const-type1/main.c @@ -0,0 +1,8 @@ + +typedef int MYINT; + +void fun() +{ + const int int_var = 3; + const MYINT myint_var = 5; +} diff --git a/regression/cbmc/typedef-const-type1/test.desc b/regression/cbmc/typedef-const-type1/test.desc new file mode 100644 index 00000000000..0e1b67ce3da --- /dev/null +++ b/regression/cbmc/typedef-const-type1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_var\nMode\.+: C\nType\.+: const signed int +Base name\.+: myint_var\nMode\.+: C\nType\.+: const MYINT +-- +warning: ignoring diff --git a/regression/cbmc/typedef-const-union1/main.c b/regression/cbmc/typedef-const-union1/main.c new file mode 100644 index 00000000000..b8defe635a6 --- /dev/null +++ b/regression/cbmc/typedef-const-union1/main.c @@ -0,0 +1,12 @@ + +typedef union tag_union_name +{ + int x; + float y; +} MYUNION; + +void fun() +{ + const union tag_union_name tag_union_var = {1}; + const MYUNION myunion_var = {.y = 2.1f}; +} diff --git a/regression/cbmc/typedef-const-union1/test.desc b/regression/cbmc/typedef-const-union1/test.desc new file mode 100644 index 00000000000..019a6551911 --- /dev/null +++ b/regression/cbmc/typedef-const-union1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_union_var\nMode\.+: C\nType\.+: const union tag_union_name +Base name\.+: myunion_var\nMode\.+: C\nType\.+: const MYUNION +-- +warning: ignoring diff --git a/regression/cbmc/typedef-param-anon-struct1/main.c b/regression/cbmc/typedef-param-anon-struct1/main.c new file mode 100644 index 00000000000..e8f3fb8fd7c --- /dev/null +++ b/regression/cbmc/typedef-param-anon-struct1/main.c @@ -0,0 +1,11 @@ + +typedef struct +{ + int x; + float y; +} MYSTRUCT; + +void fun(MYSTRUCT mystruct_param) +{ + +} diff --git a/regression/cbmc/typedef-param-anon-struct1/test.desc b/regression/cbmc/typedef-param-anon-struct1/test.desc new file mode 100644 index 00000000000..1d7c939008a --- /dev/null +++ b/regression/cbmc/typedef-param-anon-struct1/test.desc @@ -0,0 +1,10 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: mystruct_param\nMode\.+: C\nType\.+: MYSTRUCT +-- +warning: ignoring diff --git a/regression/cbmc/typedef-param-anon-union1/main.c b/regression/cbmc/typedef-param-anon-union1/main.c new file mode 100644 index 00000000000..71791d9adfc --- /dev/null +++ b/regression/cbmc/typedef-param-anon-union1/main.c @@ -0,0 +1,10 @@ + +typedef union +{ + int x; + float y; +} MYUNION; + +void fun(MYUNION myunion_param) +{ +} diff --git a/regression/cbmc/typedef-param-anon-union1/test.desc b/regression/cbmc/typedef-param-anon-union1/test.desc new file mode 100644 index 00000000000..34c29cefda9 --- /dev/null +++ b/regression/cbmc/typedef-param-anon-union1/test.desc @@ -0,0 +1,10 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: myunion_param\nMode\.+: C\nType\.+: MYUNION +-- +warning: ignoring diff --git a/regression/cbmc/typedef-param-struct1/main.c b/regression/cbmc/typedef-param-struct1/main.c new file mode 100644 index 00000000000..a358c15a030 --- /dev/null +++ b/regression/cbmc/typedef-param-struct1/main.c @@ -0,0 +1,10 @@ + +typedef struct tag_struct_name +{ + int x; + float y; +} MYSTRUCT; + +void fun(struct tag_struct_name tag_struct_param, MYSTRUCT mystruct_param) +{ +} diff --git a/regression/cbmc/typedef-param-struct1/test.desc b/regression/cbmc/typedef-param-struct1/test.desc new file mode 100644 index 00000000000..ad0d23ed7a9 --- /dev/null +++ b/regression/cbmc/typedef-param-struct1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_struct_param\nMode\.+: C\nType\.+: struct tag_struct_name +Base name\.+: mystruct_param\nMode\.+: C\nType\.+: MYSTRUCT +-- +warning: ignoring diff --git a/regression/cbmc/typedef-param-type1/main.c b/regression/cbmc/typedef-param-type1/main.c new file mode 100644 index 00000000000..b4c915066b6 --- /dev/null +++ b/regression/cbmc/typedef-param-type1/main.c @@ -0,0 +1,7 @@ + +typedef int MYINT; + +void fun(int int_param, MYINT myint_param) +{ + +} diff --git a/regression/cbmc/typedef-param-type1/test.desc b/regression/cbmc/typedef-param-type1/test.desc new file mode 100644 index 00000000000..14659940cde --- /dev/null +++ b/regression/cbmc/typedef-param-type1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_param\nMode\.+: C\nType\.+: signed int +Base name\.+: myint_param\nMode\.+: C\nType\.+: MYINT +-- +warning: ignoring diff --git a/regression/cbmc/typedef-param-type2/main.c b/regression/cbmc/typedef-param-type2/main.c new file mode 100644 index 00000000000..b5974fb6bbb --- /dev/null +++ b/regression/cbmc/typedef-param-type2/main.c @@ -0,0 +1,8 @@ + +typedef int MYINT; +typedef int ALTINT; + +void fun(int int_param, MYINT myint_param, ALTINT altint_param) +{ + +} diff --git a/regression/cbmc/typedef-param-type2/test.desc b/regression/cbmc/typedef-param-type2/test.desc new file mode 100644 index 00000000000..14e7db9d3d4 --- /dev/null +++ b/regression/cbmc/typedef-param-type2/test.desc @@ -0,0 +1,12 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_param\nMode\.+: C\nType\.+: signed int +Base name\.+: myint_param\nMode\.+: C\nType\.+: MYINT +Base name\.+: altint_param\nMode\.+: C\nType\.+: ALTINT +-- +warning: ignoring diff --git a/regression/cbmc/typedef-param-type3/main.c b/regression/cbmc/typedef-param-type3/main.c new file mode 100644 index 00000000000..4d542e10c13 --- /dev/null +++ b/regression/cbmc/typedef-param-type3/main.c @@ -0,0 +1,7 @@ + +typedef int MYINT; +typedef MYINT CHAINEDINT; + +void fun(int int_param, MYINT myint_param, CHAINEDINT chainedint_param) +{ +} diff --git a/regression/cbmc/typedef-param-type3/test.desc b/regression/cbmc/typedef-param-type3/test.desc new file mode 100644 index 00000000000..1f10dea2551 --- /dev/null +++ b/regression/cbmc/typedef-param-type3/test.desc @@ -0,0 +1,12 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_param\nMode\.+: C\nType\.+: signed int +Base name\.+: myint_param\nMode\.+: C\nType\.+: MYINT +Base name\.+: chainedint_param\nMode\.+: C\nType\.+: CHAINEDINT +-- +warning: ignoring diff --git a/regression/cbmc/typedef-param-union1/main.c b/regression/cbmc/typedef-param-union1/main.c new file mode 100644 index 00000000000..8f961614e5d --- /dev/null +++ b/regression/cbmc/typedef-param-union1/main.c @@ -0,0 +1,10 @@ + +typedef union tag_union_name +{ + int x; + float y; +} MYUNION; + +void fun(union tag_union_name tag_union_param, MYUNION myunion_param) +{ +} diff --git a/regression/cbmc/typedef-param-union1/test.desc b/regression/cbmc/typedef-param-union1/test.desc new file mode 100644 index 00000000000..37ab0aee08c --- /dev/null +++ b/regression/cbmc/typedef-param-union1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_union_param\nMode\.+: C\nType\.+: union tag_union_name +Base name\.+: myunion_param\nMode\.+: C\nType\.+: MYUNION +-- +warning: ignoring diff --git a/regression/cbmc/typedef-return-anon-struct1/main.c b/regression/cbmc/typedef-return-anon-struct1/main.c new file mode 100644 index 00000000000..0195b955cdd --- /dev/null +++ b/regression/cbmc/typedef-return-anon-struct1/main.c @@ -0,0 +1,12 @@ + +typedef struct +{ + int x; + float y; +} MYSTRUCT; + +MYSTRUCT fun() +{ + MYSTRUCT return_variable = {.x = 1, .y = 3.14f}; + return return_variable; +} diff --git a/regression/cbmc/typedef-return-anon-struct1/test.desc b/regression/cbmc/typedef-return-anon-struct1/test.desc new file mode 100644 index 00000000000..420ac1295ac --- /dev/null +++ b/regression/cbmc/typedef-return-anon-struct1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: return\nMode\.+: C\nType\.+: MYSTRUCT +Base name\.+: fun\nMode\.+: C\nType\.+: MYSTRUCT \(\) +-- +warning: ignoring diff --git a/regression/cbmc/typedef-return-anon-union1/main.c b/regression/cbmc/typedef-return-anon-union1/main.c new file mode 100644 index 00000000000..3bc7d19d5b7 --- /dev/null +++ b/regression/cbmc/typedef-return-anon-union1/main.c @@ -0,0 +1,15 @@ + +typedef union +{ + int x; + float y; +} MYUNION; + + +MYUNION fun() +{ + MYUNION return_variable = {1}; + return return_variable; +} + + diff --git a/regression/cbmc/typedef-return-anon-union1/test.desc b/regression/cbmc/typedef-return-anon-union1/test.desc new file mode 100644 index 00000000000..8d8d41a4dfe --- /dev/null +++ b/regression/cbmc/typedef-return-anon-union1/test.desc @@ -0,0 +1,10 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: fun\nMode\.+: C\nType\.+: MYUNION \(\) +-- +warning: ignoring diff --git a/regression/cbmc/typedef-return-struct1/main.c b/regression/cbmc/typedef-return-struct1/main.c new file mode 100644 index 00000000000..30c1323555c --- /dev/null +++ b/regression/cbmc/typedef-return-struct1/main.c @@ -0,0 +1,20 @@ + +typedef struct tag_struct_name +{ + int x; + float y; +} MYSTRUCT; + +struct tag_struct_name fun() +{ + struct tag_struct_name return_variable = { .x = 1, .y = 3.14f}; + return return_variable; +} + +MYSTRUCT fun2() +{ + MYSTRUCT return_variable = { .x = 1, .y = 3.14f}; + return return_variable; +} + + diff --git a/regression/cbmc/typedef-return-struct1/test.desc b/regression/cbmc/typedef-return-struct1/test.desc new file mode 100644 index 00000000000..c4a9dc3550c --- /dev/null +++ b/regression/cbmc/typedef-return-struct1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: fun\nMode\.+: C\nType\.+: struct tag_struct_name \(\) +Base name\.+: fun2\nMode\.+: C\nType\.+: MYSTRUCT \(\) +-- +warning: ignoring diff --git a/regression/cbmc/typedef-return-type1/main.c b/regression/cbmc/typedef-return-type1/main.c new file mode 100644 index 00000000000..1ba7f426f89 --- /dev/null +++ b/regression/cbmc/typedef-return-type1/main.c @@ -0,0 +1,12 @@ + +typedef int MYINT; + +int fun() +{ + return 4; +} + +MYINT fun2() +{ + return 5; +} diff --git a/regression/cbmc/typedef-return-type1/test.desc b/regression/cbmc/typedef-return-type1/test.desc new file mode 100644 index 00000000000..0ebbe5109a7 --- /dev/null +++ b/regression/cbmc/typedef-return-type1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: fun\nMode\.+: C\nType\.+: signed int \(\) +Base name\.+: fun2\nMode\.+: C\nType\.+: MYINT \(\) +-- +warning: ignoring diff --git a/regression/cbmc/typedef-return-type2/main.c b/regression/cbmc/typedef-return-type2/main.c new file mode 100644 index 00000000000..0d94ab54da3 --- /dev/null +++ b/regression/cbmc/typedef-return-type2/main.c @@ -0,0 +1,13 @@ + +typedef int MYINT; +typedef int ALTINT; + +MYINT fun() +{ + +} + +ALTINT fun2() +{ + +} diff --git a/regression/cbmc/typedef-return-type2/test.desc b/regression/cbmc/typedef-return-type2/test.desc new file mode 100644 index 00000000000..27b2e77902d --- /dev/null +++ b/regression/cbmc/typedef-return-type2/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: fun\nMode\.+: C\nType\.+: MYINT \(\) +Base name\.+: fun2\nMode\.+: C\nType\.+: ALTINT \(\) +-- +warning: ignoring diff --git a/regression/cbmc/typedef-return-type3/main.c b/regression/cbmc/typedef-return-type3/main.c new file mode 100644 index 00000000000..e246757c692 --- /dev/null +++ b/regression/cbmc/typedef-return-type3/main.c @@ -0,0 +1,12 @@ + +typedef int MYINT; +typedef MYINT CHAINEDINT; + +MYINT fun() +{ +} + +CHAINEDINT fun2() +{ + +} \ No newline at end of file diff --git a/regression/cbmc/typedef-return-type3/test.desc b/regression/cbmc/typedef-return-type3/test.desc new file mode 100644 index 00000000000..7cfecafece9 --- /dev/null +++ b/regression/cbmc/typedef-return-type3/test.desc @@ -0,0 +1,10 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +Base name\.+: fun\nMode\.+: C\nType\.+: MYINT \(\) +Base name\.+: fun2\nMode\.+: C\nType\.+: CHAINEDINT \(\) +-- +warning: ignoring diff --git a/regression/cbmc/typedef-return-union1/main.c b/regression/cbmc/typedef-return-union1/main.c new file mode 100644 index 00000000000..ad69cb04545 --- /dev/null +++ b/regression/cbmc/typedef-return-union1/main.c @@ -0,0 +1,20 @@ + +typedef union tag_union_name +{ + int x; + float y; +} MYUNION; + +union tag_union_name fun() +{ + union tag_union_name return_variable = {1}; + return return_variable; +} + +MYUNION fun2() +{ + MYUNION return_variable = {1}; + return return_variable; +} + + diff --git a/regression/cbmc/typedef-return-union1/test.desc b/regression/cbmc/typedef-return-union1/test.desc new file mode 100644 index 00000000000..b1668066f08 --- /dev/null +++ b/regression/cbmc/typedef-return-union1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: fun\nMode\.+: C\nType\.+: union tag_union_name \(\) +Base name\.+: fun2\nMode\.+: C\nType\.+: MYUNION \(\) +-- +warning: ignoring diff --git a/regression/cbmc/typedef-struct1/main.c b/regression/cbmc/typedef-struct1/main.c new file mode 100644 index 00000000000..dac5abf77b8 --- /dev/null +++ b/regression/cbmc/typedef-struct1/main.c @@ -0,0 +1,12 @@ + +typedef struct tag_struct_name +{ + int x; + float y; +} MYSTRUCT; + +void fun() +{ + struct tag_struct_name tag_struct_var = {.x = 1, .y = 3.14f}; + MYSTRUCT mystruct_var = {.x = 3, .y = 2.1f}; +} diff --git a/regression/cbmc/typedef-struct1/test.desc b/regression/cbmc/typedef-struct1/test.desc new file mode 100644 index 00000000000..90f1c22933a --- /dev/null +++ b/regression/cbmc/typedef-struct1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_struct_var\nMode\.+: C\nType\.+: struct tag_struct_name +Base name\.+: mystruct_var\nMode\.+: C\nType\.+: MYSTRUCT +-- +warning: ignoring diff --git a/regression/cbmc/typedef-struct2/main.c b/regression/cbmc/typedef-struct2/main.c new file mode 100644 index 00000000000..dac5abf77b8 --- /dev/null +++ b/regression/cbmc/typedef-struct2/main.c @@ -0,0 +1,12 @@ + +typedef struct tag_struct_name +{ + int x; + float y; +} MYSTRUCT; + +void fun() +{ + struct tag_struct_name tag_struct_var = {.x = 1, .y = 3.14f}; + MYSTRUCT mystruct_var = {.x = 3, .y = 2.1f}; +} diff --git a/regression/cbmc/typedef-struct2/test.desc b/regression/cbmc/typedef-struct2/test.desc new file mode 100644 index 00000000000..90f1c22933a --- /dev/null +++ b/regression/cbmc/typedef-struct2/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_struct_var\nMode\.+: C\nType\.+: struct tag_struct_name +Base name\.+: mystruct_var\nMode\.+: C\nType\.+: MYSTRUCT +-- +warning: ignoring diff --git a/regression/cbmc/typedef-type1/main.c b/regression/cbmc/typedef-type1/main.c new file mode 100644 index 00000000000..43f028c7772 --- /dev/null +++ b/regression/cbmc/typedef-type1/main.c @@ -0,0 +1,8 @@ + +typedef int MYINT; + +void fun() +{ + int int_var = 3; + MYINT myint_var = 5; +} diff --git a/regression/cbmc/typedef-type1/test.desc b/regression/cbmc/typedef-type1/test.desc new file mode 100644 index 00000000000..08d1f5abfcd --- /dev/null +++ b/regression/cbmc/typedef-type1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_var\nMode\.+: C\nType\.+: signed int +Base name\.+: myint_var\nMode\.+: C\nType\.+: MYINT +-- +warning: ignoring diff --git a/regression/cbmc/typedef-type2/main.c b/regression/cbmc/typedef-type2/main.c new file mode 100644 index 00000000000..acb1cce2da4 --- /dev/null +++ b/regression/cbmc/typedef-type2/main.c @@ -0,0 +1,10 @@ + +typedef int MYINT; +typedef int ALTINT; + +void fun() +{ + int int_var = 3; + MYINT myint_var = 5; + ALTINT altint_var = 7; +} diff --git a/regression/cbmc/typedef-type2/test.desc b/regression/cbmc/typedef-type2/test.desc new file mode 100644 index 00000000000..76d1d114a19 --- /dev/null +++ b/regression/cbmc/typedef-type2/test.desc @@ -0,0 +1,12 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_var\nMode\.+: C\nType\.+: signed int +Base name\.+: myint_var\nMode\.+: C\nType\.+: MYINT +Base name\.+: altint_var\nMode\.+: C\nType\.+: ALTINT +-- +warning: ignoring diff --git a/regression/cbmc/typedef-type3/main.c b/regression/cbmc/typedef-type3/main.c new file mode 100644 index 00000000000..5855e0c24cb --- /dev/null +++ b/regression/cbmc/typedef-type3/main.c @@ -0,0 +1,10 @@ + +typedef int MYINT; +typedef MYINT CHAINEDINT; + +void fun() +{ + int int_var = 3; + MYINT myint_var = 5; + CHAINEDINT chainedint_var = 5; +} diff --git a/regression/cbmc/typedef-type3/test.desc b/regression/cbmc/typedef-type3/test.desc new file mode 100644 index 00000000000..cc5ad52d953 --- /dev/null +++ b/regression/cbmc/typedef-type3/test.desc @@ -0,0 +1,12 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_var\nMode\.+: C\nType\.+: signed int +Base name\.+: myint_var\nMode\.+: C\nType\.+: MYINT +Base name\.+: chainedint_var\nMode\.+: C\nType\.+: CHAINEDINT +-- +warning: ignoring diff --git a/regression/cbmc/typedef-type4/main.c b/regression/cbmc/typedef-type4/main.c new file mode 100644 index 00000000000..aa2ec9ad7fb --- /dev/null +++ b/regression/cbmc/typedef-type4/main.c @@ -0,0 +1,8 @@ + +typedef int MYINT; + +void fun() +{ + int int_var = 3; + MYINT myint_var = 5, another_myint_var = 10; +} diff --git a/regression/cbmc/typedef-type4/test.desc b/regression/cbmc/typedef-type4/test.desc new file mode 100644 index 00000000000..1c0c063b8e1 --- /dev/null +++ b/regression/cbmc/typedef-type4/test.desc @@ -0,0 +1,12 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_var\nMode\.+: C\nType\.+: signed int +Base name\.+: myint_var\nMode\.+: C\nType\.+: MYINT +Base name\.+: another_myint_var\nMode\.+: C\nType\.+: MYINT +-- +warning: ignoring diff --git a/regression/cbmc/typedef-union1/main.c b/regression/cbmc/typedef-union1/main.c new file mode 100644 index 00000000000..6f56f3c731b --- /dev/null +++ b/regression/cbmc/typedef-union1/main.c @@ -0,0 +1,12 @@ + +typedef union tag_union_name +{ + int x; + float y; +} MYUNION; + +void fun() +{ + union tag_union_name tag_union_var = {1}; + MYUNION myunion_var = {.y = 2.1f}; +} diff --git a/regression/cbmc/typedef-union1/test.desc b/regression/cbmc/typedef-union1/test.desc new file mode 100644 index 00000000000..e7ce9b6b459 --- /dev/null +++ b/regression/cbmc/typedef-union1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_union_var\nMode\.+: C\nType\.+: union tag_union_name +Base name\.+: myunion_var\nMode\.+: C\nType\.+: MYUNION +-- +warning: ignoring diff --git a/regression/cbmc/typedef-union2/main.c b/regression/cbmc/typedef-union2/main.c new file mode 100644 index 00000000000..9ca707cf767 --- /dev/null +++ b/regression/cbmc/typedef-union2/main.c @@ -0,0 +1,12 @@ + +typedef union tag_union_name +{ + int x; + float y; +} MYUNION; + +void fun() +{ + union tag_union_name tag_union_var = {1}, another_tag_union_var = {1}; + MYUNION myunion_var = {.y = 2.1f}, another_myunion_var = {.y = 3.1f}; +} diff --git a/regression/cbmc/typedef-union2/test.desc b/regression/cbmc/typedef-union2/test.desc new file mode 100644 index 00000000000..33cbbff29af --- /dev/null +++ b/regression/cbmc/typedef-union2/test.desc @@ -0,0 +1,13 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_union_var\nMode\.+: C\nType\.+: union tag_union_name +Base name\.+: another_tag_union_var\nMode\.+: C\nType\.+: union tag_union_name +Base name\.+: myunion_var\nMode\.+: C\nType\.+: MYUNION +Base name\.+: another_myunion_var\nMode\.+: C\nType\.+: MYUNION +-- +warning: ignoring From 22e92672856cbe031c65464cbda3f92d47797ce6 Mon Sep 17 00:00:00 2001 From: thk123 Date: Fri, 16 Dec 2016 15:35:27 +0000 Subject: [PATCH 061/116] Use ID_C_typedef rather than ID_typedef This is more consistent with other flags that do not affect the semantics of the program. --- src/ansi-c/ansi_c_declaration.cpp | 2 +- src/ansi-c/c_typecheck_type.cpp | 4 ++-- src/ansi-c/expr2c.cpp | 4 ++-- src/util/irep_ids.txt | 1 + 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ansi-c/ansi_c_declaration.cpp b/src/ansi-c/ansi_c_declaration.cpp index 6834298a40b..3f79252b867 100644 --- a/src/ansi-c/ansi_c_declaration.cpp +++ b/src/ansi-c/ansi_c_declaration.cpp @@ -148,7 +148,7 @@ typet ansi_c_declarationt::full_type( // retain typedef for dump-c if(get_is_typedef()) - result.set(ID_typedef,declarator.get_name()); + result.set(ID_C_typedef,declarator.get_name()); return result; } diff --git a/src/ansi-c/c_typecheck_type.cpp b/src/ansi-c/c_typecheck_type.cpp index 909b254c611..d82e81c0038 100644 --- a/src/ansi-c/c_typecheck_type.cpp +++ b/src/ansi-c/c_typecheck_type.cpp @@ -52,7 +52,7 @@ void c_typecheck_baset::typecheck_type(typet &type) c_qualifiers+=c_qualifierst(type.subtype()); bool packed=type.get_bool(ID_C_packed); exprt alignment=static_cast(type.find(ID_C_alignment)); - irept _typedef=type.find(ID_typedef); + irept _typedef=type.find(ID_C_typedef); type.swap(type.subtype()); @@ -62,7 +62,7 @@ void c_typecheck_baset::typecheck_type(typet &type) if(alignment.is_not_nil()) type.add(ID_C_alignment, alignment); if(_typedef.is_not_nil()) - type.add(ID_typedef, _typedef); + type.add(ID_C_typedef, _typedef); return; // done } diff --git a/src/ansi-c/expr2c.cpp b/src/ansi-c/expr2c.cpp index 4f31653d91a..401c96d64d1 100644 --- a/src/ansi-c/expr2c.cpp +++ b/src/ansi-c/expr2c.cpp @@ -232,9 +232,9 @@ std::string expr2ct::convert_rec( std::string d= declarator==""?declarator:" "+declarator; - if(src.find(ID_typedef).is_not_nil()) + if(src.find(ID_C_typedef).is_not_nil()) { - return q+id2string(src.get(ID_typedef))+d; + return q+id2string(src.get(ID_C_typedef))+d; } if(src.id()==ID_bool) diff --git a/src/util/irep_ids.txt b/src/util/irep_ids.txt index 066a5f831cc..e581e70ea32 100644 --- a/src/util/irep_ids.txt +++ b/src/util/irep_ids.txt @@ -251,6 +251,7 @@ concatenation infinity return_type typedef +C_typedef extern static auto From 7c1aeb4e17aad8ffb20048e8de61c7f0f52b09f1 Mon Sep 17 00:00:00 2001 From: thk123 Date: Mon, 16 Jan 2017 18:10:30 +0000 Subject: [PATCH 062/116] Fixing relevant lint errors --- src/ansi-c/ansi_c_declaration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansi-c/ansi_c_declaration.cpp b/src/ansi-c/ansi_c_declaration.cpp index 3f79252b867..7f9d0980583 100644 --- a/src/ansi-c/ansi_c_declaration.cpp +++ b/src/ansi-c/ansi_c_declaration.cpp @@ -148,7 +148,7 @@ typet ansi_c_declarationt::full_type( // retain typedef for dump-c if(get_is_typedef()) - result.set(ID_C_typedef,declarator.get_name()); + result.set(ID_C_typedef, declarator.get_name()); return result; } From c64eaccbe88ad7762d3f725dcb375ac3d38201e2 Mon Sep 17 00:00:00 2001 From: thk123 Date: Tue, 17 Jan 2017 10:57:14 +0000 Subject: [PATCH 063/116] Fixed the failing ANSI-C test caused by typedef types not being equal Previously, basic types were being compared by directly calling operator== on the two types. However, we now add a flag to all types defined with a typedef saying what the typedef'd name was. This was causing the two types to not be equal. Now, instead of directly comparing them, we remove the ID_C_typedef flag from them if present and then compare the resulting types. Also added a few more checks to the test to cover some other typedef cases. --- .../ansi-c/gcc_types_compatible_p1/main.c | 12 +++++- .../ansi-c/gcc_types_compatible_p4/main.c | 27 +++++++++++++ .../ansi-c/gcc_types_compatible_p4/test.desc | 8 ++++ src/ansi-c/c_typecheck_base.h | 4 ++ src/ansi-c/c_typecheck_expr.cpp | 39 ++++++++++++++++++- 5 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 regression/ansi-c/gcc_types_compatible_p4/main.c create mode 100644 regression/ansi-c/gcc_types_compatible_p4/test.desc diff --git a/regression/ansi-c/gcc_types_compatible_p1/main.c b/regression/ansi-c/gcc_types_compatible_p1/main.c index 403596c4276..4f327d51085 100644 --- a/regression/ansi-c/gcc_types_compatible_p1/main.c +++ b/regression/ansi-c/gcc_types_compatible_p1/main.c @@ -7,6 +7,14 @@ double d; typedef enum T1 { hot, dog, poo, bear } dingos; typedef enum T2 { janette, laura, amanda } cranberry; +typedef enum AnonEnum { jim, bob, fred } names; + +typedef dingos altdingos; +typedef dingos diffdingos; + +typedef names altnames; +typedef names diffnames; + typedef float same1; typedef float same2; @@ -52,6 +60,9 @@ STATIC_ASSERT(__builtin_types_compatible_p(typeof (dingos), unsigned)); // ha! STATIC_ASSERT(__builtin_types_compatible_p(typeof (hot), typeof (laura))); STATIC_ASSERT(__builtin_types_compatible_p(int[5], int[])); STATIC_ASSERT(__builtin_types_compatible_p(same1, same2)); +STATIC_ASSERT(__builtin_types_compatible_p(dingos, altdingos)); +STATIC_ASSERT(__builtin_types_compatible_p(diffdingos, altdingos)); +STATIC_ASSERT(__builtin_types_compatible_p(diffnames, altnames)); STATIC_ASSERT(__builtin_types_compatible_p(typeof (hot) *, int *)); STATIC_ASSERT(__builtin_types_compatible_p(typeof (hot), typeof (janette))); STATIC_ASSERT(__builtin_types_compatible_p(__int128, signed __int128)); @@ -84,7 +95,6 @@ STATIC_ASSERT(!__builtin_types_compatible_p(__float128, long double)); STATIC_ASSERT(!__builtin_types_compatible_p(__float128, double)); STATIC_ASSERT(!__builtin_types_compatible_p(__int128, unsigned __int128)); #endif - #endif int main(void) diff --git a/regression/ansi-c/gcc_types_compatible_p4/main.c b/regression/ansi-c/gcc_types_compatible_p4/main.c new file mode 100644 index 00000000000..69b84a8304b --- /dev/null +++ b/regression/ansi-c/gcc_types_compatible_p4/main.c @@ -0,0 +1,27 @@ +#define STATIC_ASSERT(condition) \ + int some_array[(condition) ? 1 : -1]; + +typedef struct struct_tag +{ + int x; + float y; +} struct_typedef; + +typedef struct struct_tag alt_typedef; +typedef struct_typedef another_typedef; + +#ifdef __GNUC__ + + +STATIC_ASSERT(__builtin_types_compatible_p(struct struct_tag, struct_typedef)); +STATIC_ASSERT(__builtin_types_compatible_p(struct struct_tag, alt_typedef)); +STATIC_ASSERT(__builtin_types_compatible_p(struct struct_tag, another_typedef)); +STATIC_ASSERT(__builtin_types_compatible_p(struct_typedef, alt_typedef)); +STATIC_ASSERT(__builtin_types_compatible_p(struct_typedef, another_typedef)); +STATIC_ASSERT(__builtin_types_compatible_p(alt_typedef, another_typedef)); + +#endif + +int main(void) +{ +} diff --git a/regression/ansi-c/gcc_types_compatible_p4/test.desc b/regression/ansi-c/gcc_types_compatible_p4/test.desc new file mode 100644 index 00000000000..466da18b2b5 --- /dev/null +++ b/regression/ansi-c/gcc_types_compatible_p4/test.desc @@ -0,0 +1,8 @@ +CORE +main.c + +^EXIT=0$ +^SIGNAL=0$ +-- +^warning: ignoring +^CONVERSION ERROR$ diff --git a/src/ansi-c/c_typecheck_base.h b/src/ansi-c/c_typecheck_base.h index 68191f54fe9..bad408a3c5c 100644 --- a/src/ansi-c/c_typecheck_base.h +++ b/src/ansi-c/c_typecheck_base.h @@ -262,6 +262,10 @@ class c_typecheck_baset: asm_label_mapt asm_label_map; void apply_asm_label(const irep_idt &asm_label, symbolt &symbol); + +private: + static bool are_types_equal_ignoring_typedef( + const typet type1, const typet &type2); }; #endif // CPROVER_ANSI_C_C_TYPECHECK_BASE_H diff --git a/src/ansi-c/c_typecheck_expr.cpp b/src/ansi-c/c_typecheck_expr.cpp index 5961f64142e..4b721f9cf03 100644 --- a/src/ansi-c/c_typecheck_expr.cpp +++ b/src/ansi-c/c_typecheck_expr.cpp @@ -140,6 +140,8 @@ bool c_typecheck_baset::gcc_types_compatible_p( if(type1.id()==ID_c_enum) { if(type2.id()==ID_c_enum) // both are enums + // We don't need to remove the typedef flag here since as it is an enum + // we have already followed the enum tag to get to the underlying enum return type1==type2; // compares the tag else if(type2==type1.subtype()) return true; @@ -184,12 +186,13 @@ bool c_typecheck_baset::gcc_types_compatible_p( } else { - if(type1==type2) + if(are_types_equal_ignoring_typedef(type1, type2)) { // Need to distinguish e.g. long int from int or // long long int from long int. // The rules appear to match those of C++. - + // Isn't this explictly handled by checking type1==type2 (since + // operator== recursively checks all sub types). if(type1.get(ID_C_c_type)==type2.get(ID_C_c_type)) return true; } @@ -200,6 +203,38 @@ bool c_typecheck_baset::gcc_types_compatible_p( /*******************************************************************\ +Function: c_typecheck_baset::are_types_equal_ignoring_typedef + + Inputs: + type1 - the first type to compare + type2 - the second type to compare + + Outputs: True if the types are equal + + Purpose: To check whether two types are equal, ignoring if they have a + different typedef tag. We do this by explictly removing the + ID_C_typedef from the type before comparing. Then we just use + operator== to compare the resultant types. + +\*******************************************************************/ +bool c_typecheck_baset::are_types_equal_ignoring_typedef( + const typet type1, const typet &type2) +{ + typet non_typedefd_type1=type1; + typet non_typedefd_type2=type2; + if(type1.get(ID_C_typedef)!=ID_nil) + { + non_typedefd_type1.remove(ID_C_typedef); + } + if(type2.get(ID_C_typedef)!=ID_nil) + { + non_typedefd_type2.remove(ID_C_typedef); + } + return non_typedefd_type1==non_typedefd_type2; +} + +/*******************************************************************\ + Function: c_typecheck_baset::typecheck_expr_main Inputs: From eec7a5dcda6aee412a6ce542c6af5b2f05739d17 Mon Sep 17 00:00:00 2001 From: thk123 Date: Thu, 26 Jan 2017 15:11:13 +0000 Subject: [PATCH 064/116] Turn the ID_C_typedef into a comment This means that it will not be used to check types are equal, fixing the failing regression tests that were validating the types were equal (and they only differed by a typedef'd name). --- src/ansi-c/c_typecheck_base.h | 4 ---- src/ansi-c/c_typecheck_expr.cpp | 39 ++------------------------------- src/util/irep_ids.txt | 2 +- 3 files changed, 3 insertions(+), 42 deletions(-) diff --git a/src/ansi-c/c_typecheck_base.h b/src/ansi-c/c_typecheck_base.h index bad408a3c5c..68191f54fe9 100644 --- a/src/ansi-c/c_typecheck_base.h +++ b/src/ansi-c/c_typecheck_base.h @@ -262,10 +262,6 @@ class c_typecheck_baset: asm_label_mapt asm_label_map; void apply_asm_label(const irep_idt &asm_label, symbolt &symbol); - -private: - static bool are_types_equal_ignoring_typedef( - const typet type1, const typet &type2); }; #endif // CPROVER_ANSI_C_C_TYPECHECK_BASE_H diff --git a/src/ansi-c/c_typecheck_expr.cpp b/src/ansi-c/c_typecheck_expr.cpp index 4b721f9cf03..5961f64142e 100644 --- a/src/ansi-c/c_typecheck_expr.cpp +++ b/src/ansi-c/c_typecheck_expr.cpp @@ -140,8 +140,6 @@ bool c_typecheck_baset::gcc_types_compatible_p( if(type1.id()==ID_c_enum) { if(type2.id()==ID_c_enum) // both are enums - // We don't need to remove the typedef flag here since as it is an enum - // we have already followed the enum tag to get to the underlying enum return type1==type2; // compares the tag else if(type2==type1.subtype()) return true; @@ -186,13 +184,12 @@ bool c_typecheck_baset::gcc_types_compatible_p( } else { - if(are_types_equal_ignoring_typedef(type1, type2)) + if(type1==type2) { // Need to distinguish e.g. long int from int or // long long int from long int. // The rules appear to match those of C++. - // Isn't this explictly handled by checking type1==type2 (since - // operator== recursively checks all sub types). + if(type1.get(ID_C_c_type)==type2.get(ID_C_c_type)) return true; } @@ -203,38 +200,6 @@ bool c_typecheck_baset::gcc_types_compatible_p( /*******************************************************************\ -Function: c_typecheck_baset::are_types_equal_ignoring_typedef - - Inputs: - type1 - the first type to compare - type2 - the second type to compare - - Outputs: True if the types are equal - - Purpose: To check whether two types are equal, ignoring if they have a - different typedef tag. We do this by explictly removing the - ID_C_typedef from the type before comparing. Then we just use - operator== to compare the resultant types. - -\*******************************************************************/ -bool c_typecheck_baset::are_types_equal_ignoring_typedef( - const typet type1, const typet &type2) -{ - typet non_typedefd_type1=type1; - typet non_typedefd_type2=type2; - if(type1.get(ID_C_typedef)!=ID_nil) - { - non_typedefd_type1.remove(ID_C_typedef); - } - if(type2.get(ID_C_typedef)!=ID_nil) - { - non_typedefd_type2.remove(ID_C_typedef); - } - return non_typedefd_type1==non_typedefd_type2; -} - -/*******************************************************************\ - Function: c_typecheck_baset::typecheck_expr_main Inputs: diff --git a/src/util/irep_ids.txt b/src/util/irep_ids.txt index e581e70ea32..f1938026621 100644 --- a/src/util/irep_ids.txt +++ b/src/util/irep_ids.txt @@ -251,7 +251,7 @@ concatenation infinity return_type typedef -C_typedef +C_typedef #typedef extern static auto From b56a33909cb6d8a24b91f4f9bb27be0ffb47acd6 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Mon, 12 Dec 2016 10:07:04 +0000 Subject: [PATCH 065/116] Generalise witness as location numbers may vary The previous regression test may fail dependent on the platform. --- regression/cbmc/graphml_witness1/test.desc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/regression/cbmc/graphml_witness1/test.desc b/regression/cbmc/graphml_witness1/test.desc index 9e7f5b42724..bfd4cf4f3f4 100644 --- a/regression/cbmc/graphml_witness1/test.desc +++ b/regression/cbmc/graphml_witness1/test.desc @@ -46,29 +46,29 @@ main.c C - + true main.c 21 - - + + main.c 29 main - - + + main.c 15 remove_one - + true - + main.c 31 From 9c68c079fe2cc5f5ec03bd27947176357d26ed23 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Fri, 24 Mar 2017 13:42:30 +0000 Subject: [PATCH 066/116] Rename _start to __CPROVER_start While identifiers starting with _ are reserved according to the C standard, people nevertheless use them. Using __CPROVER_start will make collisions less likely. Includes cleanup such that there is exactly one point where this name is spelled out. --- regression/cbmc/graphml_witness1/test.desc | 2 +- src/cbmc/symex_coverage.cpp | 2 +- .../concrete_fitness_source_provider.cpp | 31 +++++++++++++------ src/cegis/jsa/genetic/jsa_source_provider.cpp | 13 +++++--- src/goto-instrument/cover.cpp | 2 +- src/goto-programs/goto_functions_template.h | 3 +- .../show_goto_functions_json.cpp | 2 +- src/goto-programs/show_goto_functions_xml.cpp | 2 +- src/util/irep_ids.txt | 1 - 9 files changed, 37 insertions(+), 21 deletions(-) diff --git a/regression/cbmc/graphml_witness1/test.desc b/regression/cbmc/graphml_witness1/test.desc index bfd4cf4f3f4..cb22eaba5d0 100644 --- a/regression/cbmc/graphml_witness1/test.desc +++ b/regression/cbmc/graphml_witness1/test.desc @@ -49,7 +49,7 @@ main.c true - + main.c 21 diff --git a/src/cbmc/symex_coverage.cpp b/src/cbmc/symex_coverage.cpp index 69af02e9e9e..578eb26d913 100644 --- a/src/cbmc/symex_coverage.cpp +++ b/src/cbmc/symex_coverage.cpp @@ -276,7 +276,7 @@ void symex_coveraget::compute_overall_coverage( forall_goto_functions(gf_it, goto_functions) { if(!gf_it->second.body_available() || - gf_it->first==ID__start || + gf_it->first==goto_functions.entry_point() || gf_it->first==CPROVER_PREFIX "initialize") continue; diff --git a/src/cegis/invariant/fitness/concrete_fitness_source_provider.cpp b/src/cegis/invariant/fitness/concrete_fitness_source_provider.cpp index 28e41138cb3..dbfa21257c5 100644 --- a/src/cegis/invariant/fitness/concrete_fitness_source_provider.cpp +++ b/src/cegis/invariant/fitness/concrete_fitness_source_provider.cpp @@ -69,9 +69,15 @@ bool contains(const std::string &haystack, const std::string &needle) return std::string::npos != haystack.find(needle); } -bool handle_start(std::string &source, const std::string &line) +bool handle_start( + const goto_functionst &gf, + std::string &source, + const std::string &line) { - if ("void _start(void)" != line) return false; + std::ostringstream start_sig; + start_sig << "void " << gf.entry_point() << "(void)"; + if(start_sig.str()!=line) + return false; source+="int main(const int argc, const char * const argv[])\n"; return true; } @@ -212,17 +218,24 @@ bool handle_internals(const std::string &line) || "static signed int assert#return_value;" == line; } -void post_process(std::string &source, std::stringstream &ss) +void post_process( + const goto_functionst &gf, + std::string &source, + std::stringstream &ss) { bool deserialise_initialised=false; bool ce_initialised=false; for (std::string line; std::getline(ss, line);) { - if (handle_start(source, line) || handle_return_value(line) - || handle_ce_loop(line, ss) || handle_internals(line) - || handle_programs(source, deserialise_initialised, line) - || handle_x0(source, line) || handle_ce(source, ce_initialised, line) - || handle_second_instr_struct(source, line)) continue; + if(handle_start(gf, source, line) || + handle_return_value(line) || + handle_ce_loop(line, ss) || + handle_internals(line) || + handle_programs(source, deserialise_initialised, line) || + handle_x0(source, line) || + handle_ce(source, ce_initialised, line) || + handle_second_instr_struct(source, line)) + continue; replace_ce_index(line); replace_assume(line); fix_cprover_names(line); @@ -254,7 +267,7 @@ std::string &post_process_fitness_source(std::string &result, add_first_prog_offset(result, num_ce_vars); add_assume_implementation(result); add_danger_execute(result, num_vars, num_consts, max_prog_size, exec); - post_process(result, ss); + post_process(gf, result, ss); transform_program_individual_main_to_lib(result, danger); return result; } diff --git a/src/cegis/jsa/genetic/jsa_source_provider.cpp b/src/cegis/jsa/genetic/jsa_source_provider.cpp index 4984bfe1c9b..1182317f771 100644 --- a/src/cegis/jsa/genetic/jsa_source_provider.cpp +++ b/src/cegis/jsa/genetic/jsa_source_provider.cpp @@ -26,7 +26,6 @@ jsa_source_providert::jsa_source_providert(jsa_symex_learnt &lcfg) : { } -#define START_METHOD_PREFIX "void _start" #define RETURN_VALUE_ASSIGNMENT RETURN_VALUE_SUFFIX" =" #define JUMP_BUFFER "__CPROVER_jsa_jump_buffer" #define TEST_SIGNATURE "int " CEGIS_FITNESS_TEST_FUNC \ @@ -104,7 +103,9 @@ void add_main_body(std::string &result, const jsa_symex_learnt &lcfg) std::ostringstream oss; dump_c(entry_only, false, ns, oss); const std::string main_body(oss.str()); - result+=main_body.substr(main_body.find(START_METHOD_PREFIX)); + result+= + main_body.substr( + main_body.find(std::string("void ")+id2string(gf.entry_point()))); } void fix_return_values(std::string &result) @@ -138,9 +139,11 @@ void fix_return_values(std::string &result) substitute(result, "\n return 0;", ""); } -void add_facade_function(std::string &result) +void add_facade_function(const goto_functionst &gf, std::string &result) { - substitute(result, "void _start(void)", TEST_SIGNATURE); + std::ostringstream start_sig; + start_sig << "void " << gf.entry_point() << "(void)"; + substitute(result, start_sig.str(), TEST_SIGNATURE); const std::string::size_type pos=result.find(" __CPROVER_initialize();"); result.insert(pos, " if (setjmp(" JUMP_BUFFER")) return EXIT_FAILURE;\n"); } @@ -249,7 +252,7 @@ const std::string &jsa_source_providert::operator ()() add_temp_clean(source, lcfg.get_symbol_table()); add_main_body(source, lcfg); fix_return_values(source); - add_facade_function(source); + add_facade_function(lcfg.get_goto_functions(), source); insert_solution(source, lcfg); insert_counterexample(source); cleanup(source); diff --git a/src/goto-instrument/cover.cpp b/src/goto-instrument/cover.cpp index ede599b6d8b..00a0bf86eff 100644 --- a/src/goto-instrument/cover.cpp +++ b/src/goto-instrument/cover.cpp @@ -1391,7 +1391,7 @@ void instrument_cover_goals( { Forall_goto_functions(f_it, goto_functions) { - if(f_it->first==ID__start || + if(f_it->first==goto_functions.entry_point() || f_it->first=="__CPROVER_initialize") continue; diff --git a/src/goto-programs/goto_functions_template.h b/src/goto-programs/goto_functions_template.h index 27757df4e87..7c427b4f72f 100644 --- a/src/goto-programs/goto_functions_template.h +++ b/src/goto-programs/goto_functions_template.h @@ -16,6 +16,7 @@ Date: June 2003 #include #include +#include template class goto_function_templatet @@ -123,7 +124,7 @@ class goto_functions_templatet static inline irep_idt entry_point() { // do not confuse with C's "int main()" - return ID__start; + return CPROVER_PREFIX "_start"; } void swap(goto_functions_templatet &other) diff --git a/src/goto-programs/show_goto_functions_json.cpp b/src/goto-programs/show_goto_functions_json.cpp index 1f61e30d2f6..47a19e0662a 100644 --- a/src/goto-programs/show_goto_functions_json.cpp +++ b/src/goto-programs/show_goto_functions_json.cpp @@ -67,7 +67,7 @@ json_objectt show_goto_functions_jsont::convert( json_function["isBodyAvailable"]= jsont::json_boolean(function.body_available()); bool is_internal=(has_prefix(id2string(function_name), CPROVER_PREFIX) || - function_name==ID__start); + function_name==goto_functions.entry_point()); json_function["isInternal"]=jsont::json_boolean(is_internal); if(function.body_available()) diff --git a/src/goto-programs/show_goto_functions_xml.cpp b/src/goto-programs/show_goto_functions_xml.cpp index a5d1c9d5dd4..7ccdd71a4ff 100644 --- a/src/goto-programs/show_goto_functions_xml.cpp +++ b/src/goto-programs/show_goto_functions_xml.cpp @@ -80,7 +80,7 @@ xmlt show_goto_functions_xmlt::convert( xml_function.set_attribute_bool( "is_body_available", function.body_available()); bool is_internal=(has_prefix(id2string(function_name), CPROVER_PREFIX) || - function_name==ID__start); + function_name==goto_functions.entry_point()); xml_function.set_attribute_bool("is_internal", is_internal); if(function.body_available()) diff --git a/src/util/irep_ids.txt b/src/util/irep_ids.txt index 066a5f831cc..ab812d5f289 100644 --- a/src/util/irep_ids.txt +++ b/src/util/irep_ids.txt @@ -681,7 +681,6 @@ read write native final -_start compound_literal custom_bv custom_unsignedbv From b1fd150f21053f6f8616a8fbaf4c16478fcfc2bb Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Sat, 31 Dec 2016 18:01:42 +0000 Subject: [PATCH 067/116] SV-COMP's __VERIFIER_error is assert(0); abort(); Previously, --no-assertions would cause symbolic execution to skip __VERIFIER_error and continue beyond such calls. --- src/goto-programs/builtin_functions.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/goto-programs/builtin_functions.cpp b/src/goto-programs/builtin_functions.cpp index 8fdcd28ae07..b3d6d82f650 100644 --- a/src/goto-programs/builtin_functions.cpp +++ b/src/goto-programs/builtin_functions.cpp @@ -1245,6 +1245,13 @@ void goto_convertt::do_function_call_symbol( error() << identifier << " expected not to have LHS" << eom; throw 0; } + + // __VERIFIER_error has abort() semantics, even if no assertions + // are being checked + goto_programt::targett a=dest.add_instruction(ASSUME); + a->guard=false_exprt(); + a->source_location=function.source_location(); + a->source_location.set("user-provided", true); } else if(has_prefix( id2string(identifier), "java::java.lang.AssertionError.:")) From 24a9ca0485b42a537e080093fc2bc07793bb7377 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Sat, 7 Jan 2017 00:52:11 +0000 Subject: [PATCH 068/116] Graphml output: do not output assumptions containing internal identifiers --- src/goto-programs/graphml_witness.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/goto-programs/graphml_witness.cpp b/src/goto-programs/graphml_witness.cpp index 8b0bd6dc46c..f959bfae387 100644 --- a/src/goto-programs/graphml_witness.cpp +++ b/src/goto-programs/graphml_witness.cpp @@ -285,14 +285,22 @@ void graphml_witnesst::operator()(const goto_tracet &goto_trace) { irep_idt identifier=it->lhs_object.get_identifier(); - xmlt &val=edge.new_element("data"); - val.set_attribute("key", "assumption"); - code_assignt assign(it->lhs_object, it->lhs_object_value); - val.data=convert_assign_rec(identifier, assign); - - xmlt &val_s=edge.new_element("data"); - val_s.set_attribute("key", "assumption.scope"); - val_s.data=id2string(it->pc->source_location.get_function()); + if(id2string(it->lhs_object.get_identifier()).find('$')== + std::string::npos && + (!it->lhs_object_value.is_constant() || + !it->lhs_object_value.has_operands() || + !has_prefix(id2string(it->lhs_object_value.op0().get(ID_value)), + "INVALID-"))) + { + xmlt &val=edge.new_element("data"); + val.set_attribute("key", "assumption"); + code_assignt assign(it->lhs_object, it->lhs_object_value); + val.data=convert_assign_rec(identifier, assign); + + xmlt &val_s=edge.new_element("data"); + val_s.set_attribute("key", "assumption.scope"); + val_s.data=id2string(it->pc->source_location.get_function()); + } } else if(it->type==goto_trace_stept::GOTO && it->pc->is_goto()) From df0890be06b93a65f099dea129daf4d291819814 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Sat, 25 Feb 2017 17:39:10 +0000 Subject: [PATCH 069/116] GraphML witnesses: code cleanup, output nondet return values --- src/goto-programs/graphml_witness.cpp | 87 +++++++++++++++++++-------- 1 file changed, 61 insertions(+), 26 deletions(-) diff --git a/src/goto-programs/graphml_witness.cpp b/src/goto-programs/graphml_witness.cpp index f959bfae387..85bd1eec40f 100644 --- a/src/goto-programs/graphml_witness.cpp +++ b/src/goto-programs/graphml_witness.cpp @@ -146,8 +146,11 @@ std::string graphml_witnesst::convert_assign_rec( exprt clean_rhs=assign.rhs(); remove_l0_l1(clean_rhs); - result=from_expr(ns, identifier, assign.lhs())+" = "+ - from_expr(ns, identifier, clean_rhs)+";"; + std::string lhs=from_expr(ns, identifier, assign.lhs()); + if(lhs.find('$')!=std::string::npos) + lhs="\\result"; + + result=lhs+" = "+from_expr(ns, identifier, clean_rhs)+";"; } return result; @@ -155,6 +158,53 @@ std::string graphml_witnesst::convert_assign_rec( /*******************************************************************\ +Function: filter_out + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +static bool filter_out( + const goto_tracet &goto_trace, + const goto_tracet::stepst::const_iterator &prev_it, + goto_tracet::stepst::const_iterator &it) +{ + if(it->hidden && + (!it->is_assignment() || + to_code_assign(it->pc->code).rhs().id()!=ID_side_effect || + to_code_assign(it->pc->code).rhs().get(ID_statement)!=ID_nondet)) + return true; + + if(!it->is_assignment() && !it->is_goto() && !it->is_assert()) + return true; + + // we filter out steps with the same source location + // TODO: if these are assignments we should accumulate them into + // a single edge + if(prev_it!=goto_trace.steps.end() && + prev_it->pc->source_location==it->pc->source_location) + return true; + + if(it->is_goto() && it->pc->guard.is_true()) + return true; + + const source_locationt &source_location=it->pc->source_location; + + if(source_location.is_nil() || + source_location.get_file().empty() || + source_location.is_built_in() || + source_location.get_line().empty()) + return true; + + return false; +} + +/*******************************************************************\ + Function: graphml_witnesst::operator() Inputs: @@ -184,20 +234,7 @@ void graphml_witnesst::operator()(const goto_tracet &goto_trace) it!=goto_trace.steps.end(); it++) // we cannot replace this by a ranged for { - const source_locationt &source_location=it->pc->source_location; - - if(it->hidden || - (!it->is_assignment() && !it->is_goto() && !it->is_assert()) || - // we filter out steps with the same source location - // TODO: if these are assignments we should accumulate them into - // a single edge - (prev_it!=goto_trace.steps.end() && - prev_it->pc->source_location==it->pc->source_location) || - (it->is_goto() && it->pc->guard.is_true()) || - source_location.is_nil() || - source_location.get_file().empty() || - source_location.is_built_in() || - source_location.get_line().empty()) + if(filter_out(goto_trace, prev_it, it)) { step_to_node[it->step_nr]=sink; @@ -219,6 +256,8 @@ void graphml_witnesst::operator()(const goto_tracet &goto_trace) prev_it=it; + const source_locationt &source_location=it->pc->source_location; + const graphmlt::node_indext node=graphml.add_node(); graphml[node].node_name= std::to_string(it->pc->location_number)+"."+std::to_string(it->step_nr); @@ -278,23 +317,19 @@ void graphml_witnesst::operator()(const goto_tracet &goto_trace) data_l.data=id2string(graphml[from].line); } - if((it->type==goto_trace_stept::ASSIGNMENT || - it->type==goto_trace_stept::DECL) && + if(it->type==goto_trace_stept::ASSIGNMENT && it->lhs_object_value.is_not_nil() && it->full_lhs.is_not_nil()) { - irep_idt identifier=it->lhs_object.get_identifier(); - - if(id2string(it->lhs_object.get_identifier()).find('$')== - std::string::npos && - (!it->lhs_object_value.is_constant() || - !it->lhs_object_value.has_operands() || - !has_prefix(id2string(it->lhs_object_value.op0().get(ID_value)), - "INVALID-"))) + if(!it->lhs_object_value.is_constant() || + !it->lhs_object_value.has_operands() || + !has_prefix(id2string(it->lhs_object_value.op0().get(ID_value)), + "INVALID-")) { xmlt &val=edge.new_element("data"); val.set_attribute("key", "assumption"); code_assignt assign(it->lhs_object, it->lhs_object_value); + irep_idt identifier=it->lhs_object.get_identifier(); val.data=convert_assign_rec(identifier, assign); xmlt &val_s=edge.new_element("data"); From c8687e7ec27c49522f75224e0720f627a614650b Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Mon, 13 Mar 2017 12:59:17 -0700 Subject: [PATCH 070/116] Print the original return type in coverage report remove_returns would cause return types that appear inconsistent to the user. --- src/cbmc/symex_coverage.cpp | 9 +++++- src/goto-programs/remove_returns.cpp | 42 +++++++++++++++++++++++++++- src/goto-programs/remove_returns.h | 4 +++ 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/src/cbmc/symex_coverage.cpp b/src/cbmc/symex_coverage.cpp index 69af02e9e9e..232e3b3104c 100644 --- a/src/cbmc/symex_coverage.cpp +++ b/src/cbmc/symex_coverage.cpp @@ -19,6 +19,7 @@ Date: March 2016 #include #include +#include #include "symex_coverage.h" @@ -157,8 +158,14 @@ goto_program_coverage_recordt::goto_program_coverage_recordt( // // xml.set_attribute("name", id2string(gf_it->first)); + + code_typet sig_type= + original_return_type(ns.get_symbol_table(), gf_it->first); + if(sig_type.is_nil()) + sig_type=gf_it->second.type; xml.set_attribute("signature", - from_type(ns, gf_it->first, gf_it->second.type)); + from_type(ns, gf_it->first, sig_type)); + xml.set_attribute("line-rate", rate(lines_covered, lines_total)); xml.set_attribute("branch-rate", diff --git a/src/goto-programs/remove_returns.cpp b/src/goto-programs/remove_returns.cpp index b3afbf967fc..9ca6554275c 100644 --- a/src/goto-programs/remove_returns.cpp +++ b/src/goto-programs/remove_returns.cpp @@ -269,6 +269,46 @@ void remove_returns(goto_modelt &goto_model) /*******************************************************************\ +Function: original_return_type + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + +code_typet original_return_type( + const symbol_tablet &symbol_table, + const irep_idt &function_id) +{ + code_typet type; + type.make_nil(); + + // do we have X#return_value? + std::string rv_name=id2string(function_id)+RETURN_VALUE_SUFFIX; + + symbol_tablet::symbolst::const_iterator rv_it= + symbol_table.symbols.find(rv_name); + + if(rv_it!=symbol_table.symbols.end()) + { + // look up the function symbol + symbol_tablet::symbolst::const_iterator s_it= + symbol_table.symbols.find(function_id); + + assert(s_it!=symbol_table.symbols.end()); + + type=to_code_type(s_it->second.type); + type.return_type()=rv_it->second.type; + } + + return type; +} + +/*******************************************************************\ + Function: remove_returnst::restore_returns Inputs: @@ -301,7 +341,7 @@ bool remove_returnst::restore_returns( symbolt &function_symbol=s_it->second; // restore the return type - f_it->second.type.return_type()=rv_it->second.type; + f_it->second.type=original_return_type(symbol_table, function_id); function_symbol.type=f_it->second.type; // remove the return_value symbol from the symbol_table diff --git a/src/goto-programs/remove_returns.h b/src/goto-programs/remove_returns.h index 3f68d3e89e2..453d8a7be7f 100644 --- a/src/goto-programs/remove_returns.h +++ b/src/goto-programs/remove_returns.h @@ -26,4 +26,8 @@ void remove_returns(goto_modelt &); // reverse the above operations void restore_returns(symbol_tablet &, goto_functionst &); +code_typet original_return_type( + const symbol_tablet &symbol_table, + const irep_idt &function_id); + #endif // CPROVER_GOTO_PROGRAMS_REMOVE_RETURNS_H From 08162b6f3ef2a19b74a93026d96501ba305f8c0d Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Mon, 13 Mar 2017 15:41:33 -0700 Subject: [PATCH 071/116] Make recording of branches possible symex_bmct may now re-implement merge_goto to observe each merge, just like loop unwinding is reported. --- src/goto-symex/goto_symex.h | 4 +++ src/goto-symex/goto_symex_state.h | 2 ++ src/goto-symex/symex_goto.cpp | 49 ++++++++++++++++++++----------- 3 files changed, 38 insertions(+), 17 deletions(-) diff --git a/src/goto-symex/goto_symex.h b/src/goto-symex/goto_symex.h index de71fcc9d09..f8c2cda0bf9 100644 --- a/src/goto-symex/goto_symex.h +++ b/src/goto-symex/goto_symex.h @@ -175,6 +175,10 @@ class goto_symext // gotos void merge_gotos(statet &state); + virtual void merge_goto( + const statet::goto_statet &goto_state, + statet &state); + void merge_value_sets( const statet::goto_statet &goto_state, statet &dest); diff --git a/src/goto-symex/goto_symex_state.h b/src/goto-symex/goto_symex_state.h index 5439af37e05..292dec478c7 100644 --- a/src/goto-symex/goto_symex_state.h +++ b/src/goto-symex/goto_symex_state.h @@ -189,6 +189,7 @@ class goto_symex_statet level2t::current_namest level2_current_names; value_sett value_set; guardt guard; + symex_targett::sourcet source; propagationt propagation; unsigned atomic_section_id; @@ -197,6 +198,7 @@ class goto_symex_statet level2_current_names(s.level2.current_names), value_set(s.value_set), guard(s.guard), + source(s.source), propagation(s.propagation), atomic_section_id(s.atomic_section_id) { diff --git a/src/goto-symex/symex_goto.cpp b/src/goto-symex/symex_goto.cpp index b8e6f1a0a36..7590a111e15 100644 --- a/src/goto-symex/symex_goto.cpp +++ b/src/goto-symex/symex_goto.cpp @@ -121,8 +121,6 @@ void goto_symext::symex_goto(statet &state) state_pc=goto_target; } - state.source.pc=state_pc; - // put into state-queue statet::goto_state_listt &goto_state_list= state.top().goto_state_map[new_state_pc]; @@ -130,6 +128,8 @@ void goto_symext::symex_goto(statet &state) goto_state_list.push_back(statet::goto_statet(state)); statet::goto_statet &new_state=goto_state_list.back(); + state.source.pc=state_pc; + // adjust guards if(new_guard.is_true()) { @@ -244,27 +244,42 @@ void goto_symext::merge_gotos(statet &state) list_it=state_list.rbegin(); list_it!=state_list.rend(); list_it++) - { - statet::goto_statet &goto_state=*list_it; + merge_goto(*list_it, state); - // check atomic section - if(state.atomic_section_id!=goto_state.atomic_section_id) - throw "atomic sections differ across branches"; + // clean up to save some memory + frame.goto_state_map.erase(state_map_it); +} - // do SSA phi functions - phi_function(goto_state, state); +/*******************************************************************\ - merge_value_sets(goto_state, state); +Function: goto_symext::merge_goto - // adjust guard - state.guard|=goto_state.guard; + Inputs: - // adjust depth - state.depth=std::min(state.depth, goto_state.depth); - } + Outputs: - // clean up to save some memory - frame.goto_state_map.erase(state_map_it); + Purpose: + +\*******************************************************************/ + +void goto_symext::merge_goto( + const statet::goto_statet &goto_state, + statet &state) +{ + // check atomic section + if(state.atomic_section_id!=goto_state.atomic_section_id) + throw "atomic sections differ across branches"; + + // do SSA phi functions + phi_function(goto_state, state); + + merge_value_sets(goto_state, state); + + // adjust guard + state.guard|=goto_state.guard; + + // adjust depth + state.depth=std::min(state.depth, goto_state.depth); } /*******************************************************************\ From b7b0059b2cf3a62a9b6f0fa685fb521539e652a5 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Mon, 13 Mar 2017 15:42:59 -0700 Subject: [PATCH 072/116] Properly report branch coverage --- src/cbmc/symex_bmc.cpp | 47 ++++++++++- src/cbmc/symex_bmc.h | 4 + src/cbmc/symex_coverage.cpp | 160 +++++++++++++++++++++++++----------- src/cbmc/symex_coverage.h | 18 ++-- 4 files changed, 170 insertions(+), 59 deletions(-) diff --git a/src/cbmc/symex_bmc.cpp b/src/cbmc/symex_bmc.cpp index 1dd1e8dceb9..a6dfa3bcb3a 100644 --- a/src/cbmc/symex_bmc.cpp +++ b/src/cbmc/symex_bmc.cpp @@ -63,11 +63,52 @@ void symex_bmct::symex_step( last_source_location=source_location; } - if(record_coverage && - !state.guard.is_false()) - symex_coverage.covered(state.source.pc); + const goto_programt::const_targett cur_pc=state.source.pc; goto_symext::symex_step(goto_functions, state); + + if(record_coverage && + // is the instruction being executed + !state.guard.is_false() && + // avoid an invalid iterator in state.source.pc + (!cur_pc->is_end_function() || + cur_pc->function!=ID__start) && + // ignore transition to next instruction when goto points elsewhere + (!cur_pc->is_goto() || + cur_pc->get_target()==state.source.pc || + !cur_pc->guard.is_true())) + 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) +{ + const goto_programt::const_targett prev_pc=goto_state.source.pc; + const guardt prev_guard=goto_state.guard; + + goto_symext::merge_goto(goto_state, state); + + assert(prev_pc->is_goto()); + if(record_coverage && + // could the branch possibly be taken? + !prev_guard.is_false() && + !state.guard.is_false() && + // branches only, no single-successor goto + !prev_pc->guard.is_true()) + symex_coverage.covered(prev_pc, state.source.pc); } /*******************************************************************\ diff --git a/src/cbmc/symex_bmc.h b/src/cbmc/symex_bmc.h index 10f4b821e88..8b2df348f3b 100644 --- a/src/cbmc/symex_bmc.h +++ b/src/cbmc/symex_bmc.h @@ -83,6 +83,10 @@ class symex_bmct: const goto_functionst &goto_functions, statet &state); + virtual void merge_goto( + const statet::goto_statet &goto_state, + statet &state); + // for loop unwinding virtual bool get_unwind( const symex_targett::sourcet &source, diff --git a/src/cbmc/symex_coverage.cpp b/src/cbmc/symex_coverage.cpp index 232e3b3104c..e984aa13a73 100644 --- a/src/cbmc/symex_coverage.cpp +++ b/src/cbmc/symex_coverage.cpp @@ -58,26 +58,37 @@ class goto_program_coverage_recordt:public coverage_recordt protected: irep_idt file_name; - struct line_coverage_recordt + struct coverage_conditiont { - line_coverage_recordt(): - hits(0), is_branch(false), branch_covered(false) + coverage_conditiont(): + false_taken(false), true_taken(false) + { + } + + bool false_taken; + bool true_taken; + }; + + struct coverage_linet + { + coverage_linet(): + hits(0) { } unsigned hits; - bool is_branch; - bool branch_covered; + std::map + conditions; }; - typedef std::map - line_coverage_mapt; + typedef std::map + coverage_lines_mapt; - void compute_line_coverage( + void compute_coverage_lines( const goto_programt &goto_program, const irep_idt &file_name, const symex_coveraget::coveraget &coverage, - line_coverage_mapt &dest); + coverage_lines_mapt &dest); }; /*******************************************************************\ @@ -92,17 +103,26 @@ Function: rate \*******************************************************************/ -static std::string rate(std::size_t covered, std::size_t total) +static std::string rate( + std::size_t covered, + std::size_t total, + bool per_cent=false) { + std::ostringstream oss; + #if 1 - if(total==0) - return "1.0"; + float fraction; - std::ostringstream oss; + if(total==0) + fraction=1.0; + else + fraction=static_cast(covered)/static_cast(total); - oss << static_cast(covered)/static_cast(total); + if(per_cent) + oss << fraction*100.0 << '%'; + else + oss << fraction; #else - std::ostringstream oss; oss << covered << " of " << total; #endif @@ -138,12 +158,12 @@ goto_program_coverage_recordt::goto_program_coverage_recordt( assert(!file_name.empty()); // compute the maximum coverage of individual source-code lines - line_coverage_mapt line_coverage_map; - compute_line_coverage( + coverage_lines_mapt coverage_lines_map; + compute_coverage_lines( gf_it->second.body, file_name, coverage, - line_coverage_map); + coverage_lines_map); // // @@ -173,28 +193,43 @@ goto_program_coverage_recordt::goto_program_coverage_recordt( xmlt &lines=xml.new_element("lines"); - for(line_coverage_mapt::const_iterator - it=line_coverage_map.begin(); - it!=line_coverage_map.end(); - ++it) + for(const auto &cov_line : coverage_lines_map) { xmlt &line=lines.new_element("line"); - line.set_attribute("number", std::to_string(it->first)); - line.set_attribute("hits", std::to_string(it->second.hits)); - if(!it->second.is_branch) + line.set_attribute("number", std::to_string(cov_line.first)); + line.set_attribute("hits", std::to_string(cov_line.second.hits)); + if(cov_line.second.conditions.empty()) line.set_attribute("branch", "false"); else { - // TODO: conditions line.set_attribute("branch", "true"); + + xmlt &conditions=line.new_element("conditions"); + + std::size_t number=0, total_taken=0; + for(const auto &c : cov_line.second.conditions) + { + // + xmlt &condition=conditions.new_element("condition"); + condition.set_attribute("number", std::to_string(number++)); + condition.set_attribute("type", "jump"); + unsigned taken=c.second.false_taken+c.second.true_taken; + total_taken+=taken; + condition.set_attribute("coverage", rate(taken, 2, true)); + } + + std::ostringstream oss; + oss << rate(total_taken, number*2, true) + << " (" << total_taken << '/' << number*2 << ')'; + line.set_attribute("condition-coverage", oss.str()); } } } /*******************************************************************\ -Function: goto_program_coverage_recordt::compute_line_coverage +Function: goto_program_coverage_recordt::compute_coverage_lines Inputs: @@ -204,58 +239,83 @@ Function: goto_program_coverage_recordt::compute_line_coverage \*******************************************************************/ -void goto_program_coverage_recordt::compute_line_coverage( +void goto_program_coverage_recordt::compute_coverage_lines( const goto_programt &goto_program, const irep_idt &file_name, const symex_coveraget::coveraget &coverage, - line_coverage_mapt &dest) + coverage_lines_mapt &dest) { forall_goto_program_instructions(it, goto_program) { if(it->source_location.is_nil() || - it->source_location.get_file()!=file_name) + it->source_location.get_file()!=file_name || + it->is_dead() || + it->is_end_function()) continue; const bool is_branch=it->is_goto() && !it->guard.is_constant(); unsigned l= safe_string2unsigned(id2string(it->source_location.get_line())); - std::pair entry= - dest.insert(std::make_pair(l, line_coverage_recordt())); + std::pair entry= + dest.insert(std::make_pair(l, coverage_linet())); if(entry.second) - { ++lines_total; - if(is_branch) - ++branches_total; - } // mark as branch if any instruction in this source code line is // a branching instruction - if(is_branch && - !entry.first->second.is_branch) + if(is_branch) { - ++branches_total; - entry.first->second.is_branch=true; + branches_total+=2; + if(!entry.first->second.conditions.insert( + {it, coverage_conditiont()}).second) + assert(false); } symex_coveraget::coveraget::const_iterator c_entry= coverage.find(it); - if(c_entry!=coverage.end() && - c_entry->second.num_executions>0) + if(c_entry!=coverage.end()) { - // maximum over all instructions in this source code line - if(c_entry->second.num_executions>entry.first->second.hits) + if(!(c_entry->second.size()==1 || is_branch)) { - if(entry.first->second.hits==0) - ++lines_covered; - entry.first->second.hits=c_entry->second.num_executions; + std::cerr << it->location_number << std::endl; + for(const auto &cov : c_entry->second) + std::cerr << cov.second.succ->location_number << std::endl; } + assert(c_entry->second.size()==1 || is_branch); - if(is_branch && !entry.first->second.branch_covered) + for(const auto &cov : c_entry->second) { - ++branches_covered; - entry.first->second.branch_covered=true; + assert(cov.second.num_executions>0); + + if(entry.first->second.hits==0) + ++lines_covered; + + entry.first->second.hits+=cov.second.num_executions; + + if(is_branch) + { + auto cond_entry=entry.first->second.conditions.find(it); + assert(cond_entry!=entry.first->second.conditions.end()); + + if(it->get_target()==cov.second.succ) + { + if(!cond_entry->second.false_taken) + { + cond_entry->second.false_taken=true; + ++branches_covered; + } + } + else + { + if(!cond_entry->second.true_taken) + { + cond_entry->second.true_taken=true; + ++branches_covered; + } + } + } } } } diff --git a/src/cbmc/symex_coverage.h b/src/cbmc/symex_coverage.h index 0e71b430630..c173bc65ad7 100644 --- a/src/cbmc/symex_coverage.h +++ b/src/cbmc/symex_coverage.h @@ -29,11 +29,12 @@ class symex_coveraget { } - void covered(goto_programt::const_targett location) + void covered( + goto_programt::const_targett from, + goto_programt::const_targett to) { - std::pair entry= - coverage.insert(std::make_pair(location, - coverage_infot(location, 1))); + std::pair entry= + coverage[from].insert({to, coverage_infot(from, to, 1)}); if(!entry.second) ++(entry.first->second.num_executions); @@ -49,17 +50,22 @@ class symex_coveraget struct coverage_infot { coverage_infot( - goto_programt::const_targett _location, + goto_programt::const_targett _from, + goto_programt::const_targett _to, unsigned _num_executions): - location(_location), num_executions(_num_executions) + location(_from), num_executions(_num_executions), + succ(_to) { } goto_programt::const_targett location; unsigned num_executions; + goto_programt::const_targett succ; }; typedef std::map + coverage_innert; + typedef std::map coveraget; coveraget coverage; From 2a86ae336dfa91c64df718f3ada7892023511481 Mon Sep 17 00:00:00 2001 From: Owen Jones Date: Fri, 24 Feb 2017 16:28:30 +0000 Subject: [PATCH 073/116] Tests for variable sensitivity in goto-analyzer This is the test suite for the variable sensitivity feature in goto-analyzer, which will be in a separate PR. It will allow us to control which abstract domain to use for arrays, pointers and structs separately. --- .../array_of_array_sensitivity_tests.c | 150 +++++++++++++++++ .../array_of_pointer_sensitivity_tests.c | 156 ++++++++++++++++++ .../array_sensitivity_tests.c | 101 ++++++++++++ .../char_sensitivity_tests.c | 10 ++ .../float_sensitivity_tests.c | 10 ++ .../int_sensitivity_tests.c | 55 ++++++ .../pointer_sensitivity_tests.c | 53 ++++++ .../pointer_to_array_sensitivity_tests.c | 59 +++++++ .../pointer_to_pointer_sensitivity_tests.c | 24 +++ .../pointer_to_struct_sensitivity_tests.c | 28 ++++ .../struct_of_array_sensitivity_tests.c | 58 +++++++ .../struct_of_pointer_sensitivity_tests.c | 71 ++++++++ .../struct_of_struct_sensitivity_tests.c | 55 ++++++ .../struct_sensitivity_tests.c | 47 ++++++ ..._test_constants_array_of_constants_array.c | 1 + .../test.desc | 73 ++++++++ ...est_constants_array_of_constants_pointer.c | 1 + .../test.desc | 71 ++++++++ ...est_constants_array_of_two_value_pointer.c | 1 + .../test.desc | 71 ++++++++ .../sensitivity_test_constants_array.c | 1 + .../test.desc | 39 +++++ .../sensitivity_test_constants_char.c | 1 + .../sensitivity-test-constants-char/test.desc | 9 + .../sensitivity_test_constants_float.c | 1 + .../test.desc | 9 + .../sensitivity_test_constants_int.c | 1 + .../sensitivity-test-constants-int/test.desc | 30 ++++ ...est_constants_pointer_to_constants_array.c | 1 + .../test.desc | 21 +++ ...t_constants_pointer_to_constants_pointer.c | 1 + .../test.desc | 13 ++ ...st_constants_pointer_to_constants_struct.c | 1 + .../test.desc | 16 ++ ...est_constants_pointer_to_two_value_array.c | 1 + .../test.desc | 21 +++ ...st_constants_pointer_to_two_value_struct.c | 1 + .../test.desc | 13 ++ .../sensitivity_test_constants_pointer.c | 1 + .../test.desc | 21 +++ ...test_constants_struct_of_constants_array.c | 1 + .../test.desc | 24 +++ ...st_constants_struct_of_constants_pointer.c | 1 + .../test.desc | 33 ++++ ...est_constants_struct_of_constants_struct.c | 1 + .../test.desc | 18 ++ ...test_constants_struct_of_two_value_array.c | 1 + .../test.desc | 24 +++ ...st_constants_struct_of_two_value_pointer.c | 1 + .../test.desc | 33 ++++ .../sensitivity_test_constants_struct.c | 1 + .../test.desc | 16 ++ ..._test_two_value_array_of_two_value_array.c | 1 + .../test.desc | 73 ++++++++ ...est_two_value_array_of_two_value_pointer.c | 1 + .../test.desc | 71 ++++++++ .../sensitivity_test_two_value_array.c | 1 + .../test.desc | 39 +++++ ...est_two_value_pointer_to_two_value_array.c | 1 + .../test.desc | 21 +++ ...t_two_value_pointer_to_two_value_pointer.c | 1 + .../test.desc | 13 ++ ...st_two_value_pointer_to_two_value_struct.c | 1 + .../test.desc | 13 ++ .../sensitivity_test_two_value_pointer.c | 1 + .../test.desc | 21 +++ ...test_two_value_struct_of_two_value_array.c | 1 + .../test.desc | 24 +++ ...st_two_value_struct_of_two_value_pointer.c | 1 + .../test.desc | 33 ++++ ...est_two_value_struct_of_two_value_struct.c | 1 + .../test.desc | 18 ++ .../sensitivity_test_two_value_struct.c | 1 + .../test.desc | 16 ++ 74 files changed, 1804 insertions(+) create mode 100644 regression/goto-analyzer/sensitivity-test-common-files/array_of_array_sensitivity_tests.c create mode 100644 regression/goto-analyzer/sensitivity-test-common-files/array_of_pointer_sensitivity_tests.c create mode 100644 regression/goto-analyzer/sensitivity-test-common-files/array_sensitivity_tests.c create mode 100644 regression/goto-analyzer/sensitivity-test-common-files/char_sensitivity_tests.c create mode 100644 regression/goto-analyzer/sensitivity-test-common-files/float_sensitivity_tests.c create mode 100644 regression/goto-analyzer/sensitivity-test-common-files/int_sensitivity_tests.c create mode 100644 regression/goto-analyzer/sensitivity-test-common-files/pointer_sensitivity_tests.c create mode 100644 regression/goto-analyzer/sensitivity-test-common-files/pointer_to_array_sensitivity_tests.c create mode 100644 regression/goto-analyzer/sensitivity-test-common-files/pointer_to_pointer_sensitivity_tests.c create mode 100644 regression/goto-analyzer/sensitivity-test-common-files/pointer_to_struct_sensitivity_tests.c create mode 100644 regression/goto-analyzer/sensitivity-test-common-files/struct_of_array_sensitivity_tests.c create mode 100644 regression/goto-analyzer/sensitivity-test-common-files/struct_of_pointer_sensitivity_tests.c create mode 100644 regression/goto-analyzer/sensitivity-test-common-files/struct_of_struct_sensitivity_tests.c create mode 100644 regression/goto-analyzer/sensitivity-test-common-files/struct_sensitivity_tests.c create mode 100644 regression/goto-analyzer/sensitivity-test-constants-array-of-constants-array/sensitivity_test_constants_array_of_constants_array.c create mode 100644 regression/goto-analyzer/sensitivity-test-constants-array-of-constants-array/test.desc create mode 100644 regression/goto-analyzer/sensitivity-test-constants-array-of-constants-pointer/sensitivity_test_constants_array_of_constants_pointer.c create mode 100644 regression/goto-analyzer/sensitivity-test-constants-array-of-constants-pointer/test.desc create mode 100644 regression/goto-analyzer/sensitivity-test-constants-array-of-two-value-pointer/sensitivity_test_constants_array_of_two_value_pointer.c create mode 100644 regression/goto-analyzer/sensitivity-test-constants-array-of-two-value-pointer/test.desc create mode 100644 regression/goto-analyzer/sensitivity-test-constants-array/sensitivity_test_constants_array.c create mode 100644 regression/goto-analyzer/sensitivity-test-constants-array/test.desc create mode 100644 regression/goto-analyzer/sensitivity-test-constants-char/sensitivity_test_constants_char.c create mode 100644 regression/goto-analyzer/sensitivity-test-constants-char/test.desc create mode 100644 regression/goto-analyzer/sensitivity-test-constants-float/sensitivity_test_constants_float.c create mode 100644 regression/goto-analyzer/sensitivity-test-constants-float/test.desc create mode 100644 regression/goto-analyzer/sensitivity-test-constants-int/sensitivity_test_constants_int.c create mode 100644 regression/goto-analyzer/sensitivity-test-constants-int/test.desc create mode 100644 regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-array/sensitivity_test_constants_pointer_to_constants_array.c create mode 100644 regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-array/test.desc create mode 100644 regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-pointer/sensitivity_test_constants_pointer_to_constants_pointer.c create mode 100644 regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-pointer/test.desc create mode 100644 regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-struct/sensitivity_test_constants_pointer_to_constants_struct.c create mode 100644 regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-struct/test.desc create mode 100644 regression/goto-analyzer/sensitivity-test-constants-pointer-to-two-value-array/sensitivity_test_constants_pointer_to_two_value_array.c create mode 100644 regression/goto-analyzer/sensitivity-test-constants-pointer-to-two-value-array/test.desc create mode 100644 regression/goto-analyzer/sensitivity-test-constants-pointer-to-two-value-struct/sensitivity_test_constants_pointer_to_two_value_struct.c create mode 100644 regression/goto-analyzer/sensitivity-test-constants-pointer-to-two-value-struct/test.desc create mode 100644 regression/goto-analyzer/sensitivity-test-constants-pointer/sensitivity_test_constants_pointer.c create mode 100644 regression/goto-analyzer/sensitivity-test-constants-pointer/test.desc create mode 100644 regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-array/sensitivity_test_constants_struct_of_constants_array.c create mode 100644 regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-array/test.desc create mode 100644 regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-pointer/sensitivity_test_constants_struct_of_constants_pointer.c create mode 100644 regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-pointer/test.desc create mode 100644 regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-struct/sensitivity_test_constants_struct_of_constants_struct.c create mode 100644 regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-struct/test.desc create mode 100644 regression/goto-analyzer/sensitivity-test-constants-struct-of-two-value-array/sensitivity_test_constants_struct_of_two_value_array.c create mode 100644 regression/goto-analyzer/sensitivity-test-constants-struct-of-two-value-array/test.desc create mode 100644 regression/goto-analyzer/sensitivity-test-constants-struct-of-two-value-pointer/sensitivity_test_constants_struct_of_two_value_pointer.c create mode 100644 regression/goto-analyzer/sensitivity-test-constants-struct-of-two-value-pointer/test.desc create mode 100644 regression/goto-analyzer/sensitivity-test-constants-struct/sensitivity_test_constants_struct.c create mode 100644 regression/goto-analyzer/sensitivity-test-constants-struct/test.desc create mode 100644 regression/goto-analyzer/sensitivity-test-two-value-array-of-two-value-array/sensitivity_test_two_value_array_of_two_value_array.c create mode 100644 regression/goto-analyzer/sensitivity-test-two-value-array-of-two-value-array/test.desc create mode 100644 regression/goto-analyzer/sensitivity-test-two-value-array-of-two-value-pointer/sensitivity_test_two_value_array_of_two_value_pointer.c create mode 100644 regression/goto-analyzer/sensitivity-test-two-value-array-of-two-value-pointer/test.desc create mode 100644 regression/goto-analyzer/sensitivity-test-two-value-array/sensitivity_test_two_value_array.c create mode 100644 regression/goto-analyzer/sensitivity-test-two-value-array/test.desc create mode 100644 regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-array/sensitivity_test_two_value_pointer_to_two_value_array.c create mode 100644 regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-array/test.desc create mode 100644 regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-pointer/sensitivity_test_two_value_pointer_to_two_value_pointer.c create mode 100644 regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-pointer/test.desc create mode 100644 regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-struct/sensitivity_test_two_value_pointer_to_two_value_struct.c create mode 100644 regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-struct/test.desc create mode 100644 regression/goto-analyzer/sensitivity-test-two-value-pointer/sensitivity_test_two_value_pointer.c create mode 100644 regression/goto-analyzer/sensitivity-test-two-value-pointer/test.desc create mode 100644 regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-array/sensitivity_test_two_value_struct_of_two_value_array.c create mode 100644 regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-array/test.desc create mode 100644 regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-pointer/sensitivity_test_two_value_struct_of_two_value_pointer.c create mode 100644 regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-pointer/test.desc create mode 100644 regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-struct/sensitivity_test_two_value_struct_of_two_value_struct.c create mode 100644 regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-struct/test.desc create mode 100644 regression/goto-analyzer/sensitivity-test-two-value-struct/sensitivity_test_two_value_struct.c create mode 100644 regression/goto-analyzer/sensitivity-test-two-value-struct/test.desc diff --git a/regression/goto-analyzer/sensitivity-test-common-files/array_of_array_sensitivity_tests.c b/regression/goto-analyzer/sensitivity-test-common-files/array_of_array_sensitivity_tests.c new file mode 100644 index 00000000000..63af187ade2 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-common-files/array_of_array_sensitivity_tests.c @@ -0,0 +1,150 @@ +#include + +int main(int argc, char *argv[]) +{ + // A uniform constant array + int a[3][3]={{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}; + // A non-uniform constant array + int b[3][3]={{0, 1, 2}, {3, 4, 5}, {6, 7, 8}}; + + // Test if we can represent uniform constant arrays + assert(a[1][2]==0); + assert(a[1][2]==1); + + // Test if we can represent constant arrays which aren't uniform + assert(b[1][2]==5); + assert(b[1][2]==0); + + // Test alternative syntax for accessing an array value + assert(*(b[1]+2)==5); + assert(*(b[1]+2)==0); + assert((*(b+1))[2]==5); + assert((*(b+1))[2]==0); + assert(*(*(b+1)+2)==5); + assert(*(*(b+1)+2)==0); + assert(1[b][2]==5); + assert(1[b][2]==0); + assert(*(1[b]+2)==5); + assert(*(1[b]+2)==0); + assert((*(1+b))[2]==5); + assert((*(1+b))[2]==0); + assert(*(*(1+b)+2)==5); + assert(*(*(1+b)+2)==0); + assert(2[1[b]]==5); + assert(2[1[b]]==0); + assert(*(2+1[b])==5); + assert(*(2+1[b])==0); + assert(*(2+*(1+b))==5); + assert(*(2+*(1+b))==0); + + // Test how well we can deal with merging for an array value when there is one + // possible value + if(argc>2) + { + a[0][1]=0; + } + assert(a[0][1]==0); + assert(a[0][1]==1); + assert(a[0][2]==0); + + // Test how well we can deal with merging for an array value when there are + // two possible values + if(argc>2) + { + b[0][1]=2; + } + assert(b[0][1]==2); + assert(b[0][1]==3); + assert(b[0][2]==2); + + // Reset this change to ensure tests later work as expected + b[0][1]=1; + + // The variables i, j and k will be used as indexes into arrays of size 3. + // They all require merging paths in the CFG. For i there is only one value on + // both paths, which is a valid index. The rest can each take two different + // values. For j both of these values are valid indexes. For k one is and one + // isn't. + int i=0; + int j=0; + int k=0; + if(argc>3) + { + i=0; + j=1; + k=100; + } + + // Test how well we can deal with merging for an index on a uniform array when + // the index has one possible value + assert(a[i][1]==0); + assert(a[i][1]==1); + assert(a[1][i]==0); + assert(a[1][i]==1); + assert(a[i][i]==0); + assert(a[i][i]==1); + + // Test how well we can deal with merging for an index on a uniform array when + // the index has two possible values + assert(a[j][1]==0); + assert(a[j][1]==1); + assert(a[1][j]==0); + assert(a[1][j]==1); + assert(a[j][j]==0); + assert(a[j][j]==1); + + // Test how well we can deal with merging for an index on a non-uniform array + + assert(b[i][1]==1); + assert(b[i][1]==11); + assert(b[1][i]==3); + assert(b[1][i]==11); + assert(b[i][i]==0); + assert(b[i][i]==11); + + // Test how well we can deal with merging for an index on a non-uniform array + assert(b[j][1]==1); + assert(b[j][1]==11); + assert(b[1][j]==3); + assert(b[1][j]==11); + assert(b[j][j]==0); + assert(b[j][j]==11); + + // Test how we deal with reading off the end of an array + assert(a[100][0]==0); + assert(a[0][100]==0); + + // Test how we deal with writing off the end of an array + int c=0; + a[100][0]=1; + assert(c==0); + c=0; + a[0][100]=1; + assert(c==0); + + // Test how we deal with merging for an index with one possible value when + // writing to an array + int ei[3][3]={{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}; + ei[i][1]=1; + assert(ei[0][1]==1); + assert(ei[0][1]==0); + assert(ei[2][1]==0); + assert(ei[2][1]==1); + + // Test how we deal with merging for an index with two possible values when + // writing to an array + int ej[3][3]={{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}; + ej[j][1]=1; + assert(ej[0][1]==0); + assert(ej[2][1]==0); + + // Test how we deal with merging for an index with two possible values when + // it means writing to an array element that may be out of bounds + int ek[3][3]={{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}; + c=0; + ek[k][1]=1; + assert(ek[0][1]==0); + assert(c==0); + + return 0; +} diff --git a/regression/goto-analyzer/sensitivity-test-common-files/array_of_pointer_sensitivity_tests.c b/regression/goto-analyzer/sensitivity-test-common-files/array_of_pointer_sensitivity_tests.c new file mode 100644 index 00000000000..907fc4180ad --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-common-files/array_of_pointer_sensitivity_tests.c @@ -0,0 +1,156 @@ +#include + +int main(int argc, char *argv[]) +{ + // Test how well we can represent arrays of pointers + int a0=0; + int a1=1; + int a2=2; + int a3=3; + int b0=10; + int b1=11; + int b2=12; + int b3=13; + int c0=20; + int c1=21; + int c2=22; + int c3=23; + int d0=30; + int d1=31; + int d2=32; + int d3=33; + // A uniform constant array + int *a[3]={&a0, &a0, &a0}; + // A non-uniform constant array + int *b[3]={&b0, &b1, &b2}; + + // Test if we can represent uniform constant arrays + assert(a[1]==&a0); + assert(a[1]==&a3); + assert(*a[1]==0); + assert(*a[1]==3); + + // Test if we can represent constant arrays which aren't uniform + assert(b[1]==&b1); + assert(b[1]==&b3); + assert(*b[1]==11); + assert(*b[1]==13); + + // Test alternative syntax for accessing an array value + assert(*(b+1)==&b1); + assert(*(b+1)==&b3); + assert(*(1+b)==&b1); + assert(*(1+b)==&b3); + assert(1[b]==&b1); + assert(1[b]==&b3); + assert(**(b+1)==11); + assert(**(b+1)==13); + assert(**(1+b)==11); + assert(**(1+b)==13); + assert(*1[b]==11); + assert(*1[b]==13); + + // c and d are arrays whose values requiring merging paths in the CFG. For + // c[0] there is only one possibility after merging and for d[0] there are + // two. + int *c[3]={&c0, &c1, &c2}; + int *d[3]={&d0, &d1, &d2}; + if(argc>2) + { + c[0]=&c3; + d[0]=&d3; + } + + // Test how well we can deal with merging for an array value + assert(c[0]==&c0); + assert(c[0]==&c3); + assert(d[0]==&d0); + assert(d[0]==&d3); + assert(*c[0]==20); + assert(*c[0]==23); + assert(*d[0]==30); + assert(*d[0]==33); + + // The variables i, j and k will be used as indexes into arrays of size 3. + // They all require merging paths in the CFG. For i there is only one value on + // both paths, which is a valid index. The rest can each take two different + // values. For j both of these values are valid indexes. For k one is and one + // isn't. + int i=0; + int j=0; + int k=0; + if(argc>3) + { + i=0; + j=1; + k=100; + } + + // Test how well we can deal with merging for an index on a uniform array + assert(a[i]==&a0); + assert(a[i]==&a3); + assert(a[j]==&a0); + assert(a[j]==&a3); + assert(*a[i]==0); + assert(*a[i]==3); + assert(*a[j]==0); + assert(*a[j]==3); + + // Test how well we can deal with merging for an index on a non-uniform array + assert(b[i]==&b0); + assert(b[i]==&b1); + assert(b[j]==&b0); + assert(b[j]==&b3); + assert(*b[i]==10); + assert(*b[i]==11); + assert(*b[j]==10); + assert(*b[j]==13); + + // Test how we deal with reading off the end of an array + assert(a[100]==&a2); + assert(*a[100]==2); + + // Test how we deal with writing off the end of an array + a[100]=&a2; + assert(b[1]==&b1); + assert(*b[1]==11); + + // Test how we deal with merging for an index with one possible value when + // writing to an array + int ei0=40; + int ei1=41; + int *ei[3]={&ei0, &ei0, &ei0}; + ei[i]=&ei1; + assert(ei[0]==&ei1); + assert(ei[0]==&ei0); + assert(ei[2]==&ei0); + assert(ei[2]==&ei1); + assert(*ei[0]==41); + assert(*ei[0]==40); + assert(*ei[2]==40); + assert(*ei[2]==41); + + // Test how we deal with merging for an index with two possible values when + // writing to an array + int ej0=50; + int ej1=51; + int *ej[3]={&ej0, &ej0, &ej0}; + ej[j]=&ej1; + assert(ej[0]==&ej0); + assert(ej[2]==&ej0); + assert(ej[2]==&ej1); + assert(*ej[0]==50); + assert(*ej[2]==50); + assert(*ej[2]==51); + + // Test how we deal with merging for an index with two possible values when + // it means writing to an array element that may be out of bounds + int ek0=60; + int ek1=61; + int *ek[3]={&ek0, &ek0, &ek0}; + ek[k]=&ek1; + assert(ek[0]==&ek0); + assert(*ek[0]==60); + + return 0; +} diff --git a/regression/goto-analyzer/sensitivity-test-common-files/array_sensitivity_tests.c b/regression/goto-analyzer/sensitivity-test-common-files/array_sensitivity_tests.c new file mode 100644 index 00000000000..68bace194c8 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-common-files/array_sensitivity_tests.c @@ -0,0 +1,101 @@ +#include + +int main(int argc, char *argv[]) +{ + // A uniform constant array + int a[3]={0, 0, 0}; + // A non-uniform constant array + int b[3]={1, 0, 0}; + + // Test if we can represent uniform constant arrays + assert(a[1]==0); + assert(a[1]==1); + + // Test if we can represent constant arrays which aren't uniform + assert(b[1]==0); + assert(b[1]==1); + + // Test alternative syntax for accessing an array value + assert(*(b+1)==0); + assert(*(b+1)==1); + assert(*(1+b)==0); + assert(*(1+b)==1); + assert(1[b]==0); + assert(1[b]==1); + + // c and d are arrays whose values requiring merging paths in the CFG. For + // c[0] there is only one possibility after merging and for d[0] there are + // two. + int c[3]={0, 0, 0}; + int d[3]={0, 0, 0}; + if(argc>2) + { + c[0]=0; + d[0]=1; + } + + // Test how well we can deal with merging for an array value + assert(c[0]==0); + assert(c[0]==1); + assert(d[0]==0); + assert(d[0]==2); + assert(d[1]==0); + + // The variables i, j and k will be used as indexes into arrays of size 3. + // They all require merging paths in the CFG. For i there is only one value on + // both paths, which is a valid index. The rest can each take two different + // values. For j both of these values are valid indexes. For k one is and one + // isn't. + int i=0; + int j=0; + int k=0; + if(argc>3) + { + i=0; + j=1; + k=100; + } + + // Test how well we can deal with merging for an index on a uniform array + assert(a[i]==0); + assert(a[i]==1); + assert(a[j]==0); + assert(a[j]==1); + + // Test how well we can deal with merging for an index on a non-uniform array + assert(b[i]==1); + assert(b[i]==0); + assert(b[j]==0); + assert(b[j]==1); + + // Test how we deal with reading off the end of an array + assert(a[100]==0); + + // Test how we deal with writing off the end of an array + a[100]=1; + assert(b[1]==0); + + // Test how we deal with merging for an index with one possible value when + // writing to an array + int ei[3]={0, 0, 0}; + ei[i]=1; + assert(ei[0]==1); + assert(ei[0]==0); + assert(ei[2]==0); + assert(ei[2]==1); + + // Test how we deal with merging for an index with two possible values when + // writing to an array + int ej[3]={0, 0, 0}; + ej[j]=1; + assert(ej[0]==0); + assert(ej[2]==0); + + // Test how we deal with merging for an index with two possible values when + // it means writing to an array element that may be out of bounds + int ek[3]={0, 0, 0}; + ek[k]=1; + assert(ek[0]==0); + + return 0; +} diff --git a/regression/goto-analyzer/sensitivity-test-common-files/char_sensitivity_tests.c b/regression/goto-analyzer/sensitivity-test-common-files/char_sensitivity_tests.c new file mode 100644 index 00000000000..9e87454b68e --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-common-files/char_sensitivity_tests.c @@ -0,0 +1,10 @@ +#include + +int main(int argc, char *argv[]) +{ + // Test if we can represent constant chars + char x='a'; + assert(x=='a'); + assert(x=='b'); + return 0; +} diff --git a/regression/goto-analyzer/sensitivity-test-common-files/float_sensitivity_tests.c b/regression/goto-analyzer/sensitivity-test-common-files/float_sensitivity_tests.c new file mode 100644 index 00000000000..1f73fae4a6c --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-common-files/float_sensitivity_tests.c @@ -0,0 +1,10 @@ +#include + +int main(int argc, char *argv[]) +{ + // Test if we can represent constant floats + float x=0.0; + assert(x==0.0); + assert(x==1.0); + return 0; +} diff --git a/regression/goto-analyzer/sensitivity-test-common-files/int_sensitivity_tests.c b/regression/goto-analyzer/sensitivity-test-common-files/int_sensitivity_tests.c new file mode 100644 index 00000000000..ab4265a051f --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-common-files/int_sensitivity_tests.c @@ -0,0 +1,55 @@ +#include + +int main(int argc, char *argv[]) +{ + // Test how well we can represent ints, and also that the transformers are + // working correctly. + int x=0; + int y=0; + if(argc>2) + { + y=1; + } + assert(x==0); + assert(x==1); + assert(x==y); + + assert(x<1); + assert(x<-1); + assert(x-1); + assert(x>1); + assert(x>y); + + assert(x!=1); + assert(x!=0); + assert(x!=y); + + assert(!(x==1)); + assert(!(x==0)); + assert(!(x==y)); + + // Test how well we can represent an int when it has more than one possible + // value + assert(y<2); + assert(y>2); + assert(y==1); + + // Try copying a variable and then modifying the original + int z=x; + x=10; + assert(z==0); + assert(z==10); + + // Test how we treat assertions in unreachable code + x=0; + if(0) + { + assert(x==0); + assert(x==1); + assert(y==0); + } + + return 0; +} diff --git a/regression/goto-analyzer/sensitivity-test-common-files/pointer_sensitivity_tests.c b/regression/goto-analyzer/sensitivity-test-common-files/pointer_sensitivity_tests.c new file mode 100644 index 00000000000..be328fa4a5d --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-common-files/pointer_sensitivity_tests.c @@ -0,0 +1,53 @@ +#include + +int main(int argc, char *argv[]) +{ + // Test how well we can represent pointers + // Basic use of addresses + int a=0; + int b=0; + int c=0; + int *x=&a; + int *x2=&a; + int *y=&b; + assert(x==&a); + assert(x==&b); + assert(x==x2); + assert(x==y); + + // Reading from a dereferenced pointer + assert(*x==0); + assert(*x==1); + + // Modify the referenced value and access it through the pointer again + a=1; + assert(*x==1); + assert(*x==0); + + // Writing to a dereferenced pointer + *x=2; + assert(a==2); + assert(a==0); + + // Conditionally reassign the pointer, but to the same value + if(argc>2) + { + x=&a; + } + assert(x==&a); + + // Conditionally reassign the pointer, to a different value this time + if(argc>3) + { + x=&b; + } + else + { + x=&c; + } + assert(*x==0); + assert(x==&a); + assert(x==&b); + + return 0; +} diff --git a/regression/goto-analyzer/sensitivity-test-common-files/pointer_to_array_sensitivity_tests.c b/regression/goto-analyzer/sensitivity-test-common-files/pointer_to_array_sensitivity_tests.c new file mode 100644 index 00000000000..db9fe720e15 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-common-files/pointer_to_array_sensitivity_tests.c @@ -0,0 +1,59 @@ +#include +#include + +int main(int argc, char *argv[]) +{ + // Test reading from an array using a pointer + int a[3]={1, 2, 3}; + int *p=a; + assert(p==&a[0]); + assert(*p==1); + + // Test pointer arithmetic + int *q=&a[1]; + assert(q==p+1); + assert(*q==2); + + // Test pointer diffs + ptrdiff_t x=1; + assert(q-p==x); + + // Test writing into an array using a pointer + *q=4; + assert(a[1]==4); + a[1]=2; + + // We now explore pointers and indexes each with more than one possible value + int *r=&a[1]; + int b[3]={0, 0, 0}; + int *s=&b[1]; + int i=1; + if (argc>2) + { + r=&a[2]; + s=&b[2]; + i=2; + } + + // Test reading from an array using a pointer with more than one possible + // value + assert(*r==2); + assert(*r==1); + assert(*s==0); + assert(*s==1); + + // Test pointer arithmetic with an unknown index + int *t=&a[i]; + assert(t==p+i); + + // Test pointer diffs with an unknown index + ptrdiff_t y=i; + assert(t-p==y); + + // Test writing into an array using a pointer with an unknown index + *r=5; + assert(a[i]==5); + assert(a[1]==5); + + return 0; +} diff --git a/regression/goto-analyzer/sensitivity-test-common-files/pointer_to_pointer_sensitivity_tests.c b/regression/goto-analyzer/sensitivity-test-common-files/pointer_to_pointer_sensitivity_tests.c new file mode 100644 index 00000000000..ee29a7059db --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-common-files/pointer_to_pointer_sensitivity_tests.c @@ -0,0 +1,24 @@ +#include + +int main(int argc, char *argv[]) +{ + // Test how well we can represent pointers to pointers + // Basic use of addresses + int a=0; + int *p=&a; + int **x=&p; + + // Reading from a pointer to a pointer that's been dereferenced twice + assert(**x==0); + assert(**x==1); + a=1; + assert(**x==1); + assert(**x==0); + + // Writing to a pointer to a pointer that's been dereferenced twice + **x=2; + assert(a==2); + assert(a==1); + + return 0; +} diff --git a/regression/goto-analyzer/sensitivity-test-common-files/pointer_to_struct_sensitivity_tests.c b/regression/goto-analyzer/sensitivity-test-common-files/pointer_to_struct_sensitivity_tests.c new file mode 100644 index 00000000000..e0092afae4a --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-common-files/pointer_to_struct_sensitivity_tests.c @@ -0,0 +1,28 @@ +#include + +int main(int argc, char *argv[]) +{ + // Test how well we can represent pointers to structs + struct int_float + { + int a; + float b; + }; + struct int_float x={0, 1.0}; + x.a=0; + x.b=1.0; + struct int_float *p=&x; + assert((*p).a==0); + assert((*p).a==1); + + // Test alternative syntax + assert(p->a==0); + assert(p->a==1); + + // Test writing to the struct through the pointer + p->b=2.0; + assert(p->b==2.0); + assert(p->b==1.0); + + return 0; +} diff --git a/regression/goto-analyzer/sensitivity-test-common-files/struct_of_array_sensitivity_tests.c b/regression/goto-analyzer/sensitivity-test-common-files/struct_of_array_sensitivity_tests.c new file mode 100644 index 00000000000..d5924b71ed7 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-common-files/struct_of_array_sensitivity_tests.c @@ -0,0 +1,58 @@ +#include + +int main(int argc, char *argv[]) +{ + // Test how well we can represent structs + struct int_array_float_array + { + int a[3]; + float b[3]; + }; + struct int_array_float_array x={{0, 1, 2}, {3.0f, 4.0f, 5.0f}}; + x.a[0]=0; + x.a[1]=1; + x.a[2]=2; + x.b[0]=3.0f; + x.b[1]=4.0f; + x.b[2]=5.0f; + assert(x.a[0]==0); + assert(*(x.a+0)==0); + assert(*(0+x.a)==0); + assert(0[x.a]==0); + + // Test merging when there is only one value on both paths + if(argc>2) + { + x.a[0]=0; + } + assert(x.a[0]==0); + assert(x.a[1]==1); + assert(x.b[0]==3.0f); + + // Test merging when there is one value for a and two values for b, to test if + // we are representing them separately + if(argc>3) + { + x.a[0]=0; + x.b[2]=15.0f; + } + assert(x.a[0]==0); + assert(x.a[1]==1); + assert(x.b[2]>0.0f); + assert(x.b[2]==15.0f); + assert(x.b[2]==1.0f); + assert(x.b[0]==3.0f); + + // Test merging when there are two values for a and b + if(argc>4) + { + x.a[0]=11; + x.b[2]=25.0f; + } + assert(x.a[0]<12); + assert(x.a[0]>2); + assert(x.a[0]==0); + assert(x.a[1]==1); + + return 0; +} diff --git a/regression/goto-analyzer/sensitivity-test-common-files/struct_of_pointer_sensitivity_tests.c b/regression/goto-analyzer/sensitivity-test-common-files/struct_of_pointer_sensitivity_tests.c new file mode 100644 index 00000000000..3cde8011c2b --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-common-files/struct_of_pointer_sensitivity_tests.c @@ -0,0 +1,71 @@ +#include + +int main(int argc, char *argv[]) +{ + // Test how well we can represent structs of pointers + int a1=0; + int a2=1; + int a3=2; + float b1=10.0f; + float b2=11.0f; + float b3=12.0f; + float b4=13.0f; + struct int_float + { + int *a; + float *b; + }; + struct int_float x; + x.a=&a1; + x.b=&b1; + assert(x.a==&a1); + assert(x.a==&a2); + assert(x.b==&b1); + assert(x.b==&b2); + assert(*x.a==0); + assert(*x.a==100); + assert(*x.b==10.0f); + assert(*x.b==110.0f); + + // Test merging when there is only one value on both paths + if(argc>2) + { + x.a=&a1; + x.b=&b1; + } + assert(x.a==&a1); + assert(x.a==&a2); + assert(*x.a==0); + assert(*x.a==100); + + // Test merging when there is one value for a and two values for b, to test if + // we are representing them separately + if(argc>3) + { + x.a=&a1; + x.b=&b2; + } + assert(x.a==&a1); + assert(x.b==&b2); + assert(x.b==&b3); + assert(*x.a==0); + assert(*x.b==11.0f); + assert(*x.b==12.0f); + + // Test merging when there are two values for a and b + if(argc>4) + { + x.a=&a2; + x.b=&b3; + } + assert(x.a==&a2); + assert(x.a==&a3); + assert(x.b==&b3); + assert(x.b==&b4); + assert(*x.a==1); + assert(*x.a==2); + assert(*x.b==12.0f); + assert(*x.b==13.0f); + + return 0; +} diff --git a/regression/goto-analyzer/sensitivity-test-common-files/struct_of_struct_sensitivity_tests.c b/regression/goto-analyzer/sensitivity-test-common-files/struct_of_struct_sensitivity_tests.c new file mode 100644 index 00000000000..ac6a32a0086 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-common-files/struct_of_struct_sensitivity_tests.c @@ -0,0 +1,55 @@ +#include + +int main(int argc, char *argv[]) +{ + // Test how well we can represent structs of structs + struct int_float + { + int a; + float b; + }; + struct two_int_floats + { + struct int_float s1; + struct int_float s2; + }; + struct two_int_floats x; + x.s1.a=0; + x.s1.b=1.0; + x.s2.a=2; + x.s2.b=3.0f; + assert(x.s1.a==0); + assert(x.s2.b==3.0f); + + // Test merging when there is only one value on both paths + if(argc>2) + { + x.s1.a=0; + } + assert(x.s1.a==0); + assert(x.s1.a==10); + + // Test merging when there is one value for s1 and two values for s2, to test + // if we are representing them separately + if(argc>3) + { + x.s1.b=1.0f; + x.s2.b=13.0f; + } + assert(x.s1.b==1.0f); + assert(x.s2.b==3.0f); + assert(x.s2.b==0.0f); + + // Test merging when there are two values for s1 and s2 + if(argc>4) + { + x.s1.a=20; + x.s2.a=22; + } + assert(x.s1.a==20); + assert(x.s1.a<30); + assert(x.s2.a==22); + assert(x.s2.a<30); + + return 0; +} diff --git a/regression/goto-analyzer/sensitivity-test-common-files/struct_sensitivity_tests.c b/regression/goto-analyzer/sensitivity-test-common-files/struct_sensitivity_tests.c new file mode 100644 index 00000000000..a4ad229e34c --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-common-files/struct_sensitivity_tests.c @@ -0,0 +1,47 @@ +#include + +int main(int argc, char *argv[]) +{ + // Test how well we can represent structs + struct int_float + { + int a; + float b; + }; + struct int_float x={0, 1.0f}; + x.a=0; + x.b=1.0f; + assert(x.a==0); + assert(x.a==1); + + // Test merging when there is only one value on both paths + if(argc>2) + { + x.a=0; + x.b=1.0f; + } + assert(x.a==0); + + // Test merging when there is one value for a and two values for b, to test if + // we are representing them separately + if(argc>3) + { + x.a=0; + x.b=2.0f; + } + assert(x.a==0); + assert(x.b>0.0f); + assert(x.b==1.0f); + + // Test merging when there are two values for a and b + if(argc>4) + { + x.a=1; + x.b=2.0f; + } + assert(x.a<2); + assert(x.a>2); + assert(x.a==1); + + return 0; +} diff --git a/regression/goto-analyzer/sensitivity-test-constants-array-of-constants-array/sensitivity_test_constants_array_of_constants_array.c b/regression/goto-analyzer/sensitivity-test-constants-array-of-constants-array/sensitivity_test_constants_array_of_constants_array.c new file mode 100644 index 00000000000..103849f7a32 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-array-of-constants-array/sensitivity_test_constants_array_of_constants_array.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/array_of_array_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-array-of-constants-array/test.desc b/regression/goto-analyzer/sensitivity-test-constants-array-of-constants-array/test.desc new file mode 100644 index 00000000000..c8db44a2c09 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-array-of-constants-array/test.desc @@ -0,0 +1,73 @@ +FUTURE +sensitivity_test_constants_array_of_constants_array.c +--variable --arrays --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion a\[1\]\[2\]==0: Success$ +^\[main.assertion.2\] .* assertion a\[1\]\[2\]==1: Failure \(if reachable\)$ +^\[main.assertion.3\] .* assertion b\[1\]\[2\]==5: Success$ +^\[main.assertion.4\] .* assertion b\[1\]\[2\]==0: Failure \(if reachable\)$ +^\[main.assertion.5\] .* assertion \*\(b\[1\]\+2\)==5: Success$ +^\[main.assertion.6\] .* assertion \*\(b\[1\]\+2\)==0: Failure \(if reachable\)$ +^\[main.assertion.7\] .* assertion \(\*\(b\+1\)\)\[2\]==5: Success$ +^\[main.assertion.8\] .* assertion \(\*\(b\+1\)\)\[2\]==0: Failure \(if reachable\)$ +^\[main.assertion.9\] .* assertion \*\(\*\(b\+1\)\+2\)==5: Success$ +^\[main.assertion.10\] .* assertion \*\(\*\(b\+1\)\+2\)==0: Failure \(if reachable\)$ +^\[main.assertion.11\] .* assertion 1\[b\]\[2\]==5: Success$ +^\[main.assertion.12\] .* assertion 1\[b\]\[2\]==0: Failure \(if reachable\)$ +^\[main.assertion.13\] .* assertion \*\(1\[b\]\+2\)==5: Success$ +^\[main.assertion.14\] .* assertion \*\(1\[b\]\+2\)==0: Failure \(if reachable\)$ +^\[main.assertion.15\] .* assertion \(\*\(1\+b\)\)\[2\]==5: Unknown$ +^\[main.assertion.16\] .* assertion \(\*\(1\+b\)\)\[2\]==0: Unknown$ +^\[main.assertion.17\] .* assertion \*\(\*\(1\+b\)\+2\)==5: Unknown$ +^\[main.assertion.18\] .* assertion \*\(\*\(1\+b\)\+2\)==0: Unknown$ +^\[main.assertion.19\] .* assertion 2\[1\[b\]\]==5: Success$ +^\[main.assertion.20\] .* assertion 2\[1\[b\]\]==0: Failure \(if reachable\)$ +^\[main.assertion.21\] .* assertion \*\(2\+1\[b\]\)==5: Unknown$ +^\[main.assertion.22\] .* assertion \*\(2\+1\[b\]\)==0: Unknown$ +^\[main.assertion.23\] .* assertion \*\(2\+\*\(1\+b\)\)==5: Unknown$ +^\[main.assertion.24\] .* assertion \*\(2\+\*\(1\+b\)\)==0: Unknown$ +^\[main.assertion.25\] .* assertion a\[0\]\[1\]==0: Success$ +^\[main.assertion.26\] .* assertion a\[0\]\[1\]==1: Failure \(if reachable\)$ +^\[main.assertion.27\] .* assertion a\[0\]\[2\]==0: Success$ +^\[main.assertion.28\] .* assertion b\[0\]\[1\]==2: Unknown$ +^\[main.assertion.29\] .* assertion b\[0\]\[1\]==3: Unknown$ +^\[main.assertion.30\] .* assertion b\[0\]\[2\]==2: Success$ +^\[main.assertion.31\] .* assertion a\[i\]\[1\]==0: Success$ +^\[main.assertion.32\] .* assertion a\[i\]\[1\]==1: Failure \(if reachable\)$ +^\[main.assertion.33\] .* assertion a\[1\]\[i\]==0: Success$ +^\[main.assertion.34\] .* assertion a\[1\]\[i\]==1: Failure \(if reachable\)$ +^\[main.assertion.35\] .* assertion a\[i\]\[i\]==0: Success$ +^\[main.assertion.36\] .* assertion a\[i\]\[i\]==1: Failure \(if reachable\)$ +^\[main.assertion.37\] .* assertion a\[j\]\[1\]==0: Unknown$ +^\[main.assertion.38\] .* assertion a\[j\]\[1\]==1: Unknown$ +^\[main.assertion.39\] .* assertion a\[1\]\[j\]==0: Unknown$ +^\[main.assertion.40\] .* assertion a\[1\]\[j\]==1: Unknown$ +^\[main.assertion.41\] .* assertion a\[j\]\[j\]==0: Unknown$ +^\[main.assertion.42\] .* assertion a\[j\]\[j\]==1: Unknown$ +^\[main.assertion.43\] .* assertion b\[i\]\[1\]==1: Success$ +^\[main.assertion.44\] .* assertion b\[i\]\[1\]==11: Failure \(if reachable\)$ +^\[main.assertion.45\] .* assertion b\[1\]\[i\]==3: Success$ +^\[main.assertion.46\] .* assertion b\[1\]\[i\]==11: Failure \(if reachable\)$ +^\[main.assertion.47\] .* assertion b\[i\]\[i\]==0: Success$ +^\[main.assertion.48\] .* assertion b\[i\]\[i\]==11: Failure \(if reachable\)$ +^\[main.assertion.49\] .* assertion b\[j\]\[1\]==1: Unknown$ +^\[main.assertion.50\] .* assertion b\[j\]\[1\]==11: Unknown$ +^\[main.assertion.51\] .* assertion b\[1\]\[j\]==3: Unknown$ +^\[main.assertion.52\] .* assertion b\[1\]\[j\]==11: Unknown$ +^\[main.assertion.53\] .* assertion b\[j\]\[j\]==0: Unknown$ +^\[main.assertion.54\] .* assertion b\[j\]\[j\]==11: Unknown$ +^\[main.assertion.55\] .* assertion a\[100\]\[0\]==0: Unknown$ +^\[main.assertion.56\] .* assertion a\[0\]\[100\]==0: Unknown$ +^\[main.assertion.57\] .* assertion c==0: Success$ +^\[main.assertion.58\] .* assertion c==0: Success$ +^\[main.assertion.59\] .* assertion ei\[0\]\[1\]==1: Success$ +^\[main.assertion.60\] .* assertion ei\[0\]\[1\]==0: Failure \(if reachable\)$ +^\[main.assertion.61\] .* assertion ei\[2\]\[1\]==0: Success$ +^\[main.assertion.62\] .* assertion ei\[2\]\[1\]==1: Failure \(if reachable\)$ +^\[main.assertion.63\] .* assertion ej\[0\]\[1\]==0: Unknown$ +^\[main.assertion.64\] .* assertion ej\[2\]\[1\]==0: Unknown$ +^\[main.assertion.65\] .* assertion ek\[0\]\[1\]==0: Unknown$ +^\[main.assertion.66\] .* assertion c==0: Success$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-array-of-constants-pointer/sensitivity_test_constants_array_of_constants_pointer.c b/regression/goto-analyzer/sensitivity-test-constants-array-of-constants-pointer/sensitivity_test_constants_array_of_constants_pointer.c new file mode 100644 index 00000000000..66edcccfbfb --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-array-of-constants-pointer/sensitivity_test_constants_array_of_constants_pointer.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/array_of_pointer_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-array-of-constants-pointer/test.desc b/regression/goto-analyzer/sensitivity-test-constants-array-of-constants-pointer/test.desc new file mode 100644 index 00000000000..9242552c707 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-array-of-constants-pointer/test.desc @@ -0,0 +1,71 @@ +FUTURE +sensitivity_test_constants_array_of_constants_pointer.c +--variable --arrays --pointers --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion a\[1\]==&a0: Success$ +^\[main.assertion.2\] .* assertion a\[1\]==&a3: Failure \(if reachable\)$ +^\[main.assertion.3\] .* assertion \*a\[1\]==0: Success$ +^\[main.assertion.4\] .* assertion \*a\[1\]==3: Failure \(if reachable\)$ +^\[main.assertion.5\] .* assertion b\[1\]==&b1: Success$ +^\[main.assertion.6\] .* assertion b\[1\]==&b3: Failure \(if reachable\)$ +^\[main.assertion.7\] .* assertion \*b\[1\]==11: Success$ +^\[main.assertion.8\] .* assertion \*b\[1\]==13: Failure \(if reachable\)$ +^\[main.assertion.9\] .* assertion \*\(b\+1\)==&b1: Success$ +^\[main.assertion.10\] .* assertion \*\(b\+1\)==&b3: Failure \(if reachable\)$ +^\[main.assertion.11\] .* assertion \*\(1\+b\)==&b1: Unknown$ +^\[main.assertion.12\] .* assertion \*\(1\+b\)==&b3: Unknown$ +^\[main.assertion.13\] .* assertion 1\[b\]==&b1: Success$ +^\[main.assertion.14\] .* assertion 1\[b\]==&b3: Failure \(if reachable\)$ +^\[main.assertion.15\] .* assertion \*\*\(b\+1\)==11: Success$ +^\[main.assertion.16\] .* assertion \*\*\(b\+1\)==13: Failure \(if reachable\)$ +^\[main.assertion.17\] .* assertion \*\*\(1\+b\)==11: Unknown$ +^\[main.assertion.18\] .* assertion \*\*\(1\+b\)==13: Unknown$ +^\[main.assertion.19\] .* assertion \*1\[b\]==11: Success$ +^\[main.assertion.20\] .* assertion \*1\[b\]==13: Failure \(if reachable\)$ +^\[main.assertion.21\] .* assertion c\[0\]==&c0: Unknown$ +^\[main.assertion.22\] .* assertion c\[0\]==&c3: Unknown$ +^\[main.assertion.23\] .* assertion d\[0\]==&d0: Unknown$ +^\[main.assertion.24\] .* assertion d\[0\]==&d3: Unknown$ +^\[main.assertion.25\] .* assertion \*c\[0\]==20: Unknown$ +^\[main.assertion.26\] .* assertion \*c\[0\]==23: Unknown$ +^\[main.assertion.27\] .* assertion \*d\[0\]==30: Unknown$ +^\[main.assertion.28\] .* assertion \*d\[0\]==33: Unknown$ +^\[main.assertion.29\] .* assertion a\[i\]==&a0: Success$ +^\[main.assertion.30\] .* assertion a\[i\]==&a3: Failure \(if reachable\)$ +^\[main.assertion.31\] .* assertion a\[j\]==&a0: Unknown$ +^\[main.assertion.32\] .* assertion a\[j\]==&a3: Unknown$ +^\[main.assertion.33\] .* assertion \*a\[i\]==0: Success$ +^\[main.assertion.34\] .* assertion \*a\[i\]==3: Failure \(if reachable\)$ +^\[main.assertion.35\] .* assertion \*a\[j\]==0: Unknown$ +^\[main.assertion.36\] .* assertion \*a\[j\]==3: Unknown$ +^\[main.assertion.37\] .* assertion b\[i\]==&b0: Success$ +^\[main.assertion.38\] .* assertion b\[i\]==&b1: Failure \(if reachable\)$ +^\[main.assertion.39\] .* assertion b\[j\]==&b0: Unknown$ +^\[main.assertion.40\] .* assertion b\[j\]==&b3: Unknown$ +^\[main.assertion.41\] .* assertion \*b\[i\]==10: Success$ +^\[main.assertion.42\] .* assertion \*b\[i\]==11: Failure \(if reachable\)$ +^\[main.assertion.43\] .* assertion \*b\[j\]==10: Unknown$ +^\[main.assertion.44\] .* assertion \*b\[j\]==13: Unknown$ +^\[main.assertion.45\] .* assertion a\[100\]==&a2: Unknown$ +^\[main.assertion.46\] .* assertion \*a\[100\]==2: Unknown$ +^\[main.assertion.47\] .* assertion b\[1\]==&b1: Success$ +^\[main.assertion.48\] .* assertion \*b\[1\]==11: Success$ +^\[main.assertion.49\] .* assertion ei\[0\]==&ei1: Success$ +^\[main.assertion.50\] .* assertion ei\[0\]==&ei0: Failure \(if reachable\)$ +^\[main.assertion.51\] .* assertion ei\[2\]==&ei0: Success$ +^\[main.assertion.52\] .* assertion ei\[2\]==&ei1: Failure \(if reachable\)$ +^\[main.assertion.53\] .* assertion \*ei\[0\]==41: Success$ +^\[main.assertion.54\] .* assertion \*ei\[0\]==40: Failure \(if reachable\)$ +^\[main.assertion.55\] .* assertion \*ei\[2\]==40: Success$ +^\[main.assertion.56\] .* assertion \*ei\[2\]==41: Failure \(if reachable\)$ +^\[main.assertion.57\] .* assertion ej\[0\]==&ej0: Unknown$ +^\[main.assertion.58\] .* assertion ej\[2\]==&ej0: Unknown$ +^\[main.assertion.59\] .* assertion ej\[2\]==&ej1: Unknown$ +^\[main.assertion.60\] .* assertion \*ej\[0\]==50: Unknown$ +^\[main.assertion.61\] .* assertion \*ej\[2\]==50: Unknown$ +^\[main.assertion.62\] .* assertion \*ej\[2\]==51: Unknown$ +^\[main.assertion.63\] .* assertion ek\[0\]==&ek0: Unknown$ +^\[main.assertion.64\] .* assertion \*ek\[0\]==60: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-array-of-two-value-pointer/sensitivity_test_constants_array_of_two_value_pointer.c b/regression/goto-analyzer/sensitivity-test-constants-array-of-two-value-pointer/sensitivity_test_constants_array_of_two_value_pointer.c new file mode 100644 index 00000000000..66edcccfbfb --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-array-of-two-value-pointer/sensitivity_test_constants_array_of_two_value_pointer.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/array_of_pointer_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-array-of-two-value-pointer/test.desc b/regression/goto-analyzer/sensitivity-test-constants-array-of-two-value-pointer/test.desc new file mode 100644 index 00000000000..74f5f128ed6 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-array-of-two-value-pointer/test.desc @@ -0,0 +1,71 @@ +FUTURE +sensitivity_test_constants_array_of_two_value_pointer.c +--variable --arrays --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion a\[1\]==&a0: Unknown$ +^\[main.assertion.2\] .* assertion a\[1\]==&a3: Unknown$ +^\[main.assertion.3\] .* assertion \*a\[1\]==0: Unknown$ +^\[main.assertion.4\] .* assertion \*a\[1\]==3: Unknown$ +^\[main.assertion.5\] .* assertion b\[1\]==&b1: Unknown$ +^\[main.assertion.6\] .* assertion b\[1\]==&b3: Unknown$ +^\[main.assertion.7\] .* assertion \*b\[1\]==11: Unknown$ +^\[main.assertion.8\] .* assertion \*b\[1\]==13: Unknown$ +^\[main.assertion.9\] .* assertion \*\(b\+1\)==&b1: Unknown$ +^\[main.assertion.10\] .* assertion \*\(b\+1\)==&b3: Unknown$ +^\[main.assertion.11\] .* assertion \*\(1\+b\)==&b1: Unknown$ +^\[main.assertion.12\] .* assertion \*\(1\+b\)==&b3: Unknown$ +^\[main.assertion.13\] .* assertion 1\[b\]==&b1: Unknown$ +^\[main.assertion.14\] .* assertion 1\[b\]==&b3: Unknown$ +^\[main.assertion.15\] .* assertion \*\*\(b\+1\)==11: Unknown$ +^\[main.assertion.16\] .* assertion \*\*\(b\+1\)==13: Unknown$ +^\[main.assertion.17\] .* assertion \*\*\(1\+b\)==11: Unknown$ +^\[main.assertion.18\] .* assertion \*\*\(1\+b\)==13: Unknown$ +^\[main.assertion.19\] .* assertion \*1\[b\]==11: Unknown$ +^\[main.assertion.20\] .* assertion \*1\[b\]==13: Unknown$ +^\[main.assertion.21\] .* assertion c\[0\]==&c0: Unknown$ +^\[main.assertion.22\] .* assertion c\[0\]==&c3: Unknown$ +^\[main.assertion.23\] .* assertion d\[0\]==&d0: Unknown$ +^\[main.assertion.24\] .* assertion d\[0\]==&d3: Unknown$ +^\[main.assertion.25\] .* assertion \*c\[0\]==20: Unknown$ +^\[main.assertion.26\] .* assertion \*c\[0\]==23: Unknown$ +^\[main.assertion.27\] .* assertion \*d\[0\]==30: Unknown$ +^\[main.assertion.28\] .* assertion \*d\[0\]==33: Unknown$ +^\[main.assertion.29\] .* assertion a\[i\]==&a0: Unknown$ +^\[main.assertion.30\] .* assertion a\[i\]==&a3: Unknown$ +^\[main.assertion.31\] .* assertion a\[j\]==&a0: Unknown$ +^\[main.assertion.32\] .* assertion a\[j\]==&a3: Unknown$ +^\[main.assertion.33\] .* assertion \*a\[i\]==0: Unknown$ +^\[main.assertion.34\] .* assertion \*a\[i\]==3: Unknown$ +^\[main.assertion.35\] .* assertion \*a\[j\]==0: Unknown$ +^\[main.assertion.36\] .* assertion \*a\[j\]==3: Unknown$ +^\[main.assertion.37\] .* assertion b\[i\]==&b0: Unknown$ +^\[main.assertion.38\] .* assertion b\[i\]==&b1: Unknown$ +^\[main.assertion.39\] .* assertion b\[j\]==&b0: Unknown$ +^\[main.assertion.40\] .* assertion b\[j\]==&b3: Unknown$ +^\[main.assertion.41\] .* assertion \*b\[i\]==10: Unknown$ +^\[main.assertion.42\] .* assertion \*b\[i\]==11: Unknown$ +^\[main.assertion.43\] .* assertion \*b\[j\]==10: Unknown$ +^\[main.assertion.44\] .* assertion \*b\[j\]==13: Unknown$ +^\[main.assertion.45\] .* assertion a\[100\]==&a2: Unknown$ +^\[main.assertion.46\] .* assertion \*a\[100\]==2: Unknown$ +^\[main.assertion.47\] .* assertion b\[1\]==&b1: Unknown$ +^\[main.assertion.48\] .* assertion \*b\[1\]==11: Unknown$ +^\[main.assertion.49\] .* assertion ei\[0\]==&ei1: Unknown$ +^\[main.assertion.50\] .* assertion ei\[0\]==&ei0: Unknown$ +^\[main.assertion.51\] .* assertion ei\[2\]==&ei0: Unknown$ +^\[main.assertion.52\] .* assertion ei\[2\]==&ei1: Unknown$ +^\[main.assertion.53\] .* assertion \*ei\[0\]==41: Unknown$ +^\[main.assertion.54\] .* assertion \*ei\[0\]==40: Unknown$ +^\[main.assertion.55\] .* assertion \*ei\[2\]==40: Unknown$ +^\[main.assertion.56\] .* assertion \*ei\[2\]==41: Unknown$ +^\[main.assertion.57\] .* assertion ej\[0\]==&ej0: Unknown$ +^\[main.assertion.58\] .* assertion ej\[2\]==&ej0: Unknown$ +^\[main.assertion.59\] .* assertion ej\[2\]==&ej1: Unknown$ +^\[main.assertion.60\] .* assertion \*ej\[0\]==50: Unknown$ +^\[main.assertion.61\] .* assertion \*ej\[2\]==50: Unknown$ +^\[main.assertion.62\] .* assertion \*ej\[2\]==51: Unknown$ +^\[main.assertion.63\] .* assertion ek\[0\]==&ek0: Unknown$ +^\[main.assertion.64\] .* assertion \*ek\[0\]==60: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-array/sensitivity_test_constants_array.c b/regression/goto-analyzer/sensitivity-test-constants-array/sensitivity_test_constants_array.c new file mode 100644 index 00000000000..e0a5a37a2a2 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-array/sensitivity_test_constants_array.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/array_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-array/test.desc b/regression/goto-analyzer/sensitivity-test-constants-array/test.desc new file mode 100644 index 00000000000..b48a2c823ca --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-array/test.desc @@ -0,0 +1,39 @@ +FUTURE +sensitivity_test_constants_array.c +--variable --arrays --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion a\[1\]==0: Success$ +^\[main.assertion.2\] .* assertion a\[1\]==1: Failure \(if reachable\)$ +^\[main.assertion.3\] .* assertion b\[1\]==0: Success$ +^\[main.assertion.4\] .* assertion b\[1\]==1: Failure \(if reachable\)$ +^\[main.assertion.5\] .* assertion \*\(b\+1\)==0: Success$ +^\[main.assertion.6\] .* assertion \*\(b\+1\)==1: Failure \(if reachable\)$ +^\[main.assertion.7\] .* assertion \*\(1\+b\)==0: Unknown$ +^\[main.assertion.8\] .* assertion \*\(1\+b\)==1: Unknown$ +^\[main.assertion.9\] .* assertion 1\[b\]==0: Success$ +^\[main.assertion.10\] .* assertion 1\[b\]==1: Failure \(if reachable\)$ +^\[main.assertion.11\] .* assertion c\[0\]==0: Success$ +^\[main.assertion.12\] .* assertion c\[0\]==1: Failure \(if reachable\)$ +^\[main.assertion.13\] .* assertion d\[0\]==0: Unknown$ +^\[main.assertion.14\] .* assertion d\[0\]==2: Unknown$ +^\[main.assertion.15\] .* assertion d\[1\]==0: Success$ +^\[main.assertion.16\] .* assertion a\[i\]==0: Success$ +^\[main.assertion.17\] .* assertion a\[i\]==1: Failure \(if reachable\)$ +^\[main.assertion.18\] .* assertion a\[j\]==0: Unknown$ +^\[main.assertion.19\] .* assertion a\[j\]==1: Unknown$ +^\[main.assertion.20\] .* assertion b\[i\]==1: Success$ +^\[main.assertion.21\] .* assertion b\[i\]==0: Failure \(if reachable\)$ +^\[main.assertion.22\] .* assertion b\[j\]==0: Unknown$ +^\[main.assertion.23\] .* assertion b\[j\]==1: Unknown$ +^\[main.assertion.24\] .* assertion a\[100\]==0: Unknown$ +^\[main.assertion.25\] .* assertion b\[1\]==0: Success$ +^\[main.assertion.26\] .* assertion ei\[0\]==1: Success$ +^\[main.assertion.27\] .* assertion ei\[0\]==0: Failure \(if reachable\)$ +^\[main.assertion.28\] .* assertion ei\[2\]==0: Success$ +^\[main.assertion.29\] .* assertion ei\[2\]==1: Failure \(if reachable\)$ +^\[main.assertion.30\] .* assertion ej\[0\]==0: Unknown$ +^\[main.assertion.31\] .* assertion ej\[2\]==0: Unknown$ +^\[main.assertion.32\] .* assertion ek\[0\]==0: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-char/sensitivity_test_constants_char.c b/regression/goto-analyzer/sensitivity-test-constants-char/sensitivity_test_constants_char.c new file mode 100644 index 00000000000..b97be63e211 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-char/sensitivity_test_constants_char.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/char_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-char/test.desc b/regression/goto-analyzer/sensitivity-test-constants-char/test.desc new file mode 100644 index 00000000000..4ae7832010b --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-char/test.desc @@ -0,0 +1,9 @@ +FUTURE +sensitivity_test_constants_char.c +--variable --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion x=='a': Success$ +^\[main.assertion.2\] .* assertion x=='b': Failure \(if reachable\)$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-float/sensitivity_test_constants_float.c b/regression/goto-analyzer/sensitivity-test-constants-float/sensitivity_test_constants_float.c new file mode 100644 index 00000000000..4e801235552 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-float/sensitivity_test_constants_float.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/float_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-float/test.desc b/regression/goto-analyzer/sensitivity-test-constants-float/test.desc new file mode 100644 index 00000000000..634ea862f56 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-float/test.desc @@ -0,0 +1,9 @@ +FUTURE +sensitivity_test_constants_float.c +--variable --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion x==0.0: Success$ +^\[main.assertion.2\] .* assertion x==1.0: Failure \(if reachable\)$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-int/sensitivity_test_constants_int.c b/regression/goto-analyzer/sensitivity-test-constants-int/sensitivity_test_constants_int.c new file mode 100644 index 00000000000..8a0f75feb97 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-int/sensitivity_test_constants_int.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/int_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-int/test.desc b/regression/goto-analyzer/sensitivity-test-constants-int/test.desc new file mode 100644 index 00000000000..d3c274a9447 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-int/test.desc @@ -0,0 +1,30 @@ +FUTURE +sensitivity_test_constants_int.c +--variable --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion x==0: Success$ +^\[main.assertion.2\] .* assertion x==1: Failure \(if reachable\)$ +^\[main.assertion.3\] .* assertion x==y: Unknown$ +^\[main.assertion.4\] .* assertion x<1: Success$ +^\[main.assertion.5\] .* assertion x<-1: Failure \(if reachable\)$ +^\[main.assertion.6\] .* assertion x-1: Success$ +^\[main.assertion.8\] .* assertion x>1: Failure \(if reachable\)$ +^\[main.assertion.9\] .* assertion x>y: Unknown$ +^\[main.assertion.10\] .* assertion x!=1: Success$ +^\[main.assertion.11\] .* assertion x!=0: Failure \(if reachable\)$ +^\[main.assertion.12\] .* assertion x!=y: Unknown$ +^\[main.assertion.13\] .* assertion !\(x==1\): Success$ +^\[main.assertion.14\] .* assertion !\(x==0\): Failure \(if reachable\)$ +^\[main.assertion.15\] .* assertion !\(x==y\): Unknown$ +^\[main.assertion.16\] .* assertion y<2: Unknown$ +^\[main.assertion.17\] .* assertion y>2: Unknown$ +^\[main.assertion.18\] .* assertion y==1: Unknown$ +^\[main.assertion.19\] .* assertion z==0: Success$ +^\[main.assertion.20\] .* assertion z==10: Failure \(if reachable\)$ +^\[main.assertion.21\] .* assertion x==0: Success \(unreachable\)$ +^\[main.assertion.22\] .* assertion x==1: Success \(unreachable\)$ +^\[main.assertion.23\] .* assertion y==0: Success \(unreachable\)$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-array/sensitivity_test_constants_pointer_to_constants_array.c b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-array/sensitivity_test_constants_pointer_to_constants_array.c new file mode 100644 index 00000000000..082fe2e62c8 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-array/sensitivity_test_constants_pointer_to_constants_array.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/pointer_to_array_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-array/test.desc b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-array/test.desc new file mode 100644 index 00000000000..7ccb164ab0f --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-array/test.desc @@ -0,0 +1,21 @@ +FUTURE +sensitivity_test_constants_pointer_to_constants_array.c +--variable --pointers --arrays --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion p==&a\[0\]: Success$ +^\[main.assertion.2\] .* assertion \*p==1: Success$ +^\[main.assertion.3\] .* assertion q==p\+1: Unknown$ +^\[main.assertion.4\] .* assertion \*q==2: Unknown$ +^\[main.assertion.5\] .* assertion q-p==x: Unknown$ +^\[main.assertion.6\] .* assertion a\[1\]==4: Unknown$ +^\[main.assertion.7\] .* assertion \*r==2: Unknown$ +^\[main.assertion.8\] .* assertion \*r==1: Unknown$ +^\[main.assertion.9\] .* assertion \*s==0: Unknown$ +^\[main.assertion.10\] .* assertion \*s==1: Unknown$ +^\[main.assertion.11\] .* assertion t==p\+i: Unknown$ +^\[main.assertion.12\] .* assertion t-p==y: Unknown$ +^\[main.assertion.13\] .* assertion a\[i\]==5: Unknown$ +^\[main.assertion.14\] .* assertion a\[1\]==5: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-pointer/sensitivity_test_constants_pointer_to_constants_pointer.c b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-pointer/sensitivity_test_constants_pointer_to_constants_pointer.c new file mode 100644 index 00000000000..56e6edc1093 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-pointer/sensitivity_test_constants_pointer_to_constants_pointer.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/pointer_to_pointer_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-pointer/test.desc b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-pointer/test.desc new file mode 100644 index 00000000000..f7fa1706d6a --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-pointer/test.desc @@ -0,0 +1,13 @@ +FUTURE +sensitivity_test_constants_pointer_to_constants_pointer.c +--variable --pointers --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion \*\*x==0: Success$ +^\[main.assertion.2\] .* assertion \*\*x==1: Failure \(if reachable\)$ +^\[main.assertion.3\] .* assertion \*\*x==1: Success$ +^\[main.assertion.4\] .* assertion \*\*x==0: Failure \(if reachable\)$ +^\[main.assertion.5\] .* assertion a==2: Success$ +^\[main.assertion.6\] .* assertion a==1: Failure \(if reachable\)$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-struct/sensitivity_test_constants_pointer_to_constants_struct.c b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-struct/sensitivity_test_constants_pointer_to_constants_struct.c new file mode 100644 index 00000000000..8f86047a407 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-struct/sensitivity_test_constants_pointer_to_constants_struct.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/pointer_to_struct_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-struct/test.desc b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-struct/test.desc new file mode 100644 index 00000000000..c7abd5e6821 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-struct/test.desc @@ -0,0 +1,16 @@ +KNOWNBUG +sensitivity_test_constants_pointer_to_constants_struct.c +--variable --pointers --structs --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion \(\*p\).a==0: Success$ +^\[main.assertion.2\] .* assertion \(\*p\).a==1: Failure \(if reachable\)$ +^\[main.assertion.3\] .* assertion p->a==0: Success$ +^\[main.assertion.4\] .* assertion p->a==1: Failure \(if reachable\)$ +^\[main.assertion.5\] .* assertion p->b==2.0: Success$ +^\[main.assertion.6\] .* assertion p->b==1.0: Failure \(if reachable\)$ +-- +^warning: ignoring +-- +The final two assertions are the wrong way round as modifying the pointer +does not seem to be propogating through. See #96 diff --git a/regression/goto-analyzer/sensitivity-test-constants-pointer-to-two-value-array/sensitivity_test_constants_pointer_to_two_value_array.c b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-two-value-array/sensitivity_test_constants_pointer_to_two_value_array.c new file mode 100644 index 00000000000..082fe2e62c8 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-two-value-array/sensitivity_test_constants_pointer_to_two_value_array.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/pointer_to_array_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-pointer-to-two-value-array/test.desc b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-two-value-array/test.desc new file mode 100644 index 00000000000..7121e17040d --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-two-value-array/test.desc @@ -0,0 +1,21 @@ +FUTURE +sensitivity_test_constants_pointer_to_two_value_array.c +--variable --pointers --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion p==&a\[0\]: Success$ +^\[main.assertion.2\] .* assertion \*p==1: Unknown$ +^\[main.assertion.3\] .* assertion q==p\+1: Unknown$ +^\[main.assertion.4\] .* assertion \*q==2: Unknown$ +^\[main.assertion.5\] .* assertion q-p==x: Unknown$ +^\[main.assertion.6\] .* assertion a\[1\]==4: Unknown$ +^\[main.assertion.7\] .* assertion \*r==2: Unknown$ +^\[main.assertion.8\] .* assertion \*r==1: Unknown$ +^\[main.assertion.9\] .* assertion \*s==0: Unknown$ +^\[main.assertion.10\] .* assertion \*s==1: Unknown$ +^\[main.assertion.11\] .* assertion t==p\+i: Unknown$ +^\[main.assertion.12\] .* assertion t-p==y: Unknown$ +^\[main.assertion.13\] .* assertion a\[i\]==5: Unknown$ +^\[main.assertion.14\] .* assertion a\[1\]==5: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-pointer-to-two-value-struct/sensitivity_test_constants_pointer_to_two_value_struct.c b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-two-value-struct/sensitivity_test_constants_pointer_to_two_value_struct.c new file mode 100644 index 00000000000..8f86047a407 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-two-value-struct/sensitivity_test_constants_pointer_to_two_value_struct.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/pointer_to_struct_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-pointer-to-two-value-struct/test.desc b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-two-value-struct/test.desc new file mode 100644 index 00000000000..a214499b34b --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-two-value-struct/test.desc @@ -0,0 +1,13 @@ +FUTURE +sensitivity_test_constants_pointer_to_two_value_struct.c +--variable --pointers --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion \(\*p\).a==0: Unknown$ +^\[main.assertion.2\] .* assertion \(\*p\).a==1: Unknown$ +^\[main.assertion.3\] .* assertion p->a==0: Unknown$ +^\[main.assertion.4\] .* assertion p->a==1: Unknown$ +^\[main.assertion.5\] .* assertion p->b==2.0: Unknown$ +^\[main.assertion.6\] .* assertion p->b==1.0: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-pointer/sensitivity_test_constants_pointer.c b/regression/goto-analyzer/sensitivity-test-constants-pointer/sensitivity_test_constants_pointer.c new file mode 100644 index 00000000000..a2167bc68f4 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-pointer/sensitivity_test_constants_pointer.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/pointer_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-pointer/test.desc b/regression/goto-analyzer/sensitivity-test-constants-pointer/test.desc new file mode 100644 index 00000000000..22c179f2233 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-pointer/test.desc @@ -0,0 +1,21 @@ +FUTURE +sensitivity_test_constants_pointer.c +--variable --pointers --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion x==&a: Success$ +^\[main.assertion.2\] .* assertion x==&b: Failure \(if reachable\)$ +^\[main.assertion.3\] .* assertion x==x2: Success$ +^\[main.assertion.4\] .* assertion x==y: Failure \(if reachable\)$ +^\[main.assertion.5\] .* assertion \*x==0: Success$ +^\[main.assertion.6\] .* assertion \*x==1: Failure \(if reachable\)$ +^\[main.assertion.7\] .* assertion \*x==1: Success$ +^\[main.assertion.8\] .* assertion \*x==0: Failure \(if reachable\)$ +^\[main.assertion.9\] .* assertion a==2: Success$ +^\[main.assertion.10\] .* assertion a==0: Failure \(if reachable\)$ +^\[main.assertion.11\] .* assertion x==&a: Success$ +^\[main.assertion.12\] .* assertion \*x==0: Unknown$ +^\[main.assertion.13\] .* assertion x==&a: Unknown$ +^\[main.assertion.14\] .* assertion x==&b: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-array/sensitivity_test_constants_struct_of_constants_array.c b/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-array/sensitivity_test_constants_struct_of_constants_array.c new file mode 100644 index 00000000000..d50aea1ea24 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-array/sensitivity_test_constants_struct_of_constants_array.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/struct_of_array_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-array/test.desc b/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-array/test.desc new file mode 100644 index 00000000000..7b6ae24bf61 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-array/test.desc @@ -0,0 +1,24 @@ +FUTURE +sensitivity_test_constants_struct_of_constants_array.c +--variable --structs --arrays --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion x.a\[0\]==0: Success$ +^\[main.assertion.2\] .* assertion \*\(x.a\+0\)==0: Success$ +^\[main.assertion.3\] .* assertion \*\(0\+x.a\)==0: Success$ +^\[main.assertion.4\] .* assertion 0\[x.a\]==0: Success$ +^\[main.assertion.5\] .* assertion x.a\[0\]==0: Success$ +^\[main.assertion.6\] .* assertion x.a\[1\]==1: Success$ +^\[main.assertion.7\] .* assertion x.b\[0\]==3.0f: Success$ +^\[main.assertion.8\] .* assertion x.a\[0\]==0: Success$ +^\[main.assertion.9\] .* assertion x.a\[1\]==1: Success$ +^\[main.assertion.10\] .* assertion x.b\[2\]>0.0f: Unknown$ +^\[main.assertion.11\] .* assertion x.b\[2\]==15.0f: Unknown$ +^\[main.assertion.12\] .* assertion x.b\[2\]==1.0f: Unknown$ +^\[main.assertion.13\] .* assertion x.b\[0\]==3.0f: Success$ +^\[main.assertion.14\] .* assertion x.a\[0\]<12: Unknown$ +^\[main.assertion.15\] .* assertion x.a\[0\]>2: Unknown$ +^\[main.assertion.16\] .* assertion x.a\[0\]==0: Unknown$ +^\[main.assertion.17\] .* assertion x.a\[1\]==1: Success$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-pointer/sensitivity_test_constants_struct_of_constants_pointer.c b/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-pointer/sensitivity_test_constants_struct_of_constants_pointer.c new file mode 100644 index 00000000000..ab7d896ae5d --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-pointer/sensitivity_test_constants_struct_of_constants_pointer.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/struct_of_pointer_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-pointer/test.desc b/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-pointer/test.desc new file mode 100644 index 00000000000..b278a7ed47c --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-pointer/test.desc @@ -0,0 +1,33 @@ +FUTURE +sensitivity_test_constants_struct_of_constants_pointer.c +--variable --structs --pointers --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion x.a==&a1: Success$ +^\[main.assertion.2\] .* assertion x.a==&a2: Failure \(if reachable\)$ +^\[main.assertion.3\] .* assertion x.b==&b1: Success$ +^\[main.assertion.4\] .* assertion x.b==&b2: Failure \(if reachable\)$ +^\[main.assertion.5\] .* assertion \*x.a==0: Success$ +^\[main.assertion.6\] .* assertion \*x.a==100: Failure \(if reachable\)$ +^\[main.assertion.7\] .* assertion \*x.b==10.0f: Success$ +^\[main.assertion.8\] .* assertion \*x.b==110.0f: Failure \(if reachable\)$ +^\[main.assertion.9\] .* assertion x.a==&a1: Success$ +^\[main.assertion.10\] .* assertion x.a==&a2: Failure \(if reachable\)$ +^\[main.assertion.11\] .* assertion \*x.a==0: Success$ +^\[main.assertion.12\] .* assertion \*x.a==100: Failure \(if reachable\)$ +^\[main.assertion.13\] .* assertion x.a==&a1: Success$ +^\[main.assertion.14\] .* assertion x.b==&b2: Unknown$ +^\[main.assertion.15\] .* assertion x.b==&b3: Unknown$ +^\[main.assertion.16\] .* assertion \*x.a==0: Success$ +^\[main.assertion.17\] .* assertion \*x.b==11.0f: Unknown$ +^\[main.assertion.18\] .* assertion \*x.b==12.0f: Unknown$ +^\[main.assertion.19\] .* assertion x.a==&a2: Unknown$ +^\[main.assertion.20\] .* assertion x.a==&a3: Unknown$ +^\[main.assertion.21\] .* assertion x.b==&b3: Unknown$ +^\[main.assertion.22\] .* assertion x.b==&b4: Unknown$ +^\[main.assertion.23\] .* assertion \*x.a==1: Unknown$ +^\[main.assertion.24\] .* assertion \*x.a==2: Unknown$ +^\[main.assertion.25\] .* assertion \*x.b==12.0f: Unknown$ +^\[main.assertion.26\] .* assertion \*x.b==13.0f: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-struct/sensitivity_test_constants_struct_of_constants_struct.c b/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-struct/sensitivity_test_constants_struct_of_constants_struct.c new file mode 100644 index 00000000000..ae2ab34d038 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-struct/sensitivity_test_constants_struct_of_constants_struct.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/struct_of_struct_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-struct/test.desc b/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-struct/test.desc new file mode 100644 index 00000000000..28f2e09614a --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-struct/test.desc @@ -0,0 +1,18 @@ +FUTURE +sensitivity_test_constants_struct_of_constants_struct.c +--variable --structs --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion x.s1.a==0: Success$ +^\[main.assertion.2\] .* assertion x.s2.b==3.0f: Success$ +^\[main.assertion.3\] .* assertion x.s1.a==0: Success$ +^\[main.assertion.4\] .* assertion x.s1.a==10: Failure \(if reachable\)$ +^\[main.assertion.5\] .* assertion x.s1.b==1.0f: Success$ +^\[main.assertion.6\] .* assertion x.s2.b==3.0f: Unknown$ +^\[main.assertion.7\] .* assertion x.s2.b==0.0f: Unknown$ +^\[main.assertion.8\] .* assertion x.s1.a==20: Unknown$ +^\[main.assertion.9\] .* assertion x.s1.a<30: Unknown$ +^\[main.assertion.10\] .* assertion x.s2.a==22: Unknown$ +^\[main.assertion.11\] .* assertion x.s2.a<30: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-struct-of-two-value-array/sensitivity_test_constants_struct_of_two_value_array.c b/regression/goto-analyzer/sensitivity-test-constants-struct-of-two-value-array/sensitivity_test_constants_struct_of_two_value_array.c new file mode 100644 index 00000000000..d50aea1ea24 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-struct-of-two-value-array/sensitivity_test_constants_struct_of_two_value_array.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/struct_of_array_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-struct-of-two-value-array/test.desc b/regression/goto-analyzer/sensitivity-test-constants-struct-of-two-value-array/test.desc new file mode 100644 index 00000000000..30edb4b598c --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-struct-of-two-value-array/test.desc @@ -0,0 +1,24 @@ +FUTURE +sensitivity_test_constants_struct_of_two_value_array.c +--variable --structs --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion x.a\[0\]==0: Unknown$ +^\[main.assertion.2\] .* assertion \*\(x.a\+0\)==0: Unknown$ +^\[main.assertion.3\] .* assertion \*\(0\+x.a\)==0: Unknown$ +^\[main.assertion.4\] .* assertion 0\[x.a\]==0: Unknown$ +^\[main.assertion.5\] .* assertion x.a\[0\]==0: Unknown$ +^\[main.assertion.6\] .* assertion x.a\[1\]==1: Unknown$ +^\[main.assertion.7\] .* assertion x.b\[0\]==3.0f: Unknown$ +^\[main.assertion.8\] .* assertion x.a\[0\]==0: Unknown$ +^\[main.assertion.9\] .* assertion x.a\[1\]==1: Unknown$ +^\[main.assertion.10\] .* assertion x.b\[2\]>0.0f: Unknown$ +^\[main.assertion.11\] .* assertion x.b\[2\]==15.0f: Unknown$ +^\[main.assertion.12\] .* assertion x.b\[2\]==1.0f: Unknown$ +^\[main.assertion.13\] .* assertion x.b\[0\]==3.0f: Unknown$ +^\[main.assertion.14\] .* assertion x.a\[0\]<12: Unknown$ +^\[main.assertion.15\] .* assertion x.a\[0\]>2: Unknown$ +^\[main.assertion.16\] .* assertion x.a\[0\]==0: Unknown$ +^\[main.assertion.17\] .* assertion x.a\[1\]==1: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-struct-of-two-value-pointer/sensitivity_test_constants_struct_of_two_value_pointer.c b/regression/goto-analyzer/sensitivity-test-constants-struct-of-two-value-pointer/sensitivity_test_constants_struct_of_two_value_pointer.c new file mode 100644 index 00000000000..ab7d896ae5d --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-struct-of-two-value-pointer/sensitivity_test_constants_struct_of_two_value_pointer.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/struct_of_pointer_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-struct-of-two-value-pointer/test.desc b/regression/goto-analyzer/sensitivity-test-constants-struct-of-two-value-pointer/test.desc new file mode 100644 index 00000000000..ea3a9cadb69 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-struct-of-two-value-pointer/test.desc @@ -0,0 +1,33 @@ +FUTURE +sensitivity_test_constants_struct_of_two_value_pointer.c +--variable --structs --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion x.a==&a1: Unknown$ +^\[main.assertion.2\] .* assertion x.a==&a2: Unknown$ +^\[main.assertion.3\] .* assertion x.b==&b1: Unknown$ +^\[main.assertion.4\] .* assertion x.b==&b2: Unknown$ +^\[main.assertion.5\] .* assertion \*x.a==0: Unknown$ +^\[main.assertion.6\] .* assertion \*x.a==100: Unknown$ +^\[main.assertion.7\] .* assertion \*x.b==10.0f: Unknown$ +^\[main.assertion.8\] .* assertion \*x.b==110.0f: Unknown$ +^\[main.assertion.9\] .* assertion x.a==&a1: Unknown$ +^\[main.assertion.10\] .* assertion x.a==&a2: Unknown$ +^\[main.assertion.11\] .* assertion \*x.a==0: Unknown$ +^\[main.assertion.12\] .* assertion \*x.a==100: Unknown$ +^\[main.assertion.13\] .* assertion x.a==&a1: Unknown$ +^\[main.assertion.14\] .* assertion x.b==&b2: Unknown$ +^\[main.assertion.15\] .* assertion x.b==&b3: Unknown$ +^\[main.assertion.16\] .* assertion \*x.a==0: Unknown$ +^\[main.assertion.17\] .* assertion \*x.b==11.0f: Unknown$ +^\[main.assertion.18\] .* assertion \*x.b==12.0f: Unknown$ +^\[main.assertion.19\] .* assertion x.a==&a2: Unknown$ +^\[main.assertion.20\] .* assertion x.a==&a3: Unknown$ +^\[main.assertion.21\] .* assertion x.b==&b3: Unknown$ +^\[main.assertion.22\] .* assertion x.b==&b4: Unknown$ +^\[main.assertion.23\] .* assertion \*x.a==1: Unknown$ +^\[main.assertion.24\] .* assertion \*x.a==2: Unknown$ +^\[main.assertion.25\] .* assertion \*x.b==12.0f: Unknown$ +^\[main.assertion.26\] .* assertion \*x.b==13.0f: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-struct/sensitivity_test_constants_struct.c b/regression/goto-analyzer/sensitivity-test-constants-struct/sensitivity_test_constants_struct.c new file mode 100644 index 00000000000..946ec769d9e --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-struct/sensitivity_test_constants_struct.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/struct_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-struct/test.desc b/regression/goto-analyzer/sensitivity-test-constants-struct/test.desc new file mode 100644 index 00000000000..64a15fcae85 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-struct/test.desc @@ -0,0 +1,16 @@ +FUTURE +sensitivity_test_constants_struct.c +--variable --structs --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion x.a==0: Success$ +^\[main.assertion.2\] .* assertion x.a==1: Failure \(if reachable\)$ +^\[main.assertion.3\] .* assertion x.a==0: Success$ +^\[main.assertion.4\] .* assertion x.a==0: Success$ +^\[main.assertion.5\] .* assertion x.b>0.0f: Unknown$ +^\[main.assertion.6\] .* assertion x.b==1.0f: Unknown$ +^\[main.assertion.7\] .* assertion x.a<2: Unknown$ +^\[main.assertion.8\] .* assertion x.a>2: Unknown$ +^\[main.assertion.9\] .* assertion x.a==1: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-two-value-array-of-two-value-array/sensitivity_test_two_value_array_of_two_value_array.c b/regression/goto-analyzer/sensitivity-test-two-value-array-of-two-value-array/sensitivity_test_two_value_array_of_two_value_array.c new file mode 100644 index 00000000000..103849f7a32 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-array-of-two-value-array/sensitivity_test_two_value_array_of_two_value_array.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/array_of_array_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-two-value-array-of-two-value-array/test.desc b/regression/goto-analyzer/sensitivity-test-two-value-array-of-two-value-array/test.desc new file mode 100644 index 00000000000..2c2c3ed15a8 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-array-of-two-value-array/test.desc @@ -0,0 +1,73 @@ +FUTURE +sensitivity_test_two_value_array_of_two_value_array.c +--variable --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion a\[1\]\[2\]==0: Unknown$ +^\[main.assertion.2\] .* assertion a\[1\]\[2\]==1: Unknown$ +^\[main.assertion.3\] .* assertion b\[1\]\[2\]==5: Unknown$ +^\[main.assertion.4\] .* assertion b\[1\]\[2\]==0: Unknown$ +^\[main.assertion.5\] .* assertion \*\(b\[1\]\+2\)==5: Unknown$ +^\[main.assertion.6\] .* assertion \*\(b\[1\]\+2\)==0: Unknown$ +^\[main.assertion.7\] .* assertion \(\*\(b\+1\)\)\[2\]==5: Unknown$ +^\[main.assertion.8\] .* assertion \(\*\(b\+1\)\)\[2\]==0: Unknown$ +^\[main.assertion.9\] .* assertion \*\(\*\(b\+1\)\+2\)==5: Unknown$ +^\[main.assertion.10\] .* assertion \*\(\*\(b\+1\)\+2\)==0: Unknown$ +^\[main.assertion.11\] .* assertion 1\[b\]\[2\]==5: Unknown$ +^\[main.assertion.12\] .* assertion 1\[b\]\[2\]==0: Unknown$ +^\[main.assertion.13\] .* assertion \*\(1\[b\]\+2\)==5: Unknown$ +^\[main.assertion.14\] .* assertion \*\(1\[b\]\+2\)==0: Unknown$ +^\[main.assertion.15\] .* assertion \(\*\(1\+b\)\)\[2\]==5: Unknown$ +^\[main.assertion.16\] .* assertion \(\*\(1\+b\)\)\[2\]==0: Unknown$ +^\[main.assertion.17\] .* assertion \*\(\*\(1\+b\)\+2\)==5: Unknown$ +^\[main.assertion.18\] .* assertion \*\(\*\(1\+b\)\+2\)==0: Unknown$ +^\[main.assertion.19\] .* assertion 2\[1\[b\]\]==5: Unknown$ +^\[main.assertion.20\] .* assertion 2\[1\[b\]\]==0: Unknown$ +^\[main.assertion.21\] .* assertion \*\(2\+1\[b\]\)==5: Unknown$ +^\[main.assertion.22\] .* assertion \*\(2\+1\[b\]\)==0: Unknown$ +^\[main.assertion.23\] .* assertion \*\(2\+\*\(1\+b\)\)==5: Unknown$ +^\[main.assertion.24\] .* assertion \*\(2\+\*\(1\+b\)\)==0: Unknown$ +^\[main.assertion.25\] .* assertion a\[0\]\[1\]==0: Unknown$ +^\[main.assertion.26\] .* assertion a\[0\]\[1\]==1: Unknown$ +^\[main.assertion.27\] .* assertion a\[0\]\[2\]==0: Unknown$ +^\[main.assertion.28\] .* assertion b\[0\]\[1\]==2: Unknown$ +^\[main.assertion.29\] .* assertion b\[0\]\[1\]==3: Unknown$ +^\[main.assertion.30\] .* assertion b\[0\]\[2\]==2: Unknown$ +^\[main.assertion.31\] .* assertion a\[i\]\[1\]==0: Unknown$ +^\[main.assertion.32\] .* assertion a\[i\]\[1\]==1: Unknown$ +^\[main.assertion.33\] .* assertion a\[1\]\[i\]==0: Unknown$ +^\[main.assertion.34\] .* assertion a\[1\]\[i\]==1: Unknown$ +^\[main.assertion.35\] .* assertion a\[i\]\[i\]==0: Unknown$ +^\[main.assertion.36\] .* assertion a\[i\]\[i\]==1: Unknown$ +^\[main.assertion.37\] .* assertion a\[j\]\[1\]==0: Unknown$ +^\[main.assertion.38\] .* assertion a\[j\]\[1\]==1: Unknown$ +^\[main.assertion.39\] .* assertion a\[1\]\[j\]==0: Unknown$ +^\[main.assertion.40\] .* assertion a\[1\]\[j\]==1: Unknown$ +^\[main.assertion.41\] .* assertion a\[j\]\[j\]==0: Unknown$ +^\[main.assertion.42\] .* assertion a\[j\]\[j\]==1: Unknown$ +^\[main.assertion.43\] .* assertion b\[i\]\[1\]==1: Unknown$ +^\[main.assertion.44\] .* assertion b\[i\]\[1\]==11: Unknown$ +^\[main.assertion.45\] .* assertion b\[1\]\[i\]==3: Unknown$ +^\[main.assertion.46\] .* assertion b\[1\]\[i\]==11: Unknown$ +^\[main.assertion.47\] .* assertion b\[i\]\[i\]==0: Unknown$ +^\[main.assertion.48\] .* assertion b\[i\]\[i\]==11: Unknown$ +^\[main.assertion.49\] .* assertion b\[j\]\[1\]==1: Unknown$ +^\[main.assertion.50\] .* assertion b\[j\]\[1\]==11: Unknown$ +^\[main.assertion.51\] .* assertion b\[1\]\[j\]==3: Unknown$ +^\[main.assertion.52\] .* assertion b\[1\]\[j\]==11: Unknown$ +^\[main.assertion.53\] .* assertion b\[j\]\[j\]==0: Unknown$ +^\[main.assertion.54\] .* assertion b\[j\]\[j\]==11: Unknown$ +^\[main.assertion.55\] .* assertion a\[100\]\[0\]==0: Unknown$ +^\[main.assertion.56\] .* assertion a\[0\]\[100\]==0: Unknown$ +^\[main.assertion.57\] .* assertion c==0: Success$ +^\[main.assertion.58\] .* assertion c==0: Success$ +^\[main.assertion.59\] .* assertion ei\[0\]\[1\]==1: Unknown$ +^\[main.assertion.60\] .* assertion ei\[0\]\[1\]==0: Unknown$ +^\[main.assertion.61\] .* assertion ei\[2\]\[1\]==0: Unknown$ +^\[main.assertion.62\] .* assertion ei\[2\]\[1\]==1: Unknown$ +^\[main.assertion.63\] .* assertion ej\[0\]\[1\]==0: Unknown$ +^\[main.assertion.64\] .* assertion ej\[2\]\[1\]==0: Unknown$ +^\[main.assertion.65\] .* assertion ek\[0\]\[1\]==0: Unknown$ +^\[main.assertion.66\] .* assertion c==0: Success$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-two-value-array-of-two-value-pointer/sensitivity_test_two_value_array_of_two_value_pointer.c b/regression/goto-analyzer/sensitivity-test-two-value-array-of-two-value-pointer/sensitivity_test_two_value_array_of_two_value_pointer.c new file mode 100644 index 00000000000..66edcccfbfb --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-array-of-two-value-pointer/sensitivity_test_two_value_array_of_two_value_pointer.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/array_of_pointer_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-two-value-array-of-two-value-pointer/test.desc b/regression/goto-analyzer/sensitivity-test-two-value-array-of-two-value-pointer/test.desc new file mode 100644 index 00000000000..f9de8e20a03 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-array-of-two-value-pointer/test.desc @@ -0,0 +1,71 @@ +FUTURE +sensitivity_test_two_value_array_of_two_value_pointer.c +--variable --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion a\[1\]==&a0: Unknown$ +^\[main.assertion.2\] .* assertion a\[1\]==&a3: Unknown$ +^\[main.assertion.3\] .* assertion \*a\[1\]==0: Unknown$ +^\[main.assertion.4\] .* assertion \*a\[1\]==3: Unknown$ +^\[main.assertion.5\] .* assertion b\[1\]==&b1: Unknown$ +^\[main.assertion.6\] .* assertion b\[1\]==&b3: Unknown$ +^\[main.assertion.7\] .* assertion \*b\[1\]==11: Unknown$ +^\[main.assertion.8\] .* assertion \*b\[1\]==13: Unknown$ +^\[main.assertion.9\] .* assertion \*\(b\+1\)==&b1: Unknown$ +^\[main.assertion.10\] .* assertion \*\(b\+1\)==&b3: Unknown$ +^\[main.assertion.11\] .* assertion \*\(1\+b\)==&b1: Unknown$ +^\[main.assertion.12\] .* assertion \*\(1\+b\)==&b3: Unknown$ +^\[main.assertion.13\] .* assertion 1\[b\]==&b1: Unknown$ +^\[main.assertion.14\] .* assertion 1\[b\]==&b3: Unknown$ +^\[main.assertion.15\] .* assertion \*\*\(b\+1\)==11: Unknown$ +^\[main.assertion.16\] .* assertion \*\*\(b\+1\)==13: Unknown$ +^\[main.assertion.17\] .* assertion \*\*\(1\+b\)==11: Unknown$ +^\[main.assertion.18\] .* assertion \*\*\(1\+b\)==13: Unknown$ +^\[main.assertion.19\] .* assertion \*1\[b\]==11: Unknown$ +^\[main.assertion.20\] .* assertion \*1\[b\]==13: Unknown$ +^\[main.assertion.21\] .* assertion c\[0\]==&c0: Unknown$ +^\[main.assertion.22\] .* assertion c\[0\]==&c3: Unknown$ +^\[main.assertion.23\] .* assertion d\[0\]==&d0: Unknown$ +^\[main.assertion.24\] .* assertion d\[0\]==&d3: Unknown$ +^\[main.assertion.25\] .* assertion \*c\[0\]==20: Unknown$ +^\[main.assertion.26\] .* assertion \*c\[0\]==23: Unknown$ +^\[main.assertion.27\] .* assertion \*d\[0\]==30: Unknown$ +^\[main.assertion.28\] .* assertion \*d\[0\]==33: Unknown$ +^\[main.assertion.29\] .* assertion a\[i\]==&a0: Unknown$ +^\[main.assertion.30\] .* assertion a\[i\]==&a3: Unknown$ +^\[main.assertion.31\] .* assertion a\[j\]==&a0: Unknown$ +^\[main.assertion.32\] .* assertion a\[j\]==&a3: Unknown$ +^\[main.assertion.33\] .* assertion \*a\[i\]==0: Unknown$ +^\[main.assertion.34\] .* assertion \*a\[i\]==3: Unknown$ +^\[main.assertion.35\] .* assertion \*a\[j\]==0: Unknown$ +^\[main.assertion.36\] .* assertion \*a\[j\]==3: Unknown$ +^\[main.assertion.37\] .* assertion b\[i\]==&b0: Unknown$ +^\[main.assertion.38\] .* assertion b\[i\]==&b1: Unknown$ +^\[main.assertion.39\] .* assertion b\[j\]==&b0: Unknown$ +^\[main.assertion.40\] .* assertion b\[j\]==&b3: Unknown$ +^\[main.assertion.41\] .* assertion \*b\[i\]==10: Unknown$ +^\[main.assertion.42\] .* assertion \*b\[i\]==11: Unknown$ +^\[main.assertion.43\] .* assertion \*b\[j\]==10: Unknown$ +^\[main.assertion.44\] .* assertion \*b\[j\]==13: Unknown$ +^\[main.assertion.45\] .* assertion a\[100\]==&a2: Unknown$ +^\[main.assertion.46\] .* assertion \*a\[100\]==2: Unknown$ +^\[main.assertion.47\] .* assertion b\[1\]==&b1: Unknown$ +^\[main.assertion.48\] .* assertion \*b\[1\]==11: Unknown$ +^\[main.assertion.49\] .* assertion ei\[0\]==&ei1: Unknown$ +^\[main.assertion.50\] .* assertion ei\[0\]==&ei0: Unknown$ +^\[main.assertion.51\] .* assertion ei\[2\]==&ei0: Unknown$ +^\[main.assertion.52\] .* assertion ei\[2\]==&ei1: Unknown$ +^\[main.assertion.53\] .* assertion \*ei\[0\]==41: Unknown$ +^\[main.assertion.54\] .* assertion \*ei\[0\]==40: Unknown$ +^\[main.assertion.55\] .* assertion \*ei\[2\]==40: Unknown$ +^\[main.assertion.56\] .* assertion \*ei\[2\]==41: Unknown$ +^\[main.assertion.57\] .* assertion ej\[0\]==&ej0: Unknown$ +^\[main.assertion.58\] .* assertion ej\[2\]==&ej0: Unknown$ +^\[main.assertion.59\] .* assertion ej\[2\]==&ej1: Unknown$ +^\[main.assertion.60\] .* assertion \*ej\[0\]==50: Unknown$ +^\[main.assertion.61\] .* assertion \*ej\[2\]==50: Unknown$ +^\[main.assertion.62\] .* assertion \*ej\[2\]==51: Unknown$ +^\[main.assertion.63\] .* assertion ek\[0\]==&ek0: Unknown$ +^\[main.assertion.64\] .* assertion \*ek\[0\]==60: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-two-value-array/sensitivity_test_two_value_array.c b/regression/goto-analyzer/sensitivity-test-two-value-array/sensitivity_test_two_value_array.c new file mode 100644 index 00000000000..e0a5a37a2a2 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-array/sensitivity_test_two_value_array.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/array_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-two-value-array/test.desc b/regression/goto-analyzer/sensitivity-test-two-value-array/test.desc new file mode 100644 index 00000000000..23ee78bd74f --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-array/test.desc @@ -0,0 +1,39 @@ +FUTURE +sensitivity_test_two_value_array.c +--variable --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion a\[1\]==0: Unknown$ +^\[main.assertion.2\] .* assertion a\[1\]==1: Unknown$ +^\[main.assertion.3\] .* assertion b\[1\]==0: Unknown$ +^\[main.assertion.4\] .* assertion b\[1\]==1: Unknown$ +^\[main.assertion.5\] .* assertion \*\(b\+1\)==0: Unknown$ +^\[main.assertion.6\] .* assertion \*\(b\+1\)==1: Unknown$ +^\[main.assertion.7\] .* assertion \*\(1\+b\)==0: Unknown$ +^\[main.assertion.8\] .* assertion \*\(1\+b\)==1: Unknown$ +^\[main.assertion.9\] .* assertion 1\[b\]==0: Unknown$ +^\[main.assertion.10\] .* assertion 1\[b\]==1: Unknown$ +^\[main.assertion.11\] .* assertion c\[0\]==0: Unknown$ +^\[main.assertion.12\] .* assertion c\[0\]==1: Unknown$ +^\[main.assertion.13\] .* assertion d\[0\]==0: Unknown$ +^\[main.assertion.14\] .* assertion d\[0\]==2: Unknown$ +^\[main.assertion.15\] .* assertion d\[1\]==0: Unknown$ +^\[main.assertion.16\] .* assertion a\[i\]==0: Unknown$ +^\[main.assertion.17\] .* assertion a\[i\]==1: Unknown$ +^\[main.assertion.18\] .* assertion a\[j\]==0: Unknown$ +^\[main.assertion.19\] .* assertion a\[j\]==1: Unknown$ +^\[main.assertion.20\] .* assertion b\[i\]==1: Unknown$ +^\[main.assertion.21\] .* assertion b\[i\]==0: Unknown$ +^\[main.assertion.22\] .* assertion b\[j\]==0: Unknown$ +^\[main.assertion.23\] .* assertion b\[j\]==1: Unknown$ +^\[main.assertion.24\] .* assertion a\[100\]==0: Unknown$ +^\[main.assertion.25\] .* assertion b\[1\]==0: Unknown$ +^\[main.assertion.26\] .* assertion ei\[0\]==1: Unknown$ +^\[main.assertion.27\] .* assertion ei\[0\]==0: Unknown$ +^\[main.assertion.28\] .* assertion ei\[2\]==0: Unknown$ +^\[main.assertion.29\] .* assertion ei\[2\]==1: Unknown$ +^\[main.assertion.30\] .* assertion ej\[0\]==0: Unknown$ +^\[main.assertion.31\] .* assertion ej\[2\]==0: Unknown$ +^\[main.assertion.32\] .* assertion ek\[0\]==0: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-array/sensitivity_test_two_value_pointer_to_two_value_array.c b/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-array/sensitivity_test_two_value_pointer_to_two_value_array.c new file mode 100644 index 00000000000..082fe2e62c8 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-array/sensitivity_test_two_value_pointer_to_two_value_array.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/pointer_to_array_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-array/test.desc b/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-array/test.desc new file mode 100644 index 00000000000..974705f9fc1 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-array/test.desc @@ -0,0 +1,21 @@ +FUTURE +sensitivity_test_two_value_pointer_to_two_value_array.c +--variable --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion p==&a\[0\]: Unknown$ +^\[main.assertion.2\] .* assertion \*p==1: Unknown$ +^\[main.assertion.3\] .* assertion q==p\+1: Unknown$ +^\[main.assertion.4\] .* assertion \*q==2: Unknown$ +^\[main.assertion.5\] .* assertion q-p==x: Unknown$ +^\[main.assertion.6\] .* assertion a\[1\]==4: Unknown$ +^\[main.assertion.7\] .* assertion \*r==2: Unknown$ +^\[main.assertion.8\] .* assertion \*r==1: Unknown$ +^\[main.assertion.9\] .* assertion \*s==0: Unknown$ +^\[main.assertion.10\] .* assertion \*s==1: Unknown$ +^\[main.assertion.11\] .* assertion t==p\+i: Unknown$ +^\[main.assertion.12\] .* assertion t-p==y: Unknown$ +^\[main.assertion.13\] .* assertion a\[i\]==5: Unknown$ +^\[main.assertion.14\] .* assertion a\[1\]==5: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-pointer/sensitivity_test_two_value_pointer_to_two_value_pointer.c b/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-pointer/sensitivity_test_two_value_pointer_to_two_value_pointer.c new file mode 100644 index 00000000000..56e6edc1093 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-pointer/sensitivity_test_two_value_pointer_to_two_value_pointer.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/pointer_to_pointer_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-pointer/test.desc b/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-pointer/test.desc new file mode 100644 index 00000000000..e3582834688 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-pointer/test.desc @@ -0,0 +1,13 @@ +FUTURE +sensitivity_test_two_value_pointer_to_two_value_pointer.c +--variable --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion \*\*x==0: Unknown$ +^\[main.assertion.2\] .* assertion \*\*x==1: Unknown$ +^\[main.assertion.3\] .* assertion \*\*x==1: Unknown$ +^\[main.assertion.4\] .* assertion \*\*x==0: Unknown$ +^\[main.assertion.5\] .* assertion a==2: Unknown$ +^\[main.assertion.6\] .* assertion a==1: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-struct/sensitivity_test_two_value_pointer_to_two_value_struct.c b/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-struct/sensitivity_test_two_value_pointer_to_two_value_struct.c new file mode 100644 index 00000000000..8f86047a407 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-struct/sensitivity_test_two_value_pointer_to_two_value_struct.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/pointer_to_struct_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-struct/test.desc b/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-struct/test.desc new file mode 100644 index 00000000000..56a0be48407 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-struct/test.desc @@ -0,0 +1,13 @@ +FUTURE +sensitivity_test_two_value_pointer_to_two_value_struct.c +--variable --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion \(\*p\).a==0: Unknown$ +^\[main.assertion.2\] .* assertion \(\*p\).a==1: Unknown$ +^\[main.assertion.3\] .* assertion p->a==0: Unknown$ +^\[main.assertion.4\] .* assertion p->a==1: Unknown$ +^\[main.assertion.5\] .* assertion p->b==2.0: Unknown$ +^\[main.assertion.6\] .* assertion p->b==1.0: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-two-value-pointer/sensitivity_test_two_value_pointer.c b/regression/goto-analyzer/sensitivity-test-two-value-pointer/sensitivity_test_two_value_pointer.c new file mode 100644 index 00000000000..a2167bc68f4 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-pointer/sensitivity_test_two_value_pointer.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/pointer_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-two-value-pointer/test.desc b/regression/goto-analyzer/sensitivity-test-two-value-pointer/test.desc new file mode 100644 index 00000000000..da9abe2464f --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-pointer/test.desc @@ -0,0 +1,21 @@ +FUTURE +sensitivity_test_two_value_pointer.c +--variable --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion x==&a: Unknown$ +^\[main.assertion.2\] .* assertion x==&b: Unknown$ +^\[main.assertion.3\] .* assertion x==x2: Unknown$ +^\[main.assertion.4\] .* assertion x==y: Unknown$ +^\[main.assertion.5\] .* assertion \*x==0: Unknown$ +^\[main.assertion.6\] .* assertion \*x==1: Unknown$ +^\[main.assertion.7\] .* assertion \*x==1: Unknown$ +^\[main.assertion.8\] .* assertion \*x==0: Unknown$ +^\[main.assertion.9\] .* assertion a==2: Unknown$ +^\[main.assertion.10\] .* assertion a==0: Unknown$ +^\[main.assertion.11\] .* assertion x==&a: Unknown$ +^\[main.assertion.12\] .* assertion \*x==0: Unknown$ +^\[main.assertion.13\] .* assertion x==&a: Unknown$ +^\[main.assertion.14\] .* assertion x==&b: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-array/sensitivity_test_two_value_struct_of_two_value_array.c b/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-array/sensitivity_test_two_value_struct_of_two_value_array.c new file mode 100644 index 00000000000..d50aea1ea24 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-array/sensitivity_test_two_value_struct_of_two_value_array.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/struct_of_array_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-array/test.desc b/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-array/test.desc new file mode 100644 index 00000000000..e8773cf68fc --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-array/test.desc @@ -0,0 +1,24 @@ +FUTURE +sensitivity_test_two_value_struct_of_two_value_array.c +--variable --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion x.a\[0\]==0: Unknown$ +^\[main.assertion.2\] .* assertion \*\(x.a\+0\)==0: Unknown$ +^\[main.assertion.3\] .* assertion \*\(0\+x.a\)==0: Unknown$ +^\[main.assertion.4\] .* assertion 0\[x.a\]==0: Unknown$ +^\[main.assertion.5\] .* assertion x.a\[0\]==0: Unknown$ +^\[main.assertion.6\] .* assertion x.a\[1\]==1: Unknown$ +^\[main.assertion.7\] .* assertion x.b\[0\]==3.0f: Unknown$ +^\[main.assertion.8\] .* assertion x.a\[0\]==0: Unknown$ +^\[main.assertion.9\] .* assertion x.a\[1\]==1: Unknown$ +^\[main.assertion.10\] .* assertion x.b\[2\]>0.0f: Unknown$ +^\[main.assertion.11\] .* assertion x.b\[2\]==15.0f: Unknown$ +^\[main.assertion.12\] .* assertion x.b\[2\]==1.0f: Unknown$ +^\[main.assertion.13\] .* assertion x.b\[0\]==3.0f: Unknown$ +^\[main.assertion.14\] .* assertion x.a\[0\]<12: Unknown$ +^\[main.assertion.15\] .* assertion x.a\[0\]>2: Unknown$ +^\[main.assertion.16\] .* assertion x.a\[0\]==0: Unknown$ +^\[main.assertion.17\] .* assertion x.a\[1\]==1: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-pointer/sensitivity_test_two_value_struct_of_two_value_pointer.c b/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-pointer/sensitivity_test_two_value_struct_of_two_value_pointer.c new file mode 100644 index 00000000000..ab7d896ae5d --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-pointer/sensitivity_test_two_value_struct_of_two_value_pointer.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/struct_of_pointer_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-pointer/test.desc b/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-pointer/test.desc new file mode 100644 index 00000000000..06ebb29d047 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-pointer/test.desc @@ -0,0 +1,33 @@ +FUTURE +sensitivity_test_two_value_struct_of_two_value_pointer.c +--variable --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion x.a==&a1: Unknown$ +^\[main.assertion.2\] .* assertion x.a==&a2: Unknown$ +^\[main.assertion.3\] .* assertion x.b==&b1: Unknown$ +^\[main.assertion.4\] .* assertion x.b==&b2: Unknown$ +^\[main.assertion.5\] .* assertion \*x.a==0: Unknown$ +^\[main.assertion.6\] .* assertion \*x.a==100: Unknown$ +^\[main.assertion.7\] .* assertion \*x.b==10.0f: Unknown$ +^\[main.assertion.8\] .* assertion \*x.b==110.0f: Unknown$ +^\[main.assertion.9\] .* assertion x.a==&a1: Unknown$ +^\[main.assertion.10\] .* assertion x.a==&a2: Unknown$ +^\[main.assertion.11\] .* assertion \*x.a==0: Unknown$ +^\[main.assertion.12\] .* assertion \*x.a==100: Unknown$ +^\[main.assertion.13\] .* assertion x.a==&a1: Unknown$ +^\[main.assertion.14\] .* assertion x.b==&b2: Unknown$ +^\[main.assertion.15\] .* assertion x.b==&b3: Unknown$ +^\[main.assertion.16\] .* assertion \*x.a==0: Unknown$ +^\[main.assertion.17\] .* assertion \*x.b==11.0f: Unknown$ +^\[main.assertion.18\] .* assertion \*x.b==12.0f: Unknown$ +^\[main.assertion.19\] .* assertion x.a==&a2: Unknown$ +^\[main.assertion.20\] .* assertion x.a==&a3: Unknown$ +^\[main.assertion.21\] .* assertion x.b==&b3: Unknown$ +^\[main.assertion.22\] .* assertion x.b==&b4: Unknown$ +^\[main.assertion.23\] .* assertion \*x.a==1: Unknown$ +^\[main.assertion.24\] .* assertion \*x.a==2: Unknown$ +^\[main.assertion.25\] .* assertion \*x.b==12.0f: Unknown$ +^\[main.assertion.26\] .* assertion \*x.b==13.0f: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-struct/sensitivity_test_two_value_struct_of_two_value_struct.c b/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-struct/sensitivity_test_two_value_struct_of_two_value_struct.c new file mode 100644 index 00000000000..ae2ab34d038 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-struct/sensitivity_test_two_value_struct_of_two_value_struct.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/struct_of_struct_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-struct/test.desc b/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-struct/test.desc new file mode 100644 index 00000000000..450055d2be6 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-struct/test.desc @@ -0,0 +1,18 @@ +FUTURE +sensitivity_test_two_value_struct_of_two_value_struct.c +--variable --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion x.s1.a==0: Unknown$ +^\[main.assertion.2\] .* assertion x.s2.b==3.0f: Unknown$ +^\[main.assertion.3\] .* assertion x.s1.a==0: Unknown$ +^\[main.assertion.4\] .* assertion x.s1.a==10: Unknown$ +^\[main.assertion.5\] .* assertion x.s1.b==1.0f: Unknown$ +^\[main.assertion.6\] .* assertion x.s2.b==3.0f: Unknown$ +^\[main.assertion.7\] .* assertion x.s2.b==0.0f: Unknown$ +^\[main.assertion.8\] .* assertion x.s1.a==20: Unknown$ +^\[main.assertion.9\] .* assertion x.s1.a<30: Unknown$ +^\[main.assertion.10\] .* assertion x.s2.a==22: Unknown$ +^\[main.assertion.11\] .* assertion x.s2.a<30: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-two-value-struct/sensitivity_test_two_value_struct.c b/regression/goto-analyzer/sensitivity-test-two-value-struct/sensitivity_test_two_value_struct.c new file mode 100644 index 00000000000..946ec769d9e --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-struct/sensitivity_test_two_value_struct.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/struct_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-two-value-struct/test.desc b/regression/goto-analyzer/sensitivity-test-two-value-struct/test.desc new file mode 100644 index 00000000000..157a3b25968 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-struct/test.desc @@ -0,0 +1,16 @@ +FUTURE +sensitivity_test_two_value_struct.c +--variable --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion x.a==0: Unknown$ +^\[main.assertion.2\] .* assertion x.a==1: Unknown$ +^\[main.assertion.3\] .* assertion x.a==0: Unknown$ +^\[main.assertion.4\] .* assertion x.a==0: Unknown$ +^\[main.assertion.5\] .* assertion x.b>0.0f: Unknown$ +^\[main.assertion.6\] .* assertion x.b==1.0f: Unknown$ +^\[main.assertion.7\] .* assertion x.a<2: Unknown$ +^\[main.assertion.8\] .* assertion x.a>2: Unknown$ +^\[main.assertion.9\] .* assertion x.a==1: Unknown$ +-- +^warning: ignoring From dfc3b6ef726d11e6c9405663057c5b9327ccee70 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Fri, 3 Mar 2017 08:17:34 +0000 Subject: [PATCH 074/116] Support --property with --reachability-slice Make the support for property-guided slicing the same for both --full-slice and --reachability-slice. Furthermore replace sliced code by assume(false) instead of unbounded (self-)loops. --- CHANGELOG | 7 ++++ src/goto-instrument/full_slicer.cpp | 3 -- src/goto-instrument/full_slicer_class.h | 6 ++-- .../goto_instrument_parse_options.cpp | 5 ++- src/goto-instrument/reachability_slicer.cpp | 35 ++++++++++++++++--- src/goto-instrument/reachability_slicer.h | 4 +++ .../reachability_slicer_class.h | 12 +++++-- 7 files changed, 57 insertions(+), 15 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0f15c3d5081..6c613977e3a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,10 @@ +5.8 +=== + +* GOTO-INSTRUMENT: --reachability-slice can be used with --property to slice + down to a single property only. + + 5.7 === diff --git a/src/goto-instrument/full_slicer.cpp b/src/goto-instrument/full_slicer.cpp index f7b42a0af3c..887805ad80a 100644 --- a/src/goto-instrument/full_slicer.cpp +++ b/src/goto-instrument/full_slicer.cpp @@ -13,9 +13,6 @@ Author: Daniel Kroening, kroening@kroening.com #include -#include - -#include "full_slicer.h" #include "full_slicer_class.h" /*******************************************************************\ diff --git a/src/goto-instrument/full_slicer_class.h b/src/goto-instrument/full_slicer_class.h index 4495fa95246..93894513f57 100644 --- a/src/goto-instrument/full_slicer_class.h +++ b/src/goto-instrument/full_slicer_class.h @@ -16,7 +16,9 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -#include +#include + +#include "full_slicer.h" // #define DEBUG_FULL_SLICERT #if 0 @@ -30,8 +32,6 @@ echo 'digraph g {' > c.dot ; cat c.goto | \ dot -Tpdf -oc-red.pdf c-red.dot #endif -class dependence_grapht; - /*******************************************************************\ Class: full_slicert diff --git a/src/goto-instrument/goto_instrument_parse_options.cpp b/src/goto-instrument/goto_instrument_parse_options.cpp index 21000a78da6..1c60205b5c7 100644 --- a/src/goto-instrument/goto_instrument_parse_options.cpp +++ b/src/goto-instrument/goto_instrument_parse_options.cpp @@ -1441,7 +1441,10 @@ void goto_instrument_parse_optionst::instrument_goto_program() if(cmdline.isset("reachability-slice")) { status() << "Performing a reachability slice" << eom; - reachability_slicer(goto_functions); + if(cmdline.isset("property")) + reachability_slicer(goto_functions, cmdline.get_values("property")); + else + reachability_slicer(goto_functions); } // full slice? diff --git a/src/goto-instrument/reachability_slicer.cpp b/src/goto-instrument/reachability_slicer.cpp index 231ae40cde9..073f9284add 100644 --- a/src/goto-instrument/reachability_slicer.cpp +++ b/src/goto-instrument/reachability_slicer.cpp @@ -13,6 +13,7 @@ Author: Daniel Kroening, kroening@kroening.com #include #include +#include "full_slicer_class.h" #include "reachability_slicer.h" #include "reachability_slicer_class.h" @@ -29,7 +30,8 @@ Function: reachability_slicert::fixedpoint_assertions \*******************************************************************/ void reachability_slicert::fixedpoint_assertions( - const is_threadedt &is_threaded) + const is_threadedt &is_threaded, + slicing_criteriont &criterion) { queuet queue; @@ -37,7 +39,7 @@ void reachability_slicert::fixedpoint_assertions( e_it=cfg.entry_map.begin(); e_it!=cfg.entry_map.end(); e_it++) - if(e_it->first->is_assert() || + if(criterion(e_it->first) || is_threaded(e_it->first)) queue.push(e_it->second); @@ -77,7 +79,7 @@ Function: reachability_slicert::slice void reachability_slicert::slice(goto_functionst &goto_functions) { // now replace those instructions that do not reach any assertions - // by self-loops + // by assume(false) Forall_goto_functions(f_it, goto_functions) if(f_it->second.body_available()) @@ -87,7 +89,7 @@ void reachability_slicert::slice(goto_functionst &goto_functions) const cfgt::nodet &e=cfg[cfg.entry_map[i_it]]; if(!e.reaches_assertion && !i_it->is_end_function()) - i_it->make_goto(i_it); + i_it->make_assumption(false_exprt()); } // replace unreachable code by skip @@ -113,5 +115,28 @@ Function: reachability_slicer void reachability_slicer(goto_functionst &goto_functions) { - reachability_slicert()(goto_functions); + reachability_slicert s; + assert_criteriont a; + s(goto_functions, a); +} + +/*******************************************************************\ + +Function: reachability_slicer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +void reachability_slicer( + goto_functionst &goto_functions, + const std::list &properties) +{ + reachability_slicert s; + properties_criteriont p(properties); + s(goto_functions, p); } diff --git a/src/goto-instrument/reachability_slicer.h b/src/goto-instrument/reachability_slicer.h index 7ce03a1d612..e45aa81f27e 100644 --- a/src/goto-instrument/reachability_slicer.h +++ b/src/goto-instrument/reachability_slicer.h @@ -13,4 +13,8 @@ Author: Daniel Kroening, kroening@kroening.com void reachability_slicer(goto_functionst &goto_functions); +void reachability_slicer( + goto_functionst &goto_functions, + const std::list &properties); + #endif // 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 85f1e62a345..224259b57cd 100644 --- a/src/goto-instrument/reachability_slicer_class.h +++ b/src/goto-instrument/reachability_slicer_class.h @@ -14,6 +14,8 @@ Author: Daniel Kroening, kroening@kroening.com #include +class slicing_criteriont; + /*******************************************************************\ Class: reachability_slicert @@ -25,11 +27,13 @@ Author: Daniel Kroening, kroening@kroening.com class reachability_slicert { public: - void operator()(goto_functionst &goto_functions) + void operator()( + goto_functionst &goto_functions, + slicing_criteriont &criterion) { cfg(goto_functions); is_threadedt is_threaded(goto_functions); - fixedpoint_assertions(is_threaded); + fixedpoint_assertions(is_threaded, criterion); slice(goto_functions); } @@ -48,7 +52,9 @@ class reachability_slicert typedef std::stack queuet; - void fixedpoint_assertions(const is_threadedt &is_threaded); + void fixedpoint_assertions( + const is_threadedt &is_threaded, + slicing_criteriont &criterion); void slice(goto_functionst &goto_functions); }; From ee3c39a65c770de3e5f2e19ce24109777867db84 Mon Sep 17 00:00:00 2001 From: Chris Smowton Date: Thu, 30 Mar 2017 17:13:54 +0100 Subject: [PATCH 075/116] Always check Java pointers for null before deref This also improves goto-check's resolution for finding symbol modes by finding the function in the symbol table and parameterising from above. --- src/analyses/goto_check.cpp | 92 ++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 47 deletions(-) diff --git a/src/analyses/goto_check.cpp b/src/analyses/goto_check.cpp index 7bba83bd298..cc418d6aed9 100644 --- a/src/analyses/goto_check.cpp +++ b/src/analyses/goto_check.cpp @@ -62,17 +62,19 @@ class goto_checkt typedef goto_functionst::goto_functiont goto_functiont; - void goto_check(goto_functiont &goto_function); - - irep_idt mode; + void goto_check(goto_functiont &goto_function, const irep_idt &mode); protected: const namespacet &ns; local_bitvector_analysist *local_bitvector_analysis; goto_programt::const_targett t; - void check_rec(const exprt &expr, guardt &guard, bool address); - void check(const exprt &expr); + void check_rec( + const exprt &expr, + guardt &guard, + bool address, + const irep_idt &mode); + void check(const exprt &expr, const irep_idt &mode); void bounds_check(const index_exprt &expr, const guardt &guard); void div_by_zero_check(const div_exprt &expr, const guardt &guard); @@ -84,7 +86,8 @@ class goto_checkt const dereference_exprt &expr, const guardt &guard, const exprt &access_lb, - const exprt &access_ub); + const exprt &access_ub, + const irep_idt &mode); void integer_overflow_check(const exprt &expr, const guardt &guard); void conversion_check(const exprt &expr, const guardt &guard); void float_overflow_check(const exprt &expr, const guardt &guard); @@ -993,9 +996,10 @@ void goto_checkt::pointer_validity_check( const dereference_exprt &expr, const guardt &guard, const exprt &access_lb, - const exprt &access_ub) + const exprt &access_ub, + const irep_idt &mode) { - if(!enable_pointer_check) + if(mode!=ID_java && !enable_pointer_check) return; const exprt &pointer=expr.op0(); @@ -1373,7 +1377,8 @@ Function: goto_checkt::check_rec void goto_checkt::check_rec( const exprt &expr, guardt &guard, - bool address) + bool address, + const irep_idt &mode) { // we don't look into quantifiers if(expr.id()==ID_exists || expr.id()==ID_forall) @@ -1384,18 +1389,18 @@ void goto_checkt::check_rec( if(expr.id()==ID_dereference) { assert(expr.operands().size()==1); - check_rec(expr.op0(), guard, false); + check_rec(expr.op0(), guard, false, mode); } else if(expr.id()==ID_index) { assert(expr.operands().size()==2); - check_rec(expr.op0(), guard, true); - check_rec(expr.op1(), guard, false); + check_rec(expr.op0(), guard, true, mode); + check_rec(expr.op1(), guard, false, mode); } else { forall_operands(it, expr) - check_rec(*it, guard, true); + check_rec(*it, guard, true, mode); } return; } @@ -1403,7 +1408,7 @@ void goto_checkt::check_rec( if(expr.id()==ID_address_of) { assert(expr.operands().size()==1); - check_rec(expr.op0(), guard, true); + check_rec(expr.op0(), guard, true, mode); return; } else if(expr.id()==ID_and || expr.id()==ID_or) @@ -1420,7 +1425,7 @@ void goto_checkt::check_rec( throw "`"+expr.id_string()+"' takes Boolean operands only, but got "+ op.pretty(); - check_rec(op, guard, false); + check_rec(op, guard, false, mode); if(expr.id()==ID_or) guard.add(not_exprt(op)); @@ -1445,19 +1450,19 @@ void goto_checkt::check_rec( throw msg; } - check_rec(expr.op0(), guard, false); + check_rec(expr.op0(), guard, false, mode); { guardt old_guard=guard; guard.add(expr.op0()); - check_rec(expr.op1(), guard, false); + check_rec(expr.op1(), guard, false, mode); guard.swap(old_guard); } { guardt old_guard=guard; guard.add(not_exprt(expr.op0())); - check_rec(expr.op2(), guard, false); + check_rec(expr.op2(), guard, false, mode); guard.swap(old_guard); } @@ -1470,7 +1475,7 @@ void goto_checkt::check_rec( const dereference_exprt &deref= to_dereference_expr(member.struct_op()); - check_rec(deref.op0(), guard, false); + check_rec(deref.op0(), guard, false, mode); exprt access_ub=nil_exprt(); @@ -1480,13 +1485,13 @@ void goto_checkt::check_rec( if(member_offset.is_not_nil() && size.is_not_nil()) access_ub=plus_exprt(member_offset, size); - pointer_validity_check(deref, guard, member_offset, access_ub); + pointer_validity_check(deref, guard, member_offset, access_ub, mode); return; } forall_operands(it, expr) - check_rec(*it, guard, false); + check_rec(*it, guard, false, mode); if(expr.id()==ID_index) { @@ -1545,7 +1550,8 @@ void goto_checkt::check_rec( to_dereference_expr(expr), guard, nil_exprt(), - size_of_expr(expr.type(), ns)); + size_of_expr(expr.type(), ns), + mode); } /*******************************************************************\ @@ -1560,10 +1566,10 @@ Function: goto_checkt::check \*******************************************************************/ -void goto_checkt::check(const exprt &expr) +void goto_checkt::check(const exprt &expr, const irep_idt &mode) { guardt guard; - check_rec(expr, guard, false); + check_rec(expr, guard, false, mode); } /*******************************************************************\ @@ -1574,18 +1580,14 @@ Function: goto_checkt::goto_check Outputs: - Purpose:[B + Purpose: \*******************************************************************/ -void goto_checkt::goto_check(goto_functiont &goto_function) +void goto_checkt::goto_check( + goto_functiont &goto_function, + const irep_idt &mode) { - { - const symbolt *init_symbol; - if(!ns.lookup(CPROVER_PREFIX "initialize", init_symbol)) - mode=init_symbol->mode; - } - assertions.clear(); local_bitvector_analysist local_bitvector_analysis_obj(goto_function); @@ -1607,7 +1609,7 @@ void goto_checkt::goto_check(goto_functiont &goto_function) i.is_target()) assertions.clear(); - check(i.guard); + check(i.guard, mode); // magic ERROR label? for(const auto &label : error_labels) @@ -1633,20 +1635,20 @@ void goto_checkt::goto_check(goto_functiont &goto_function) if(statement==ID_expression) { - check(i.code); + check(i.code, mode); } else if(statement==ID_printf) { forall_operands(it, i.code) - check(*it); + check(*it, mode); } } else if(i.is_assign()) { const code_assignt &code_assign=to_code_assign(i.code); - check(code_assign.lhs()); - check(code_assign.rhs()); + check(code_assign.lhs(), mode); + check(code_assign.rhs(), mode); // the LHS might invalidate any assertion invalidate(code_assign.lhs()); @@ -1686,7 +1688,7 @@ void goto_checkt::goto_check(goto_functiont &goto_function) } forall_operands(it, code_function_call) - check(*it); + check(*it, mode); // the call might invalidate any assertion assertions.clear(); @@ -1695,7 +1697,7 @@ void goto_checkt::goto_check(goto_functiont &goto_function) { if(i.code.operands().size()==1) { - check(i.code.op0()); + check(i.code.op0(), mode); // the return value invalidate any assertion invalidate(i.code.op0()); } @@ -1853,7 +1855,7 @@ void goto_check( goto_functionst::goto_functiont &goto_function) { goto_checkt goto_check(ns, options); - goto_check.goto_check(goto_function); + goto_check.goto_check(goto_function, irep_idt()); } /*******************************************************************\ @@ -1877,7 +1879,8 @@ void goto_check( Forall_goto_functions(it, goto_functions) { - goto_check.goto_check(it->second); + irep_idt mode=ns.lookup(it->first).mode; + goto_check.goto_check(it->second, mode); } } @@ -1898,10 +1901,5 @@ void goto_check( goto_modelt &goto_model) { const namespacet ns(goto_model.symbol_table); - goto_checkt goto_check(ns, options); - - Forall_goto_functions(it, goto_model.goto_functions) - { - goto_check.goto_check(it->second); - } + goto_check(ns, options, goto_model.goto_functions); } From eb20cdf93362a2b0cae8bb8153ec7174f97fcb6c Mon Sep 17 00:00:00 2001 From: Chris Smowton Date: Fri, 31 Mar 2017 13:11:32 +0100 Subject: [PATCH 076/116] Amend tests perturbed by adding null pointer checks They required "1 of N successful" reports, where N is changed by the addition of new assertions. --- regression/cbmc-java/exceptions1/test.desc | 2 +- regression/cbmc-java/exceptions2/test.desc | 2 +- regression/cbmc-java/lazyloading3/A.class | Bin 222 -> 222 bytes regression/cbmc-java/lazyloading3/B.class | Bin 222 -> 222 bytes regression/cbmc-java/lazyloading3/C.class | Bin 197 -> 197 bytes regression/cbmc-java/lazyloading3/D.class | Bin 197 -> 197 bytes regression/cbmc-java/lazyloading3/test.class | Bin 296 -> 334 bytes regression/cbmc-java/lazyloading3/test.java | 2 ++ 8 files changed, 4 insertions(+), 2 deletions(-) diff --git a/regression/cbmc-java/exceptions1/test.desc b/regression/cbmc-java/exceptions1/test.desc index 638351f4397..1405444f649 100644 --- a/regression/cbmc-java/exceptions1/test.desc +++ b/regression/cbmc-java/exceptions1/test.desc @@ -4,7 +4,7 @@ test.class ^EXIT=10$ ^SIGNAL=0$ ^.*assertion at file test.java line 26 function.*: FAILURE$ -\*\* 1 of 9 failed \(2 iterations\)$ +\*\* 1 of [0-9]* failed \(2 iterations\)$ ^VERIFICATION FAILED$ -- ^warning: ignoring diff --git a/regression/cbmc-java/exceptions2/test.desc b/regression/cbmc-java/exceptions2/test.desc index 8645e5ea074..724e37b0677 100644 --- a/regression/cbmc-java/exceptions2/test.desc +++ b/regression/cbmc-java/exceptions2/test.desc @@ -4,7 +4,7 @@ test.class ^EXIT=10$ ^SIGNAL=0$ ^.*assertion at file test.java line 15 function.*: FAILURE$ -^\*\* 1 of 5 failed \(2 iterations\)$ +^\*\* 1 of [0-9]* failed \(2 iterations\)$ ^VERIFICATION FAILED$ -- ^warning: ignoring diff --git a/regression/cbmc-java/lazyloading3/A.class b/regression/cbmc-java/lazyloading3/A.class index affb565d6253a844a8381a1df84e84414972ecbb..3c3c1f099973f8d7064ac6217f6b1b24d896d254 100644 GIT binary patch delta 23 ecmcb|c#m)W2Q(7#J8#7^JxvSQ+>^83Y&vxfp~PgxMKH*cn78%3JaA2A3ozXZt1= zgd`^Aq)rT1;1T0t5ND8JXOQG!keb+>5zNBC$-u?H&A`aO0W`}BNHYRyUajK{EE~19 tFfeUnVBQE6U;-**0GiDLBsqX2C(uSN1|FbB9-s&_10yR?A1_!T9{@=*6h#04 delta 120 zcmWlQJr06E7)0NG1Q(W7RKOn!X{@ZRNW708XTv3ENsI*r2cYms#*b#+Wb)=Ky)^T0 zoPayEBW9D5vvus)TMA1Vnl`*HzVaM6T27vG=$;QliX+32==rKN%H;M&K174|#Xud= MjIpeA@!Ey;A2PiS8~^|S diff --git a/regression/cbmc-java/lazyloading3/test.java b/regression/cbmc-java/lazyloading3/test.java index 6d3129d1261..f69a9898472 100644 --- a/regression/cbmc-java/lazyloading3/test.java +++ b/regression/cbmc-java/lazyloading3/test.java @@ -5,6 +5,8 @@ public class test { public static void main(C c) { + if(c==null) + return; c.a.f(); } } From f9cd371a6050e21dde68f3f9675cfc9c84706999 Mon Sep 17 00:00:00 2001 From: Chris Smowton Date: Fri, 31 Mar 2017 13:13:35 +0100 Subject: [PATCH 077/116] Document change to pointer-check option This is effectively always enabled for Java programs now. For others this is still optional. --- src/analyses/goto_check.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/analyses/goto_check.h b/src/analyses/goto_check.h index 7ad04f99f79..4e1bbbbba60 100644 --- a/src/analyses/goto_check.h +++ b/src/analyses/goto_check.h @@ -37,7 +37,7 @@ void goto_check( #define HELP_GOTO_CHECK \ " --bounds-check enable array bounds checks\n" \ - " --pointer-check enable pointer checks\n" \ + " --pointer-check enable pointer checks (always enabled for Java)\n" /* NOLINT(whitespace/line_length) */ \ " --memory-leak-check enable memory leak checks\n" \ " --div-by-zero-check enable division by zero checks\n" \ " --signed-overflow-check enable signed arithmetic over- and underflow checks\n" /* NOLINT(whitespace/line_length) */ \ From acbe2d0cc459d8342fa66afeb39ca95f3b932b07 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Thu, 21 Apr 2016 16:23:40 +0000 Subject: [PATCH 078/116] New goto-instrument option --list-calls-args --- CHANGELOG | 6 ++ src/goto-instrument/call_sequences.cpp | 81 +++++++++++++++++++ src/goto-instrument/call_sequences.h | 4 + .../goto_instrument_parse_options.cpp | 13 +++ .../goto_instrument_parse_options.h | 2 +- 5 files changed, 105 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 0f15c3d5081..fa9bb4a0367 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,9 @@ +5.8 +=== + +* GOTO-INSTRUMENT: New option --list-calls-args + + 5.7 === diff --git a/src/goto-instrument/call_sequences.cpp b/src/goto-instrument/call_sequences.cpp index 65fa225c7ed..875d89051a6 100644 --- a/src/goto-instrument/call_sequences.cpp +++ b/src/goto-instrument/call_sequences.cpp @@ -13,6 +13,7 @@ Date: April 2013 #include #include +#include #include "call_sequences.h" @@ -358,3 +359,83 @@ 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, + const goto_programt &goto_program) +{ + forall_goto_program_instructions(i_it, goto_program) + { + if(!i_it->is_function_call()) + continue; + + const code_function_callt call=to_code_function_call(i_it->code); + + const exprt &f=call.function(); + + if(f.id()!=ID_symbol) + continue; + + const irep_idt &identifier=to_symbol_expr(f).get_identifier(); + if(identifier=="__CPROVER_initialize") + continue; + + std::string name=from_expr(ns, identifier, f); + std::string::size_type java_type_suffix=name.find(":("); + if(java_type_suffix!=std::string::npos) + name.erase(java_type_suffix); + + std::cout << "found call to " << name; + + if(!call.arguments().empty()) + { + std::cout << " with arguments "; + for(exprt::operandst::const_iterator + it=call.arguments().begin(); + it!=call.arguments().end(); + ++it) + { + if(it!=call.arguments().begin()) + std::cout << ", "; + std::cout << from_expr(ns, identifier, simplify_expr(*it, ns)); + } + } + + std::cout << '\n'; + } +} + +/*******************************************************************\ + +Function: show_call_sequences + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +void list_calls_and_arguments( + const namespacet &ns, + const goto_functionst &goto_functions) +{ + // do per function + + forall_goto_functions(f_it, goto_functions) + list_calls_and_arguments(ns, f_it->first, f_it->second.body); +} diff --git a/src/goto-instrument/call_sequences.h b/src/goto-instrument/call_sequences.h index 5036d5bc845..ecfc5921ef8 100644 --- a/src/goto-instrument/call_sequences.h +++ b/src/goto-instrument/call_sequences.h @@ -16,4 +16,8 @@ Date: September 2011 void show_call_sequences(const goto_functionst &goto_functions); void check_call_sequence(const goto_functionst &goto_functions); +void list_calls_and_arguments( + const namespacet &ns, + const goto_functionst &goto_functions); + #endif // CPROVER_GOTO_INSTRUMENT_CALL_SEQUENCES_H diff --git a/src/goto-instrument/goto_instrument_parse_options.cpp b/src/goto-instrument/goto_instrument_parse_options.cpp index 21000a78da6..906c135322d 100644 --- a/src/goto-instrument/goto_instrument_parse_options.cpp +++ b/src/goto-instrument/goto_instrument_parse_options.cpp @@ -456,6 +456,17 @@ int goto_instrument_parse_optionst::doit() return 0; } + if(cmdline.isset("list-calls-args")) + { + do_indirect_call_and_rtti_removal(); + do_partial_inlining(); + + namespacet ns(symbol_table); + list_calls_and_arguments(ns, goto_functions); + + return 0; + } + if(cmdline.isset("show-rw-set")) { namespacet ns(symbol_table); @@ -1508,6 +1519,8 @@ void goto_instrument_parse_optionst::help() " --list-undefined-functions list functions without body\n" " --show-struct-alignment show struct members that might be concurrently accessed\n" // NOLINT(*) " --show-natural-loops show natural loop heads\n" + // NOLINTNEXTLINE(whitespace/line_length) + " --list-calls-args list all function calls with their arguments\n" "\n" "Safety checks:\n" " --no-assertions ignore user assertions\n" diff --git a/src/goto-instrument/goto_instrument_parse_options.h b/src/goto-instrument/goto_instrument_parse_options.h index 180eeb7a2f5..7d84408f790 100644 --- a/src/goto-instrument/goto_instrument_parse_options.h +++ b/src/goto-instrument/goto_instrument_parse_options.h @@ -69,7 +69,7 @@ Author: Daniel Kroening, kroening@kroening.com "(list-symbols)(list-undefined-functions)" \ "(z3)(add-library)(show-dependence-graph)" \ "(horn)(skip-loops):(apply-code-contracts)(model-argc-argv):" \ - "(show-threaded)" + "(show-threaded)(list-calls-args)" class goto_instrument_parse_optionst: public parse_options_baset, From bacd44472c310dc3c6c9b42cc5018d03205bc610 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Fri, 13 May 2016 22:21:50 +0200 Subject: [PATCH 079/116] goto-instrument --print-path-lengths: statistics about control-flow graph paths --- CHANGELOG | 1 + src/goto-instrument/count_eloc.cpp | 82 +++++++++++++++++++ src/goto-instrument/count_eloc.h | 2 + .../goto_instrument_parse_options.cpp | 6 ++ .../goto_instrument_parse_options.h | 2 +- 5 files changed, 92 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index fa9bb4a0367..34883b92939 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ === * GOTO-INSTRUMENT: New option --list-calls-args +* GOTO-INSTRUMENT: New option --print-path-lenghts 5.7 diff --git a/src/goto-instrument/count_eloc.cpp b/src/goto-instrument/count_eloc.cpp index 96b21195a82..a54bc11f2ad 100644 --- a/src/goto-instrument/count_eloc.cpp +++ b/src/goto-instrument/count_eloc.cpp @@ -14,6 +14,8 @@ Date: December 2012 #include #include +#include + #include "count_eloc.h" typedef std::unordered_set linest; @@ -104,3 +106,83 @@ void list_eloc(const goto_functionst &goto_functions) std::cout << file << ':' << line << '\n'; } } + +/*******************************************************************\ + +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(); + goto_functionst::function_mapt::const_iterator start= + goto_functions.function_map.find(entry_point); + + if(start==goto_functions.function_map.end() || + !start->second.body_available()) + { + std::cout << "No entry point found, path length undefined\n"; + return; + } + + struct visited_cfg_nodet + { + bool visited; + + visited_cfg_nodet():visited(false) + { + } + }; + + typedef cfg_baset cfgt; + cfgt cfg; + cfg(goto_functions); + + const goto_programt &start_program=start->second.body; + + const cfgt::entryt &start_node= + cfg.entry_map[start_program.instructions.begin()]; + const cfgt::entryt &last_node= + cfg.entry_map[--start_program.instructions.end()]; + + cfgt::patht shortest_path; + cfg.shortest_path(start_node, last_node, shortest_path); + std::cout << "Shortest control-flow path: " << shortest_path.size() + << " instructions\n"; + + std::size_t n_loops=0, loop_ins=0; + forall_goto_functions(gf_it, goto_functions) + forall_goto_program_instructions(i_it, gf_it->second.body) + // loops or recursion + if(i_it->is_backwards_goto() || + i_it==gf_it->second.body.instructions.begin()) + { + const cfgt::entryt &node=cfg.entry_map[i_it]; + cfgt::patht loop; + cfg.shortest_loop(node, loop); + + if(!loop.empty()) + { + ++n_loops; + loop_ins+=loop.size()-1; + } + } + + if(n_loops>0) + std::cout << "Loop information: " << n_loops << " loops, " + << loop_ins << " instructions in shortest paths of loop bodies\n"; + + std::size_t n_reachable=0; + cfg.visit_reachable(start_node); + for(std::size_t i=0; i Date: Thu, 1 Sep 2016 14:48:42 +0200 Subject: [PATCH 080/116] List functions (with start and end lines) that won't be used --- CHANGELOG | 1 + .../goto_analyzer_parse_options.cpp | 26 ++++ .../goto_analyzer_parse_options.h | 2 +- .../unreachable_instructions.cpp | 112 +++++++++++++++++- src/goto-analyzer/unreachable_instructions.h | 5 + 5 files changed, 144 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 34883b92939..14190664b15 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ * GOTO-INSTRUMENT: New option --list-calls-args * GOTO-INSTRUMENT: New option --print-path-lenghts +* GOTO-ANALYZER: New option --unreachable-functions 5.7 diff --git a/src/goto-analyzer/goto_analyzer_parse_options.cpp b/src/goto-analyzer/goto_analyzer_parse_options.cpp index bceddfadc54..88a5db5d9a9 100644 --- a/src/goto-analyzer/goto_analyzer_parse_options.cpp +++ b/src/goto-analyzer/goto_analyzer_parse_options.cpp @@ -265,6 +265,30 @@ int goto_analyzer_parse_optionst::doit() return 0; } + if(cmdline.isset("unreachable-functions")) + { + const std::string json_file=cmdline.get_value("json"); + + if(json_file.empty()) + unreachable_functions(goto_model, false, std::cout); + else if(json_file=="-") + unreachable_functions(goto_model, true, std::cout); + else + { + std::ofstream ofs(json_file); + if(!ofs) + { + error() << "Failed to open json output `" + << json_file << "'" << eom; + return 6; + } + + unreachable_functions(goto_model, true, ofs); + } + + return 0; + } + if(cmdline.isset("show-local-may-alias")) { namespacet ns(goto_model.symbol_table); @@ -489,6 +513,8 @@ void goto_analyzer_parse_optionst::help() // NOLINTNEXTLINE(whitespace/line_length) " --taint file_name perform taint analysis using rules in given file\n" " --unreachable-instructions list dead code\n" + // NOLINTNEXTLINE(whitespace/line_length) + " --unreachable-functions list functions unreachable from the entry point\n" " --intervals interval analysis\n" " --non-null non-null analysis\n" "\n" diff --git a/src/goto-analyzer/goto_analyzer_parse_options.h b/src/goto-analyzer/goto_analyzer_parse_options.h index 7b319c8b99b..0f33397ce88 100644 --- a/src/goto-analyzer/goto_analyzer_parse_options.h +++ b/src/goto-analyzer/goto_analyzer_parse_options.h @@ -36,7 +36,7 @@ class optionst; "(taint):(show-taint)" \ "(show-local-may-alias)" \ "(json):(xml):" \ - "(unreachable-instructions)" \ + "(unreachable-instructions)(unreachable-functions)" \ "(intervals)(show-intervals)" \ "(non-null)(show-non-null)" diff --git a/src/goto-analyzer/unreachable_instructions.cpp b/src/goto-analyzer/unreachable_instructions.cpp index 06edd28bca6..7f229b7c459 100644 --- a/src/goto-analyzer/unreachable_instructions.cpp +++ b/src/goto-analyzer/unreachable_instructions.cpp @@ -198,7 +198,12 @@ void unreachable_instructions( const goto_programt &goto_program=f_it->second.body; dead_mapt dead_map; - if(called.find(f_it->first)!=called.end()) + const symbolt &decl=ns.lookup(f_it->first); + + // f_it->first may be a link-time renamed version, use the + // base_name instead; do not list inlined functions + if(called.find(decl.base_name)!=called.end() || + f_it->second.is_inlined()) unreachable_instructions(goto_program, dead_map); else all_unreachable(goto_program, dead_map); @@ -215,3 +220,108 @@ void unreachable_instructions( if(json && !json_result.array.empty()) os << json_result << std::endl; } + +/*******************************************************************\ + +Function: output_unreachable_function + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +static void json_output_unreachable_function( + const irep_idt &function, + const source_locationt &first_location, + const source_locationt &last_location, + json_arrayt &dest) +{ + json_objectt &entry=dest.push_back().make_object(); + + entry["function"]=json_stringt(id2string(function)); + entry["file name"]= + json_stringt(concat_dir_file( + id2string(first_location.get_working_directory()), + id2string(first_location.get_file()))); + entry["first line"]= + json_numbert(id2string(first_location.get_line())); + entry["last line"]= + json_numbert(id2string(last_location.get_line())); +} + +/*******************************************************************\ + +Function: unreachable_functions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +void unreachable_functions( + const goto_modelt &goto_model, + const bool json, + std::ostream &os) +{ + json_arrayt json_result; + + std::set called; + compute_called_functions(goto_model, called); + + const namespacet ns(goto_model.symbol_table); + + forall_goto_functions(f_it, goto_model.goto_functions) + { + const symbolt &decl=ns.lookup(f_it->first); + + // f_it->first may be a link-time renamed version, use the + // base_name instead; do not list inlined functions + if(called.find(decl.base_name)!=called.end() || + f_it->second.is_inlined()) + continue; + + source_locationt first_location=decl.location; + + source_locationt last_location; + if(f_it->second.body_available()) + { + const goto_programt &goto_program=f_it->second.body; + + goto_programt::const_targett end_function= + goto_program.instructions.end(); + --end_function; + assert(end_function->is_end_function()); + last_location=end_function->source_location; + } + else + // completely ignore functions without a body, both for + // reachable and unreachable functions; we could also restrict + // this to macros/asm renaming + continue; + + if(!json) + { + os << concat_dir_file( + id2string(first_location.get_working_directory()), + id2string(first_location.get_file())) << " " + << decl.base_name << " " + << first_location.get_line() << " " + << last_location.get_line() << "\n"; + } + else + json_output_unreachable_function( + decl.base_name, + first_location, + last_location, + json_result); + } + + if(json && !json_result.array.empty()) + os << json_result << std::endl; +} diff --git a/src/goto-analyzer/unreachable_instructions.h b/src/goto-analyzer/unreachable_instructions.h index 137e6a62040..5fefbf6da41 100644 --- a/src/goto-analyzer/unreachable_instructions.h +++ b/src/goto-analyzer/unreachable_instructions.h @@ -20,4 +20,9 @@ void unreachable_instructions( const bool json, std::ostream &os); +void unreachable_functions( + const goto_modelt &, + const bool json, + std::ostream &os); + #endif // CPROVER_GOTO_ANALYZER_UNREACHABLE_INSTRUCTIONS_H From 50170f0dffc6e26f804b3935e1114fd3f58a12c2 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Mon, 5 Sep 2016 08:34:41 +0000 Subject: [PATCH 081/116] goto-analyzer --reachable-functions Provide the complement of --unreachable-functions --- CHANGELOG | 2 +- .../goto_analyzer_parse_options.cpp | 26 +++++++++ .../goto_analyzer_parse_options.h | 1 + .../unreachable_instructions.cpp | 58 ++++++++++++++++--- src/goto-analyzer/unreachable_instructions.h | 5 ++ 5 files changed, 83 insertions(+), 9 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 14190664b15..7fdb24e61b9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,7 +3,7 @@ * GOTO-INSTRUMENT: New option --list-calls-args * GOTO-INSTRUMENT: New option --print-path-lenghts -* GOTO-ANALYZER: New option --unreachable-functions +* GOTO-ANALYZER: New option --unreachable-functions, --reachable-functions 5.7 diff --git a/src/goto-analyzer/goto_analyzer_parse_options.cpp b/src/goto-analyzer/goto_analyzer_parse_options.cpp index 88a5db5d9a9..04836903ea9 100644 --- a/src/goto-analyzer/goto_analyzer_parse_options.cpp +++ b/src/goto-analyzer/goto_analyzer_parse_options.cpp @@ -289,6 +289,30 @@ int goto_analyzer_parse_optionst::doit() return 0; } + if(cmdline.isset("reachable-functions")) + { + const std::string json_file=cmdline.get_value("json"); + + if(json_file.empty()) + reachable_functions(goto_model, false, std::cout); + else if(json_file=="-") + reachable_functions(goto_model, true, std::cout); + else + { + std::ofstream ofs(json_file); + if(!ofs) + { + error() << "Failed to open json output `" + << json_file << "'" << eom; + return 6; + } + + reachable_functions(goto_model, true, ofs); + } + + return 0; + } + if(cmdline.isset("show-local-may-alias")) { namespacet ns(goto_model.symbol_table); @@ -515,6 +539,8 @@ void goto_analyzer_parse_optionst::help() " --unreachable-instructions list dead code\n" // NOLINTNEXTLINE(whitespace/line_length) " --unreachable-functions list functions unreachable from the entry point\n" + // NOLINTNEXTLINE(whitespace/line_length) + " --reachable-functions list functions reachable from the entry point\n" " --intervals interval analysis\n" " --non-null non-null analysis\n" "\n" diff --git a/src/goto-analyzer/goto_analyzer_parse_options.h b/src/goto-analyzer/goto_analyzer_parse_options.h index 0f33397ce88..416a6df1888 100644 --- a/src/goto-analyzer/goto_analyzer_parse_options.h +++ b/src/goto-analyzer/goto_analyzer_parse_options.h @@ -37,6 +37,7 @@ class optionst; "(show-local-may-alias)" \ "(json):(xml):" \ "(unreachable-instructions)(unreachable-functions)" \ + "(reachable-functions)" \ "(intervals)(show-intervals)" \ "(non-null)(show-non-null)" diff --git a/src/goto-analyzer/unreachable_instructions.cpp b/src/goto-analyzer/unreachable_instructions.cpp index 7f229b7c459..73514f5b5d5 100644 --- a/src/goto-analyzer/unreachable_instructions.cpp +++ b/src/goto-analyzer/unreachable_instructions.cpp @@ -223,7 +223,7 @@ void unreachable_instructions( /*******************************************************************\ -Function: output_unreachable_function +Function: json_output_function Inputs: @@ -233,7 +233,7 @@ Function: output_unreachable_function \*******************************************************************/ -static void json_output_unreachable_function( +static void json_output_function( const irep_idt &function, const source_locationt &first_location, const source_locationt &last_location, @@ -254,7 +254,7 @@ static void json_output_unreachable_function( /*******************************************************************\ -Function: unreachable_functions +Function: list_functions Inputs: @@ -264,10 +264,11 @@ Function: unreachable_functions \*******************************************************************/ -void unreachable_functions( +static void list_functions( const goto_modelt &goto_model, const bool json, - std::ostream &os) + std::ostream &os, + bool unreachable) { json_arrayt json_result; @@ -282,8 +283,9 @@ void unreachable_functions( // f_it->first may be a link-time renamed version, use the // base_name instead; do not list inlined functions - if(called.find(decl.base_name)!=called.end() || - f_it->second.is_inlined()) + if(unreachable == + (called.find(decl.base_name)!=called.end() || + f_it->second.is_inlined())) continue; source_locationt first_location=decl.location; @@ -315,7 +317,7 @@ void unreachable_functions( << last_location.get_line() << "\n"; } else - json_output_unreachable_function( + json_output_function( decl.base_name, first_location, last_location, @@ -325,3 +327,43 @@ void unreachable_functions( if(json && !json_result.array.empty()) os << json_result << std::endl; } + +/*******************************************************************\ + +Function: unreachable_functions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +void unreachable_functions( + const goto_modelt &goto_model, + const bool json, + std::ostream &os) +{ + list_functions(goto_model, json, os, true); +} + +/*******************************************************************\ + +Function: reachable_functions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +void reachable_functions( + const goto_modelt &goto_model, + const bool json, + std::ostream &os) +{ + list_functions(goto_model, json, os, false); +} diff --git a/src/goto-analyzer/unreachable_instructions.h b/src/goto-analyzer/unreachable_instructions.h index 5fefbf6da41..a408e004bd8 100644 --- a/src/goto-analyzer/unreachable_instructions.h +++ b/src/goto-analyzer/unreachable_instructions.h @@ -25,4 +25,9 @@ void unreachable_functions( const bool json, std::ostream &os); +void reachable_functions( + const goto_modelt &, + const bool json, + std::ostream &os); + #endif // CPROVER_GOTO_ANALYZER_UNREACHABLE_INSTRUCTIONS_H From 5875335d4afcf26ea70222296c8d149d9326df92 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Mon, 11 Jul 2016 14:54:25 +0100 Subject: [PATCH 082/116] goto-instrument: Replace calls to undefined functions by assume(false) Refactoring: moving print-undefined-functions to the new source file. --- CHANGELOG | 1 + src/goto-instrument/Makefile | 3 +- .../goto_instrument_parse_options.cpp | 16 ++-- .../goto_instrument_parse_options.h | 3 +- src/goto-instrument/undefined_functions.cpp | 81 +++++++++++++++++++ src/goto-instrument/undefined_functions.h | 25 ++++++ 6 files changed, 122 insertions(+), 7 deletions(-) create mode 100644 src/goto-instrument/undefined_functions.cpp create mode 100644 src/goto-instrument/undefined_functions.h diff --git a/CHANGELOG b/CHANGELOG index 7fdb24e61b9..14fd89ae52c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ * GOTO-INSTRUMENT: New option --list-calls-args * GOTO-INSTRUMENT: New option --print-path-lenghts * GOTO-ANALYZER: New option --unreachable-functions, --reachable-functions +* GOTO-INSTRUMENT: New option --undefined-function-is-assume-false 5.7 diff --git a/src/goto-instrument/Makefile b/src/goto-instrument/Makefile index 4cbd6121b24..3fbaac8620b 100644 --- a/src/goto-instrument/Makefile +++ b/src/goto-instrument/Makefile @@ -23,7 +23,8 @@ SRC = goto_instrument_parse_options.cpp rw_set.cpp \ wmm/event_graph.cpp wmm/pair_collection.cpp \ goto_instrument_main.cpp horn_encoding.cpp \ thread_instrumentation.cpp skip_loops.cpp loop_utils.cpp \ - code_contracts.cpp cover.cpp model_argc_argv.cpp + code_contracts.cpp cover.cpp model_argc_argv.cpp \ + undefined_functions.cpp OBJ += ../ansi-c/ansi-c$(LIBEXT) \ ../cpp/cpp$(LIBEXT) \ diff --git a/src/goto-instrument/goto_instrument_parse_options.cpp b/src/goto-instrument/goto_instrument_parse_options.cpp index 29ba9f474e4..b2f31ee4952 100644 --- a/src/goto-instrument/goto_instrument_parse_options.cpp +++ b/src/goto-instrument/goto_instrument_parse_options.cpp @@ -89,6 +89,7 @@ Author: Daniel Kroening, kroening@kroening.com #include "code_contracts.h" #include "unwind.h" #include "model_argc_argv.h" +#include "undefined_functions.h" /*******************************************************************\ @@ -628,11 +629,7 @@ int goto_instrument_parse_optionst::doit() if(cmdline.isset("list-undefined-functions")) { const namespacet ns(symbol_table); - - Forall_goto_functions(it, goto_functions) - if(!ns.lookup(it->first).is_macro && - !it->second.body_available()) - std::cout << it->first << std::endl; + list_undefined_functions(goto_functions, ns, std::cout); return 0; } @@ -769,6 +766,13 @@ int goto_instrument_parse_optionst::doit() remove_unused_functions(goto_functions, get_message_handler()); } + if(cmdline.isset("undefined-function-is-assume-false")) + { + do_indirect_call_and_rtti_removal(); + + undefined_function_abort_path(goto_functions); + } + // write new binary? if(cmdline.args.size()==2) { @@ -1549,6 +1553,8 @@ void goto_instrument_parse_optionst::help() " --nondet-static add nondeterministic initialization of variables with static lifetime\n" // NOLINT(*) " --check-invariant function instruments invariant checking function\n" " --remove-pointers converts pointer arithmetic to base+offset expressions\n" // NOLINT(*) + " --undefined-function-is-assume-false\n" + " convert each call to an undefined function to assume(false)\n" "\n" "Loop transformations:\n" " --k-induction check loops with k-induction\n" diff --git a/src/goto-instrument/goto_instrument_parse_options.h b/src/goto-instrument/goto_instrument_parse_options.h index f8a3c16b346..fff8910971b 100644 --- a/src/goto-instrument/goto_instrument_parse_options.h +++ b/src/goto-instrument/goto_instrument_parse_options.h @@ -69,7 +69,8 @@ Author: Daniel Kroening, kroening@kroening.com "(list-symbols)(list-undefined-functions)" \ "(z3)(add-library)(show-dependence-graph)" \ "(horn)(skip-loops):(apply-code-contracts)(model-argc-argv):" \ - "(show-threaded)(list-calls-args)(print-path-lengths)" + "(show-threaded)(list-calls-args)(print-path-lengths)" \ + "(undefined-function-is-assume-false)" class goto_instrument_parse_optionst: public parse_options_baset, diff --git a/src/goto-instrument/undefined_functions.cpp b/src/goto-instrument/undefined_functions.cpp new file mode 100644 index 00000000000..53fff3ff84b --- /dev/null +++ b/src/goto-instrument/undefined_functions.cpp @@ -0,0 +1,81 @@ +/*******************************************************************\ + +Module: Handling of functions without body + +Author: Michael Tautschnig + +Date: July 2016 + +\*******************************************************************/ + +#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, + std::ostream &os) +{ + forall_goto_functions(it, goto_functions) + if(!ns.lookup(it->first).is_macro && + !it->second.body_available()) + 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) + Forall_goto_program_instructions(iit, it->second.body) + { + goto_programt::instructiont &ins=*iit; + + if(!ins.is_function_call()) + continue; + + const code_function_callt &call=to_code_function_call(ins.code); + + if(call.function().id()!=ID_symbol) + continue; + + const irep_idt &function= + to_symbol_expr(call.function()).get_identifier(); + + goto_functionst::function_mapt::const_iterator entry= + goto_functions.function_map.find(function); + assert(entry!=goto_functions.function_map.end()); + + if(entry->second.body_available()) + continue; + + ins.make_assumption(false_exprt()); + ins.source_location.set_comment( + "`"+id2string(function)+"' is undefined"); + } +} diff --git a/src/goto-instrument/undefined_functions.h b/src/goto-instrument/undefined_functions.h new file mode 100644 index 00000000000..7b700c839a0 --- /dev/null +++ b/src/goto-instrument/undefined_functions.h @@ -0,0 +1,25 @@ +/*******************************************************************\ + +Module: Handling of functions without body + +Author: Michael Tautschnig + +Date: July 2016 + +\*******************************************************************/ + +#ifndef CPROVER_UNDEFINED_FUNCTIONS_H +#define CPROVER_UNDEFINED_FUNCTIONS_H + +#include + +class goto_functionst; + +void list_undefined_functions( + const goto_functionst &goto_functions, + const namespacet &ns, + std::ostream &os); + +void undefined_function_abort_path(goto_functionst &goto_functions); + +#endif From 1bc123979c9300482f4a0987a430c90e25129f64 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Mon, 11 Jul 2016 13:37:11 +0100 Subject: [PATCH 083/116] Print status information upon reaching assume(false) --- src/cbmc/symex_bmc.cpp | 16 ++++++++++++++++ src/symex/path_search.cpp | 21 ++++++++++++++++++++- src/symex/path_search.h | 2 +- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/cbmc/symex_bmc.cpp b/src/cbmc/symex_bmc.cpp index 1dd1e8dceb9..b9b519d21fb 100644 --- a/src/cbmc/symex_bmc.cpp +++ b/src/cbmc/symex_bmc.cpp @@ -9,6 +9,7 @@ Author: Daniel Kroening, kroening@kroening.com #include #include +#include #include "symex_bmc.h" @@ -67,6 +68,21 @@ void symex_bmct::symex_step( !state.guard.is_false()) symex_coverage.covered(state.source.pc); + if(!state.guard.is_false() && + state.source.pc->is_assume() && + simplify_expr(state.source.pc->guard, ns).is_false()) + { + statistics() << "aborting path on assume(false) at " + << state.source.pc->source_location + << " thread " << state.source.thread_nr; + + const irep_idt &c=state.source.pc->source_location.get_comment(); + if(!c.empty()) + statistics() << ": " << c; + + statistics() << eom; + } + goto_symext::symex_step(goto_functions, state); } diff --git a/src/symex/path_search.cpp b/src/symex/path_search.cpp index fe34b04cc66..fcbaebbc39a 100644 --- a/src/symex/path_search.cpp +++ b/src/symex/path_search.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +#include #include #include @@ -315,8 +316,10 @@ Function: path_searcht::drop_state \*******************************************************************/ -bool path_searcht::drop_state(const statet &state) const +bool path_searcht::drop_state(const statet &state) { + goto_programt::const_targett pc=state.get_instruction(); + // depth limit if(depth_limit_set && state.get_depth()>depth_limit) return true; @@ -345,6 +348,22 @@ bool path_searcht::drop_state(const statet &state) const return true; } + if(pc->is_assume() && + simplify_expr(pc->guard, ns).is_false()) + { + debug() << "aborting path on assume(false) at " + << pc->source_location + << " thread " << state.get_current_thread(); + + const irep_idt &c=pc->source_location.get_comment(); + if(!c.empty()) + debug() << ": " << c; + + debug() << eom; + + return true; + } + return false; } diff --git a/src/symex/path_search.h b/src/symex/path_search.h index b72588c593c..49fc621b84e 100644 --- a/src/symex/path_search.h +++ b/src/symex/path_search.h @@ -120,7 +120,7 @@ class path_searcht:public safety_checkert bool is_feasible(statet &state); void do_show_vcc(statet &state); - bool drop_state(const statet &state) const; + bool drop_state(const statet &state); void report_statistics(); From 5d1f30156cc915374225caeee11dac8af79a0b56 Mon Sep 17 00:00:00 2001 From: Vojtech Forejt Date: Fri, 24 Mar 2017 20:06:34 +0000 Subject: [PATCH 084/116] Enable ccache on Travis, plus travis.yml restructuring All jobs now have ccache enabled, which means that subsequent compilation should be able to reuse the compiled files, and thus the job running time should be faster. As part of the above, travis.yml needed to be restructured, in particular: * instead of running the compilation and tests as one command, they are split * cegis etc. compilation takes place before the tests are run. --- .travis.yml | 59 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index f3147e89e53..5572e085ce4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,30 +7,44 @@ matrix: - os: linux sudo: required compiler: gcc + cache: ccache services: - docker before_install: - docker pull diffblue/cbmc-builder:alpine env: - - PRE_COMMAND="docker run -v ${TRAVIS_BUILD_DIR}:/cbmc diffblue/cbmc-builder:alpine" - - COMPILER=g++ + - PRE_COMMAND="docker run -v ${TRAVIS_BUILD_DIR}:/cbmc -v ${HOME}/.ccache:/root/.ccache diffblue/cbmc-builder:alpine" + - COMPILER="ccache g++" # OS X using g++ - os: osx sudo: false compiler: gcc + cache: ccache + before_install: + #we create symlink to non-ccache gcc, to be used in tests + - mkdir bin ; ln -s /usr/bin/gcc bin/gcc + - brew install ccache + - export PATH=/usr/local/opt/ccache/libexec:$PATH env: COMPILER=g++ # OS X using clang++ - os: osx sudo: false compiler: clang - env: COMPILER=clang++ + cache: ccache + before_install: + - brew install ccache + - export PATH=/usr/local/opt/ccache/libexec:$PATH + env: + - COMPILER="ccache clang++ -Qunused-arguments -fcolor-diagnostics" + - CCACHE_CPP2=yes # Ubuntu Linux with glibc using g++-5 - os: linux sudo: false compiler: gcc + cache: ccache addons: apt: sources: @@ -42,12 +56,13 @@ matrix: before_install: - mkdir bin ; ln -s /usr/bin/gcc-5 bin/gcc # env: COMPILER=g++-5 SAN_FLAGS="-fsanitize=undefined -fno-sanitize-recover -fno-omit-frame-pointer" - env: COMPILER=g++-5 + env: COMPILER="g++-5" # Ubuntu Linux with glibc using clang++-3.7 - os: linux sudo: false compiler: clang + cache: ccache addons: apt: sources: @@ -60,23 +75,33 @@ matrix: - libubsan0 before_install: - mkdir bin ; ln -s /usr/bin/clang-3.7 bin/gcc + - export CCACHE_CPP2=yes # env: COMPILER=clang++-3.7 SAN_FLAGS="-fsanitize=undefined -fno-sanitize-recover=undefined,integer -fno-omit-frame-pointer" - env: COMPILER=clang++-3.7 + env: + - COMPILER="ccache clang++-3.7 -Qunused-arguments -fcolor-diagnostics" + - CCACHE_CPP2=yes - env: NAME="CPP-LINT" - script: scripts/travis_lint.sh || true + install: + script: scripts/travis_lint.sh + before_cache: + +install: + - COMMAND="make -C src minisat2-download" && + eval ${PRE_COMMAND} ${COMMAND} + - COMMAND="make -C src CXX=\"$COMPILER\" CXXFLAGS=\"-Wall -O2 -g -Werror -Wno-deprecated-register -pedantic -Wno-sign-compare\" -j2" && + eval ${PRE_COMMAND} ${COMMAND} + - COMMAND="make -C src CXX=\"$COMPILER\" CXXFLAGS=$FLAGS -j2 cegis.dir clobber.dir memory-models.dir musketeer.dir" && + eval ${PRE_COMMAND} ${COMMAND} + - COMMAND="make -C src clean" && + eval ${PRE_COMMAND} ${COMMAND} + - COMMAND="make -C src CXX=$COMPILER CXXFLAGS=\"-Wall -O0 -ggdb3 -Werror -Wno-deprecated-register -pedantic -Wno-sign-compare -DDEBUG\" -j2" && + eval ${PRE_COMMAND} ${COMMAND} script: - - if [ -L bin/gcc ] ; then export PATH=$PWD/bin:$PATH ; fi ; - COMMAND="make -C src minisat2-download" && - eval ${PRE_COMMAND} ${COMMAND} && - COMMAND="make -C src CXX=$COMPILER CXXFLAGS=\"-Wall -O2 -g -Werror -Wno-deprecated-register -pedantic -Wno-sign-compare\" -j2" && - eval ${PRE_COMMAND} ${COMMAND} && + - if [ -e bin/gcc ] ; then export PATH=$PWD/bin:$PATH ; fi ; COMMAND="env UBSAN_OPTIONS=print_stacktrace=1 make -C regression test" && - eval ${PRE_COMMAND} ${COMMAND} && - COMMAND="make -C src CXX=$COMPILER CXXFLAGS=$FLAGS -j2 cegis.dir clobber.dir memory-models.dir musketeer.dir" && - eval ${PRE_COMMAND} ${COMMAND} && - COMMAND="make -C src clean" && - eval ${PRE_COMMAND} ${COMMAND} && - COMMAND="make -C src CXX=$COMPILER CXXFLAGS=\"-Wall -O0 -ggdb3 -Werror -Wno-deprecated-register -pedantic -Wno-sign-compare -DDEBUG\" -j2" && eval ${PRE_COMMAND} ${COMMAND} + +before_cache: + - ccache -s From 279b3caf913dbda62292709e9dafacb823f3ec81 Mon Sep 17 00:00:00 2001 From: Vojtech Forejt Date: Fri, 31 Mar 2017 16:10:50 +0100 Subject: [PATCH 085/116] Allow cpplint to fail on Travis. This is more preferrable than using ``|| true``. --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index 5572e085ce4..f129daadf9a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -86,6 +86,12 @@ matrix: script: scripts/travis_lint.sh before_cache: + allow_failures: + - env: NAME="CPP-LINT" + install: + script: scripts/travis_lint.sh + before_cache: + install: - COMMAND="make -C src minisat2-download" && eval ${PRE_COMMAND} ${COMMAND} From e7529e8cb5811d78a8fc98b9b042fedc60930295 Mon Sep 17 00:00:00 2001 From: Martin Brain Date: Thu, 8 Sep 2016 07:58:26 +0100 Subject: [PATCH 086/116] Add XML and JSON output to the base of both ai domains and the ai analysis. --- src/analyses/ai.cpp | 152 ++++++++++++++++++++++++++++++++++++++++++++ src/analyses/ai.h | 88 +++++++++++++++++++++++++ 2 files changed, 240 insertions(+) diff --git a/src/analyses/ai.cpp b/src/analyses/ai.cpp index 06dd02af83f..3c62b79965b 100644 --- a/src/analyses/ai.cpp +++ b/src/analyses/ai.cpp @@ -81,6 +81,158 @@ void ai_baset::output( /*******************************************************************\ +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 +{ + json_objectt result; + + forall_goto_functions(f_it, goto_functions) + { + if(f_it->second.body_available()) + { + result[id2string(f_it->first)]= + output_json(ns, f_it->second.body, f_it->first); + } + else + { + result[id2string(f_it->first)]=json_arrayt(); + } + } + + return result; +} + +/*******************************************************************\ + +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, + const irep_idt &identifier) const +{ + json_arrayt contents; + + forall_goto_program_instructions(i_it, goto_program) + { + json_objectt location; + location["location_number"]= + json_numbert(std::to_string(i_it->location_number)); + location["source_location"]= + json_stringt(i_it->source_location.as_string()); + location["domain"]=find_state(i_it).output_json(*this, ns); + + // Ideally we need output_instruction_json + std::ostringstream out; + goto_program.output_instruction(ns, identifier, out, i_it); + location["instruction"]=json_stringt(out.str()); + + contents.push_back(location); + } + + return contents; +} + +/*******************************************************************\ + +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 +{ + xmlt program("program"); + + forall_goto_functions(f_it, goto_functions) + { + xmlt function("function"); + function.set_attribute("name", id2string(f_it->first)); + function.set_attribute( + "body_available", + f_it->second.body_available() ? "true" : "false"); + + if(f_it->second.body_available()) + { + function.new_element(output_xml(ns, f_it->second.body, f_it->first)); + } + + program.new_element(function); + } + + return program; +} + +/*******************************************************************\ + +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, + const irep_idt &identifier) const +{ + xmlt function_body; + + forall_goto_program_instructions(i_it, goto_program) + { + xmlt location; + location.set_attribute( + "location_number", + std::to_string(i_it->location_number)); + location.set_attribute( + "source_location", + i_it->source_location.as_string()); + + location.new_element(find_state(i_it).output_xml(*this, ns)); + + // Ideally we need output_instruction_xml + std::ostringstream out; + goto_program.output_instruction(ns, identifier, out, i_it); + location.set_attribute("instruction", out.str()); + + function_body.new_element(location); + } + + return function_body; +} + +/*******************************************************************\ + Function: ai_baset::entry_state Inputs: diff --git a/src/analyses/ai.h b/src/analyses/ai.h index c506cbbeb08..2894cde3b10 100644 --- a/src/analyses/ai.h +++ b/src/analyses/ai.h @@ -11,6 +11,10 @@ Author: Daniel Kroening, kroening@kroening.com #include #include +#include + +#include +#include #include @@ -53,6 +57,27 @@ class ai_domain_baset { } + virtual jsont output_json( + const ai_baset &ai, + const namespacet &ns) const + { + std::ostringstream out; + output(out, ai, ns); + json_stringt json(out.str()); + return json; + } + + virtual xmlt output_xml( + const ai_baset &ai, + const namespacet &ns) const + { + std::ostringstream out; + output(out, ai, ns); + xmlt xml("domain"); + xml.data=out.str(); + return xml; + } + // no states virtual void make_bottom()=0; @@ -157,6 +182,58 @@ class ai_baset output(ns, goto_function.body, "", out); } + + virtual jsont output_json( + const namespacet &ns, + const goto_functionst &goto_functions) const; + + jsont output_json( + const goto_modelt &goto_model) const + { + const namespacet ns(goto_model.symbol_table); + return output_json(ns, goto_model.goto_functions); + } + + jsont output_json( + const namespacet &ns, + const goto_programt &goto_program) const + { + return output_json(ns, goto_program, ""); + } + + jsont output_json( + const namespacet &ns, + const goto_functionst::goto_functiont &goto_function) const + { + return output_json(ns, goto_function.body, ""); + } + + + virtual xmlt output_xml( + const namespacet &ns, + const goto_functionst &goto_functions) const; + + xmlt output_xml( + const goto_modelt &goto_model) const + { + const namespacet ns(goto_model.symbol_table); + return output_xml(ns, goto_model.goto_functions); + } + + xmlt output_xml( + const namespacet &ns, + const goto_programt &goto_program) const + { + return output_xml(ns, goto_program, ""); + } + + xmlt output_xml( + const namespacet &ns, + const goto_functionst::goto_functiont &goto_function) const + { + return output_xml(ns, goto_function.body, ""); + } + protected: // overload to add a factory virtual void initialize(const goto_programt &); @@ -172,6 +249,17 @@ class ai_baset const irep_idt &identifier, std::ostream &out) const; + virtual jsont output_json( + const namespacet &ns, + const goto_programt &goto_program, + const irep_idt &identifier) const; + + virtual xmlt output_xml( + const namespacet &ns, + const goto_programt &goto_program, + const irep_idt &identifier) const; + + // the work-queue is sorted by location number typedef std::map working_sett; From 23d6aade2af1a1689e5ce5e3527fc5b3ec6c79ae Mon Sep 17 00:00:00 2001 From: Martin Brain Date: Fri, 9 Sep 2016 08:19:26 +0100 Subject: [PATCH 087/116] Constant propagator and intervals regression tests Where the current precision is insufficient, the tests are marked FUTURE. --- regression/goto-analyzer/Makefile | 6 ++ .../constant_propagation1.c | 14 ++++ .../constant_propagation_01/test.desc | 9 +++ .../constant_propagation_02.c | 13 +++ .../constant_propagation_02/original | 3 + .../constant_propagation_02/simplified | 81 +++++++++++++++++++ .../constant_propagation_02/test.desc | 9 +++ .../constant_propagation_03.c | 13 +++ .../constant_propagation_03/test.desc | 9 +++ .../constant_propagation_04.c | 13 +++ .../constant_propagation_04/test.desc | 9 +++ .../constant_propagation_05.c | 13 +++ .../constant_propagation_05/test.desc | 8 ++ .../constant_propagation_06.c | 30 +++++++ .../constant_propagation_06/test.desc | 15 ++++ .../constant_propagation_07.c | 14 ++++ .../constant_propagation_07/test.desc | 8 ++ .../constant_propagation_08.c | 16 ++++ .../constant_propagation_08/test.desc | 10 +++ .../constant_propagation_09.c | 14 ++++ .../constant_propagation_09/test.desc | 9 +++ .../constant_propagation_10.c | 25 ++++++ .../constant_propagation_10/test.desc | 9 +++ .../constant_propagation_11.c | 17 ++++ .../constant_propagation_11/test.desc | 9 +++ .../constant_propagation_12.c | 13 +++ .../constant_propagation_12/test.desc | 9 +++ .../constant_propagation_13.c | 14 ++++ .../constant_propagation_13/test.desc | 8 ++ .../constant_propagation_14.c | 13 +++ .../constant_propagation_14/test.desc | 9 +++ .../constant_propagation_15.c | 13 +++ .../constant_propagation_15/test.desc | 9 +++ .../constant_propagation_16.c | 13 +++ .../constant_propagation_16/test.desc | 8 ++ .../constant_propagation_17.c | 16 ++++ .../constant_propagation_17/test.desc | 9 +++ .../constant_propagation_18.c | 13 +++ .../constant_propagation_18/test.desc | 8 ++ .../goto-analyzer/intervals1/intervals1.c | 4 +- regression/goto-analyzer/intervals1/test.desc | 2 +- .../goto-analyzer/intervals10/intervals10.c | 21 +++++ .../goto-analyzer/intervals10/test.desc | 12 +++ .../goto-analyzer/intervals11/intervals11.c | 43 ++++++++++ .../goto-analyzer/intervals11/test.desc | 9 +++ .../goto-analyzer/intervals12/intervals12.c | 16 ++++ .../goto-analyzer/intervals12/test.desc | 9 +++ .../goto-analyzer/intervals2/intervals2.c | 6 +- regression/goto-analyzer/intervals2/test.desc | 2 +- regression/goto-analyzer/intervals3/test.desc | 2 +- regression/goto-analyzer/intervals4/test.desc | 2 +- regression/goto-analyzer/intervals5/test.desc | 2 +- regression/goto-analyzer/intervals6/test.desc | 6 +- regression/goto-analyzer/intervals7/test.desc | 6 +- .../goto-analyzer/intervals8/intervals8.c | 9 +++ regression/goto-analyzer/intervals8/test.desc | 8 ++ .../goto-analyzer/intervals9/intervals9.c | 12 +++ regression/goto-analyzer/intervals9/test.desc | 8 ++ 58 files changed, 694 insertions(+), 16 deletions(-) create mode 100644 regression/goto-analyzer/constant_propagation_01/constant_propagation1.c create mode 100644 regression/goto-analyzer/constant_propagation_01/test.desc create mode 100644 regression/goto-analyzer/constant_propagation_02/constant_propagation_02.c create mode 100644 regression/goto-analyzer/constant_propagation_02/original create mode 100644 regression/goto-analyzer/constant_propagation_02/simplified create mode 100644 regression/goto-analyzer/constant_propagation_02/test.desc create mode 100644 regression/goto-analyzer/constant_propagation_03/constant_propagation_03.c create mode 100644 regression/goto-analyzer/constant_propagation_03/test.desc create mode 100644 regression/goto-analyzer/constant_propagation_04/constant_propagation_04.c create mode 100644 regression/goto-analyzer/constant_propagation_04/test.desc create mode 100644 regression/goto-analyzer/constant_propagation_05/constant_propagation_05.c create mode 100644 regression/goto-analyzer/constant_propagation_05/test.desc create mode 100644 regression/goto-analyzer/constant_propagation_06/constant_propagation_06.c create mode 100644 regression/goto-analyzer/constant_propagation_06/test.desc create mode 100644 regression/goto-analyzer/constant_propagation_07/constant_propagation_07.c create mode 100644 regression/goto-analyzer/constant_propagation_07/test.desc create mode 100644 regression/goto-analyzer/constant_propagation_08/constant_propagation_08.c create mode 100644 regression/goto-analyzer/constant_propagation_08/test.desc create mode 100644 regression/goto-analyzer/constant_propagation_09/constant_propagation_09.c create mode 100644 regression/goto-analyzer/constant_propagation_09/test.desc create mode 100644 regression/goto-analyzer/constant_propagation_10/constant_propagation_10.c create mode 100644 regression/goto-analyzer/constant_propagation_10/test.desc create mode 100644 regression/goto-analyzer/constant_propagation_11/constant_propagation_11.c create mode 100644 regression/goto-analyzer/constant_propagation_11/test.desc create mode 100644 regression/goto-analyzer/constant_propagation_12/constant_propagation_12.c create mode 100644 regression/goto-analyzer/constant_propagation_12/test.desc create mode 100644 regression/goto-analyzer/constant_propagation_13/constant_propagation_13.c create mode 100644 regression/goto-analyzer/constant_propagation_13/test.desc create mode 100644 regression/goto-analyzer/constant_propagation_14/constant_propagation_14.c create mode 100644 regression/goto-analyzer/constant_propagation_14/test.desc create mode 100644 regression/goto-analyzer/constant_propagation_15/constant_propagation_15.c create mode 100644 regression/goto-analyzer/constant_propagation_15/test.desc create mode 100644 regression/goto-analyzer/constant_propagation_16/constant_propagation_16.c create mode 100644 regression/goto-analyzer/constant_propagation_16/test.desc create mode 100644 regression/goto-analyzer/constant_propagation_17/constant_propagation_17.c create mode 100644 regression/goto-analyzer/constant_propagation_17/test.desc create mode 100644 regression/goto-analyzer/constant_propagation_18/constant_propagation_18.c create mode 100644 regression/goto-analyzer/constant_propagation_18/test.desc create mode 100644 regression/goto-analyzer/intervals10/intervals10.c create mode 100644 regression/goto-analyzer/intervals10/test.desc create mode 100644 regression/goto-analyzer/intervals11/intervals11.c create mode 100644 regression/goto-analyzer/intervals11/test.desc create mode 100644 regression/goto-analyzer/intervals12/intervals12.c create mode 100644 regression/goto-analyzer/intervals12/test.desc create mode 100644 regression/goto-analyzer/intervals8/intervals8.c create mode 100644 regression/goto-analyzer/intervals8/test.desc create mode 100644 regression/goto-analyzer/intervals9/intervals9.c create mode 100644 regression/goto-analyzer/intervals9/test.desc diff --git a/regression/goto-analyzer/Makefile b/regression/goto-analyzer/Makefile index 2630bf17097..c5e98e260c5 100644 --- a/regression/goto-analyzer/Makefile +++ b/regression/goto-analyzer/Makefile @@ -18,3 +18,9 @@ show: vim -o "$$dir/*.java" "$$dir/*.out"; \ fi; \ done; + +clean: + find . -name *.*~ | xargs rm -f + find . -name *.out | xargs rm -f + find . -name *.goto | xargs rm -f + rm -f tests.log diff --git a/regression/goto-analyzer/constant_propagation_01/constant_propagation1.c b/regression/goto-analyzer/constant_propagation_01/constant_propagation1.c new file mode 100644 index 00000000000..801a21535a9 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_01/constant_propagation1.c @@ -0,0 +1,14 @@ +#include + +int main() +{ + int i, j=20; + + if (j==20) + { + int x=1,y=2,z; + z=x+y; + assert(z==3); + } + +} diff --git a/regression/goto-analyzer/constant_propagation_01/test.desc b/regression/goto-analyzer/constant_propagation_01/test.desc new file mode 100644 index 00000000000..7e9cac6056b --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_01/test.desc @@ -0,0 +1,9 @@ +CORE +constant_propagation1.c +--constants --simplify out.goto +^EXIT=0$ +^SIGNAL=0$ +^SIMPLIFIED: assert: 1, assume: 0, goto: 2, assigns: 5, function calls: 0$ +^UNMODIFIED: assert: 0, assume: 0, goto: 0, assigns: 12, function calls: 2$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_02/constant_propagation_02.c b/regression/goto-analyzer/constant_propagation_02/constant_propagation_02.c new file mode 100644 index 00000000000..ff139437bd8 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_02/constant_propagation_02.c @@ -0,0 +1,13 @@ +#include + +int main() +{ + int i=0, j=2; + + if (i==0) + { + i++; + j++; + } + assert(j!=3); +} diff --git a/regression/goto-analyzer/constant_propagation_02/original b/regression/goto-analyzer/constant_propagation_02/original new file mode 100644 index 00000000000..13a9e245c81 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_02/original @@ -0,0 +1,3 @@ +Task defaults to --show +Domain defaults to --constants +GOTO-ANALYSER version 5.5 64-bit x86_64 linux diff --git a/regression/goto-analyzer/constant_propagation_02/simplified b/regression/goto-analyzer/constant_propagation_02/simplified new file mode 100644 index 00000000000..6c722a607de --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_02/simplified @@ -0,0 +1,81 @@ +Reading GOTO program from `out.goto' +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +main /* main */ + // 0 file constant_propagation_02.c line 5 function main + signed int i; + // 1 file constant_propagation_02.c line 5 function main + i = 0; + // 2 file constant_propagation_02.c line 5 function main + signed int j; + // 3 file constant_propagation_02.c line 5 function main + j = 2; + // 4 file constant_propagation_02.c line 7 function main + IF FALSE THEN GOTO 1 + // 5 file constant_propagation_02.c line 9 function main + 0 = 1; + // 6 file constant_propagation_02.c line 10 function main + 2 = 3; + // 7 no location + 1: SKIP + // 8 file constant_propagation_02.c line 12 function main + ASSERT FALSE // assertion j!=3 + // 9 file constant_propagation_02.c line 12 function main + GOTO 2 + // 10 file constant_propagation_02.c line 12 function main + (void)0; + // 11 no location + 2: SKIP + // 12 file constant_propagation_02.c line 13 function main + dead j; + // 13 file constant_propagation_02.c line 13 function main + dead i; + // 14 file constant_propagation_02.c line 13 function main + main#return_value = NONDET(signed int); + // 15 file constant_propagation_02.c line 13 function main + END_FUNCTION +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +_start /* _start */ + // 16 no location + __CPROVER_initialize(); + // 17 file constant_propagation_02.c line 3 + main(); + // 18 file constant_propagation_02.c line 3 + return' = main#return_value; + // 19 file constant_propagation_02.c line 3 + dead main#return_value; + // 20 file constant_propagation_02.c line 3 + OUTPUT("return", return'); + // 21 no location + END_FUNCTION +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +__CPROVER_initialize /* __CPROVER_initialize */ + // 22 no location + // Labels: __CPROVER_HIDE + SKIP + // 23 file line 39 + __CPROVER_dead_object = NULL; + // 24 file line 38 + __CPROVER_deallocated = NULL; + // 25 file line 42 + __CPROVER_malloc_is_new_array = FALSE; + // 26 file line 40 + __CPROVER_malloc_object = NULL; + // 27 file line 41 + __CPROVER_malloc_size = 0ul; + // 28 file line 43 + __CPROVER_memory_leak = NULL; + // 29 file line 31 + __CPROVER_next_thread_id = 0ul; + // 30 file line 85 + __CPROVER_pipe_count = 0u; + // 31 file line 65 + __CPROVER_rounding_mode = 0; + // 32 file line 29 + __CPROVER_thread_id = 0ul; + // 33 file line 30 + __CPROVER_threads_exited = ARRAY_OF(FALSE); + // 34 no location + END_FUNCTION diff --git a/regression/goto-analyzer/constant_propagation_02/test.desc b/regression/goto-analyzer/constant_propagation_02/test.desc new file mode 100644 index 00000000000..635f7dcf620 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_02/test.desc @@ -0,0 +1,9 @@ +CORE +constant_propagation_02.c +--constants --simplify out.goto +^EXIT=0$ +^SIGNAL=0$ +^SIMPLIFIED: assert: 1, assume: 0, goto: 2, assigns: 6, function calls: 0$ +^UNMODIFIED: assert: 0, assume: 0, goto: 0, assigns: 11, function calls: 2$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_03/constant_propagation_03.c b/regression/goto-analyzer/constant_propagation_03/constant_propagation_03.c new file mode 100644 index 00000000000..f08f6020d82 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_03/constant_propagation_03.c @@ -0,0 +1,13 @@ +#include + +int main() +{ + int i=0, j=2; + + if (i==0) + { + i++; + j++; + } + assert(j==3); +} diff --git a/regression/goto-analyzer/constant_propagation_03/test.desc b/regression/goto-analyzer/constant_propagation_03/test.desc new file mode 100644 index 00000000000..37962658987 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_03/test.desc @@ -0,0 +1,9 @@ +CORE +constant_propagation_03.c +--constants --simplify out.goto +^EXIT=0$ +^SIGNAL=0$ +^SIMPLIFIED: assert: 1, assume: 0, goto: 2, assigns: 6, function calls: 0$ +^UNMODIFIED: assert: 0, assume: 0, goto: 0, assigns: 11, function calls: 2$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_04/constant_propagation_04.c b/regression/goto-analyzer/constant_propagation_04/constant_propagation_04.c new file mode 100644 index 00000000000..ca003ccd2b8 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_04/constant_propagation_04.c @@ -0,0 +1,13 @@ +#include + +int main() +{ + int i=0, j=2; + + if (i<50) + { + i++; + j++; + } + assert(j==3); +} diff --git a/regression/goto-analyzer/constant_propagation_04/test.desc b/regression/goto-analyzer/constant_propagation_04/test.desc new file mode 100644 index 00000000000..2b23ac224f7 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_04/test.desc @@ -0,0 +1,9 @@ +CORE +constant_propagation_04.c +--constants --simplify out.goto +^EXIT=0$ +^SIGNAL=0$ +^SIMPLIFIED: assert: 1, assume: 0, goto: 2, assigns: 6, function calls: 0$ +^UNMODIFIED: assert: 0, assume: 0, goto: 0, assigns: 11, function calls: 2$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_05/constant_propagation_05.c b/regression/goto-analyzer/constant_propagation_05/constant_propagation_05.c new file mode 100644 index 00000000000..037fbbe0632 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_05/constant_propagation_05.c @@ -0,0 +1,13 @@ +#include + +int main() +{ + int i=0, j=2; + + if (i<50) + { + i++; + j++; + } + assert(j!=3); +} diff --git a/regression/goto-analyzer/constant_propagation_05/test.desc b/regression/goto-analyzer/constant_propagation_05/test.desc new file mode 100644 index 00000000000..84712b085da --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_05/test.desc @@ -0,0 +1,8 @@ +CORE +constant_propagation_05.c +--constants --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] file constant_propagation_05.c line 12 function main, assertion j!=3: FAILURE (if reachable)$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_06/constant_propagation_06.c b/regression/goto-analyzer/constant_propagation_06/constant_propagation_06.c new file mode 100644 index 00000000000..d1d29427250 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_06/constant_propagation_06.c @@ -0,0 +1,30 @@ +#include + +int main() +{ + int i, j=20; + + if(i>=20) + assert(i>=10); // success + + if(i>=10 && i<=20) + assert(i!=30); // success + + if(i>=10 && i<=20) + assert(i!=15); // fails + + if(i<1 && i>10) + assert(0); // success + + if(i>=10 && j>=i) + assert(j>=10); // success + + if(i>=j) + assert(i>=j); // unknown + + if(i>10) + assert(i>=11); // success + + if(i<=100 && j=10: SUCCESS$ +^\[main.assertion.2\] file constant_propagation_06.c line 11 function main, assertion i!=30: SUCCESS$ +^\[main.assertion.3\] file constant_propagation_06.c line 14 function main, assertion i!=15: UNKNOWN$ +^\[main.assertion.4\] file constant_propagation_06.c line 17 function main, assertion 0: SUCCESS$ +^\[main.assertion.5\] file constant_propagation_06.c line 20 function main, assertion j>=10: SUCCESS$ +^\[main.assertion.6\] file constant_propagation_06.c line 23 function main, assertion i>=j: UNKNOWN$ +^\[main.assertion.7\] file constant_propagation_06.c line 26 function main, assertion i>=11: SUCCESS$ +^\[main.assertion.8\] file constant_propagation_06.c line 29 function main, assertion j<100: SUCCESS$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_07/constant_propagation_07.c b/regression/goto-analyzer/constant_propagation_07/constant_propagation_07.c new file mode 100644 index 00000000000..40b04edfdd0 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_07/constant_propagation_07.c @@ -0,0 +1,14 @@ +#include + +int main() +{ + int i=0, j=2; + + while (i<50) + { + i++; + j++; + } + assert(i<51); +} + diff --git a/regression/goto-analyzer/constant_propagation_07/test.desc b/regression/goto-analyzer/constant_propagation_07/test.desc new file mode 100644 index 00000000000..7494eafcd54 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_07/test.desc @@ -0,0 +1,8 @@ +CORE +constant_propagation_07.c +--constants --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] file constant_propagation_07.c line 12 function main, assertion i<51: UNKNOWN$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_08/constant_propagation_08.c b/regression/goto-analyzer/constant_propagation_08/constant_propagation_08.c new file mode 100644 index 00000000000..3909e3889e4 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_08/constant_propagation_08.c @@ -0,0 +1,16 @@ +#include + +int main() +{ + int i=0, j=2; + + while (i<=50) + { + i++; + j++; + } + assert(i<50); + assert(i<51); + assert(i<52); +} + diff --git a/regression/goto-analyzer/constant_propagation_08/test.desc b/regression/goto-analyzer/constant_propagation_08/test.desc new file mode 100644 index 00000000000..994c2c532df --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_08/test.desc @@ -0,0 +1,10 @@ +FUTURE +constant_propagation_08.c +--intervals --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] file constant_propagation_08.c line 12 function main, assertion i<50: UNKNOWN$ +^\[main.assertion.2\] file constant_propagation_08.c line 13 function main, assertion i<51: UNKNOWN$ +^\[main.assertion.3\] file constant_propagation_08.c line 14 function main, assertion i<52: SUCCESS$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_09/constant_propagation_09.c b/regression/goto-analyzer/constant_propagation_09/constant_propagation_09.c new file mode 100644 index 00000000000..002e9063228 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_09/constant_propagation_09.c @@ -0,0 +1,14 @@ +#include + +int main() +{ + int i=0, j=2; + + while (i<=50) + { + i++; + j++; + } + assert(j<52); +} + diff --git a/regression/goto-analyzer/constant_propagation_09/test.desc b/regression/goto-analyzer/constant_propagation_09/test.desc new file mode 100644 index 00000000000..8cb0ec6a003 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_09/test.desc @@ -0,0 +1,9 @@ +CORE +constant_propagation_09.c +--intervals --verify +^EXIT=0$ +^SIGNAL=0$ +******** Function main +^\[main.assertion.1\] file constant_propagation_09.c line 12 function main, assertion j<52: UNKNOWN$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_10/constant_propagation_10.c b/regression/goto-analyzer/constant_propagation_10/constant_propagation_10.c new file mode 100644 index 00000000000..169f7965b9d --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_10/constant_propagation_10.c @@ -0,0 +1,25 @@ +#include +int main() +{ + signed int i; + signed int j; + i = 0; + if(!(i >= 2)) + { + j = j + 1; + i = i + 1; + if(!(i >= 2)) + { + j = j + 1; + i = i + 1; + if(!(i >= 2)) + { + j = j + 1; + i = i + 1; + } + assert(!(i < 2)); + } + } + return 0; +} + diff --git a/regression/goto-analyzer/constant_propagation_10/test.desc b/regression/goto-analyzer/constant_propagation_10/test.desc new file mode 100644 index 00000000000..7b78521a13d --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_10/test.desc @@ -0,0 +1,9 @@ +CORE +constant_propagation_10.c +--constants --simplify out.goto +^EXIT=0$ +^SIGNAL=0$ +^SIMPLIFIED: assert: 1, assume: 0, goto: 4, assigns: 10, function calls: 0$ +^UNMODIFIED: assert: 0, assume: 0, goto: 1, assigns: 10, function calls: 2$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_11/constant_propagation_11.c b/regression/goto-analyzer/constant_propagation_11/constant_propagation_11.c new file mode 100644 index 00000000000..3022a4f0f19 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_11/constant_propagation_11.c @@ -0,0 +1,17 @@ +#include +int main() +{ + int a[2]; + int i; + i = 0; + + if (i==0) + a[0]=1; + else + a[1]=2; + + assert(a[0]==1 || a[1]==2); + + return 0; +} + diff --git a/regression/goto-analyzer/constant_propagation_11/test.desc b/regression/goto-analyzer/constant_propagation_11/test.desc new file mode 100644 index 00000000000..7c849326cf6 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_11/test.desc @@ -0,0 +1,9 @@ +FUTURE +constant_propagation_11.c +--constants --simplify out.goto +^EXIT=0$ +^SIGNAL=0$ +^SIMPLIFIED: assert: 1, assume: 0, goto: 2, assigns: 5, function calls: 0$ +^UNMODIFIED: assert: 0, assume: 0, goto: 4, assigns: 13, function calls: 2$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_12/constant_propagation_12.c b/regression/goto-analyzer/constant_propagation_12/constant_propagation_12.c new file mode 100644 index 00000000000..55ea9ac7fc2 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_12/constant_propagation_12.c @@ -0,0 +1,13 @@ +#include +int main() +{ + int a[2]={0,0}; + + if (a[0]==0) + a[0]=1; + + assert(a[0]==0); + + return 0; +} + diff --git a/regression/goto-analyzer/constant_propagation_12/test.desc b/regression/goto-analyzer/constant_propagation_12/test.desc new file mode 100644 index 00000000000..ca5803363ad --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_12/test.desc @@ -0,0 +1,9 @@ +FUTURE +constant_propagation_12.c +--constants --simplify out.goto +^EXIT=0$ +^SIGNAL=0$ +^SIMPLIFIED: assert: 1, assume: 0, goto: 3, assigns: 4, function calls: 0$ +^UNMODIFIED: assert: 0, assume: 0, goto: 0, assigns: 11, function calls: 2$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_13/constant_propagation_13.c b/regression/goto-analyzer/constant_propagation_13/constant_propagation_13.c new file mode 100644 index 00000000000..ac5933e9177 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_13/constant_propagation_13.c @@ -0,0 +1,14 @@ +#include +int main() +{ + int a[2]={0,0}; + int i, y; + + if (a[0]==0) + a[0]=1; + + assert(a[0]==2); + + return 0; +} + diff --git a/regression/goto-analyzer/constant_propagation_13/test.desc b/regression/goto-analyzer/constant_propagation_13/test.desc new file mode 100644 index 00000000000..22f10d125e3 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_13/test.desc @@ -0,0 +1,8 @@ +FUTURE +constant_propagation_13.c +--constants --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] file constant_propagation_13.c line 10 function main, assertion a\[0\]==2: FAILURE$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_14/constant_propagation_14.c b/regression/goto-analyzer/constant_propagation_14/constant_propagation_14.c new file mode 100644 index 00000000000..124d1e30a20 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_14/constant_propagation_14.c @@ -0,0 +1,13 @@ +#include +int main() +{ + int a[2]={0,0}; + + if (a[0]==0) + a[0]=1; + + assert(a[0]==1 /*|| a[0]==2*/); + + return 0; +} + diff --git a/regression/goto-analyzer/constant_propagation_14/test.desc b/regression/goto-analyzer/constant_propagation_14/test.desc new file mode 100644 index 00000000000..a39a1f66cda --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_14/test.desc @@ -0,0 +1,9 @@ +FUTURE +constant_propagation_14.c +--constants --simplify out.goto +^EXIT=0$ +^SIGNAL=0$ +^SIMPLIFIED: assert: 1, assume: 0, goto: 0$ +^UNKNOWN: assert: 0, assume: 0, goto: 0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_15/constant_propagation_15.c b/regression/goto-analyzer/constant_propagation_15/constant_propagation_15.c new file mode 100644 index 00000000000..9a7e7692d62 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_15/constant_propagation_15.c @@ -0,0 +1,13 @@ +#include +int main() +{ + int i=0, y; + + if (i==0) + y=1; + + assert(y==1); + + return 0; +} + diff --git a/regression/goto-analyzer/constant_propagation_15/test.desc b/regression/goto-analyzer/constant_propagation_15/test.desc new file mode 100644 index 00000000000..20d36183eb0 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_15/test.desc @@ -0,0 +1,9 @@ +FUTURE +constant_propagation_15.c +--constants --simplify out.goto +^EXIT=0$ +^SIGNAL=0$ +^SIMPLIFIED: assert: 1, assume: 0, goto: 1, assigns: 4, function calls: 0$ +^UNMODIFIED: assert: 0, assume: 0, goto: 2, assigns: 11, function calls: 2$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_16/constant_propagation_16.c b/regression/goto-analyzer/constant_propagation_16/constant_propagation_16.c new file mode 100644 index 00000000000..102cfd7f812 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_16/constant_propagation_16.c @@ -0,0 +1,13 @@ +#include +int main() +{ + int i=0, y; + + if (i==0) + y=1; + + assert(y==0); + + return 0; +} + diff --git a/regression/goto-analyzer/constant_propagation_16/test.desc b/regression/goto-analyzer/constant_propagation_16/test.desc new file mode 100644 index 00000000000..b56c871deb4 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_16/test.desc @@ -0,0 +1,8 @@ +FUTURE +constant_propagation_16.c +--constants --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] file constant_propagation_16.c line 9 function main, assertion y==0: FAILURE (if reachable)$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_17/constant_propagation_17.c b/regression/goto-analyzer/constant_propagation_17/constant_propagation_17.c new file mode 100644 index 00000000000..8b426fe84b5 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_17/constant_propagation_17.c @@ -0,0 +1,16 @@ +#include +int main() +{ + int a[2]={0,0}; + + if (a[0]==0) + a[0]=1; + else + a[0]=2; + + assert(a[0]==1 || a[0]==2); + assert(a[0]==1 && a[0]==2); + + return 0; +} + diff --git a/regression/goto-analyzer/constant_propagation_17/test.desc b/regression/goto-analyzer/constant_propagation_17/test.desc new file mode 100644 index 00000000000..acecb91eb0a --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_17/test.desc @@ -0,0 +1,9 @@ +FUTURE +constant_propagation_17.c +--constants --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] file constant_propagation_17.c line 11 function main, assertion a\[0\]==1 || a\[0\]==2: SUCCESS$ +^\[main.assertion.2\] file constant_propagation_17.c line 12 function main, assertion a\[0\]==1 && a\[0\]==2: FAILURE$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_18/constant_propagation_18.c b/regression/goto-analyzer/constant_propagation_18/constant_propagation_18.c new file mode 100644 index 00000000000..6639f9b5c81 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_18/constant_propagation_18.c @@ -0,0 +1,13 @@ +#include +int main() +{ + int a[2]={0,0}; + + if (a[0]==0) + a[0]=1; + + assert(a[0]==2); + + return 0; +} + diff --git a/regression/goto-analyzer/constant_propagation_18/test.desc b/regression/goto-analyzer/constant_propagation_18/test.desc new file mode 100644 index 00000000000..7ea74c4d264 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_18/test.desc @@ -0,0 +1,8 @@ +FUTURE +constant_propagation_18.c +--constants --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] file constant_propagation_18.c line 9 function main, assertion a\[0\]==2: FAILURE$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/intervals1/intervals1.c b/regression/goto-analyzer/intervals1/intervals1.c index a797452b198..cdec490fe6d 100644 --- a/regression/goto-analyzer/intervals1/intervals1.c +++ b/regression/goto-analyzer/intervals1/intervals1.c @@ -2,8 +2,8 @@ int main() { - int i, j; - + int i, j=20; + if(i>=20) assert(i>=10); diff --git a/regression/goto-analyzer/intervals1/test.desc b/regression/goto-analyzer/intervals1/test.desc index 3e81f14023a..7aca700f7a5 100644 --- a/regression/goto-analyzer/intervals1/test.desc +++ b/regression/goto-analyzer/intervals1/test.desc @@ -1,6 +1,6 @@ CORE intervals1.c ---intervals +--intervals --verify ^EXIT=0$ ^SIGNAL=0$ ^\[main.assertion.1\] file intervals1.c line 8 function main, assertion i>=10: SUCCESS$ diff --git a/regression/goto-analyzer/intervals10/intervals10.c b/regression/goto-analyzer/intervals10/intervals10.c new file mode 100644 index 00000000000..b27cc6f2001 --- /dev/null +++ b/regression/goto-analyzer/intervals10/intervals10.c @@ -0,0 +1,21 @@ +#include + +int main() +{ + int i, j; + + if(i<=100 && j100); // fails + + if(i<=100 && j100: FAILURE (if reachable)$ +^\[main.assertion.4\] file intervals10.c line 17 function main, assertion j<99: UNKNOWN$ +^\[main.assertion.5\] file intervals10.c line 20 function main, assertion j==100: FAILURE (if reachable)$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/intervals11/intervals11.c b/regression/goto-analyzer/intervals11/intervals11.c new file mode 100644 index 00000000000..2f061cd554d --- /dev/null +++ b/regression/goto-analyzer/intervals11/intervals11.c @@ -0,0 +1,43 @@ +#include +const int xLen = 10; +const int Alen = 2; +const int Blen = 1; +float nondet_float(); +int main() { + float A[] = {1.0f,-0.5f}; + float B[] = {1.0f}; + int i,j; + float x[xLen]; + float x_aux[xLen]; + float y[xLen]; + float y_aux[xLen]; + float total=0; + for (i=0;i=-1 && x[i]<=1); + x_aux[i]=0; + y_aux[i]=0; + } + for(i=0;i=1;j--) + x_aux[j] = x_aux[j-1]; + x_aux[0] = x[i]; + /* Num, x values */ + for (j = 0; j < Blen; j++) { + y[i] = y[i] + B[j]*x_aux[j]; + assert(y[i]>=-1.0f && y[i]<=1.0f); //success + } + /* Den, y values */ + for(j=0;j=-1.0f && y[i]<=1.0f); //fails + } + /* Update past y values */ + for(j=Alen-2;j>=1;j--) + y_aux[j] = y_aux[j-1]; + y_aux[0] = y[i]; + } +} + diff --git a/regression/goto-analyzer/intervals11/test.desc b/regression/goto-analyzer/intervals11/test.desc new file mode 100644 index 00000000000..039cbffbeb0 --- /dev/null +++ b/regression/goto-analyzer/intervals11/test.desc @@ -0,0 +1,9 @@ +FUTURE +intervals11.c +--intervals --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] file intervals11.c line 30 function main, assertion y\[i\]>=-1.0f && y\[i\]<=1.0f: UNKNOWN$ +^\[main.assertion.2\] file intervals11.c line 35 function main, assertion y\[i\]>=-1.0f && y\[i\]<=1.0f: UNKNOWN$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/intervals12/intervals12.c b/regression/goto-analyzer/intervals12/intervals12.c new file mode 100644 index 00000000000..15d865adf80 --- /dev/null +++ b/regression/goto-analyzer/intervals12/intervals12.c @@ -0,0 +1,16 @@ +#include + +int main (void) { + int i; + int j; + + if (i <= 0 && j < i) + assert(j < 0); + + if (j < i && i <= 0) + assert(j < 0); + + return 0; +} + + diff --git a/regression/goto-analyzer/intervals12/test.desc b/regression/goto-analyzer/intervals12/test.desc new file mode 100644 index 00000000000..59a724c28b5 --- /dev/null +++ b/regression/goto-analyzer/intervals12/test.desc @@ -0,0 +1,9 @@ +FUTURE +intervals12.c +--intervals --verify +^EXIT=0$ +^SIGNAL=0$ +^[main.assertion.1] file intervals12.c line 8 function main, assertion j < 0: SUCCESS$ +^[main.assertion.2] file intervals12.c line 11 function main, assertion j < 0: SUCCESS$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/intervals2/intervals2.c b/regression/goto-analyzer/intervals2/intervals2.c index d1eaf25240e..d542854bb6a 100644 --- a/regression/goto-analyzer/intervals2/intervals2.c +++ b/regression/goto-analyzer/intervals2/intervals2.c @@ -2,10 +2,10 @@ int main(){ int x; - if (x > 0) { - if (x < 20) { + if (x > 0 && x < 20) { + //if (x < 20) { assert(x > -10 && x < 100); - } + //} } return 0; } diff --git a/regression/goto-analyzer/intervals2/test.desc b/regression/goto-analyzer/intervals2/test.desc index 16a8ca559e2..65aae030db1 100644 --- a/regression/goto-analyzer/intervals2/test.desc +++ b/regression/goto-analyzer/intervals2/test.desc @@ -1,6 +1,6 @@ KNOWNBUG intervals2.c ---intervals +--intervals --verify ^EXIT=0$ ^SIGNAL=0$ ^\[main.assertion.1\] file intervals2.c line 7 function main, assertion x > -10 && x < 100: SUCCESS$ diff --git a/regression/goto-analyzer/intervals3/test.desc b/regression/goto-analyzer/intervals3/test.desc index 5db07df08a4..dceec17bc81 100644 --- a/regression/goto-analyzer/intervals3/test.desc +++ b/regression/goto-analyzer/intervals3/test.desc @@ -1,6 +1,6 @@ CORE intervals3.c ---intervals +--intervals --verify ^EXIT=0$ ^SIGNAL=0$ ^\[main.assertion.1\] file intervals3.c line 7 function main, assertion x > -10 || x < 100: SUCCESS$ diff --git a/regression/goto-analyzer/intervals4/test.desc b/regression/goto-analyzer/intervals4/test.desc index 97d222012ad..2b725180e3f 100644 --- a/regression/goto-analyzer/intervals4/test.desc +++ b/regression/goto-analyzer/intervals4/test.desc @@ -1,6 +1,6 @@ KNOWNBUG intervals4.c ---intervals +--intervals --verify ^EXIT=0$ ^SIGNAL=0$ ^\[main.assertion.1\] file intervals4.c line 9 function main, assertion i >= 1 && i <= 2: SUCCESS$ diff --git a/regression/goto-analyzer/intervals5/test.desc b/regression/goto-analyzer/intervals5/test.desc index 42554724e2d..0213e7b3297 100644 --- a/regression/goto-analyzer/intervals5/test.desc +++ b/regression/goto-analyzer/intervals5/test.desc @@ -1,6 +1,6 @@ CORE intervals5.c ---intervals +--intervals --verify ^EXIT=0$ ^SIGNAL=0$ ^\[main.assertion.1\] file intervals5.c line 9 function main, assertion i >= 1 || i <= 2: SUCCESS$ diff --git a/regression/goto-analyzer/intervals6/test.desc b/regression/goto-analyzer/intervals6/test.desc index 14fd64f33dd..6e36b7948d2 100644 --- a/regression/goto-analyzer/intervals6/test.desc +++ b/regression/goto-analyzer/intervals6/test.desc @@ -1,8 +1,8 @@ -CORE +FUTURE intervals6.c ---intervals +--intervals --verify ^EXIT=0$ ^SIGNAL=0$ -^\[main.assertion.1\] file intervals6.c line 7 function main, assertion x < -10 || x > 100: UNKNOWN$ +^\[main.assertion.1\] file intervals6.c line 7 function main, assertion x < -10 || x > 100: FAILURE (if reachable)$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/intervals7/test.desc b/regression/goto-analyzer/intervals7/test.desc index aeeb24bd0a9..6a42b4a30ec 100644 --- a/regression/goto-analyzer/intervals7/test.desc +++ b/regression/goto-analyzer/intervals7/test.desc @@ -1,8 +1,8 @@ -CORE +FUTURE intervals7.c ---intervals +--intervals --verify ^EXIT=0$ ^SIGNAL=0$ -^\[main.assertion.1\] file intervals7.c line 7 function main, assertion x < -10 && x > 100: UNKNOWN$ +^\[main.assertion.1\] file intervals7.c line 7 function main, assertion x < -10 && x > 100: FAILURE (if reachable)$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/intervals8/intervals8.c b/regression/goto-analyzer/intervals8/intervals8.c new file mode 100644 index 00000000000..4128ac07ce5 --- /dev/null +++ b/regression/goto-analyzer/intervals8/intervals8.c @@ -0,0 +1,9 @@ +#include + +int main(){ + int x; + if (x > 0 && x < 20) { + assert(x < -10 && x < 100); + } + return 0; +} diff --git a/regression/goto-analyzer/intervals8/test.desc b/regression/goto-analyzer/intervals8/test.desc new file mode 100644 index 00000000000..7500059a717 --- /dev/null +++ b/regression/goto-analyzer/intervals8/test.desc @@ -0,0 +1,8 @@ +FUTURE +intervals8.c +--intervals --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] file intervals8.c line 6 function main, assertion x < -10 && x < 100: FAILURE (if reachable)$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/intervals9/intervals9.c b/regression/goto-analyzer/intervals9/intervals9.c new file mode 100644 index 00000000000..27739c7aa28 --- /dev/null +++ b/regression/goto-analyzer/intervals9/intervals9.c @@ -0,0 +1,12 @@ +#include + +int main() +{ + int i; + + if(i>0) + if(i<3) + assert(i>=1 && i<=2); + + return 0; +} diff --git a/regression/goto-analyzer/intervals9/test.desc b/regression/goto-analyzer/intervals9/test.desc new file mode 100644 index 00000000000..33f92abcdb2 --- /dev/null +++ b/regression/goto-analyzer/intervals9/test.desc @@ -0,0 +1,8 @@ +CORE +intervals9.c +--intervals --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] file intervals9.c line 9 function main, assertion i>=1 && i<=2: SUCCESS$ +-- +^warning: ignoring From b0846b26a33fc470d582b5041a07059d1ff298d7 Mon Sep 17 00:00:00 2001 From: martin Date: Thu, 15 Dec 2016 20:05:53 +0000 Subject: [PATCH 088/116] Add utility function to tell if a program is threaded or not. --- src/analyses/is_threaded.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/analyses/is_threaded.h b/src/analyses/is_threaded.h index ceb10494665..738857b8b8a 100644 --- a/src/analyses/is_threaded.h +++ b/src/analyses/is_threaded.h @@ -29,6 +29,11 @@ class is_threadedt return is_threaded_set.find(t)!=is_threaded_set.end(); } + bool operator()(void) const + { + return !is_threaded_set.empty(); + } + protected: typedef std::set is_threaded_sett; is_threaded_sett is_threaded_set; From cc26814b239013949b0c1343dacc65f8a2bd4eac Mon Sep 17 00:00:00 2001 From: martin Date: Mon, 19 Dec 2016 20:07:52 +0000 Subject: [PATCH 089/116] Fixes and improvements to the constant and interval domain. --- src/analyses/constant_propagator.cpp | 212 +++++++++++++++++++++++---- src/analyses/constant_propagator.h | 8 + src/analyses/interval_domain.cpp | 4 +- 3 files changed, 194 insertions(+), 30 deletions(-) diff --git a/src/analyses/constant_propagator.cpp b/src/analyses/constant_propagator.cpp index 189048994b8..6735d558cc3 100644 --- a/src/analyses/constant_propagator.cpp +++ b/src/analyses/constant_propagator.cpp @@ -18,6 +18,61 @@ Author: Peter Schrammel /*******************************************************************\ +Function: concatenate_array_id + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +exprt concatenate_array_id( + const exprt &array, const exprt &index, + const typet &type) +{ + std::string a, idx, identifier; + a = array.get_string(ID_identifier); + + if (index.id()==ID_typecast) + idx = index.op0().get_string(ID_value); + else + idx = index.get_string(ID_value); + + mp_integer i=string2integer(idx); + identifier=a+"["+integer2string(i)+"]"; + symbol_exprt new_expr(identifier, type); + + return new_expr; +} + +/*******************************************************************\ + +Function: concatenate_array_id + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +exprt concatenate_array_id( + const exprt &array, const mp_integer &index, + const typet &type) +{ + std::string a, identifier; + a = array.get_string(ID_identifier); + identifier=a+"["+integer2string(index)+"]"; + symbol_exprt new_expr(identifier, type); + + return new_expr; +} + +/*******************************************************************\ + Function: constant_propagator_domaint::assign_rec Inputs: @@ -33,14 +88,36 @@ void constant_propagator_domaint::assign_rec( const exprt &lhs, const exprt &rhs, const namespacet &ns) { - const typet &rhs_type = ns.follow(rhs.type()); + const typet & lhs_type = ns.follow(lhs.type()); + const typet & rhs_type = ns.follow(rhs.type()); #ifdef DEBUG std::cout << "assign: " << from_expr(ns, "", lhs) << " := " << from_type(ns, "", rhs_type) << std::endl; #endif - if(lhs.id()==ID_symbol && rhs_type.id()!=ID_array + if(lhs.id()==ID_symbol && rhs.id()==ID_if) + { + exprt cond=rhs.op0(); + assert(cond.operands().size()==2); + if(values.is_constant(cond.op0()) + && values.is_constant(cond.op1())) + { + if(cond.op0().id()==ID_index) + { + exprt index=cond.op0(); + exprt new_expr=concatenate_array_id(index.op0(), index.op1(), index.type()); + values.replace_const(new_expr); + cond.op0()=new_expr; + cond = simplify_expr(cond,ns); + } + else + assert(0); + + assign(values, to_symbol_expr(lhs), cond, ns); + } + } + else if(lhs.id()==ID_symbol && rhs_type.id()!=ID_array && rhs_type.id()!=ID_struct && rhs_type.id()!=ID_union) { @@ -49,6 +126,27 @@ void constant_propagator_domaint::assign_rec( else values.set_to_top(to_symbol_expr(lhs)); } + else if(lhs.id()==ID_symbol && lhs_type.id()==ID_array + && rhs_type.id()==ID_array) + { + exprt new_expr; + mp_integer idx=0; + forall_operands(it, rhs) + { + new_expr=concatenate_array_id(lhs, idx, it->type()); + assign(values, to_symbol_expr(new_expr), *it, ns); + idx = idx +1; + } + } + else if (lhs.id()==ID_index) + { + if (values.is_constant(lhs.op1()) + && values.is_constant(rhs)) + { + exprt new_expr=concatenate_array_id(lhs.op0(), lhs.op1(), rhs.type()); + assign(values, to_symbol_expr(new_expr), rhs, ns); + } + } #if 0 else // TODO: could make field or array element-sensitive { @@ -104,12 +202,22 @@ void constant_propagator_domaint::transform( else if(from->is_goto()) { exprt g; + if(from->get_target()==to) g = simplify_expr(from->guard, ns); else g = simplify_expr(not_exprt(from->guard), ns); - two_way_propagate_rec(g, ns); + if (g.is_false()) + values.set_to_bottom(); + else + { + //TODO: we need to support widening! + if (g.is_constant()) + values.set_to_top(); + else + two_way_propagate_rec(g, ns); + } } else if(from->is_dead()) { @@ -139,6 +247,7 @@ void constant_propagator_domaint::transform( else values.set_to_top(); } + #ifdef DEBUG std::cout << "after:\n"; output(std::cout, ai, ns); @@ -224,6 +333,30 @@ void constant_propagator_domaint::assign( /*******************************************************************\ +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(), + expr.op1(), expr.type()); + + if (replace_const.expr_map.find(to_symbol_expr(new_expr).get_identifier()) == + replace_const.expr_map.end()) + return false; + + return true; +} + +/*******************************************************************\ + Function: constant_propagator_domaint::valuest::is_constant Inputs: @@ -249,6 +382,9 @@ bool constant_propagator_domaint::valuest::is_constant(const exprt &expr) const replace_const.expr_map.end()) return false; + if (expr.id()==ID_index) + return is_array_constant(expr); + if(expr.id()==ID_address_of) return is_constant_address_of(to_address_of_expr(expr).object()); @@ -399,38 +535,25 @@ bool constant_propagator_domaint::valuest::merge(const valuest &src) it!=replace_const.expr_map.end(); ) // no it++ { - if(src.replace_const.expr_map.find(it->first) == - src.replace_const.expr_map.end()) + const replace_symbolt::expr_mapt::const_iterator + b_it=src.replace_const.expr_map.find(it->first); + + if(b_it==src.replace_const.expr_map.end()) { - // cannot use set_to_top here - replace_const.expr_map.erase(it++); + //cannot use set_to_top here + replace_const.expr_map.erase(it); changed = true; + break; } - else ++it; - } - - for(const auto &src_replace_pair : src.replace_const.expr_map) - { - replace_symbolt::expr_mapt::iterator c_it= - replace_const.expr_map.find(src_replace_pair.first); - - if(c_it!=replace_const.expr_map.end()) + else { - // values are different, set to top - if(c_it->second!=src_replace_pair.second) - { - changed=set_to_top(src_replace_pair.first); - assert(changed); - } + const exprt previous=it->second; + replace_const.expr_map[b_it->first]=b_it->second; + if (it->second != previous) changed = true; + + it++; } - // is not in "this", ignore - else { } } - -#ifdef DEBUG - std::cout << "merged: " << changed << '\n'; -#endif - return changed; } @@ -519,6 +642,34 @@ void constant_propagator_ait::replace( /*******************************************************************\ +Function: constant_propagator_ait::replace_array_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +void constant_propagator_ait::replace_array_symbol(exprt &expr) +{ + if (expr.id()==ID_index) + expr = concatenate_array_id(expr.op0(), + expr.op1(), expr.type()); + + Forall_operands(it, expr) + { + if (it->id()==ID_equal) + replace_array_symbol(it->op0()); + else if (it->id()==ID_index) + replace_array_symbol(expr.op0()); + } + +} + +/*******************************************************************\ + Function: constant_propagator_ait::replace Inputs: @@ -545,6 +696,7 @@ void constant_propagator_ait::replace( if(it->is_goto() || it->is_assume() || it->is_assert()) { + replace_array_symbol(it->guard); s_it->second.values.replace_const(it->guard); it->guard = simplify_expr(it->guard, ns); } @@ -553,6 +705,8 @@ void constant_propagator_ait::replace( exprt &rhs = to_code_assign(it->code).rhs(); s_it->second.values.replace_const(rhs); rhs = simplify_expr(rhs, ns); + if (rhs.id()==ID_constant) + rhs.add_source_location()=it->code.op0().source_location(); } else if(it->is_function_call()) { diff --git a/src/analyses/constant_propagator.h b/src/analyses/constant_propagator.h index 935b74a1421..0766b458f7d 100644 --- a/src/analyses/constant_propagator.h +++ b/src/analyses/constant_propagator.h @@ -62,6 +62,7 @@ class constant_propagator_domaint:public ai_domain_baset } bool is_constant(const exprt &expr) const; + bool is_array_constant(const exprt &expr) const; bool is_constant_address_of(const exprt &expr) const; bool set_to_top(const irep_idt &id); @@ -75,6 +76,7 @@ class constant_propagator_domaint:public ai_domain_baset replace_const.clear(); is_bottom = false; } + }; valuest values; @@ -117,6 +119,11 @@ class constant_propagator_ait:public ait } protected: + friend class constant_propagator_domaint; + + void replace_array_symbol( + exprt &expr); + void replace( goto_functionst::goto_functiont &, const namespacet &); @@ -128,6 +135,7 @@ class constant_propagator_ait:public ait void replace_types_rec( const replace_symbolt &replace_const, exprt &expr); + }; #endif // CPROVER_ANALYSES_CONSTANT_PROPAGATOR_H diff --git a/src/analyses/interval_domain.cpp b/src/analyses/interval_domain.cpp index cc10fd89b00..1faf8c52364 100644 --- a/src/analyses/interval_domain.cpp +++ b/src/analyses/interval_domain.cpp @@ -157,7 +157,9 @@ bool interval_domaint::merge( for(int_mapt::iterator it=int_map.begin(); it!=int_map.end(); ) // no it++ { - const int_mapt::const_iterator b_it=b.int_map.begin(); + //search for the variable that needs to be merged + //containers have different size and variable order + const int_mapt::const_iterator b_it=b.int_map.find(it->first); if(b_it==b.int_map.end()) { it=int_map.erase(it); From d5e8fca33048e4c79583fbf96e29b1f7597b40f0 Mon Sep 17 00:00:00 2001 From: Daniel Poetzl Date: Fri, 27 Jan 2017 15:17:08 +0000 Subject: [PATCH 090/116] camel case for json --- src/analyses/ai.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/analyses/ai.cpp b/src/analyses/ai.cpp index 3c62b79965b..2d1f4f6b986 100644 --- a/src/analyses/ai.cpp +++ b/src/analyses/ai.cpp @@ -135,9 +135,9 @@ jsont ai_baset::output_json( forall_goto_program_instructions(i_it, goto_program) { json_objectt location; - location["location_number"]= + location["locationNumber"]= json_numbert(std::to_string(i_it->location_number)); - location["source_location"]= + location["sourceLocation"]= json_stringt(i_it->source_location.as_string()); location["domain"]=find_state(i_it).output_json(*this, ns); From c16d75b5f6b030fdd48835d692e167e9775c6289 Mon Sep 17 00:00:00 2001 From: Daniel Poetzl Date: Wed, 22 Feb 2017 14:42:15 +0000 Subject: [PATCH 091/116] merge fixes --- regression/acceleration/Makefile | 4 ++-- regression/ansi-c/Makefile | 5 +++++ regression/array-refinement-with-incr/Makefile | 5 +++++ regression/array-refinement/Makefile | 5 +++++ regression/cbmc-concurrency/Makefile | 5 +++++ regression/cbmc-cover/Makefile | 5 +++++ regression/cbmc-cpp/Makefile | 5 +++++ regression/cbmc-from-CVS/Makefile | 5 +++++ regression/cbmc-incr-oneloop/Makefile | 4 ++-- regression/cbmc-incr/Makefile | 4 ++-- regression/cbmc-java/Makefile | 5 +++++ regression/cbmc-with-incr/Makefile | 4 ++-- regression/cbmc/Makefile | 5 +++++ regression/cpp-from-CVS/Makefile | 5 +++++ regression/cpp-linter/Makefile | 5 +++++ regression/cpp/Makefile | 5 +++++ regression/fault-localization/Makefile | 5 +++++ regression/goto-analyzer/Makefile | 7 +++---- regression/goto-instrument-wmm-core/Makefile | 2 +- regression/goto-instrument/Makefile | 4 ++-- regression/k-induction/Makefile | 5 +++++ regression/symex-infeasibility/Makefile | 5 +++++ regression/symex/Makefile | 5 +++++ regression/taint/Makefile | 5 +++++ regression/test-script/Makefile | 4 ++-- src/solvers/miniBDD/Makefile | 2 +- 26 files changed, 102 insertions(+), 18 deletions(-) diff --git a/regression/acceleration/Makefile b/regression/acceleration/Makefile index 396fa63f22d..805ebaec1e8 100644 --- a/regression/acceleration/Makefile +++ b/regression/acceleration/Makefile @@ -14,5 +14,5 @@ show: done; clean: - rm -f tests.log - rm -f */main.out + $(RM) tests.log + $(RM) */main.out diff --git a/regression/ansi-c/Makefile b/regression/ansi-c/Makefile index b03e120015b..87af55e3306 100644 --- a/regression/ansi-c/Makefile +++ b/regression/ansi-c/Makefile @@ -18,3 +18,8 @@ show: vim -o "$$dir/*.c" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/array-refinement-with-incr/Makefile b/regression/array-refinement-with-incr/Makefile index 579de53f6c3..67153d5df71 100644 --- a/regression/array-refinement-with-incr/Makefile +++ b/regression/array-refinement-with-incr/Makefile @@ -14,3 +14,8 @@ show: vim -o "$$dir/*.c" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/array-refinement/Makefile b/regression/array-refinement/Makefile index 41e06e86158..0fd2a56b6f6 100644 --- a/regression/array-refinement/Makefile +++ b/regression/array-refinement/Makefile @@ -14,3 +14,8 @@ show: vim -o "$$dir/*.c" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/cbmc-concurrency/Makefile b/regression/cbmc-concurrency/Makefile index f40172c17a2..bf0682a5381 100644 --- a/regression/cbmc-concurrency/Makefile +++ b/regression/cbmc-concurrency/Makefile @@ -12,3 +12,8 @@ show: vim -o "$$dir/*.c" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/cbmc-cover/Makefile b/regression/cbmc-cover/Makefile index cbdd3378bac..9a14abc905f 100644 --- a/regression/cbmc-cover/Makefile +++ b/regression/cbmc-cover/Makefile @@ -18,3 +18,8 @@ show: vim -o "$$dir/*.c" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/cbmc-cpp/Makefile b/regression/cbmc-cpp/Makefile index f40172c17a2..bf0682a5381 100644 --- a/regression/cbmc-cpp/Makefile +++ b/regression/cbmc-cpp/Makefile @@ -12,3 +12,8 @@ show: vim -o "$$dir/*.c" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/cbmc-from-CVS/Makefile b/regression/cbmc-from-CVS/Makefile index f40172c17a2..bf0682a5381 100644 --- a/regression/cbmc-from-CVS/Makefile +++ b/regression/cbmc-from-CVS/Makefile @@ -12,3 +12,8 @@ show: vim -o "$$dir/*.c" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/cbmc-incr-oneloop/Makefile b/regression/cbmc-incr-oneloop/Makefile index 4c5b7ceffd3..00c5ea25db4 100644 --- a/regression/cbmc-incr-oneloop/Makefile +++ b/regression/cbmc-incr-oneloop/Makefile @@ -14,5 +14,5 @@ show: done; clean: - @rm -f *.log - @(for dir in *; do rm -f $$dir/*.out; done;) + @$(RM) *.log + @(for dir in *; do $(RM) $$dir/*.out; done;) diff --git a/regression/cbmc-incr/Makefile b/regression/cbmc-incr/Makefile index 965ce493fc5..08b694ea9b5 100644 --- a/regression/cbmc-incr/Makefile +++ b/regression/cbmc-incr/Makefile @@ -17,5 +17,5 @@ show: done; clean: - @rm -f *.log - @(for dir in *; do rm -f $$dir/*.out; done;) + @$(RM) *.log + @(for dir in *; do $(RM) $$dir/*.out; done;) diff --git a/regression/cbmc-java/Makefile b/regression/cbmc-java/Makefile index cee83cba67a..a1b44c5a948 100644 --- a/regression/cbmc-java/Makefile +++ b/regression/cbmc-java/Makefile @@ -18,3 +18,8 @@ show: vim -o "$$dir/*.java" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/cbmc-with-incr/Makefile b/regression/cbmc-with-incr/Makefile index 4ab60f487d0..4389f3bb8ef 100644 --- a/regression/cbmc-with-incr/Makefile +++ b/regression/cbmc-with-incr/Makefile @@ -14,5 +14,5 @@ show: done; clean: - @rm -f *.log - @for dir in *; do rm -f $$dir/*.out; done; + @$(RM) *.log + @for dir in *; do $(RM) $$dir/*.out; done; diff --git a/regression/cbmc/Makefile b/regression/cbmc/Makefile index cbdd3378bac..9a14abc905f 100644 --- a/regression/cbmc/Makefile +++ b/regression/cbmc/Makefile @@ -18,3 +18,8 @@ show: vim -o "$$dir/*.c" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/cpp-from-CVS/Makefile b/regression/cpp-from-CVS/Makefile index b092e240b99..e28536a2988 100644 --- a/regression/cpp-from-CVS/Makefile +++ b/regression/cpp-from-CVS/Makefile @@ -12,3 +12,8 @@ show: vim -o "$$dir/main.c" "$$dir/main.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/cpp-linter/Makefile b/regression/cpp-linter/Makefile index b84f9ae3d18..097b463fce5 100644 --- a/regression/cpp-linter/Makefile +++ b/regression/cpp-linter/Makefile @@ -18,3 +18,8 @@ show: vim -o "$$dir/*.c" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/cpp/Makefile b/regression/cpp/Makefile index b03e120015b..87af55e3306 100644 --- a/regression/cpp/Makefile +++ b/regression/cpp/Makefile @@ -18,3 +18,8 @@ show: vim -o "$$dir/*.c" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/fault-localization/Makefile b/regression/fault-localization/Makefile index cbdd3378bac..9a14abc905f 100644 --- a/regression/fault-localization/Makefile +++ b/regression/fault-localization/Makefile @@ -18,3 +18,8 @@ show: vim -o "$$dir/*.c" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/goto-analyzer/Makefile b/regression/goto-analyzer/Makefile index c5e98e260c5..ca7e7707afe 100644 --- a/regression/goto-analyzer/Makefile +++ b/regression/goto-analyzer/Makefile @@ -20,7 +20,6 @@ show: done; clean: - find . -name *.*~ | xargs rm -f - find . -name *.out | xargs rm -f - find . -name *.goto | xargs rm -f - rm -f tests.log + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/goto-instrument-wmm-core/Makefile b/regression/goto-instrument-wmm-core/Makefile index c1f99d1da81..85c17bf622b 100644 --- a/regression/goto-instrument-wmm-core/Makefile +++ b/regression/goto-instrument-wmm-core/Makefile @@ -21,7 +21,7 @@ tests.log: ../test.pl clean: @for dir in *; do \ if [ -d "$$dir" ]; then \ - rm $$dir/*.txt $$dir/*.dot $$dir/*.gb $$dir/*.out; \ + $(RM) $$dir/*.txt $$dir/*.dot $$dir/*.gb $$dir/*.out; \ fi; \ done; diff --git a/regression/goto-instrument/Makefile b/regression/goto-instrument/Makefile index 08fe97ae88c..94605814b4a 100644 --- a/regression/goto-instrument/Makefile +++ b/regression/goto-instrument/Makefile @@ -22,10 +22,10 @@ show: clean: @for dir in *; do \ - rm -f tests.log; \ + $(RM) tests.log; \ if [ -d "$$dir" ]; then \ cd "$$dir"; \ - rm -f *.out *.gb; \ + $(RM) *.out *.gb; \ cd ..; \ fi \ done diff --git a/regression/k-induction/Makefile b/regression/k-induction/Makefile index 009b420f259..bfd7ece4734 100644 --- a/regression/k-induction/Makefile +++ b/regression/k-induction/Makefile @@ -12,3 +12,8 @@ show: vim -o "$$dir/*.c" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/symex-infeasibility/Makefile b/regression/symex-infeasibility/Makefile index d8a99eec731..120e9a347c0 100644 --- a/regression/symex-infeasibility/Makefile +++ b/regression/symex-infeasibility/Makefile @@ -12,3 +12,8 @@ show: vim -o "$$dir/*.c" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/symex/Makefile b/regression/symex/Makefile index d8a99eec731..120e9a347c0 100644 --- a/regression/symex/Makefile +++ b/regression/symex/Makefile @@ -12,3 +12,8 @@ show: vim -o "$$dir/*.c" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/taint/Makefile b/regression/taint/Makefile index 5701431a37e..40dbe9c53be 100644 --- a/regression/taint/Makefile +++ b/regression/taint/Makefile @@ -12,3 +12,8 @@ show: vim -o "$$dir/*.java" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/test-script/Makefile b/regression/test-script/Makefile index ba7db5e6250..ee6eaf02884 100644 --- a/regression/test-script/Makefile +++ b/regression/test-script/Makefile @@ -37,10 +37,10 @@ show: clean: @for dir in *; do \ - rm -f tests.log; \ + $(RM) tests.log; \ if [ -d "$$dir" ]; then \ cd "$$dir"; \ - rm -f *.out *.gb; \ + $(RM) *.out *.gb; \ cd ..; \ fi \ done diff --git a/src/solvers/miniBDD/Makefile b/src/solvers/miniBDD/Makefile index aa4d2f532df..55b6a0ed86c 100644 --- a/src/solvers/miniBDD/Makefile +++ b/src/solvers/miniBDD/Makefile @@ -16,7 +16,7 @@ test_miniBDD: miniBDD.o test_miniBDD.o g++ $(CPLUSFLAGS) miniBDD.o test_miniBDD.o -o test_miniBDD clean: - rm -f miniBDD.o test_miniBDD.o test_miniBDD + $(RM) miniBDD.o test_miniBDD.o test_miniBDD miniBDD.tgz: miniBDD.cpp miniBDD.inc miniBDD.h test_miniBDD.cpp Makefile tar cvfz miniBDD.tgz miniBDD.cpp miniBDD.inc \ From 1e0334d89450cfee6e0fe4239342d49ceb799bb4 Mon Sep 17 00:00:00 2001 From: Vojtech Forejt Date: Mon, 3 Apr 2017 18:32:13 +0100 Subject: [PATCH 092/116] fix travis merge problem --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f129daadf9a..30a59230a88 100644 --- a/.travis.yml +++ b/.travis.yml @@ -101,7 +101,7 @@ install: eval ${PRE_COMMAND} ${COMMAND} - COMMAND="make -C src clean" && eval ${PRE_COMMAND} ${COMMAND} - - COMMAND="make -C src CXX=$COMPILER CXXFLAGS=\"-Wall -O0 -ggdb3 -Werror -Wno-deprecated-register -pedantic -Wno-sign-compare -DDEBUG\" -j2" && + - COMMAND="make -C src CXX=\"$COMPILER\" CXXFLAGS=\"-Wall -O0 -ggdb3 -Werror -Wno-deprecated-register -pedantic -Wno-sign-compare -DDEBUG\" -j2" && eval ${PRE_COMMAND} ${COMMAND} script: From b4b3c7540a47657abf612ffc94805cb89aca70a7 Mon Sep 17 00:00:00 2001 From: Vojtech Forejt Date: Mon, 3 Apr 2017 21:29:41 +0100 Subject: [PATCH 093/116] Mark goto-analyzer tests as not working until the new version is merged in --- regression/goto-analyzer/constant_propagation_01/test.desc | 2 +- regression/goto-analyzer/constant_propagation_02/test.desc | 2 +- regression/goto-analyzer/constant_propagation_03/test.desc | 2 +- regression/goto-analyzer/constant_propagation_04/test.desc | 2 +- regression/goto-analyzer/constant_propagation_05/test.desc | 2 +- regression/goto-analyzer/constant_propagation_06/test.desc | 2 +- regression/goto-analyzer/constant_propagation_07/test.desc | 2 +- regression/goto-analyzer/constant_propagation_09/test.desc | 2 +- regression/goto-analyzer/constant_propagation_10/test.desc | 2 +- regression/goto-analyzer/intervals1/test.desc | 2 +- regression/goto-analyzer/intervals3/test.desc | 2 +- regression/goto-analyzer/intervals5/test.desc | 2 +- regression/goto-analyzer/intervals9/test.desc | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/regression/goto-analyzer/constant_propagation_01/test.desc b/regression/goto-analyzer/constant_propagation_01/test.desc index 7e9cac6056b..1eb849c3c7a 100644 --- a/regression/goto-analyzer/constant_propagation_01/test.desc +++ b/regression/goto-analyzer/constant_propagation_01/test.desc @@ -1,4 +1,4 @@ -CORE +FUTURE constant_propagation1.c --constants --simplify out.goto ^EXIT=0$ diff --git a/regression/goto-analyzer/constant_propagation_02/test.desc b/regression/goto-analyzer/constant_propagation_02/test.desc index 635f7dcf620..20cc5fcf86e 100644 --- a/regression/goto-analyzer/constant_propagation_02/test.desc +++ b/regression/goto-analyzer/constant_propagation_02/test.desc @@ -1,4 +1,4 @@ -CORE +FUTURE constant_propagation_02.c --constants --simplify out.goto ^EXIT=0$ diff --git a/regression/goto-analyzer/constant_propagation_03/test.desc b/regression/goto-analyzer/constant_propagation_03/test.desc index 37962658987..2225c1a666e 100644 --- a/regression/goto-analyzer/constant_propagation_03/test.desc +++ b/regression/goto-analyzer/constant_propagation_03/test.desc @@ -1,4 +1,4 @@ -CORE +FUTURE constant_propagation_03.c --constants --simplify out.goto ^EXIT=0$ diff --git a/regression/goto-analyzer/constant_propagation_04/test.desc b/regression/goto-analyzer/constant_propagation_04/test.desc index 2b23ac224f7..2510b3f8a5e 100644 --- a/regression/goto-analyzer/constant_propagation_04/test.desc +++ b/regression/goto-analyzer/constant_propagation_04/test.desc @@ -1,4 +1,4 @@ -CORE +FUTURE constant_propagation_04.c --constants --simplify out.goto ^EXIT=0$ diff --git a/regression/goto-analyzer/constant_propagation_05/test.desc b/regression/goto-analyzer/constant_propagation_05/test.desc index 84712b085da..ddb22cc3616 100644 --- a/regression/goto-analyzer/constant_propagation_05/test.desc +++ b/regression/goto-analyzer/constant_propagation_05/test.desc @@ -1,4 +1,4 @@ -CORE +FUTURE constant_propagation_05.c --constants --verify ^EXIT=0$ diff --git a/regression/goto-analyzer/constant_propagation_06/test.desc b/regression/goto-analyzer/constant_propagation_06/test.desc index db151228d5c..2c2596fe092 100644 --- a/regression/goto-analyzer/constant_propagation_06/test.desc +++ b/regression/goto-analyzer/constant_propagation_06/test.desc @@ -1,4 +1,4 @@ -CORE +FUTURE constant_propagation_06.c --intervals --verify ^EXIT=0$ diff --git a/regression/goto-analyzer/constant_propagation_07/test.desc b/regression/goto-analyzer/constant_propagation_07/test.desc index 7494eafcd54..615893d4f78 100644 --- a/regression/goto-analyzer/constant_propagation_07/test.desc +++ b/regression/goto-analyzer/constant_propagation_07/test.desc @@ -1,4 +1,4 @@ -CORE +FUTURE constant_propagation_07.c --constants --verify ^EXIT=0$ diff --git a/regression/goto-analyzer/constant_propagation_09/test.desc b/regression/goto-analyzer/constant_propagation_09/test.desc index 8cb0ec6a003..6a1b75f0c1b 100644 --- a/regression/goto-analyzer/constant_propagation_09/test.desc +++ b/regression/goto-analyzer/constant_propagation_09/test.desc @@ -1,4 +1,4 @@ -CORE +FUTURE constant_propagation_09.c --intervals --verify ^EXIT=0$ diff --git a/regression/goto-analyzer/constant_propagation_10/test.desc b/regression/goto-analyzer/constant_propagation_10/test.desc index 7b78521a13d..52d98cb611b 100644 --- a/regression/goto-analyzer/constant_propagation_10/test.desc +++ b/regression/goto-analyzer/constant_propagation_10/test.desc @@ -1,4 +1,4 @@ -CORE +FUTURE constant_propagation_10.c --constants --simplify out.goto ^EXIT=0$ diff --git a/regression/goto-analyzer/intervals1/test.desc b/regression/goto-analyzer/intervals1/test.desc index 7aca700f7a5..5a9802eeb20 100644 --- a/regression/goto-analyzer/intervals1/test.desc +++ b/regression/goto-analyzer/intervals1/test.desc @@ -1,4 +1,4 @@ -CORE +KNOWNBUG intervals1.c --intervals --verify ^EXIT=0$ diff --git a/regression/goto-analyzer/intervals3/test.desc b/regression/goto-analyzer/intervals3/test.desc index dceec17bc81..69ded2182ee 100644 --- a/regression/goto-analyzer/intervals3/test.desc +++ b/regression/goto-analyzer/intervals3/test.desc @@ -1,4 +1,4 @@ -CORE +KNOWNBUG intervals3.c --intervals --verify ^EXIT=0$ diff --git a/regression/goto-analyzer/intervals5/test.desc b/regression/goto-analyzer/intervals5/test.desc index 0213e7b3297..eb64fbc13d1 100644 --- a/regression/goto-analyzer/intervals5/test.desc +++ b/regression/goto-analyzer/intervals5/test.desc @@ -1,4 +1,4 @@ -CORE +KNOWNBUG intervals5.c --intervals --verify ^EXIT=0$ diff --git a/regression/goto-analyzer/intervals9/test.desc b/regression/goto-analyzer/intervals9/test.desc index 33f92abcdb2..37c33b97288 100644 --- a/regression/goto-analyzer/intervals9/test.desc +++ b/regression/goto-analyzer/intervals9/test.desc @@ -1,4 +1,4 @@ -CORE +KNOWNBUG intervals9.c --intervals --verify ^EXIT=0$ From ea1f4759768a937685770117dbe8ee41c2ae5843 Mon Sep 17 00:00:00 2001 From: Vojtech Forejt Date: Mon, 3 Apr 2017 22:24:49 +0100 Subject: [PATCH 094/116] Split Travis debug build to separate jobs, and run it only on Linux. This is used as a trade-off between comprehensive CI run, and time efficiency --- .travis.yml | 54 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 30a59230a88..f4eff522ede 100644 --- a/.travis.yml +++ b/.travis.yml @@ -58,6 +58,27 @@ matrix: # env: COMPILER=g++-5 SAN_FLAGS="-fsanitize=undefined -fno-sanitize-recover -fno-omit-frame-pointer" env: COMPILER="g++-5" + # Ubuntu Linux with glibc using g++-5, debug mode + - os: linux + sudo: false + compiler: gcc + cache: ccache + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - libwww-perl + - g++-5 + - libubsan0 + before_install: + - mkdir bin ; ln -s /usr/bin/gcc-5 bin/gcc + # env: COMPILER=g++-5 SAN_FLAGS="-fsanitize=undefined -fno-sanitize-recover -fno-omit-frame-pointer" + env: + - COMPILER="g++-5" + - EXTRA_CXXFLAGS="-DDEBUG" + script: echo "Not running any tests for a debug build." + # Ubuntu Linux with glibc using clang++-3.7 - os: linux sudo: false @@ -81,6 +102,31 @@ matrix: - COMPILER="ccache clang++-3.7 -Qunused-arguments -fcolor-diagnostics" - CCACHE_CPP2=yes + # Ubuntu Linux with glibc using clang++-3.7, debug mode + - os: linux + sudo: false + compiler: clang + cache: ccache + addons: + apt: + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.7 + packages: + - libwww-perl + - clang-3.7 + - libstdc++-5-dev + - libubsan0 + before_install: + - mkdir bin ; ln -s /usr/bin/clang-3.7 bin/gcc + - export CCACHE_CPP2=yes + # env: COMPILER=clang++-3.7 SAN_FLAGS="-fsanitize=undefined -fno-sanitize-recover=undefined,integer -fno-omit-frame-pointer" + env: + - COMPILER="ccache clang++-3.7 -Qunused-arguments -fcolor-diagnostics" + - CCACHE_CPP2=yes + - EXTRA_CXXFLAGS="-DDEBUG" + script: echo "Not running any tests for a debug build." + - env: NAME="CPP-LINT" install: script: scripts/travis_lint.sh @@ -95,13 +141,9 @@ matrix: install: - COMMAND="make -C src minisat2-download" && eval ${PRE_COMMAND} ${COMMAND} - - COMMAND="make -C src CXX=\"$COMPILER\" CXXFLAGS=\"-Wall -O2 -g -Werror -Wno-deprecated-register -pedantic -Wno-sign-compare\" -j2" && - eval ${PRE_COMMAND} ${COMMAND} - - COMMAND="make -C src CXX=\"$COMPILER\" CXXFLAGS=$FLAGS -j2 cegis.dir clobber.dir memory-models.dir musketeer.dir" && - eval ${PRE_COMMAND} ${COMMAND} - - COMMAND="make -C src clean" && + - COMMAND="make -C src CXX=\"$COMPILER\" CXXFLAGS=\"-Wall -O2 -g -Werror -Wno-deprecated-register -pedantic -Wno-sign-compare $EXTRA_CXXFLAGS\" -j2" && eval ${PRE_COMMAND} ${COMMAND} - - COMMAND="make -C src CXX=\"$COMPILER\" CXXFLAGS=\"-Wall -O0 -ggdb3 -Werror -Wno-deprecated-register -pedantic -Wno-sign-compare -DDEBUG\" -j2" && + - COMMAND="make -C src CXX=\"$COMPILER\" CXXFLAGS=\"$FLAGS $EXTRA_CXXFLAGS\" -j2 cegis.dir clobber.dir memory-models.dir musketeer.dir" && eval ${PRE_COMMAND} ${COMMAND} script: From 07e072b573aead6bd9477822aff325536b1f1163 Mon Sep 17 00:00:00 2001 From: Vlastimil Zeman Date: Thu, 30 Mar 2017 14:47:51 +0100 Subject: [PATCH 095/116] Use versioned container of Alpine linux. After standardisation and release of diffblue/cbmc-builder, we should use versioned number of container so change to new version will be under control (currently we always fetch latest). --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f4eff522ede..54078b93f76 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,9 +11,9 @@ matrix: services: - docker before_install: - - docker pull diffblue/cbmc-builder:alpine + - docker pull diffblue/cbmc-builder:alpine-0.0.1 env: - - PRE_COMMAND="docker run -v ${TRAVIS_BUILD_DIR}:/cbmc -v ${HOME}/.ccache:/root/.ccache diffblue/cbmc-builder:alpine" + - PRE_COMMAND="docker run -v ${TRAVIS_BUILD_DIR}:/cbmc -v ${HOME}/.ccache:/root/.ccache diffblue/cbmc-builder:alpine-0.0.1" - COMPILER="ccache g++" # OS X using g++ From 7b6b5279db0b90825dd2fac073296fc96c711c19 Mon Sep 17 00:00:00 2001 From: Vojtech Forejt Date: Tue, 4 Apr 2017 14:29:20 +0100 Subject: [PATCH 096/116] Fix failing build on master. Fixes a simple problem introduced by incompatible changes in PRs #680 and #721 --- src/cbmc/symex_bmc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cbmc/symex_bmc.cpp b/src/cbmc/symex_bmc.cpp index 6522f95d66b..5ae65275ef6 100644 --- a/src/cbmc/symex_bmc.cpp +++ b/src/cbmc/symex_bmc.cpp @@ -88,7 +88,7 @@ void symex_bmct::symex_step( !state.guard.is_false() && // avoid an invalid iterator in state.source.pc (!cur_pc->is_end_function() || - cur_pc->function!=ID__start) && + cur_pc->function!=goto_functions.entry_point()) && // ignore transition to next instruction when goto points elsewhere (!cur_pc->is_goto() || cur_pc->get_target()==state.source.pc || From 65cad8fe7e395b44320ee0e4a52a46a8b8a6bfc0 Mon Sep 17 00:00:00 2001 From: Vojtech Forejt Date: Tue, 4 Apr 2017 14:38:55 +0100 Subject: [PATCH 097/116] Fix failing test's regexp. This was caused by two PRs being merged concurrently, #519 which introduced the test and #358 which changed the output when running the test. --- .../test.desc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/test.desc index b6e93d5b677..6df2697851a 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/test.desc +++ b/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/test.desc @@ -3,9 +3,9 @@ main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF fp == \(void \(\*\)\(void\)\)f2 THEN GOTO [0-9]$ -^\s*IF fp == \(void \(\*\)\(void\)\)f3 THEN GOTO [0-9]$ -^\s*IF fp == \(void \(\*\)\(void\)\)f4 THEN GOTO [0-9]$ +^\s*IF fp == \(const void_fp\)f2 THEN GOTO [0-9]$ +^\s*IF fp == \(const void_fp\)f3 THEN GOTO [0-9]$ +^\s*IF fp == \(const void_fp\)f4 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring From b917b5e798321aec1c3ed3aa1e01f6a1cb9482f5 Mon Sep 17 00:00:00 2001 From: reuk Date: Sun, 12 Mar 2017 13:21:43 +0000 Subject: [PATCH 098/116] Replace irep_ids_convert program with preprocessor --- .gitignore | 2 - src/util/Makefile | 23 +- src/util/irep_ids.cpp | 8 +- src/util/irep_ids.def | 807 ++++++++++++++++++++++++++++++++++ src/util/irep_ids.h | 42 ++ src/util/irep_ids.txt | 804 --------------------------------- src/util/irep_ids_convert.cpp | 96 ---- 7 files changed, 856 insertions(+), 926 deletions(-) create mode 100644 src/util/irep_ids.def create mode 100644 src/util/irep_ids.h delete mode 100644 src/util/irep_ids.txt delete mode 100644 src/util/irep_ids_convert.cpp diff --git a/.gitignore b/.gitignore index cf449ea4f76..7ba5ba011b4 100644 --- a/.gitignore +++ b/.gitignore @@ -31,8 +31,6 @@ src/ansi-c/gcc_builtin_headers_ia32-2.inc src/ansi-c/gcc_builtin_headers_ia32.inc src/ansi-c/gcc_builtin_headers_mips.inc src/ansi-c/gcc_builtin_headers_power.inc -src/util/irep_ids.h -src/util/irep_ids.inc # regression/test files *.out diff --git a/src/util/Makefile b/src/util/Makefile index 0cab8cd8a04..84aa55afdd4 100644 --- a/src/util/Makefile +++ b/src/util/Makefile @@ -30,30 +30,9 @@ INCLUDES= -I .. include ../config.inc include ../common -CLEANFILES = util$(LIBEXT) \ - irep_ids.h irep_ids.inc \ - irep_ids_convert$(EXEEXT) irep_ids_convert$(OBJEXT) irep_ids_convert.d +CLEANFILES = util$(LIBEXT) all: util$(LIBEXT) -############################################################################### - -irep_ids.h: irep_ids.txt irep_ids_convert$(EXEEXT) - ./irep_ids_convert$(EXEEXT) header < $< > $@ - -irep_ids.inc: irep_ids.txt irep_ids_convert$(EXEEXT) - ./irep_ids_convert$(EXEEXT) table < $< > $@ - -irep_ids.cpp: irep_ids.inc irep_ids.h - -irep_ids_convert$(EXEEXT): irep_ids_convert.cpp - $(LINKNATIVE) - -generated_files: irep_ids.h irep_ids.inc - -# Most of the others will need irep_ids.h, -# which we first need to generate. -$(OBJ): irep_ids.h - util$(LIBEXT): $(OBJ) $(LINKLIB) diff --git a/src/util/irep_ids.cpp b/src/util/irep_ids.cpp index 154683d3552..34b56573961 100644 --- a/src/util/irep_ids.cpp +++ b/src/util/irep_ids.cpp @@ -13,8 +13,12 @@ Author: Daniel Kroening, kroening@kroening.com const char *irep_ids_table[]= { - #include "irep_ids.inc" - NULL +#define IREP_ID_ONE(id) #id, +#define IREP_ID_TWO(id, str) #str, + +#include "irep_ids.def" + + NULL, }; /*******************************************************************\ diff --git a/src/util/irep_ids.def b/src/util/irep_ids.def new file mode 100644 index 00000000000..11baf80f474 --- /dev/null +++ b/src/util/irep_ids.def @@ -0,0 +1,807 @@ +IREP_ID_ONE(let) +IREP_ID_ONE(nil) +IREP_ID_ONE(type) +IREP_ID_ONE(operands) +IREP_ID_ONE(bool) +IREP_ID_ONE(c_bool) +IREP_ID_ONE(proper_bool) +IREP_ID_ONE(signedbv) +IREP_ID_ONE(unsignedbv) +IREP_ID_ONE(verilog_signedbv) +IREP_ID_ONE(verilog_unsignedbv) +IREP_ID_ONE(floatbv) +IREP_ID_ONE(fixedbv) +IREP_ID_ONE(x86_extended) +IREP_ID_TWO(C_source_location, #source_location) +IREP_ID_TWO(C_end_location, #end_location) +IREP_ID_TWO(C_is_padding, #is_padding) +IREP_ID_ONE(file) +IREP_ID_ONE(line) +IREP_ID_ONE(column) +IREP_ID_ONE(comment) +IREP_ID_ONE(property) +IREP_ID_ONE(property_class) +IREP_ID_ONE(property_id) +IREP_ID_ONE(function) +IREP_ID_ONE(code) +IREP_ID_ONE(typecast) +IREP_ID_ONE(static_cast) +IREP_ID_ONE(dynamic_cast) +IREP_ID_ONE(const_cast) +IREP_ID_ONE(reinterpret_cast) +IREP_ID_ONE(index) +IREP_ID_ONE(index_range) +IREP_ID_ONE(ptrmember) +IREP_ID_ONE(member) +IREP_ID_ONE(member_name) +IREP_ID_TWO(C_member_name, #member_name) +IREP_ID_TWO(equal, =) +IREP_ID_TWO(implies, =>) +IREP_ID_TWO(iff, <=>) +IREP_ID_ONE(and) +IREP_ID_ONE(nand) +IREP_ID_ONE(or) +IREP_ID_ONE(nor) +IREP_ID_ONE(xor) +IREP_ID_ONE(xnor) +IREP_ID_ONE(not) +IREP_ID_ONE(bitand) +IREP_ID_ONE(bitor) +IREP_ID_ONE(bitnot) +IREP_ID_ONE(bitxor) +IREP_ID_ONE(bitnand) +IREP_ID_ONE(bitnor) +IREP_ID_ONE(bitxnor) +IREP_ID_ONE(notequal) +IREP_ID_ONE(if) +IREP_ID_ONE(symbol) +IREP_ID_ONE(next_symbol) +IREP_ID_ONE(nondet_symbol) +IREP_ID_ONE(predicate) +IREP_ID_ONE(predicate_symbol) +IREP_ID_ONE(predicate_next_symbol) +IREP_ID_ONE(nondet_bool) +IREP_ID_ONE(empty) +IREP_ID_ONE(side_effect) +IREP_ID_ONE(statement) +IREP_ID_ONE(statement_expression) +IREP_ID_ONE(value) +IREP_ID_ONE(constant) +IREP_ID_ONE(block) +IREP_ID_ONE(decl) +IREP_ID_ONE(dead) +IREP_ID_ONE(assign) +IREP_ID_ONE(assign_div) +IREP_ID_TWO(assign_mult, assign*) +IREP_ID_TWO(assign_plus, assign+) +IREP_ID_TWO(assign_minus, assign-) +IREP_ID_ONE(assign_mod) +IREP_ID_ONE(assign_shl) +IREP_ID_ONE(assign_shr) +IREP_ID_ONE(assign_ashr) +IREP_ID_ONE(assign_lshr) +IREP_ID_ONE(assign_bitand) +IREP_ID_ONE(assign_bitxor) +IREP_ID_ONE(assign_bitor) +IREP_ID_ONE(assume) +IREP_ID_ONE(assert) +IREP_ID_ONE(assertion) +IREP_ID_ONE(goto) +IREP_ID_ONE(gcc_computed_goto) +IREP_ID_ONE(ifthenelse) +IREP_ID_ONE(label) +IREP_ID_ONE(break) +IREP_ID_ONE(continue) +IREP_ID_ONE(function_call) +IREP_ID_ONE(return) +IREP_ID_ONE(skip) +IREP_ID_ONE(arguments) +IREP_ID_ONE(array) +IREP_ID_ONE(size) +IREP_ID_ONE(pointer) +IREP_ID_ONE(block_pointer) +IREP_ID_ONE(switch) +IREP_ID_ONE(switch_case) +IREP_ID_ONE(gcc_switch_case_range) +IREP_ID_ONE(for) +IREP_ID_ONE(while) +IREP_ID_ONE(dowhile) +IREP_ID_ONE(int) +IREP_ID_ONE(integer) +IREP_ID_ONE(natural) +IREP_ID_ONE(real) +IREP_ID_ONE(rational) +IREP_ID_ONE(complex) +IREP_ID_ONE(signed) +IREP_ID_ONE(unsigned) +IREP_ID_ONE(asm) +IREP_ID_ONE(gcc_asm_input) +IREP_ID_ONE(gcc_asm_output) +IREP_ID_ONE(gcc_asm_clobbered_register) +IREP_ID_ONE(incomplete_array) +IREP_ID_ONE(incomplete_struct) +IREP_ID_ONE(incomplete_union) +IREP_ID_ONE(incomplete_class) +IREP_ID_ONE(incomplete_c_enum) +IREP_ID_TWO(C_incomplete, #incomplete) +IREP_ID_ONE(identifier) +IREP_ID_ONE(name) +IREP_ID_ONE(cpp_name) +IREP_ID_ONE(component_cpp_name) +IREP_ID_TWO(C_id_class, #id_class) +IREP_ID_ONE(declaration) +IREP_ID_ONE(declaration_list) +IREP_ID_ONE(declarator) +IREP_ID_ONE(struct) +IREP_ID_ONE(c_bit_field) +IREP_ID_ONE(union) +IREP_ID_ONE(class) +IREP_ID_ONE(merged_type) +IREP_ID_ONE(range) +IREP_ID_ONE(from) +IREP_ID_ONE(to) +IREP_ID_ONE(module) +IREP_ID_ONE(module_instance) +IREP_ID_ONE(macromodule) +IREP_ID_ONE(primitive_module_instance) +IREP_ID_ONE(module_items) +IREP_ID_ONE(module_source) +IREP_ID_ONE(parameter_decl) +IREP_ID_ONE(local_parameter_decl) +IREP_ID_ONE(parameter) +IREP_ID_ONE(component_name) +IREP_ID_ONE(component_number) +IREP_ID_ONE(tag) +IREP_ID_ONE(default) +IREP_ID_TWO(C_default_value, #default_value) +IREP_ID_ONE(base_name) +IREP_ID_TWO(C_base_name, #base_name) +IREP_ID_ONE(string) +IREP_ID_TWO(C_string_constant, #string_constant) +IREP_ID_ONE(string_constant) +IREP_ID_ONE(width) +IREP_ID_ONE(components) +IREP_ID_ONE(bv) +IREP_ID_ONE(f) +IREP_ID_ONE(ports) +IREP_ID_ONE(port) +IREP_ID_ONE(offset) +IREP_ID_ONE(with) +IREP_ID_ONE(trans) +IREP_ID_ONE(throw) +IREP_ID_ONE(catch) +IREP_ID_ONE(try_catch) +IREP_ID_ONE(noexcept) +IREP_ID_ONE(CPROVER_throw) +IREP_ID_ONE(CPROVER_try_catch) +IREP_ID_ONE(CPROVER_try_finally) +IREP_ID_ONE(protection) +IREP_ID_ONE(private) +IREP_ID_ONE(public) +IREP_ID_ONE(protected) +IREP_ID_ONE(virtual) +IREP_ID_ONE(volatile) +IREP_ID_ONE(const) +IREP_ID_ONE(constexpr) +IREP_ID_ONE(inline) +IREP_ID_ONE(forall) +IREP_ID_ONE(exists) +IREP_ID_ONE(forever) +IREP_ID_ONE(repeat) +IREP_ID_ONE(extractbit) +IREP_ID_ONE(extractbits) +IREP_ID_ONE(reference) +IREP_ID_TWO(C_reference, #reference) +IREP_ID_TWO(C_rvalue_reference, #rvalue_reference) +IREP_ID_ONE(true) +IREP_ID_ONE(false) +IREP_ID_ONE(address_of) +IREP_ID_ONE(dereference) +IREP_ID_TWO(C_lvalue, #lvalue) +IREP_ID_TWO(C_base, #base) +IREP_ID_ONE(destination) +IREP_ID_ONE(main) +IREP_ID_ONE(expression) +IREP_ID_ONE(free) +IREP_ID_ONE(malloc) +IREP_ID_ONE(cpp_new) +IREP_ID_ONE(cpp_delete) +IREP_ID_TWO(cpp_new_array, cpp_new[]) +IREP_ID_TWO(cpp_delete_array, cpp_delete[]) +IREP_ID_ONE(java_new) +IREP_ID_ONE(java_new_array) +IREP_ID_ONE(java_string_literal) +IREP_ID_ONE(printf) +IREP_ID_ONE(input) +IREP_ID_ONE(output) +IREP_ID_ONE(output_register) +IREP_ID_ONE(inout) +IREP_ID_ONE(nondet) +IREP_ID_ONE(NULL) +IREP_ID_ONE(null) +IREP_ID_ONE(nullptr) +IREP_ID_ONE(c_enum) +IREP_ID_ONE(enumeration) +IREP_ID_ONE(elements) +IREP_ID_ONE(unknown) +IREP_ID_ONE(uninitialized) +IREP_ID_ONE(invalid) +IREP_ID_TWO(C_invalid_object, #invalid_object) +IREP_ID_ONE(pointer_offset) +IREP_ID_ONE(pointer_object) +IREP_ID_TWO(invalid_pointer, invalid-pointer) +IREP_ID_ONE(ieee_float_equal) +IREP_ID_ONE(ieee_float_notequal) +IREP_ID_ONE(isnan) +IREP_ID_ONE(lambda) +IREP_ID_ONE(array_of) +IREP_ID_ONE(array_equal) +IREP_ID_ONE(array_set) +IREP_ID_ONE(array_copy) +IREP_ID_ONE(mod) +IREP_ID_ONE(rem) +IREP_ID_ONE(shr) +IREP_ID_ONE(ashr) +IREP_ID_ONE(lshr) +IREP_ID_ONE(shl) +IREP_ID_ONE(rol) +IREP_ID_ONE(ror) +IREP_ID_ONE(comma) +IREP_ID_ONE(concatenation) +IREP_ID_ONE(infinity) +IREP_ID_ONE(return_type) +IREP_ID_ONE(typedef) +IREP_ID_TWO(C_typedef, #typedef) +IREP_ID_ONE(extern) +IREP_ID_ONE(static) +IREP_ID_ONE(auto) +IREP_ID_ONE(register) +IREP_ID_ONE(thread_local) +IREP_ID_ONE(thread) +IREP_ID_TWO(C_thread_local, #thread_local) +IREP_ID_TWO(C_static_lifetime, #static_lifetime) +IREP_ID_ONE(mutable) +IREP_ID_ONE(void) +IREP_ID_ONE(int8) +IREP_ID_ONE(int16) +IREP_ID_ONE(int32) +IREP_ID_ONE(int64) +IREP_ID_ONE(ptr32) +IREP_ID_ONE(ptr64) +IREP_ID_ONE(char) +IREP_ID_ONE(short) +IREP_ID_ONE(long) +IREP_ID_ONE(longlong) +IREP_ID_ONE(float) +IREP_ID_ONE(double) +IREP_ID_ONE(byte) +IREP_ID_ONE(boolean) +IREP_ID_ONE(long_double) +IREP_ID_ONE(signed_char) +IREP_ID_ONE(unsigned_char) +IREP_ID_ONE(signed_int) +IREP_ID_ONE(unsigned_int) +IREP_ID_ONE(signed_long_int) +IREP_ID_ONE(unsigned_long_int) +IREP_ID_ONE(signed_short_int) +IREP_ID_ONE(unsigned_short_int) +IREP_ID_ONE(signed_long_long_int) +IREP_ID_ONE(unsigned_long_long_int) +IREP_ID_ONE(signed_int128) +IREP_ID_ONE(unsigned_int128) +IREP_ID_ONE(case) +IREP_ID_ONE(casex) +IREP_ID_ONE(casez) +IREP_ID_ONE(case_item) +IREP_ID_TWO(C_inlined, #inlined) +IREP_ID_TWO(C_hide, #hide) +IREP_ID_ONE(hide) +IREP_ID_ONE(abs) +IREP_ID_ONE(sign) +IREP_ID_ONE(access) +IREP_ID_TWO(C_access, #access) +IREP_ID_ONE(postincrement) +IREP_ID_ONE(postdecrement) +IREP_ID_ONE(preincrement) +IREP_ID_ONE(predecrement) +IREP_ID_ONE(integer_bits) +IREP_ID_ONE(KnR) +IREP_ID_TWO(C_KnR, #KnR) +IREP_ID_ONE(constraint_select_one) +IREP_ID_ONE(cond) +IREP_ID_ONE(bv_literals) +IREP_ID_ONE(isfinite) +IREP_ID_ONE(isinf) +IREP_ID_ONE(isnormal) +IREP_ID_ONE(AG) +IREP_ID_ONE(AF) +IREP_ID_ONE(AX) +IREP_ID_ONE(EG) +IREP_ID_ONE(EF) +IREP_ID_ONE(EX) +IREP_ID_ONE(U) +IREP_ID_ONE(R) +IREP_ID_ONE(A) +IREP_ID_ONE(F) +IREP_ID_ONE(E) +IREP_ID_ONE(G) +IREP_ID_ONE(X) +IREP_ID_ONE(continuous_assign) +IREP_ID_ONE(blocking_assign) +IREP_ID_ONE(non_blocking_assign) +IREP_ID_ONE(alignof) +IREP_ID_ONE(gcc_builtin_va_arg) +IREP_ID_ONE(gcc_builtin_types_compatible_p) +IREP_ID_ONE(gcc_builtin_va_arg_next) +IREP_ID_ONE(gcc_builtin_va_list) +IREP_ID_ONE(gcc_float80) +IREP_ID_ONE(gcc_float128) +IREP_ID_ONE(gcc_int128) +IREP_ID_ONE(gcc_decimal32) +IREP_ID_ONE(gcc_decimal64) +IREP_ID_ONE(gcc_decimal128) +IREP_ID_ONE(builtin_offsetof) +IREP_ID_ONE(0) +IREP_ID_ONE(1) +IREP_ID_ONE(8) +IREP_ID_ONE(16) +IREP_ID_ONE(32) +IREP_ID_ONE(64) +IREP_ID_ONE(128) +IREP_ID_ONE(sizeof) +IREP_ID_ONE(type_arg) +IREP_ID_ONE(expr_arg) +IREP_ID_ONE(expression_list) +IREP_ID_ONE(initializer_list) +IREP_ID_ONE(gcc_conditional_expression) +IREP_ID_ONE(gcc_local_label) +IREP_ID_ONE(gcc) +IREP_ID_ONE(msc) +IREP_ID_ONE(typeof) +IREP_ID_ONE(ellipsis) +IREP_ID_ONE(flavor) +IREP_ID_TWO(ge, >=) +IREP_ID_TWO(le, <=) +IREP_ID_TWO(gt, >) +IREP_ID_TWO(lt, <) +IREP_ID_TWO(plus, +) +IREP_ID_TWO(minus, -) +IREP_ID_TWO(unary_minus, unary-) +IREP_ID_TWO(unary_plus, unary+) +IREP_ID_TWO(mult, *) +IREP_ID_TWO(div, /) +IREP_ID_TWO(power, **) +IREP_ID_ONE(factorial_power) +IREP_ID_ONE(component) +IREP_ID_ONE(pretty_name) +IREP_ID_TWO(C_class, #class) +IREP_ID_TWO(C_interface, #interface) +IREP_ID_ONE(interface) +IREP_ID_ONE(targets) +IREP_ID_ONE(location) +IREP_ID_ONE(labels) +IREP_ID_ONE(event) +IREP_ID_ONE(guard) +IREP_ID_ONE(designated_initializer) +IREP_ID_ONE(designator) +IREP_ID_ONE(member_designator) +IREP_ID_ONE(index_designator) +IREP_ID_ONE(offset_designator) +IREP_ID_TWO(C_constant, #constant) +IREP_ID_TWO(C_volatile, #volatile) +IREP_ID_TWO(C_restricted, #restricted) +IREP_ID_TWO(C_identifier, #identifier) +IREP_ID_TWO(C_implicit, #implicit) +IREP_ID_TWO(C_ptr32, #ptr32) +IREP_ID_TWO(C_ptr64, #ptr64) +IREP_ID_TWO(C_atomic, #atomic) +IREP_ID_ONE(restrict) +IREP_ID_ONE(byte_extract_big_endian) +IREP_ID_ONE(byte_extract_little_endian) +IREP_ID_ONE(byte_update_big_endian) +IREP_ID_ONE(byte_update_little_endian) +IREP_ID_ONE(replication) +IREP_ID_ONE(dummy) +IREP_ID_ONE(init) +IREP_ID_ONE(cprover_atomic) +IREP_ID_ONE(atomic) +IREP_ID_ONE(atomic_type_specifier) +IREP_ID_ONE(atomic_begin) +IREP_ID_ONE(atomic_end) +IREP_ID_ONE(start_thread) +IREP_ID_ONE(end_thread) +IREP_ID_ONE(specc_notify) +IREP_ID_ONE(specc_par) +IREP_ID_ONE(specc_wait) +IREP_ID_ONE(specc_event) +IREP_ID_ONE(bp_enforce) +IREP_ID_ONE(bp_abortif) +IREP_ID_ONE(bp_constrain) +IREP_ID_ONE(bp_schoose) +IREP_ID_ONE(bp_dead) +IREP_ID_ONE(instance) +IREP_ID_ONE(cover) +IREP_ID_ONE(coverage_criterion) +IREP_ID_ONE(initializer) +IREP_ID_ONE(anonymous) +IREP_ID_TWO(C_is_anonymous, #is_anonymous) +IREP_ID_ONE(is_macro) +IREP_ID_ONE(is_enum_constant) +IREP_ID_ONE(is_inline) +IREP_ID_ONE(is_extern) +IREP_ID_ONE(is_global) +IREP_ID_ONE(is_thread_local) +IREP_ID_ONE(is_parameter) +IREP_ID_ONE(is_member) +IREP_ID_ONE(is_type) +IREP_ID_ONE(is_register) +IREP_ID_ONE(is_typedef) +IREP_ID_ONE(is_static) +IREP_ID_ONE(is_template) +IREP_ID_ONE(is_static_assert) +IREP_ID_ONE(is_virtual) +IREP_ID_TWO(C_is_virtual, #is_virtual) +IREP_ID_ONE(literal) +IREP_ID_ONE(member_initializers) +IREP_ID_ONE(member_initializer) +IREP_ID_ONE(method_qualifier) +IREP_ID_ONE(methods) +IREP_ID_ONE(constructor) +IREP_ID_ONE(destructor) +IREP_ID_ONE(bases) +IREP_ID_ONE(base) +IREP_ID_ONE(from_base) +IREP_ID_ONE(operator) +IREP_ID_ONE(template) +IREP_ID_ONE(template_class_instance) +IREP_ID_ONE(template_function_instance) +IREP_ID_ONE(template_type) +IREP_ID_ONE(template_args) +IREP_ID_ONE(template_parameter) +IREP_ID_ONE(template_parameters) +IREP_ID_TWO(C_template, #template) +IREP_ID_TWO(C_template_arguments, #template_arguments) +IREP_ID_ONE(typename) +IREP_ID_ONE(C) +IREP_ID_ONE(cpp) +IREP_ID_ONE(java) +IREP_ID_ONE(SpecC) +IREP_ID_ONE(SystemC) +IREP_ID_ONE(decl_block) +IREP_ID_ONE(decl_type) +IREP_ID_ONE(genvar) +IREP_ID_ONE(realtime) +IREP_ID_ONE(parameters) +IREP_ID_ONE(parameter_assignments) +IREP_ID_ONE(named_parameter_assignment) +IREP_ID_ONE(specify) +IREP_ID_ONE(pullup) +IREP_ID_ONE(pulldown) +IREP_ID_ONE(automatic) +IREP_ID_ONE(rcmos) +IREP_ID_ONE(cmos) +IREP_ID_ONE(nmos) +IREP_ID_ONE(pmos) +IREP_ID_ONE(rnmos) +IREP_ID_ONE(rpmos) +IREP_ID_ONE(wchar_t) +IREP_ID_ONE(char16_t) +IREP_ID_ONE(char32_t) +IREP_ID_ONE(size_t) +IREP_ID_ONE(ssize_t) +IREP_ID_ONE(inst) +IREP_ID_ONE(inst_builtin) +IREP_ID_ONE(always) +IREP_ID_ONE(initial) +IREP_ID_ONE(mode) +IREP_ID_ONE(this) +IREP_ID_TWO(C_this, #this) +IREP_ID_ONE(reduction_and) +IREP_ID_ONE(reduction_or) +IREP_ID_ONE(reduction_nand) +IREP_ID_ONE(reduction_nor) +IREP_ID_ONE(reduction_xor) +IREP_ID_ONE(reduction_xnor) +IREP_ID_TWO(C_zero_initializer, #zero_initializer) +IREP_ID_ONE(body) +IREP_ID_ONE(entity) +IREP_ID_ONE(temporary_object) +IREP_ID_TWO(overflow_plus, overflow-+) +IREP_ID_TWO(overflow_minus, overflow--) +IREP_ID_TWO(overflow_mult, overflow-*) +IREP_ID_TWO(overflow_unary_minus, overflow-unary-) +IREP_ID_ONE(object_descriptor) +IREP_ID_ONE(dynamic_object) +IREP_ID_ONE(object_size) +IREP_ID_ONE(good_pointer) +IREP_ID_ONE(integer_address) +IREP_ID_ONE(integer_address_object) +IREP_ID_ONE(null_object) +IREP_ID_ONE(static_object) +IREP_ID_ONE(stack_object) +IREP_ID_TWO(C_is_failed_symbol, #is_failed_symbol) +IREP_ID_TWO(C_failed_symbol, #failed_symbol) +IREP_ID_ONE(list) +IREP_ID_ONE(map) +IREP_ID_ONE(set) +IREP_ID_ONE(storage) +IREP_ID_ONE(friend) +IREP_ID_ONE(explicit) +IREP_ID_ONE(storage_spec) +IREP_ID_ONE(member_spec) +IREP_ID_ONE(msc_declspec) +IREP_ID_ONE(packed) +IREP_ID_TWO(C_packed, #packed) +IREP_ID_ONE(transparent_union) +IREP_ID_TWO(C_transparent_union, #transparent_union) +IREP_ID_ONE(aligned) +IREP_ID_TWO(C_alignment, #alignment) +IREP_ID_ONE(vector) +IREP_ID_ONE(abstract) +IREP_ID_ONE(bit) +IREP_ID_ONE(logic) +IREP_ID_ONE(chandle) +IREP_ID_ONE(reg) +IREP_ID_ONE(wire) +IREP_ID_ONE(tri) +IREP_ID_ONE(tri1) +IREP_ID_ONE(supply0) +IREP_ID_ONE(wand) +IREP_ID_ONE(triand) +IREP_ID_ONE(tri0) +IREP_ID_ONE(supply1) +IREP_ID_ONE(wor) +IREP_ID_ONE(trior) +IREP_ID_ONE(trireg) +IREP_ID_ONE(function_application) +IREP_ID_ONE(cpp_declarator) +IREP_ID_ONE(cpp_linkage_spec) +IREP_ID_ONE(cpp_namespace_spec) +IREP_ID_ONE(cpp_storage_spec) +IREP_ID_ONE(cpp_using) +IREP_ID_ONE(cpp_declaration) +IREP_ID_ONE(cpp_static_assert) +IREP_ID_ONE(cpp_member_spec) +IREP_ID_TWO(C_c_type, #c_type) +IREP_ID_ONE(namespace) +IREP_ID_ONE(linkage) +IREP_ID_ONE(decltype) +IREP_ID_ONE(buf) +IREP_ID_ONE(bufif0) +IREP_ID_ONE(bufif1) +IREP_ID_ONE(notif0) +IREP_ID_ONE(notif1) +IREP_ID_ONE(task) +IREP_ID_TWO(C_little_endian, #little_endian) +IREP_ID_TWO(C_offset, #offset) +IREP_ID_TWO(C_tag_only_declaration, #tag_only_declaration) +IREP_ID_ONE(struct_tag) +IREP_ID_ONE(union_tag) +IREP_ID_ONE(c_enum_tag) +IREP_ID_ONE(enum_constant) +IREP_ID_ONE(bit_select) +IREP_ID_ONE(part_select) +IREP_ID_ONE(indexed_part_select_plus) +IREP_ID_ONE(indexed_part_select_minus) +IREP_ID_ONE(generate_block) +IREP_ID_ONE(generate_assign) +IREP_ID_ONE(generate_skip) +IREP_ID_ONE(generate_case) +IREP_ID_ONE(generate_if) +IREP_ID_ONE(generate_for) +IREP_ID_ONE(delay) +IREP_ID_ONE(verilog_cycle_delay) +IREP_ID_ONE(sva_cycle_delay) +IREP_ID_ONE(sva_sequence_throughout) +IREP_ID_ONE(sva_sequence_concatenation) +IREP_ID_ONE(sva_sequence_first_match) +IREP_ID_ONE(sva_always) +IREP_ID_ONE(sva_nexttime) +IREP_ID_ONE(sva_s_nexttime) +IREP_ID_ONE(sva_eventually) +IREP_ID_ONE(sva_s_eventually) +IREP_ID_ONE(sva_until) +IREP_ID_ONE(sva_s_until) +IREP_ID_ONE(sva_until_with) +IREP_ID_ONE(sva_s_until_with) +IREP_ID_ONE(sva_overlapped_implication) +IREP_ID_ONE(sva_non_overlapped_implication) +IREP_ID_ONE(hierarchical_identifier) +IREP_ID_ONE(named_port_connection) +IREP_ID_ONE(named_block) +IREP_ID_ONE(verilog_primitive_module) +IREP_ID_ONE(verilog_module) +IREP_ID_ONE(verilog_case_equality) +IREP_ID_ONE(verilog_case_inequality) +IREP_ID_ONE(event_guard) +IREP_ID_ONE(posedge) +IREP_ID_ONE(negedge) +IREP_ID_ONE(pointer_and_address_pair) +IREP_ID_ONE(user_specified_predicate) +IREP_ID_ONE(user_specified_parameter_predicates) +IREP_ID_ONE(user_specified_return_predicates) +IREP_ID_ONE(unassigned) +IREP_ID_ONE(new_object) +IREP_ID_ONE(complex_real) +IREP_ID_ONE(complex_imag) +IREP_ID_ONE(imag) +IREP_ID_ONE(msc_try_except) +IREP_ID_ONE(msc_try_finally) +IREP_ID_ONE(msc_leave) +IREP_ID_ONE(msc_uuidof) +IREP_ID_ONE(msc_if_exists) +IREP_ID_ONE(msc_if_not_exists) +IREP_ID_ONE(msc_underlying_type) +IREP_ID_ONE(msc_based) +IREP_ID_ONE(alias) +IREP_ID_ONE(auto_object) +IREP_ID_ONE(ssa_object) +IREP_ID_ONE(ptr_object) +IREP_ID_TWO(C_c_sizeof_type, #c_sizeof_type) +IREP_ID_ONE(array_update) +IREP_ID_ONE(struct_update) +IREP_ID_ONE(union_update) +IREP_ID_ONE(update) +IREP_ID_ONE(float_debug1) +IREP_ID_ONE(float_debug2) +IREP_ID_ONE(static_assert) +IREP_ID_ONE(gcc_attribute_mode) +IREP_ID_TWO(built_in, ) +IREP_ID_ONE(exception_list) +IREP_ID_ONE(exception_id) +IREP_ID_ONE(priority) +IREP_ID_ONE(predicate_passive_symbol) +IREP_ID_ONE(all) +IREP_ID_ONE(when) +IREP_ID_ONE(cw_va_arg_typeof) +IREP_ID_ONE(fence) +IREP_ID_ONE(sync) +IREP_ID_ONE(lwsync) +IREP_ID_ONE(isync) +IREP_ID_ONE(WRfence) +IREP_ID_ONE(RRfence) +IREP_ID_ONE(RWfence) +IREP_ID_ONE(WWfence) +IREP_ID_ONE(RRcumul) +IREP_ID_ONE(RWcumul) +IREP_ID_ONE(WWcumul) +IREP_ID_ONE(WRcumul) +IREP_ID_ONE(claim) +IREP_ID_ONE(generic_selection) +IREP_ID_ONE(generic_associations) +IREP_ID_ONE(generic_association) +IREP_ID_ONE(floatbv_plus) +IREP_ID_ONE(floatbv_minus) +IREP_ID_ONE(floatbv_mult) +IREP_ID_ONE(floatbv_div) +IREP_ID_ONE(floatbv_rem) +IREP_ID_ONE(floatbv_sin) +IREP_ID_ONE(floatbv_cos) +IREP_ID_ONE(floatbv_typecast) +IREP_ID_ONE(read) +IREP_ID_ONE(write) +IREP_ID_ONE(native) +IREP_ID_ONE(final) +IREP_ID_ONE(compound_literal) +IREP_ID_ONE(custom_bv) +IREP_ID_ONE(custom_unsignedbv) +IREP_ID_ONE(custom_signedbv) +IREP_ID_ONE(custom_fixedbv) +IREP_ID_ONE(custom_floatbv) +IREP_ID_TWO(C_SSA_symbol, #SSA_symbol) +IREP_ID_TWO(C_full_identifier, #full_identifier) +IREP_ID_ONE(L0) +IREP_ID_ONE(L1) +IREP_ID_ONE(L2) +IREP_ID_ONE(L1_object_identifier) +IREP_ID_ONE(already_typechecked) +IREP_ID_TWO(C_va_arg_type, #va_arg_type) +IREP_ID_ONE(smt2_symbol) +IREP_ID_ONE(VHDL) +IREP_ID_ONE(Verilog) +IREP_ID_ONE(verilog_realtime) +IREP_ID_ONE(onehot) +IREP_ID_ONE(onehot0) +IREP_ID_ONE(verilog_star_event) +IREP_ID_ONE(verilog_attribute) +IREP_ID_ONE(time) +IREP_ID_ONE(fork) +IREP_ID_ONE(disable) +IREP_ID_ONE(wait) +IREP_ID_ONE(deassign) +IREP_ID_ONE(force) +IREP_ID_ONE(release) +IREP_ID_ONE(popcount) +IREP_ID_ONE(function_type) +IREP_ID_ONE(noreturn) +IREP_ID_TWO(C_noreturn, #noreturn) +IREP_ID_ONE(process) +IREP_ID_ONE(signal) +IREP_ID_ONE(weak) +IREP_ID_ONE(is_weak) +IREP_ID_TWO(C_spec_loop_invariant, #spec_loop_invariant) +IREP_ID_TWO(C_spec_requires, #spec_requires) +IREP_ID_TWO(C_spec_ensures, #spec_ensures) +IREP_ID_ONE(virtual_function) +IREP_ID_TWO(C_element_type, #element_type) +IREP_ID_ONE(working_directory) +IREP_ID_ONE(section) +IREP_ID_ONE(msb) +IREP_ID_ONE(lsb) +IREP_ID_ONE(verilog_signed_vector) +IREP_ID_ONE(verilog_unsigned_vector) +IREP_ID_ONE(verilog_array) +IREP_ID_ONE(low) +IREP_ID_ONE(high) +IREP_ID_ONE(bswap) +IREP_ID_ONE(java_bytecode_index) +IREP_ID_ONE(java_instanceof) +IREP_ID_ONE(java_super_method_call) +IREP_ID_ONE(java_enum_static_unwind) +IREP_ID_ONE(push_catch) +IREP_ID_ONE(string_constraint) +IREP_ID_ONE(string_not_contains_constraint) +IREP_ID_ONE(cprover_char_literal_func) +IREP_ID_ONE(cprover_string_literal_func) +IREP_ID_ONE(cprover_string_char_at_func) +IREP_ID_ONE(cprover_string_char_set_func) +IREP_ID_ONE(cprover_string_code_point_at_func) +IREP_ID_ONE(cprover_string_code_point_before_func) +IREP_ID_ONE(cprover_string_code_point_count_func) +IREP_ID_ONE(cprover_string_offset_by_code_point_func) +IREP_ID_ONE(cprover_string_compare_to_func) +IREP_ID_ONE(cprover_string_concat_func) +IREP_ID_ONE(cprover_string_concat_int_func) +IREP_ID_ONE(cprover_string_concat_long_func) +IREP_ID_ONE(cprover_string_concat_char_func) +IREP_ID_ONE(cprover_string_concat_bool_func) +IREP_ID_ONE(cprover_string_concat_double_func) +IREP_ID_ONE(cprover_string_concat_float_func) +IREP_ID_ONE(cprover_string_concat_code_point_func) +IREP_ID_ONE(cprover_string_contains_func) +IREP_ID_ONE(cprover_string_copy_func) +IREP_ID_ONE(cprover_string_delete_func) +IREP_ID_ONE(cprover_string_delete_char_at_func) +IREP_ID_ONE(cprover_string_equal_func) +IREP_ID_ONE(cprover_string_equals_ignore_case_func) +IREP_ID_ONE(cprover_string_empty_string_func) +IREP_ID_ONE(cprover_string_endswith_func) +IREP_ID_ONE(cprover_string_format_func) +IREP_ID_ONE(cprover_string_hash_code_func) +IREP_ID_ONE(cprover_string_index_of_func) +IREP_ID_ONE(cprover_string_intern_func) +IREP_ID_ONE(cprover_string_insert_func) +IREP_ID_ONE(cprover_string_insert_int_func) +IREP_ID_ONE(cprover_string_insert_long_func) +IREP_ID_ONE(cprover_string_insert_bool_func) +IREP_ID_ONE(cprover_string_insert_char_func) +IREP_ID_ONE(cprover_string_insert_float_func) +IREP_ID_ONE(cprover_string_insert_double_func) +IREP_ID_ONE(cprover_string_insert_char_array_func) +IREP_ID_ONE(cprover_string_is_prefix_func) +IREP_ID_ONE(cprover_string_is_suffix_func) +IREP_ID_ONE(cprover_string_is_empty_func) +IREP_ID_ONE(cprover_string_last_index_of_func) +IREP_ID_ONE(cprover_string_length_func) +IREP_ID_ONE(cprover_string_data_func) +IREP_ID_ONE(cprover_string_of_int_func) +IREP_ID_ONE(cprover_string_of_int_hex_func) +IREP_ID_ONE(cprover_string_of_long_func) +IREP_ID_ONE(cprover_string_of_bool_func) +IREP_ID_ONE(cprover_string_of_float_func) +IREP_ID_ONE(cprover_string_of_double_func) +IREP_ID_ONE(cprover_string_of_char_func) +IREP_ID_ONE(cprover_string_of_char_array_func) +IREP_ID_ONE(cprover_string_parse_int_func) +IREP_ID_ONE(cprover_string_replace_func) +IREP_ID_ONE(cprover_string_set_length_func) +IREP_ID_ONE(cprover_string_startswith_func) +IREP_ID_ONE(cprover_string_substring_func) +IREP_ID_ONE(cprover_string_to_char_array_func) +IREP_ID_ONE(cprover_string_to_lower_case_func) +IREP_ID_ONE(cprover_string_to_upper_case_func) +IREP_ID_ONE(cprover_string_trim_func) +IREP_ID_ONE(cprover_string_value_of_func) + +#undef IREP_ID_ONE +#undef IREP_ID_TWO diff --git a/src/util/irep_ids.h b/src/util/irep_ids.h new file mode 100644 index 00000000000..733661542e4 --- /dev/null +++ b/src/util/irep_ids.h @@ -0,0 +1,42 @@ +/*******************************************************************\ + +Module: util + +Author: Reuben Thomas, reuben.thomas@me.com + +\*******************************************************************/ + +#ifndef CPROVER_UTIL_IREP_IDS_H +#define CPROVER_UTIL_IREP_IDS_H + +#include "dstring.h" + +enum class idt:unsigned short +{ +#define IREP_ID_ONE(the_id) id_##the_id, +#define IREP_ID_TWO(the_id, str) id_##the_id, + +#include "irep_ids.def" +}; + +#ifdef USE_DSTRING + +#define IREP_ID_ONE(the_id) \ + static const dstringt ID_##the_id( \ + static_cast(idt::id_##the_id), 0); +#define IREP_ID_TWO(the_id, str) \ + static const dstringt ID_##the_id( \ + static_cast(idt::id_##the_id), 0); + +#else + +#define IREP_ID_ONE(the_id) \ + static const std::string ID_##the_id(#the_id); +#define IREP_ID_TWO(the_id, str) \ + static const std::string ID_##the_id(#the_id); + +#endif + +#include "irep_ids.def" + +#endif diff --git a/src/util/irep_ids.txt b/src/util/irep_ids.txt deleted file mode 100644 index 6405b9bc5d7..00000000000 --- a/src/util/irep_ids.txt +++ /dev/null @@ -1,804 +0,0 @@ -let -nil -type -operands -bool -c_bool -proper_bool -signedbv -unsignedbv -verilog_signedbv -verilog_unsignedbv -floatbv -fixedbv -x86_extended -C_source_location #source_location -C_end_location #end_location -C_is_padding #is_padding -file -line -column -comment -property -property_class -property_id -function -code -typecast -static_cast -dynamic_cast -const_cast -reinterpret_cast -index -index_range -ptrmember -member -member_name -C_member_name #member_name -equal = -implies => -iff <=> -and -nand -or -nor -xor -xnor -not -bitand -bitor -bitnot -bitxor -bitnand -bitnor -bitxnor -notequal -if -symbol -next_symbol -nondet_symbol -predicate -predicate_symbol -predicate_next_symbol -nondet_bool -empty -side_effect -statement -statement_expression -value -constant -block -decl -dead -assign -assign_div -assign_mult assign* -assign_plus assign+ -assign_minus assign- -assign_mod -assign_shl -assign_shr -assign_ashr -assign_lshr -assign_bitand -assign_bitxor -assign_bitor -assume -assert -assertion -goto -gcc_computed_goto -ifthenelse -label -break -continue -function_call -return -skip -arguments -array -size -pointer -block_pointer -switch -switch_case -gcc_switch_case_range -for -while -dowhile -int -integer -natural -real -rational -complex -signed -unsigned -asm -gcc_asm_input -gcc_asm_output -gcc_asm_clobbered_register -incomplete_array -incomplete_struct -incomplete_union -incomplete_class -incomplete_c_enum -C_incomplete #incomplete -identifier -name -cpp_name -component_cpp_name -C_id_class #id_class -declaration -declaration_list -declarator -struct -c_bit_field -union -class -merged_type -range -from -to -module -module_instance -macromodule -primitive_module_instance -module_items -module_source -parameter_decl -local_parameter_decl -parameter -component_name -component_number -tag -default -C_default_value #default_value -base_name -C_base_name #base_name -string -C_string_constant #string_constant -string_constant -width -components -bv -f -ports -port -offset -with -trans -throw -catch -try_catch -noexcept -CPROVER_throw -CPROVER_try_catch -CPROVER_try_finally -protection -private -public -protected -virtual -volatile -const -constexpr -inline -forall -exists -forever -repeat -extractbit -extractbits -reference -C_reference #reference -C_rvalue_reference #rvalue_reference -true -false -address_of -dereference -C_lvalue #lvalue -C_base #base -destination -main -expression -free -malloc -cpp_new -cpp_delete -cpp_new_array cpp_new[] -cpp_delete_array cpp_delete[] -java_new -java_new_array -java_string_literal -printf -input -output -output_register -inout -nondet -NULL -null -nullptr -c_enum -enumeration -elements -unknown -uninitialized -invalid -C_invalid_object #invalid_object -pointer_offset -pointer_object -invalid_pointer invalid-pointer -ieee_float_equal -ieee_float_notequal -isnan -lambda -array_of -array_equal -array_set -array_copy -mod -rem -shr -ashr -lshr -shl -rol -ror -comma -concatenation -infinity -return_type -typedef -C_typedef #typedef -extern -static -auto -register -thread_local -thread -C_thread_local #thread_local -C_static_lifetime #static_lifetime -mutable -void -int8 -int16 -int32 -int64 -ptr32 -ptr64 -char -short -long -longlong -float -double -byte -boolean -long_double -signed_char -unsigned_char -signed_int -unsigned_int -signed_long_int -unsigned_long_int -signed_short_int -unsigned_short_int -signed_long_long_int -unsigned_long_long_int -signed_int128 -unsigned_int128 -case -casex -casez -case_item -C_inlined #inlined -C_hide #hide -hide -abs -sign -access -C_access #access -postincrement -postdecrement -preincrement -predecrement -integer_bits -KnR -C_KnR #KnR -constraint_select_one -cond -bv_literals -isfinite -isinf -isnormal -AG -AF -AX -EG -EF -EX -U -R -A -F -E -G -X -continuous_assign -blocking_assign -non_blocking_assign -alignof -gcc_builtin_va_arg -gcc_builtin_types_compatible_p -gcc_builtin_va_arg_next -gcc_builtin_va_list -gcc_float80 -gcc_float128 -gcc_int128 -gcc_decimal32 -gcc_decimal64 -gcc_decimal128 -builtin_offsetof -0 -1 -8 -16 -32 -64 -128 -sizeof -type_arg -expr_arg -expression_list -initializer_list -gcc_conditional_expression -gcc_local_label -gcc -msc -typeof -ellipsis -flavor -ge >= -le <= -gt > -lt < -plus + -minus - -unary_minus unary- -unary_plus unary+ -mult * -div / -power ** -factorial_power -component -pretty_name -C_class #class -C_interface #interface -interface -targets -location -labels -event -guard -designated_initializer -designator -member_designator -index_designator -offset_designator -C_constant #constant -C_volatile #volatile -C_restricted #restricted -C_identifier #identifier -C_implicit #implicit -C_ptr32 #ptr32 -C_ptr64 #ptr64 -C_atomic #atomic -restrict -byte_extract_big_endian -byte_extract_little_endian -byte_update_big_endian -byte_update_little_endian -replication -dummy -init -cprover_atomic -atomic -atomic_type_specifier -atomic_begin -atomic_end -start_thread -end_thread -specc_notify -specc_par -specc_wait -specc_event -bp_enforce -bp_abortif -bp_constrain -bp_schoose -bp_dead -instance -cover -coverage_criterion -initializer -anonymous -C_is_anonymous #is_anonymous -is_macro -is_enum_constant -is_inline -is_extern -is_global -is_thread_local -is_parameter -is_member -is_type -is_register -is_typedef -is_static -is_template -is_static_assert -is_virtual -C_is_virtual #is_virtual -literal -member_initializers -member_initializer -method_qualifier -methods -constructor -destructor -bases -base -from_base -operator -template -template_class_instance -template_function_instance -template_type -template_args -template_parameter -template_parameters -C_template #template -C_template_arguments #template_arguments -typename -C -cpp -java -SpecC -SystemC -decl_block -decl_type -genvar -realtime -parameters -parameter_assignments -named_parameter_assignment -specify -pullup -pulldown -automatic -rcmos -cmos -nmos -pmos -rnmos -rpmos -wchar_t -char16_t -char32_t -size_t -ssize_t -inst -inst_builtin -always -initial -mode -this -C_this #this -reduction_and -reduction_or -reduction_nand -reduction_nor -reduction_xor -reduction_xnor -C_zero_initializer #zero_initializer -body -entity -temporary_object -overflow_plus overflow-+ -overflow_minus overflow-- -overflow_mult overflow-* -overflow_unary_minus overflow-unary- -object_descriptor -dynamic_object -object_size -good_pointer -integer_address -integer_address_object -null_object -static_object -stack_object -C_is_failed_symbol #is_failed_symbol -C_failed_symbol #failed_symbol -list -map -set -storage -friend -explicit -storage_spec -member_spec -msc_declspec -packed -C_packed #packed -transparent_union -C_transparent_union #transparent_union -aligned -C_alignment #alignment -vector -abstract -bit -logic -chandle -reg -wire -tri -tri1 -supply0 -wand -triand -tri0 -supply1 -wor -trior -trireg -function_application -cpp_declarator -cpp_linkage_spec -cpp_namespace_spec -cpp_storage_spec -cpp_using -cpp_declaration -cpp_static_assert -cpp_member_spec -C_c_type #c_type -namespace -linkage -decltype -buf -bufif0 -bufif1 -notif0 -notif1 -task -C_little_endian #little_endian -C_offset #offset -C_tag_only_declaration #tag_only_declaration -struct_tag -union_tag -c_enum_tag -enum_constant -bit_select -part_select -indexed_part_select_plus -indexed_part_select_minus -generate_block -generate_assign -generate_skip -generate_case -generate_if -generate_for -delay -verilog_cycle_delay -sva_cycle_delay -sva_sequence_throughout -sva_sequence_concatenation -sva_sequence_first_match -sva_always -sva_nexttime -sva_s_nexttime -sva_eventually -sva_s_eventually -sva_until -sva_s_until -sva_until_with -sva_s_until_with -sva_overlapped_implication -sva_non_overlapped_implication -hierarchical_identifier -named_port_connection -named_block -verilog_primitive_module -verilog_module -verilog_case_equality -verilog_case_inequality -event_guard -posedge -negedge -pointer_and_address_pair -user_specified_predicate -user_specified_parameter_predicates -user_specified_return_predicates -unassigned -new_object -complex_real -complex_imag -imag -msc_try_except -msc_try_finally -msc_leave -msc_uuidof -msc_if_exists -msc_if_not_exists -msc_underlying_type -msc_based -alias -auto_object -ssa_object -ptr_object -C_c_sizeof_type #c_sizeof_type -array_update -struct_update -union_update -update -float_debug1 -float_debug2 -static_assert -gcc_attribute_mode -built_in -exception_list -exception_id -priority -predicate_passive_symbol -all -when -cw_va_arg_typeof -fence -sync -lwsync -isync -WRfence -RRfence -RWfence -WWfence -RRcumul -RWcumul -WWcumul -WRcumul -claim -generic_selection -generic_associations -generic_association -floatbv_plus -floatbv_minus -floatbv_mult -floatbv_div -floatbv_rem -floatbv_sin -floatbv_cos -floatbv_typecast -read -write -native -final -compound_literal -custom_bv -custom_unsignedbv -custom_signedbv -custom_fixedbv -custom_floatbv -C_SSA_symbol #SSA_symbol -C_full_identifier #full_identifier -L0 -L1 -L2 -L1_object_identifier -already_typechecked -C_va_arg_type #va_arg_type -smt2_symbol -VHDL -Verilog -verilog_realtime -onehot -onehot0 -verilog_star_event -verilog_attribute -time -fork -disable -wait -deassign -force -release -popcount -function_type -noreturn -C_noreturn #noreturn -process -signal -weak -is_weak -C_spec_loop_invariant #spec_loop_invariant -C_spec_requires #spec_requires -C_spec_ensures #spec_ensures -virtual_function -C_element_type #element_type -working_directory -section -msb -lsb -verilog_signed_vector -verilog_unsigned_vector -verilog_array -low -high -bswap -java_bytecode_index -java_instanceof -java_super_method_call -java_enum_static_unwind -push_catch -string_constraint -string_not_contains_constraint -cprover_char_literal_func -cprover_string_literal_func -cprover_string_char_at_func -cprover_string_char_set_func -cprover_string_code_point_at_func -cprover_string_code_point_before_func -cprover_string_code_point_count_func -cprover_string_offset_by_code_point_func -cprover_string_compare_to_func -cprover_string_concat_func -cprover_string_concat_int_func -cprover_string_concat_long_func -cprover_string_concat_char_func -cprover_string_concat_bool_func -cprover_string_concat_double_func -cprover_string_concat_float_func -cprover_string_concat_code_point_func -cprover_string_contains_func -cprover_string_copy_func -cprover_string_delete_func -cprover_string_delete_char_at_func -cprover_string_equal_func -cprover_string_equals_ignore_case_func -cprover_string_empty_string_func -cprover_string_endswith_func -cprover_string_format_func -cprover_string_hash_code_func -cprover_string_index_of_func -cprover_string_intern_func -cprover_string_insert_func -cprover_string_insert_int_func -cprover_string_insert_long_func -cprover_string_insert_bool_func -cprover_string_insert_char_func -cprover_string_insert_float_func -cprover_string_insert_double_func -cprover_string_insert_char_array_func -cprover_string_is_prefix_func -cprover_string_is_suffix_func -cprover_string_is_empty_func -cprover_string_last_index_of_func -cprover_string_length_func -cprover_string_data_func -cprover_string_of_int_func -cprover_string_of_int_hex_func -cprover_string_of_long_func -cprover_string_of_bool_func -cprover_string_of_float_func -cprover_string_of_double_func -cprover_string_of_char_func -cprover_string_of_char_array_func -cprover_string_parse_int_func -cprover_string_replace_func -cprover_string_set_length_func -cprover_string_startswith_func -cprover_string_substring_func -cprover_string_to_char_array_func -cprover_string_to_lower_case_func -cprover_string_to_upper_case_func -cprover_string_trim_func -cprover_string_value_of_func diff --git a/src/util/irep_ids_convert.cpp b/src/util/irep_ids_convert.cpp deleted file mode 100644 index b55a3e7a96a..00000000000 --- a/src/util/irep_ids_convert.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/*******************************************************************\ - -Module: Build pre-initialized entries for C-string container - -Author: Daniel Kroening, kroening@kroening.com - -\*******************************************************************/ - -#include -#include - -#define USE_DSTRING - -int main(int argc, const char **argv) -{ - if(argc!=2) - return 1; - - std::cout << "// Generated by irep_ids_convert" - << std::endl << std::endl; - - if(std::string(argv[1])=="header") - { - std::string line; - - std::cout << "#ifndef CPROVER_UTIL_IREP_IDS_H" << std::endl; - std::cout << "#define CPROVER_UTIL_IREP_IDS_H" << std::endl; - std::cout << std::endl; - - unsigned count=1; - - while(getline(std::cin, line)) - { - if(line=="") - continue; - - std::cout << "#define ID_"; - - std::size_t pos=line.find(' '); - -#ifdef USE_DSTRING - if(pos==std::string::npos) - std::cout << line - << " dstringt(" << count << ", 0)"; - else - std::cout << std::string(line, 0, pos) - << " dstringt(" << count << ", 0)" - << " // " - << std::string(line, pos+1, std::string::npos); -#else - if(pos==std::string::npos) - std::cout << line - << " \"" << line << "\""; - else - std::cout << std::string(line, 0, pos) - << " \"" << std::string(line, 0, pos) << "\"" - << " // " - << std::string(line, pos+1, std::string::npos); -#endif - - std::cout << std::endl; - - count++; - } - - std::cout << std::endl; - std::cout << "#endif" << std::endl; - } - else if(std::string(argv[1])=="table") - { - std::string line; - - std::cout << " \"\"," << std::endl; - - while(getline(std::cin, line)) - { - if(line=="") - continue; - - std::cout << " \""; - - std::size_t pos=line.find(' '); - - if(pos==std::string::npos) - std::cout << line << "\","; - else - std::cout << std::string(line, pos+1, std::string::npos) - << "\", // ID_" - << std::string(line, 0, pos); - - std::cout << std::endl; - } - } - - return 0; -} From 52300e96f1268da0f6d494eb939119c220d49a68 Mon Sep 17 00:00:00 2001 From: reuk Date: Sun, 12 Mar 2017 15:21:03 +0000 Subject: [PATCH 099/116] Mark dstring constructor `explicit` ...and remove dummy parameter. --- src/util/dstring.h | 10 ++++++---- src/util/irep_ids.h | 8 +++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/util/dstring.h b/src/util/dstring.h index 9fdfd1ecddd..fe9c7c29299 100644 --- a/src/util/dstring.h +++ b/src/util/dstring.h @@ -13,7 +13,9 @@ Author: Daniel Kroening, kroening@kroening.com #include "string_container.h" -class dstringt +// Marked final to disable inheritance. +// No virtual destructor, so runtime-polymorphic use would be unsafe. +class dstringt final { public: // this is safe for static objects @@ -25,11 +27,11 @@ class dstringt } // this is safe for static objects - // the 2nd argument is to avoid accidental conversions + // marked explicit to avoid accidental conversions #ifdef __GNUC__ constexpr #endif - dstringt(unsigned _no, unsigned):no(_no) + explicit dstringt(unsigned _no):no(_no) { } @@ -135,7 +137,7 @@ class dstringt return no; } -protected: +private: unsigned no; // the reference returned is guaranteed to be stable diff --git a/src/util/irep_ids.h b/src/util/irep_ids.h index 733661542e4..8545b08d87b 100644 --- a/src/util/irep_ids.h +++ b/src/util/irep_ids.h @@ -11,7 +11,7 @@ Author: Reuben Thomas, reuben.thomas@me.com #include "dstring.h" -enum class idt:unsigned short +enum class idt:unsigned { #define IREP_ID_ONE(the_id) id_##the_id, #define IREP_ID_TWO(the_id, str) id_##the_id, @@ -22,11 +22,9 @@ enum class idt:unsigned short #ifdef USE_DSTRING #define IREP_ID_ONE(the_id) \ - static const dstringt ID_##the_id( \ - static_cast(idt::id_##the_id), 0); + static const dstringt ID_##the_id(static_cast(idt::id_##the_id)); #define IREP_ID_TWO(the_id, str) \ - static const dstringt ID_##the_id( \ - static_cast(idt::id_##the_id), 0); + static const dstringt ID_##the_id(static_cast(idt::id_##the_id)); #else From e4ac03154ec89ea7bdf756e22285c4bc5ca34899 Mon Sep 17 00:00:00 2001 From: reuk Date: Mon, 13 Mar 2017 16:15:51 +0000 Subject: [PATCH 100/116] Use static constructor idiom --- src/util/dstring.h | 11 +++++++++-- src/util/irep_ids.h | 8 +++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/util/dstring.h b/src/util/dstring.h index fe9c7c29299..bda6dece8e6 100644 --- a/src/util/dstring.h +++ b/src/util/dstring.h @@ -27,12 +27,12 @@ class dstringt final } // this is safe for static objects - // marked explicit to avoid accidental conversions #ifdef __GNUC__ constexpr #endif - explicit dstringt(unsigned _no):no(_no) + static dstringt make_from_table_index(unsigned no) { + return dstringt(no); } #if 0 @@ -138,6 +138,13 @@ class dstringt final } private: + #ifdef __GNUC__ + constexpr + #endif + explicit dstringt(unsigned _no):no(_no) + { + } + unsigned no; // the reference returned is guaranteed to be stable diff --git a/src/util/irep_ids.h b/src/util/irep_ids.h index 8545b08d87b..b2ed21d29be 100644 --- a/src/util/irep_ids.h +++ b/src/util/irep_ids.h @@ -22,9 +22,11 @@ enum class idt:unsigned #ifdef USE_DSTRING #define IREP_ID_ONE(the_id) \ - static const dstringt ID_##the_id(static_cast(idt::id_##the_id)); + static const dstringt ID_##the_id= \ + dstringt::make_from_table_index(static_cast(idt::id_##the_id)); #define IREP_ID_TWO(the_id, str) \ - static const dstringt ID_##the_id(static_cast(idt::id_##the_id)); + static const dstringt ID_##the_id= \ + dstringt::make_from_table_index(static_cast(idt::id_##the_id)); #else @@ -35,6 +37,6 @@ enum class idt:unsigned #endif -#include "irep_ids.def" +#include "irep_ids.def" // NOLINT(build/include) #endif From 494d772383fbf7a3658b27338ab61dde02affe13 Mon Sep 17 00:00:00 2001 From: reuk Date: Tue, 14 Mar 2017 09:32:31 +0000 Subject: [PATCH 101/116] Declare strings extern --- src/util/irep.h | 9 ++------- src/util/irep_ids.cpp | 18 ++++++++++++++++++ src/util/irep_ids.h | 18 ++++++++---------- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/util/irep.h b/src/util/irep.h index 6dd15df0983..938462868b6 100644 --- a/src/util/irep.h +++ b/src/util/irep.h @@ -14,7 +14,8 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -#define USE_DSTRING +#include "irep_ids.h" + #define SHARING // #define HASH_CODE #define USE_MOVE @@ -26,12 +27,6 @@ Author: Daniel Kroening, kroening@kroening.com #include #endif -#ifdef USE_DSTRING -#include "dstring.h" -#endif - -#include "irep_ids.h" - #ifdef USE_DSTRING typedef dstringt irep_idt; typedef dstringt irep_namet; diff --git a/src/util/irep_ids.cpp b/src/util/irep_ids.cpp index 34b56573961..bb67b275f0a 100644 --- a/src/util/irep_ids.cpp +++ b/src/util/irep_ids.cpp @@ -21,6 +21,24 @@ const char *irep_ids_table[]= NULL, }; +#ifdef USE_DSTRING + +#define IREP_ID_ONE(the_id) \ + const dstringt ID_##the_id=dstringt::make_from_table_index( \ + static_cast(idt::id_##the_id)); +#define IREP_ID_TWO(the_id, str) \ + const dstringt ID_##the_id=dstringt::make_from_table_index( \ + static_cast(idt::id_##the_id)); + +#else + +#define IREP_ID_ONE(the_id) const std::string ID_##the_id(#the_id); +#define IREP_ID_TWO(the_id, str) const std::string ID_##the_id(#the_id); + +#endif + +#include "irep_ids.def" // NOLINT(build/include) + /*******************************************************************\ Function: initialize_string_container diff --git a/src/util/irep_ids.h b/src/util/irep_ids.h index b2ed21d29be..50fc06314b5 100644 --- a/src/util/irep_ids.h +++ b/src/util/irep_ids.h @@ -9,7 +9,11 @@ Author: Reuben Thomas, reuben.thomas@me.com #ifndef CPROVER_UTIL_IREP_IDS_H #define CPROVER_UTIL_IREP_IDS_H +#define USE_DSTRING + +#ifdef USE_DSTRING #include "dstring.h" +#endif enum class idt:unsigned { @@ -21,19 +25,13 @@ enum class idt:unsigned #ifdef USE_DSTRING -#define IREP_ID_ONE(the_id) \ - static const dstringt ID_##the_id= \ - dstringt::make_from_table_index(static_cast(idt::id_##the_id)); -#define IREP_ID_TWO(the_id, str) \ - static const dstringt ID_##the_id= \ - dstringt::make_from_table_index(static_cast(idt::id_##the_id)); +#define IREP_ID_ONE(the_id) extern const dstringt ID_##the_id; +#define IREP_ID_TWO(the_id, str) extern const dstringt ID_##the_id; #else -#define IREP_ID_ONE(the_id) \ - static const std::string ID_##the_id(#the_id); -#define IREP_ID_TWO(the_id, str) \ - static const std::string ID_##the_id(#the_id); +#define IREP_ID_ONE(the_id) extern const std::string ID_##the_id; +#define IREP_ID_TWO(the_id, str) extern const std::string ID_##the_id; #endif From e0f32f084a270d07132efb466d8b457f873fdb61 Mon Sep 17 00:00:00 2001 From: reuk Date: Thu, 6 Apr 2017 10:01:44 +0100 Subject: [PATCH 102/116] Add empty string to list of irep ids --- src/util/irep_ids.def | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/irep_ids.def b/src/util/irep_ids.def index 11baf80f474..91379187bde 100644 --- a/src/util/irep_ids.def +++ b/src/util/irep_ids.def @@ -1,3 +1,4 @@ +IREP_ID_TWO(empty_string, ) IREP_ID_ONE(let) IREP_ID_ONE(nil) IREP_ID_ONE(type) From 05192db2b81e78b5edfb71e271a3aa32bf47df23 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Thu, 6 Apr 2017 14:08:21 +0100 Subject: [PATCH 103/116] Remove blank lines from regression test specs Matching blank lines fails on Windows/AppVeyor. Also, there should not be any requirement for our output to contain blank lines. --- regression/acceleration/array_unsafe1/test.desc | 1 - regression/acceleration/array_unsafe2/test.desc | 1 - regression/acceleration/array_unsafe3/test.desc | 1 - regression/acceleration/array_unsafe4/test.desc | 1 - regression/acceleration/const_unsafe1/test.desc | 1 - regression/acceleration/diamond_unsafe1/test.desc | 1 - regression/acceleration/diamond_unsafe2/test.desc | 1 - regression/acceleration/functions_unsafe1/test.desc | 1 - regression/acceleration/multivar_unsafe1/test.desc | 1 - regression/acceleration/nested_unsafe1/test.desc | 1 - regression/acceleration/overflow_unsafe1/test.desc | 1 - regression/acceleration/phases_unsafe1/test.desc | 1 - regression/acceleration/simple_unsafe1/test.desc | 1 - regression/acceleration/simple_unsafe2/test.desc | 1 - regression/acceleration/simple_unsafe3/test.desc | 1 - regression/acceleration/simple_unsafe4/test.desc | 1 - regression/ansi-c/static_inline1/test.desc | 1 - regression/ansi-c/static_inline2/test.desc | 1 - regression/cbmc-incr-oneloop/unwind-forever1/test.desc | 1 - regression/cbmc-incr-oneloop/unwind-forever2/test.desc | 1 - regression/cbmc-java/tableswitch2/test.desc | 1 - regression/cpp-linter/function-comment-header1/test.desc | 1 - regression/cpp-linter/struct-inline-decl/test.desc | 1 - .../goto-analyzer/approx-array-variable-const-fp/test.desc | 1 - .../approx-const-fp-array-variable-cast-const-fp/test.desc | 1 - .../approx-const-fp-array-variable-const-fp-with-null/test.desc | 1 - .../approx-const-fp-array-variable-const-fp/test.desc | 1 - .../test.desc | 1 - .../test.desc | 1 - .../test.desc | 1 - .../test.desc | 1 - .../no-match-const-fp-array-literal-const-fp-run-time/test.desc | 1 - .../test.desc | 1 - .../no-match-const-fp-array-literal-non-const-fp/test.desc | 1 - .../goto-analyzer/no-match-const-fp-array-non-const-fp/test.desc | 1 - .../no-match-const-fp-binary-op-const-lost/test.desc | 1 - .../no-match-const-fp-const-array-index-lost/test.desc | 1 - .../goto-analyzer/no-match-const-fp-const-array-lost/test.desc | 1 - regression/goto-analyzer/no-match-const-fp-const-cast/test.desc | 1 - regression/goto-analyzer/no-match-const-fp-const-lost/test.desc | 1 - .../test.desc | 1 - .../test.desc | 1 - .../no-match-const-fp-dereference-const-pointer-null/test.desc | 1 - .../test.desc | 1 - .../no-match-const-fp-dynamic-array-non-const-fp/test.desc | 1 - .../test.desc | 1 - .../no-match-const-fp-non-const-struct-const-fp/test.desc | 1 - .../no-match-const-fp-non-const-struct-non-const-fp/test.desc | 1 - regression/goto-analyzer/no-match-const-fp-null/test.desc | 1 - .../no-match-const-fp-ternerary-op-const-lost/test.desc | 1 - .../test.desc | 1 - .../no-match-const-pointer-non-const-struct-const-fp/test.desc | 1 - .../no-match-const-struct-non-const-fp-null/test.desc | 1 - .../test.desc | 1 - .../test.desc | 1 - .../test.desc | 1 - regression/goto-analyzer/no-match-non-const-fp/test.desc | 1 - regression/goto-analyzer/no-match-parameter-const-fp/test.desc | 1 - regression/goto-analyzer/no-match-parameter-fp/test.desc | 1 - .../test.desc | 1 - .../precise-const-fp-array-literal-const-fp-run-time/test.desc | 1 - .../test.desc | 1 - .../test.desc | 1 - .../test.desc | 1 - .../test.desc | 1 - .../precise-const-fp-const-struct-non-const-fp/test.desc | 1 - .../test.desc | 1 - regression/goto-analyzer/precise-const-fp/test.desc | 1 - .../precise-const-pointer-const-struct-fp/test.desc | 1 - .../goto-analyzer/precise-const-struct-non-const-fp/test.desc | 1 - .../precise-derefence-const-pointer-const-fp/test.desc | 1 - regression/goto-analyzer/precise-derefence/test.desc | 1 - .../precise-dereference-address-pointer-const-fp/test.desc | 1 - .../test.desc | 1 - .../test.desc | 1 - .../precise-dereference-const-struct-pointer-const-fp/test.desc | 1 - .../approx-array-variable-const-fp-only-remove-const/test.desc | 1 - .../approx-array-variable-const-fp-remove-all-fp/test.desc | 1 - .../no-match-non-const-fp-only-remove-const/test.desc | 1 - .../no-match-non-const-fp-remove-all-fp/test.desc | 1 - .../goto-instrument/precise-const-fp-only-remove-const/test.desc | 1 - .../goto-instrument/precise-const-fp-remove-all-fp/test.desc | 1 - 82 files changed, 82 deletions(-) diff --git a/regression/acceleration/array_unsafe1/test.desc b/regression/acceleration/array_unsafe1/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/array_unsafe1/test.desc +++ b/regression/acceleration/array_unsafe1/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/acceleration/array_unsafe2/test.desc b/regression/acceleration/array_unsafe2/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/array_unsafe2/test.desc +++ b/regression/acceleration/array_unsafe2/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/acceleration/array_unsafe3/test.desc b/regression/acceleration/array_unsafe3/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/array_unsafe3/test.desc +++ b/regression/acceleration/array_unsafe3/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/acceleration/array_unsafe4/test.desc b/regression/acceleration/array_unsafe4/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/array_unsafe4/test.desc +++ b/regression/acceleration/array_unsafe4/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/acceleration/const_unsafe1/test.desc b/regression/acceleration/const_unsafe1/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/const_unsafe1/test.desc +++ b/regression/acceleration/const_unsafe1/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/acceleration/diamond_unsafe1/test.desc b/regression/acceleration/diamond_unsafe1/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/diamond_unsafe1/test.desc +++ b/regression/acceleration/diamond_unsafe1/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/acceleration/diamond_unsafe2/test.desc b/regression/acceleration/diamond_unsafe2/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/diamond_unsafe2/test.desc +++ b/regression/acceleration/diamond_unsafe2/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/acceleration/functions_unsafe1/test.desc b/regression/acceleration/functions_unsafe1/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/functions_unsafe1/test.desc +++ b/regression/acceleration/functions_unsafe1/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/acceleration/multivar_unsafe1/test.desc b/regression/acceleration/multivar_unsafe1/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/multivar_unsafe1/test.desc +++ b/regression/acceleration/multivar_unsafe1/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/acceleration/nested_unsafe1/test.desc b/regression/acceleration/nested_unsafe1/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/nested_unsafe1/test.desc +++ b/regression/acceleration/nested_unsafe1/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/acceleration/overflow_unsafe1/test.desc b/regression/acceleration/overflow_unsafe1/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/overflow_unsafe1/test.desc +++ b/regression/acceleration/overflow_unsafe1/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/acceleration/phases_unsafe1/test.desc b/regression/acceleration/phases_unsafe1/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/phases_unsafe1/test.desc +++ b/regression/acceleration/phases_unsafe1/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/acceleration/simple_unsafe1/test.desc b/regression/acceleration/simple_unsafe1/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/simple_unsafe1/test.desc +++ b/regression/acceleration/simple_unsafe1/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/acceleration/simple_unsafe2/test.desc b/regression/acceleration/simple_unsafe2/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/simple_unsafe2/test.desc +++ b/regression/acceleration/simple_unsafe2/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/acceleration/simple_unsafe3/test.desc b/regression/acceleration/simple_unsafe3/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/simple_unsafe3/test.desc +++ b/regression/acceleration/simple_unsafe3/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/acceleration/simple_unsafe4/test.desc b/regression/acceleration/simple_unsafe4/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/simple_unsafe4/test.desc +++ b/regression/acceleration/simple_unsafe4/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/ansi-c/static_inline1/test.desc b/regression/ansi-c/static_inline1/test.desc index 5717777037a..52168c7eba4 100644 --- a/regression/ansi-c/static_inline1/test.desc +++ b/regression/ansi-c/static_inline1/test.desc @@ -4,6 +4,5 @@ main.c ^EXIT=0$ ^SIGNAL=0$ ^VERIFICATION SUCCESSFUL$ - -- ^warning: ignoring diff --git a/regression/ansi-c/static_inline2/test.desc b/regression/ansi-c/static_inline2/test.desc index c5c5692745d..6a006f47021 100644 --- a/regression/ansi-c/static_inline2/test.desc +++ b/regression/ansi-c/static_inline2/test.desc @@ -4,6 +4,5 @@ main.c ^EXIT=0$ ^SIGNAL=0$ ^VERIFICATION SUCCESSFUL$ - -- ^warning: ignoring diff --git a/regression/cbmc-incr-oneloop/unwind-forever1/test.desc b/regression/cbmc-incr-oneloop/unwind-forever1/test.desc index 617547e56ad..5d03502707e 100644 --- a/regression/cbmc-incr-oneloop/unwind-forever1/test.desc +++ b/regression/cbmc-incr-oneloop/unwind-forever1/test.desc @@ -3,6 +3,5 @@ main.c --incremental-check main.0 ^EXIT=142$ ^SIGNAL=0$ - -- ^warning: ignoring diff --git a/regression/cbmc-incr-oneloop/unwind-forever2/test.desc b/regression/cbmc-incr-oneloop/unwind-forever2/test.desc index bff68c7e0c8..920f3890da5 100644 --- a/regression/cbmc-incr-oneloop/unwind-forever2/test.desc +++ b/regression/cbmc-incr-oneloop/unwind-forever2/test.desc @@ -3,6 +3,5 @@ main.c --incremental-check main.0 ^EXIT=142$ ^SIGNAL=0$ - -- ^warning: ignoring diff --git a/regression/cbmc-java/tableswitch2/test.desc b/regression/cbmc-java/tableswitch2/test.desc index b9e08d5d49b..baee77bb8e9 100644 --- a/regression/cbmc-java/tableswitch2/test.desc +++ b/regression/cbmc-java/tableswitch2/test.desc @@ -1,7 +1,6 @@ CORE table_switch_neg_offset.class --function table_switch_neg_offset.f - ^EXIT=0$ ^SIGNAL=0$ ^VERIFICATION SUCCESSFUL$ diff --git a/regression/cpp-linter/function-comment-header1/test.desc b/regression/cpp-linter/function-comment-header1/test.desc index efaae0b7391..708eecf0783 100644 --- a/regression/cpp-linter/function-comment-header1/test.desc +++ b/regression/cpp-linter/function-comment-header1/test.desc @@ -3,6 +3,5 @@ main.cpp ^main\.cpp:26: Could not find function header comment for foo \[readability/function_comment\] \[4\] ^Total errors found: 1$ - ^SIGNAL=0$ -- diff --git a/regression/cpp-linter/struct-inline-decl/test.desc b/regression/cpp-linter/struct-inline-decl/test.desc index 4a53c26c870..12418d892f4 100644 --- a/regression/cpp-linter/struct-inline-decl/test.desc +++ b/regression/cpp-linter/struct-inline-decl/test.desc @@ -1,7 +1,6 @@ CORE main.cpp - ^Total errors found: 0$ ^EXIT=0$ ^SIGNAL=0$ diff --git a/regression/goto-analyzer/approx-array-variable-const-fp/test.desc b/regression/goto-analyzer/approx-array-variable-const-fp/test.desc index 83a930d1c36..a0db9ddeaa9 100644 --- a/regression/goto-analyzer/approx-array-variable-const-fp/test.desc +++ b/regression/goto-analyzer/approx-array-variable-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF fp_tbl\[\(signed long int\)i\] == f2 THEN GOTO [0-9]$ ^\s*IF fp_tbl\[\(signed long int\)i\] == f3 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/test.desc index a937e306d31..e6f1f4b5752 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/test.desc +++ b/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF fp == f2 THEN GOTO [0-9]$ ^\s*IF fp == f3 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/test.desc index a937e306d31..e6f1f4b5752 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/test.desc +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF fp == f2 THEN GOTO [0-9]$ ^\s*IF fp == f3 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/test.desc index a937e306d31..e6f1f4b5752 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/test.desc +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF fp == f2 THEN GOTO [0-9]$ ^\s*IF fp == f3 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc index a937e306d31..e6f1f4b5752 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF fp == f2 THEN GOTO [0-9]$ ^\s*IF fp == f3 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/test.desc index a937e306d31..e6f1f4b5752 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/test.desc +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF fp == f2 THEN GOTO [0-9]$ ^\s*IF fp == f3 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/test.desc index 6df2697851a..661ac93a14f 100644 --- a/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/test.desc +++ b/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF fp == \(const void_fp\)f2 THEN GOTO [0-9]$ ^\s*IF fp == \(const void_fp\)f3 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/no-match-const-array-const-pointer-const-fp-const-lost/test.desc b/regression/goto-analyzer/no-match-const-array-const-pointer-const-fp-const-lost/test.desc index 9ac0520abde..cb389930278 100644 --- a/regression/goto-analyzer/no-match-const-array-const-pointer-const-fp-const-lost/test.desc +++ b/regression/goto-analyzer/no-match-const-array-const-pointer-const-fp-const-lost/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF \*fp == f1 THEN GOTO [0-9]$ ^\s*IF \*fp == f2 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/test.desc b/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/test.desc index 997ec886207..a73805f5730 100644 --- a/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF fp == f1 THEN GOTO [0-9]$ ^\s*IF fp == f2 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/test.desc b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/test.desc index 997ec886207..a73805f5730 100644 --- a/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF fp == f1 THEN GOTO [0-9]$ ^\s*IF fp == f2 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/test.desc index 9c0926c2e7a..13d0c5353ce 100644 --- a/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF fp2 == f1 THEN GOTO [0-9]$ ^\s*IF fp2 == f2 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/test.desc index 9c0926c2e7a..13d0c5353ce 100644 --- a/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF fp2 == f1 THEN GOTO [0-9]$ ^\s*IF fp2 == f2 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/no-match-const-fp-binary-op-const-lost/test.desc b/regression/goto-analyzer/no-match-const-fp-binary-op-const-lost/test.desc index e8357d911c6..b9a72f79cfe 100644 --- a/regression/goto-analyzer/no-match-const-fp-binary-op-const-lost/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-binary-op-const-lost/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF fp == f1 THEN GOTO [0-9]$ ^\s*IF fp == f2 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/no-match-const-fp-const-array-index-lost/test.desc b/regression/goto-analyzer/no-match-const-fp-const-array-index-lost/test.desc index 9ac0520abde..cb389930278 100644 --- a/regression/goto-analyzer/no-match-const-fp-const-array-index-lost/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-const-array-index-lost/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF \*fp == f1 THEN GOTO [0-9]$ ^\s*IF \*fp == f2 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/no-match-const-fp-const-array-lost/test.desc b/regression/goto-analyzer/no-match-const-fp-const-array-lost/test.desc index 9ac0520abde..cb389930278 100644 --- a/regression/goto-analyzer/no-match-const-fp-const-array-lost/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-const-array-lost/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF \*fp == f1 THEN GOTO [0-9]$ ^\s*IF \*fp == f2 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/no-match-const-fp-const-cast/test.desc b/regression/goto-analyzer/no-match-const-fp-const-cast/test.desc index e8357d911c6..b9a72f79cfe 100644 --- a/regression/goto-analyzer/no-match-const-fp-const-cast/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-const-cast/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF fp == f1 THEN GOTO [0-9]$ ^\s*IF fp == f2 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/no-match-const-fp-const-lost/test.desc b/regression/goto-analyzer/no-match-const-fp-const-lost/test.desc index e8357d911c6..b9a72f79cfe 100644 --- a/regression/goto-analyzer/no-match-const-fp-const-lost/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-const-lost/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF fp == f1 THEN GOTO [0-9]$ ^\s*IF fp == f2 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/no-match-const-fp-const-pointer-const-struct-const-fp-null/test.desc b/regression/goto-analyzer/no-match-const-fp-const-pointer-const-struct-const-fp-null/test.desc index 25b505c0a0f..4786993cade 100644 --- a/regression/goto-analyzer/no-match-const-fp-const-pointer-const-struct-const-fp-null/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-const-pointer-const-struct-const-fp-null/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*ASSERT FALSE // invalid function pointer$ ^SIGNAL=0$ diff --git a/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/test.desc index 997ec886207..a73805f5730 100644 --- a/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF fp == f1 THEN GOTO [0-9]$ ^\s*IF fp == f2 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/no-match-const-fp-dereference-const-pointer-null/test.desc b/regression/goto-analyzer/no-match-const-fp-dereference-const-pointer-null/test.desc index 25b505c0a0f..4786993cade 100644 --- a/regression/goto-analyzer/no-match-const-fp-dereference-const-pointer-null/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-dereference-const-pointer-null/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*ASSERT FALSE // invalid function pointer$ ^SIGNAL=0$ diff --git a/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/test.desc index 61a7ec29e6b..f7f42277bae 100644 --- a/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF final_fp == f1 THEN GOTO [0-9]$ ^\s*IF final_fp == f2 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/no-match-const-fp-dynamic-array-non-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-dynamic-array-non-const-fp/test.desc index 997ec886207..a73805f5730 100644 --- a/regression/goto-analyzer/no-match-const-fp-dynamic-array-non-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-dynamic-array-non-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF fp == f1 THEN GOTO [0-9]$ ^\s*IF fp == f2 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/test.desc index 997ec886207..a73805f5730 100644 --- a/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF fp == f1 THEN GOTO [0-9]$ ^\s*IF fp == f2 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/test.desc index 997ec886207..a73805f5730 100644 --- a/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF fp == f1 THEN GOTO [0-9]$ ^\s*IF fp == f2 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/test.desc index 997ec886207..a73805f5730 100644 --- a/regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF fp == f1 THEN GOTO [0-9]$ ^\s*IF fp == f2 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/no-match-const-fp-null/test.desc b/regression/goto-analyzer/no-match-const-fp-null/test.desc index 267ec2284f7..d8e8d833238 100644 --- a/regression/goto-analyzer/no-match-const-fp-null/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-null/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*ASSERT FALSE // invalid function pointer$ -- diff --git a/regression/goto-analyzer/no-match-const-fp-ternerary-op-const-lost/test.desc b/regression/goto-analyzer/no-match-const-fp-ternerary-op-const-lost/test.desc index e8357d911c6..b9a72f79cfe 100644 --- a/regression/goto-analyzer/no-match-const-fp-ternerary-op-const-lost/test.desc +++ b/regression/goto-analyzer/no-match-const-fp-ternerary-op-const-lost/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF fp == f1 THEN GOTO [0-9]$ ^\s*IF fp == f2 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/no-match-const-pointer-const-struct-const-fp-const-cast/test.desc b/regression/goto-analyzer/no-match-const-pointer-const-struct-const-fp-const-cast/test.desc index 2f4b2832b4d..4e6fda43498 100644 --- a/regression/goto-analyzer/no-match-const-pointer-const-struct-const-fp-const-cast/test.desc +++ b/regression/goto-analyzer/no-match-const-pointer-const-struct-const-fp-const-cast/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF container_pointer->fp == f1 THEN GOTO [0-9]$ ^\s*IF container_pointer->fp == f2 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/test.desc b/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/test.desc index 2760fadd576..eaad08aafe0 100644 --- a/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF pts->go == f1 THEN GOTO [0-9]$ ^\s*IF pts->go == f2 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/no-match-const-struct-non-const-fp-null/test.desc b/regression/goto-analyzer/no-match-const-struct-non-const-fp-null/test.desc index 25b505c0a0f..4786993cade 100644 --- a/regression/goto-analyzer/no-match-const-struct-non-const-fp-null/test.desc +++ b/regression/goto-analyzer/no-match-const-struct-non-const-fp-null/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*ASSERT FALSE // invalid function pointer$ ^SIGNAL=0$ diff --git a/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/test.desc b/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/test.desc index 7e0aca75523..9c63fcd4c03 100644 --- a/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF \*container_ptr->fp_tbl\[\(signed long int\)1\] == f1 THEN GOTO [0-9]$ ^\s*IF \*container_ptr->fp_tbl\[\(signed long int\)1\] == f2 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/no-match-dereference-non-const-struct-const-pointer-const-fp/test.desc b/regression/goto-analyzer/no-match-dereference-non-const-struct-const-pointer-const-fp/test.desc index f55defde97b..662bd323844 100644 --- a/regression/goto-analyzer/no-match-dereference-non-const-struct-const-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-dereference-non-const-struct-const-pointer-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF \*container_container\.container == f1 THEN GOTO [0-9]$ ^\s*IF \*container_container\.container == f2 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/no-match-dereference-non-const-struct-non-const-pointer-const-fp/test.desc b/regression/goto-analyzer/no-match-dereference-non-const-struct-non-const-pointer-const-fp/test.desc index f55defde97b..662bd323844 100644 --- a/regression/goto-analyzer/no-match-dereference-non-const-struct-non-const-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-dereference-non-const-struct-non-const-pointer-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF \*container_container\.container == f1 THEN GOTO [0-9]$ ^\s*IF \*container_container\.container == f2 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/no-match-non-const-fp/test.desc b/regression/goto-analyzer/no-match-non-const-fp/test.desc index 997ec886207..a73805f5730 100644 --- a/regression/goto-analyzer/no-match-non-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-non-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF fp == f1 THEN GOTO [0-9]$ ^\s*IF fp == f2 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/no-match-parameter-const-fp/test.desc b/regression/goto-analyzer/no-match-parameter-const-fp/test.desc index 997ec886207..a73805f5730 100644 --- a/regression/goto-analyzer/no-match-parameter-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-parameter-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF fp == f1 THEN GOTO [0-9]$ ^\s*IF fp == f2 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/no-match-parameter-fp/test.desc b/regression/goto-analyzer/no-match-parameter-fp/test.desc index 997ec886207..a73805f5730 100644 --- a/regression/goto-analyzer/no-match-parameter-fp/test.desc +++ b/regression/goto-analyzer/no-match-parameter-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF fp == f1 THEN GOTO [0-9]$ ^\s*IF fp == f2 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/test.desc b/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/test.desc index 83a4d98d9f4..24a5ab5ddda 100644 --- a/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*IF container_ptr->fp_tbl\[\(signed long int\)1\] == f1 THEN GOTO [0-9]$ ^\s*IF container_ptr->fp_tbl\[\(signed long int\)1\] == f2 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/precise-const-fp-array-literal-const-fp-run-time/test.desc b/regression/goto-analyzer/precise-const-fp-array-literal-const-fp-run-time/test.desc index 6c7de56a1a0..ab2a0acefba 100644 --- a/regression/goto-analyzer/precise-const-fp-array-literal-const-fp-run-time/test.desc +++ b/regression/goto-analyzer/precise-const-fp-array-literal-const-fp-run-time/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*f3\(\);$ -- diff --git a/regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/test.desc index 2eff811f4bc..fad0e6c7a1d 100644 --- a/regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*f3\(\);$ ^SIGNAL=0$ diff --git a/regression/goto-analyzer/precise-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc index eb1e2781ef1..90cd2485ce1 100644 --- a/regression/goto-analyzer/precise-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*f2\(\); ^SIGNAL=0$ diff --git a/regression/goto-analyzer/precise-const-fp-const-struct-const-array-literal-fp/test.desc b/regression/goto-analyzer/precise-const-fp-const-struct-const-array-literal-fp/test.desc index 2eff811f4bc..fad0e6c7a1d 100644 --- a/regression/goto-analyzer/precise-const-fp-const-struct-const-array-literal-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-const-struct-const-array-literal-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*f3\(\);$ ^SIGNAL=0$ diff --git a/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/test.desc b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/test.desc index 2eff811f4bc..fad0e6c7a1d 100644 --- a/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*f3\(\);$ ^SIGNAL=0$ diff --git a/regression/goto-analyzer/precise-const-fp-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-fp/test.desc index eb1e2781ef1..90cd2485ce1 100644 --- a/regression/goto-analyzer/precise-const-fp-const-struct-non-const-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*f2\(\); ^SIGNAL=0$ diff --git a/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/test.desc index 2eff811f4bc..fad0e6c7a1d 100644 --- a/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*f3\(\);$ ^SIGNAL=0$ diff --git a/regression/goto-analyzer/precise-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp/test.desc index ef4cf690b60..4dd6e7fd098 100644 --- a/regression/goto-analyzer/precise-const-fp/test.desc +++ b/regression/goto-analyzer/precise-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*f2\(\); -- diff --git a/regression/goto-analyzer/precise-const-pointer-const-struct-fp/test.desc b/regression/goto-analyzer/precise-const-pointer-const-struct-fp/test.desc index 0de6942ba42..40361f6ccc2 100644 --- a/regression/goto-analyzer/precise-const-pointer-const-struct-fp/test.desc +++ b/regression/goto-analyzer/precise-const-pointer-const-struct-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*f2\(\);$ ^SIGNAL=0$ diff --git a/regression/goto-analyzer/precise-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/precise-const-struct-non-const-fp/test.desc index eb1e2781ef1..90cd2485ce1 100644 --- a/regression/goto-analyzer/precise-const-struct-non-const-fp/test.desc +++ b/regression/goto-analyzer/precise-const-struct-non-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*f2\(\); ^SIGNAL=0$ diff --git a/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/test.desc b/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/test.desc index 2eff811f4bc..fad0e6c7a1d 100644 --- a/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*f3\(\);$ ^SIGNAL=0$ diff --git a/regression/goto-analyzer/precise-derefence/test.desc b/regression/goto-analyzer/precise-derefence/test.desc index ef4cf690b60..4dd6e7fd098 100644 --- a/regression/goto-analyzer/precise-derefence/test.desc +++ b/regression/goto-analyzer/precise-derefence/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*f2\(\); -- diff --git a/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/test.desc b/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/test.desc index 2eff811f4bc..fad0e6c7a1d 100644 --- a/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*f3\(\);$ ^SIGNAL=0$ diff --git a/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-fp/test.desc b/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-fp/test.desc index 2eff811f4bc..fad0e6c7a1d 100644 --- a/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*f3\(\);$ ^SIGNAL=0$ diff --git a/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-struct-const-fp/test.desc b/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-struct-const-fp/test.desc index 2eff811f4bc..fad0e6c7a1d 100644 --- a/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-struct-const-fp/test.desc +++ b/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-struct-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*f3\(\);$ ^SIGNAL=0$ diff --git a/regression/goto-analyzer/precise-dereference-const-struct-pointer-const-fp/test.desc b/regression/goto-analyzer/precise-dereference-const-struct-pointer-const-fp/test.desc index 2eff811f4bc..fad0e6c7a1d 100644 --- a/regression/goto-analyzer/precise-dereference-const-struct-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/precise-dereference-const-struct-pointer-const-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check - ^Removing function pointers and virtual functions$ ^\s*f3\(\);$ ^SIGNAL=0$ diff --git a/regression/goto-instrument/approx-array-variable-const-fp-only-remove-const/test.desc b/regression/goto-instrument/approx-array-variable-const-fp-only-remove-const/test.desc index f58b03a58b3..83e4f545415 100644 --- a/regression/goto-instrument/approx-array-variable-const-fp-only-remove-const/test.desc +++ b/regression/goto-instrument/approx-array-variable-const-fp-only-remove-const/test.desc @@ -1,7 +1,6 @@ CORE main.c --verbosity 10 --pointer-check --remove-const-function-pointers - ^\s*IF fp_tbl\[\(signed long int\)i\] == f2 THEN GOTO [0-9]$ ^\s*IF fp_tbl\[\(signed long int\)i\] == f3 THEN GOTO [0-9]$ ^\s*IF fp_tbl\[\(signed long int\)i\] == f4 THEN GOTO [0-9]$ diff --git a/regression/goto-instrument/approx-array-variable-const-fp-remove-all-fp/test.desc b/regression/goto-instrument/approx-array-variable-const-fp-remove-all-fp/test.desc index 3d065f1a742..35ed94ae046 100644 --- a/regression/goto-instrument/approx-array-variable-const-fp-remove-all-fp/test.desc +++ b/regression/goto-instrument/approx-array-variable-const-fp-remove-all-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --verbosity 10 --pointer-check --remove-function-pointers - ^\s*IF fp_tbl\[\(signed long int\)i\] == f2 THEN GOTO [0-9]$ ^\s*IF fp_tbl\[\(signed long int\)i\] == f3 THEN GOTO [0-9]$ ^\s*IF fp_tbl\[\(signed long int\)i\] == f4 THEN GOTO [0-9]$ diff --git a/regression/goto-instrument/no-match-non-const-fp-only-remove-const/test.desc b/regression/goto-instrument/no-match-non-const-fp-only-remove-const/test.desc index 3b016907a44..9c23726e83c 100644 --- a/regression/goto-instrument/no-match-non-const-fp-only-remove-const/test.desc +++ b/regression/goto-instrument/no-match-non-const-fp-only-remove-const/test.desc @@ -1,7 +1,6 @@ CORE main.c --verbosity 10 --pointer-check --remove-const-function-pointers - ^\s*fp\(\);$ ^SIGNAL=0$ -- diff --git a/regression/goto-instrument/no-match-non-const-fp-remove-all-fp/test.desc b/regression/goto-instrument/no-match-non-const-fp-remove-all-fp/test.desc index 3190d348aae..46c2f8cd2d4 100644 --- a/regression/goto-instrument/no-match-non-const-fp-remove-all-fp/test.desc +++ b/regression/goto-instrument/no-match-non-const-fp-remove-all-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --verbosity 10 --pointer-check --remove-function-pointers - ^\s*IF fp == f1 THEN GOTO [0-9]$ ^\s*IF fp == f2 THEN GOTO [0-9]$ ^\s*IF fp == f3 THEN GOTO [0-9]$ diff --git a/regression/goto-instrument/precise-const-fp-only-remove-const/test.desc b/regression/goto-instrument/precise-const-fp-only-remove-const/test.desc index 2304d56b239..cdf49005c0b 100644 --- a/regression/goto-instrument/precise-const-fp-only-remove-const/test.desc +++ b/regression/goto-instrument/precise-const-fp-only-remove-const/test.desc @@ -1,7 +1,6 @@ CORE main.c --verbosity 10 --pointer-check --remove-const-function-pointers - ^\s*f2\(\); -- ^warning: ignoring diff --git a/regression/goto-instrument/precise-const-fp-remove-all-fp/test.desc b/regression/goto-instrument/precise-const-fp-remove-all-fp/test.desc index dd072b1c232..a559b2b1747 100644 --- a/regression/goto-instrument/precise-const-fp-remove-all-fp/test.desc +++ b/regression/goto-instrument/precise-const-fp-remove-all-fp/test.desc @@ -1,7 +1,6 @@ CORE main.c --verbosity 10 --pointer-check --remove-function-pointers - ^\s*f2\(\); -- ^warning: ignoring From 82cbd73d43dbedb37c50b833bd8536299c3c0200 Mon Sep 17 00:00:00 2001 From: Vojtech Forejt Date: Thu, 6 Apr 2017 17:19:18 +0100 Subject: [PATCH 104/116] Allow long long int instead of just long int in regexp of some tests. This prevents spurious test failures on Windows. Fixes #769. --- .../approx-array-variable-const-fp/test.desc | 18 +++++++++--------- .../test.desc | 18 +++++++++--------- .../test.desc | 18 +++++++++--------- .../test.desc | 18 +++++++++--------- .../test.desc | 18 +++++++++--------- 5 files changed, 45 insertions(+), 45 deletions(-) diff --git a/regression/goto-analyzer/approx-array-variable-const-fp/test.desc b/regression/goto-analyzer/approx-array-variable-const-fp/test.desc index a0db9ddeaa9..38027f70600 100644 --- a/regression/goto-analyzer/approx-array-variable-const-fp/test.desc +++ b/regression/goto-analyzer/approx-array-variable-const-fp/test.desc @@ -2,15 +2,15 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF fp_tbl\[\(signed long int\)i\] == f2 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[\(signed long int\)i\] == f3 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[\(signed long int\)i\] == f4 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f2 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f3 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f4 THEN GOTO [0-9]$ ^SIGNAL=0$ -- -^\s*IF fp_tbl\[\(signed long int\)i\] == f1 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[\(signed long int\)i\] == f5 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[\(signed long int\)i\] == f6 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[\(signed long int\)i\] == f7 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[\(signed long int\)i\] == f8 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[\(signed long int\)i\] == f9 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f1 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f5 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f6 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f7 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f8 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f9 THEN GOTO [0-9]$ ^warning: ignoring diff --git a/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/test.desc b/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/test.desc index 9c63fcd4c03..ef491f67113 100644 --- a/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/test.desc @@ -2,15 +2,15 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF \*container_ptr->fp_tbl\[\(signed long int\)1\] == f1 THEN GOTO [0-9]$ -^\s*IF \*container_ptr->fp_tbl\[\(signed long int\)1\] == f2 THEN GOTO [0-9]$ -^\s*IF \*container_ptr->fp_tbl\[\(signed long int\)1\] == f3 THEN GOTO [0-9]$ -^\s*IF \*container_ptr->fp_tbl\[\(signed long int\)1\] == f4 THEN GOTO [0-9]$ -^\s*IF \*container_ptr->fp_tbl\[\(signed long int\)1\] == f5 THEN GOTO [0-9]$ -^\s*IF \*container_ptr->fp_tbl\[\(signed long int\)1\] == f6 THEN GOTO [0-9]$ -^\s*IF \*container_ptr->fp_tbl\[\(signed long int\)1\] == f7 THEN GOTO [0-9]$ -^\s*IF \*container_ptr->fp_tbl\[\(signed long int\)1\] == f8 THEN GOTO [0-9]$ -^\s*IF \*container_ptr->fp_tbl\[\(signed long int\)1\] == f9 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f1 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f2 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f3 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f4 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f5 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f6 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f7 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f8 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f9 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/test.desc b/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/test.desc index 24a5ab5ddda..a85714b51a1 100644 --- a/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/test.desc +++ b/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/test.desc @@ -2,15 +2,15 @@ CORE main.c --show-goto-functions --verbosity 10 --pointer-check ^Removing function pointers and virtual functions$ -^\s*IF container_ptr->fp_tbl\[\(signed long int\)1\] == f1 THEN GOTO [0-9]$ -^\s*IF container_ptr->fp_tbl\[\(signed long int\)1\] == f2 THEN GOTO [0-9]$ -^\s*IF container_ptr->fp_tbl\[\(signed long int\)1\] == f3 THEN GOTO [0-9]$ -^\s*IF container_ptr->fp_tbl\[\(signed long int\)1\] == f4 THEN GOTO [0-9]$ -^\s*IF container_ptr->fp_tbl\[\(signed long int\)1\] == f5 THEN GOTO [0-9]$ -^\s*IF container_ptr->fp_tbl\[\(signed long int\)1\] == f6 THEN GOTO [0-9]$ -^\s*IF container_ptr->fp_tbl\[\(signed long int\)1\] == f7 THEN GOTO [0-9]$ -^\s*IF container_ptr->fp_tbl\[\(signed long int\)1\] == f8 THEN GOTO [0-9]$ -^\s*IF container_ptr->fp_tbl\[\(signed long int\)1\] == f9 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f1 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f2 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f3 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f4 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f5 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f6 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f7 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f8 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f9 THEN GOTO [0-9]$ ^SIGNAL=0$ -- ^warning: ignoring diff --git a/regression/goto-instrument/approx-array-variable-const-fp-only-remove-const/test.desc b/regression/goto-instrument/approx-array-variable-const-fp-only-remove-const/test.desc index 83e4f545415..bc553fa5a0f 100644 --- a/regression/goto-instrument/approx-array-variable-const-fp-only-remove-const/test.desc +++ b/regression/goto-instrument/approx-array-variable-const-fp-only-remove-const/test.desc @@ -1,15 +1,15 @@ CORE main.c --verbosity 10 --pointer-check --remove-const-function-pointers -^\s*IF fp_tbl\[\(signed long int\)i\] == f2 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[\(signed long int\)i\] == f3 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[\(signed long int\)i\] == f4 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f2 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f3 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f4 THEN GOTO [0-9]$ ^SIGNAL=0$ -- -^\s*IF fp_tbl\[\(signed long int\)i\] == f1 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[\(signed long int\)i\] == f5 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[\(signed long int\)i\] == f6 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[\(signed long int\)i\] == f7 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[\(signed long int\)i\] == f8 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[\(signed long int\)i\] == f9 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f1 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f5 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f6 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f7 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f8 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f9 THEN GOTO [0-9]$ ^warning: ignoring diff --git a/regression/goto-instrument/approx-array-variable-const-fp-remove-all-fp/test.desc b/regression/goto-instrument/approx-array-variable-const-fp-remove-all-fp/test.desc index 35ed94ae046..e9ede02a296 100644 --- a/regression/goto-instrument/approx-array-variable-const-fp-remove-all-fp/test.desc +++ b/regression/goto-instrument/approx-array-variable-const-fp-remove-all-fp/test.desc @@ -1,15 +1,15 @@ CORE main.c --verbosity 10 --pointer-check --remove-function-pointers -^\s*IF fp_tbl\[\(signed long int\)i\] == f2 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[\(signed long int\)i\] == f3 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[\(signed long int\)i\] == f4 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f2 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f3 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f4 THEN GOTO [0-9]$ ^SIGNAL=0$ -- -^\s*IF fp_tbl\[\(signed long int\)i\] == f1 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[\(signed long int\)i\] == f5 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[\(signed long int\)i\] == f6 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[\(signed long int\)i\] == f7 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[\(signed long int\)i\] == f8 THEN GOTO [0-9]$ -^\s*IF fp_tbl\[\(signed long int\)i\] == f9 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f1 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f5 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f6 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f7 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f8 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f9 THEN GOTO [0-9]$ ^warning: ignoring From 5df0da698685f21166116247e08405213cd1a2e3 Mon Sep 17 00:00:00 2001 From: Daniel Kroening Date: Fri, 7 Apr 2017 12:18:39 +0100 Subject: [PATCH 105/116] fix for wrong refactoring to ranged-for --- src/solvers/qbf/qbf_bdd_core.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/solvers/qbf/qbf_bdd_core.cpp b/src/solvers/qbf/qbf_bdd_core.cpp index 7071a6abc66..9fa58639ad0 100644 --- a/src/solvers/qbf/qbf_bdd_core.cpp +++ b/src/solvers/qbf/qbf_bdd_core.cpp @@ -445,7 +445,7 @@ void qbf_bdd_coret::compress_certificate(void) if(model==bdd_manager->bddOne() || model==bdd_manager->bddZero()) { - for(const quantifiert &quantifier2 : quantifier) + for(const quantifiert &quantifier2 : quantifiers) { BDD &model2=*model_bdds[quantifier2.var_no]; From 0d7975c5cbc5de2477cfa01c50ab02b5f5c896e1 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Fri, 7 Apr 2017 12:40:00 +0100 Subject: [PATCH 106/116] musketeer: fix edge types Fixes: #778 --- src/musketeer/fence_inserter.cpp | 20 ++++++++++---------- src/musketeer/fence_inserter.h | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/musketeer/fence_inserter.cpp b/src/musketeer/fence_inserter.cpp index dc1de9fb037..20236dfb956 100644 --- a/src/musketeer/fence_inserter.cpp +++ b/src/musketeer/fence_inserter.cpp @@ -494,7 +494,7 @@ void inline fence_insertert::mip_fill_matrix( e_c_it!=e_i->end(); ++e_c_it) { - std::set pt_set; + std::set pt_set; assert(map_to_e.find(*e_c_it)!=map_to_e.end()); const_graph_visitor.PT(map_to_e.find(*e_c_it)->second, pt_set); /* sum_e' f_e' */ @@ -538,7 +538,7 @@ void inline fence_insertert::mip_fill_matrix( e_nc_it!=e_i->end(); ++e_nc_it) { - std::set pt_set; + std::set pt_set; assert(map_to_e.find(*e_nc_it)!=map_to_e.end()); const_graph_visitor.PT(map_to_e.find(*e_nc_it)->second, pt_set); /* sum_e' (f_e' + lwf_e') */ @@ -582,7 +582,7 @@ void inline fence_insertert::mip_fill_matrix( e_nc_it!=e_i->end(); ++e_nc_it) { - std::set pt_set; + std::set pt_set; assert(map_to_e.find(*e_nc_it)!=map_to_e.end()); const_graph_visitor.PT(map_to_e.find(*e_nc_it)->second, pt_set); /* dp_e + sum_e' (f_e' + lwf_e' + br_e') */ @@ -649,12 +649,12 @@ void inline fence_insertert::mip_fill_matrix( e_nc_it!=e_i->end(); ++e_nc_it) { - std::set pt_set; + std::set pt_set; assert(map_to_e.find(*e_nc_it)!=map_to_e.end()); const_graph_visitor.PT(map_to_e.find(*e_nc_it)->second, pt_set); // uncomment for cf #if 0 - std::set it_set; + std::set it_set; IT(map_to_e.find(*e_nc_it)->second, it_set); #endif /* dp_e + sum_e' (f_e' + lwf_e') + sum_e'' cf_e'') */ @@ -722,13 +722,13 @@ void inline fence_insertert::mip_fill_matrix( { unsigned possibilities_met=0; - std::set ct_set; + std::set ct_set; assert(invisible_var.map_to_e.find(*e_c_it)!= invisible_var.map_to_e.end()); const_graph_visitor.CT(invisible_var.map_to_e.find(*e_c_it)->second, ct_set); - std::set ct_not_powr_set; + std::set ct_not_powr_set; const_graph_visitor.CT_not_powr(invisible_var.map_to_e.find( *e_c_it)->second, ct_not_powr_set); @@ -801,7 +801,7 @@ void fence_insertert::solve() assert(i-1==constraints_number); const std::size_t const_constraints_number=constraints_number; - const event_idt const_unique=unique; + const unsigned const_unique=unique; const std::size_t mat_size= // NOLINTNEXTLINE(whitespace/operators) @@ -1234,13 +1234,13 @@ void fence_insertert::print_vars() const { instrumenter.message.statistics() << "---- pos/pos+ (visible) variables ----" << messaget::eom; - for(std::map::const_iterator it=map_from_e.begin(); + for(std::map::const_iterator it=map_from_e.begin(); it!=map_from_e.end(); ++it) instrumenter.message.statistics() << it->first.first << "," << it->first.second << messaget::eom; instrumenter.message.statistics() << "---- cmp (invisible) variables ----" << messaget::eom; - for(std::map::const_iterator it= + for(std::map::const_iterator it= invisible_var.map_from_e.begin(); it!=invisible_var.map_from_e.end(); ++it) instrumenter.message.statistics() << it->first.first << "," diff --git a/src/musketeer/fence_inserter.h b/src/musketeer/fence_inserter.h index eaabff176ff..8f5e6286407 100644 --- a/src/musketeer/fence_inserter.h +++ b/src/musketeer/fence_inserter.h @@ -30,19 +30,19 @@ struct mip_vart { typedef event_grapht::critical_cyclet::delayt edget; - event_idt unique; + unsigned unique; - std::map map_to_e; - std::map map_from_e; + std::map map_to_e; + std::map map_from_e; - event_idt add_edge(const edget &e) + unsigned add_edge(const edget &e) { if(map_from_e.find(e) != map_from_e.end()) return map_from_e[e]; else { ++unique; - map_to_e.insert(std::pair(unique, e)); + map_to_e.insert(std::pair(unique, e)); map_from_e[e] = unique; return unique; } @@ -62,10 +62,10 @@ class fence_insertert instrumentert &instrumenter; /* normal variables used almost everytime */ - std::map &map_to_e; - std::map &map_from_e; - event_idt add_edge(const edget &e) { return var.add_edge(e); } - event_idt add_invisible_edge(const edget &e) + std::map &map_to_e; + std::map &map_from_e; + unsigned add_edge(const edget &e) { return var.add_edge(e); } + unsigned add_invisible_edge(const edget &e) { return invisible_var.add_edge(e); } @@ -78,7 +78,7 @@ class fence_insertert const_graph_visitort const_graph_visitor; protected: - event_idt &unique; + unsigned &unique; unsigned fence_options; /* MIP variables to edges in po^+/\C */ From 31ea4c3c9bab2f5dc6177ca55fa06791a81659cb Mon Sep 17 00:00:00 2001 From: thk123 Date: Thu, 6 Apr 2017 17:16:56 +0100 Subject: [PATCH 107/116] Adding build icon for AppVeyor --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bb1bf51de0a..e1c2b090091 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build Status][build_img]][travis] +[![Build Status][travis_img]][travis] [![Build Status][appveyor_img]][appveyor] [CProver Wiki](http://www.cprover.org/wiki) @@ -19,5 +19,7 @@ License ======= 4-clause BSD license, see `LICENSE` file. -[build_img]: https://travis-ci.org/diffblue/cbmc.svg?branch=master [travis]: https://travis-ci.org/diffblue/cbmc +[travis_img]: https://travis-ci.org/diffblue/cbmc.svg?branch=master +[appveyor]: https://ci.appveyor.com/project/diffblue/cbmc/ +[appveyor_img]: https://ci.appveyor.com/api/projects/status/github/diffblue/cbmc?svg=true&branch=master \ No newline at end of file From 219b8bd2cbc51e050616d3a6dc4f550539225497 Mon Sep 17 00:00:00 2001 From: Owen Jones Date: Thu, 6 Apr 2017 15:12:56 +0100 Subject: [PATCH 108/116] Make it clear test isn't really working CBMC can't cope with arrays as parameters to C functions yet. It assumes they are null pointers. I'm not sure why this test was passing, but refactoring it to not use arrays makes it clear it shouldn't be. (Also remove some unneeded whitespace.) --- regression/cbmc/unsigned___int128/main.c | 18 +++++++++++------- regression/cbmc/unsigned___int128/test.desc | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/regression/cbmc/unsigned___int128/main.c b/regression/cbmc/unsigned___int128/main.c index b695484a332..21cfcf4a0df 100644 --- a/regression/cbmc/unsigned___int128/main.c +++ b/regression/cbmc/unsigned___int128/main.c @@ -1,6 +1,6 @@ # include -typedef unsigned __int128 uint128_t; +typedef unsigned __int128 uint128_t; typedef uint64_t limb; typedef uint128_t widelimb; @@ -8,9 +8,9 @@ typedef uint128_t widelimb; typedef limb felem[4]; typedef widelimb widefelem[7]; -felem p = {0x1FFFFFFFFFFFFFF, - 0xFFFFFFFFFFFFFF, - 0xFFFFE000000000, +felem p = {0x1FFFFFFFFFFFFFF, + 0xFFFFFFFFFFFFFF, + 0xFFFFE000000000, 0x00000000000002}; @@ -18,8 +18,12 @@ felem p = {0x1FFFFFFFFFFFFFF, * Reduce seven 128-bit coefficients to four 64-bit coefficients. * Requires in[i] < 2^126, * ensures out[0] < 2^56, out[1] < 2^56, out[2] < 2^56, out[3] <= 2^56 + 2^16 */ -void reduce(felem out, const widefelem in) +void reduce( + limb out0, limb out1, limb out2, limb out3, widelimb in0, widelimb in1, + widelimb in2, widelimb in3, widelimb in4, widelimb in5, widelimb in6) { + felem out = {out0, out1, out2, out3}; + const widefelem in = {in0, in1, in2, in3, in4, in5, in6}; __CPROVER_assume(in[0]<(widelimb)((widelimb)1<<126)); __CPROVER_assume(in[1]<((widelimb)1<<126)); @@ -75,9 +79,9 @@ void reduce(felem out, const widefelem in) output[2] += output[1] >> 56; /* output[2] < 2^57 + 2^72 */ - + assert(output[2] < (((widelimb)1)<<57)+(((widelimb)1)<<72)); - + out[1] = output[1] & 0x00ffffffffffffff; output[3] += output[2] >> 56; /* output[3] <= 2^56 + 2^16 */ diff --git a/regression/cbmc/unsigned___int128/test.desc b/regression/cbmc/unsigned___int128/test.desc index 67b0294bc90..aaeabeba360 100644 --- a/regression/cbmc/unsigned___int128/test.desc +++ b/regression/cbmc/unsigned___int128/test.desc @@ -1,4 +1,4 @@ -CORE +KNOWNBUG main.c --unsigned-overflow-check --signed-overflow-check --function reduce ^EXIT=0$ From 8dcd386add4214eb95012a3816ae817fac5a658d Mon Sep 17 00:00:00 2001 From: Owen Jones Date: Thu, 6 Apr 2017 15:44:59 +0100 Subject: [PATCH 109/116] Make test work again and turn it on Three assumptions were missing. Now the test works and we can turn it back on. --- regression/cbmc/unsigned___int128/main.c | 3 +++ regression/cbmc/unsigned___int128/test.desc | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/regression/cbmc/unsigned___int128/main.c b/regression/cbmc/unsigned___int128/main.c index 21cfcf4a0df..b3bfbd5ea28 100644 --- a/regression/cbmc/unsigned___int128/main.c +++ b/regression/cbmc/unsigned___int128/main.c @@ -29,6 +29,9 @@ void reduce( __CPROVER_assume(in[1]<((widelimb)1<<126)); __CPROVER_assume(in[2]<((widelimb)1<<126)); __CPROVER_assume(in[3]<((widelimb)1<<126)); + __CPROVER_assume(in[4]<((widelimb)1<<126)); + __CPROVER_assume(in[5]<((widelimb)1<<126)); + __CPROVER_assume(in[6]<((widelimb)1<<126)); static const widelimb two127p15 = (((widelimb) 1) << 127) + (((widelimb) 1) << 15); diff --git a/regression/cbmc/unsigned___int128/test.desc b/regression/cbmc/unsigned___int128/test.desc index aaeabeba360..67b0294bc90 100644 --- a/regression/cbmc/unsigned___int128/test.desc +++ b/regression/cbmc/unsigned___int128/test.desc @@ -1,4 +1,4 @@ -KNOWNBUG +CORE main.c --unsigned-overflow-check --signed-overflow-check --function reduce ^EXIT=0$ From ff0088fafe876b29d84775855272008ed8b44346 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Tue, 4 Apr 2017 15:10:37 +0100 Subject: [PATCH 110/116] Provide statistics of function-pointer removal --- src/goto-programs/remove_function_pointers.cpp | 5 +++++ src/musketeer/musketeer_parse_options.cpp | 13 +++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/goto-programs/remove_function_pointers.cpp b/src/goto-programs/remove_function_pointers.cpp index c67c834b2ce..2d5be9c0ab2 100644 --- a/src/goto-programs/remove_function_pointers.cpp +++ b/src/goto-programs/remove_function_pointers.cpp @@ -503,6 +503,11 @@ void remove_function_pointerst::remove_function_pointer( code_expression.expression()=function; target->code.swap(code_expression); target->type=OTHER; + + // report statistics + statistics().source_location=target->source_location; + statistics() << "replacing function pointer by " + << functions.size() << " possible targets" << eom; } /*******************************************************************\ diff --git a/src/musketeer/musketeer_parse_options.cpp b/src/musketeer/musketeer_parse_options.cpp index f2ca143683f..ae40a2f2318 100644 --- a/src/musketeer/musketeer_parse_options.cpp +++ b/src/musketeer/musketeer_parse_options.cpp @@ -244,14 +244,11 @@ void goto_fence_inserter_parse_optionst::instrument_goto_program( // return; #if 0 status() << "Function Pointer Removal" << eom; - remove_function_pointers(symbol_table, goto_functions, - cmdline.isset("pointer-check")); -#endif - -#if 0 - // do partial inlining - status() << "Partial Inlining" << eom; - goto_partial_inline(goto_functions, ns, ui_message_handler); + remove_function_pointers( + get_message_handler(), + symbol_table, + goto_functions, + cmdline.isset("pointer-check"); #endif status() << "Pointer Analysis" << eom; From 4b42ad66f7f3378bcc0569a23832a51aa24f7074 Mon Sep 17 00:00:00 2001 From: Vojtech Forejt Date: Fri, 7 Apr 2017 16:16:40 +0100 Subject: [PATCH 111/116] Speed up OSX builds on Travis. Do not autoupdate Homebrew, and limit cache size to 1G. --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 54078b93f76..a2396927dab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,8 +24,9 @@ matrix: before_install: #we create symlink to non-ccache gcc, to be used in tests - mkdir bin ; ln -s /usr/bin/gcc bin/gcc - - brew install ccache + - HOMEBREW_NO_AUTO_UPDATE=1 brew install ccache - export PATH=/usr/local/opt/ccache/libexec:$PATH + - ccache -M 1G env: COMPILER=g++ # OS X using clang++ @@ -34,11 +35,12 @@ matrix: compiler: clang cache: ccache before_install: - - brew install ccache + - HOMEBREW_NO_AUTO_UPDATE=1 brew install ccache - export PATH=/usr/local/opt/ccache/libexec:$PATH env: - COMPILER="ccache clang++ -Qunused-arguments -fcolor-diagnostics" - CCACHE_CPP2=yes + - ccache -M 1G # Ubuntu Linux with glibc using g++-5 - os: linux From 2dc514a07c10d1f026bb58826251f10488ff70f1 Mon Sep 17 00:00:00 2001 From: Vojtech Forejt Date: Fri, 7 Apr 2017 17:17:53 +0100 Subject: [PATCH 112/116] Add appveyor.yml Currently we use config set in an AppVeyor UI, which is inconvenient: It is tedious to edit, and config cannot be modified per branch. With this commit, we are taking a similar approach as the one Travis has. The config file largely mirrors what was being used in the UI config up until now. There is a couple of tests we delete before `make test` is run, see #623 for more info. --- appveyor.yml | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000000..5f287b193d4 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,110 @@ +version: 1.0.{build} +image: Visual Studio 2013 +clone_depth: 50 +environment: + BUILD_ENV: MSVC + PATH: C:\projects\cbmc\deps\bin;%PATH% + INCLUDE: C:\projects\cbmc\deps\include +install: +- ps: | + #check if dependencies were copied from cache, if not, download them. + if (!(Test-Path deps)) { + md deps + } + cd deps + if (!(Test-Path bin\bison.exe)) { + & appveyor DownloadFile "https://storage.googleapis.com/diffblue-mirror/appveyor-deps/bison-2.4.1-bin.zip?GoogleAccessId=diffbluemaster@diffblue-cr.iam.gserviceaccount.com&Expires=1519839050&Signature=JAPFzNPMJDI4IViAVlJAEc6l8aHB3k17NpZRdoWDMLbALaJNX88vfwocuezU1tfhyrSJxfo2fTK4rgP5OULkikJs7MBZI9ovp2V%2BMT6yg87KDdH9EIOlMgltGfbP%2BoZkwBY7kXb3W5puSlt4OTE%2Bw7CRlHF9MNqFXVBqVBfa%2BGw0gXDe5Jd9qV%2BvUXZzRuBl9ERSQkSD%2B%2B%2BxFo24FZoOeYkgBHJz03%2BHuIMnlmcLgneTB2aiZZU3%2B6UTPceUxLus9%2Bksb5UbqEVaVE06TIXl76VKwqAgXM2LWaNyeJDog%2BT%2BhjW4v4ypxh6mIBo5KRNXVLPc1MxSPFQB3ITlIXv9Zg%3D%3D" + & 7z x bison-2.4.1-bin.zip + } + if (!(Test-Path bin\flex.exe)) { + & appveyor DownloadFile "https://storage.googleapis.com/diffblue-mirror/appveyor-deps/flex-2.5.4a-1-bin.zip?GoogleAccessId=diffbluemaster@diffblue-cr.iam.gserviceaccount.com&Expires=1519839050&Signature=WriP8S047Mmq271ZHWL0MCPGx1gEFsuc%2BKMmChoXhXFRkn0GlIgCxZEiOu52ke9fT1kAvycWXePNBFAyCHjpF%2BJkXCwisQ6FLIf3NL%2F92849YgQKdJkDUOcZ%2Bh82XVTwNBrljKIkExkak7QEyhOf3buTC1oeuatCUV5Ez42RZjgtRiJaqcFW6xLbhfuVONr39KxH5hGx%2FDUi2RRXPbgoKDwavc9s56NP1rNbWMTE6NdNHzJeaf43E%2BSMemlVO%2BhhIY6W0f%2FtaQ7fYF%2F6YaqxdQ0sB8W5DnG4Hb%2F0CyQlrTZpGDXGr301rV0M4WBkYLmfauq4IyJsBaR095tXGW%2BzmA%3D%3D" + & 7z x flex-2.5.4a-1-bin.zip + } + if (!(Test-Path include\FlexLexer.h)) { + & appveyor DownloadFile "https://storage.googleapis.com/diffblue-mirror/appveyor-deps/flex-2.5.4a-1-lib.zip?GoogleAccessId=diffbluemaster@diffblue-cr.iam.gserviceaccount.com&Expires=1519839050&Signature=H%2FLeKGv2QqKAGDTP%2F6TYPhDzuL6K%2F5dFOt61HfYBm1vUWVUNmAYVGvUAcvnUqBnhEHwZgtc8vZt1H7k3W8azxCUc7l6ZhlCDbqQ6Mg2VhfpBaQMbL1V%2BjSq5ePpWcuLMBntKk2br38PF1NtiAwCCpRTRPptaYPeGs%2BOjAH%2BN8aIIxjvj45QAgt9mcg6dfBsyfj5fdJmpHRQFuJ7%2FnsG50fmN5JDvdvmBWloB6rjxVWaN4XO6VTWZFZ34JWFyOqgWNEw9aDN3HdsSuJ0Uz19AbdwZBIWe5Elrl71rRJjn1lijCknDB7D4sAmP33k71e%2BB0qvsNl1Shuh9FkY8Z6y05Q%3D%3D" + & 7z x flex-2.5.4a-1-lib.zip + } + if (!(Test-Path bin\iconv.exe)) { + & appveyor DownloadFile "https://storage.googleapis.com/diffblue-mirror/appveyor-deps/libiconv-1.9.2-1-bin.zip?GoogleAccessId=diffbluemaster@diffblue-cr.iam.gserviceaccount.com&Expires=1519839050&Signature=sS3Y2lC1oWOhBDsL8C9ASuO4LOM%2BpB%2F8PwG5w5CdB9JnPfLqhb3FnA1zkkZJoSNuIYS3DM6CN2qxoWjpJbLEtVQe0PpxziQZjLpJw2MpxXdJiJHRDu8x9THgzwuZ3ze5BWHzPoCBQPdRkKzVPezf1HwptUsm3Y9c2jlWljQjhc8NVsI4iPmjEOwT8E%2BYpR5fsLs2GsRjuoyqKa%2Bi4JJ6MbpXVX1IgR4fzp1Li9SnE39ujHDb%2FyI3c96eCdVm1Oa6jNxzSJNfq%2FgOZM8BIxlR55a%2BtM3oBQhU0voEtDOABwuO7ZBay8dLt%2FG5vz1%2Bi%2FIlRLFxQfICaprPLzw6pXRm8Q%3D%3D" + & 7z x libiconv-1.9.2-1-bin.zip + } + if (!(Test-Path bin\libintl3.dll)) { + & appveyor DownloadFile "https://storage.googleapis.com/diffblue-mirror/appveyor-deps/libintl-0.14.4-bin.zip?GoogleAccessId=diffbluemaster@diffblue-cr.iam.gserviceaccount.com&Expires=1519839050&Signature=lJViGr6bl%2F4i%2B6nIfeYChreq%2FKfgid9QqGSq7Ie%2FMG%2Fmr9nPyPUA%2BLtT7jn1ogunTzQLZP%2FNxVFcYqyd8gyuT%2Bn2MF80Ds4Whw4cRYnXPb2LZg4%2FiEqZV6wgBMIQfq5v2l3lAsglISVErOik%2BQAHec5gZe2%2BKaVjRnJnhPRziZkQyzF9Xdf2xsPi28hBaX4RQx8XqSLcY1kQpY13PDBZDi9lmdKHf0pBKu%2F0WXspmRAU02HtleMk6Zeg5vEDFcwoe8C3fb4vwtpwGwN9TX5ddaq56yUVn70zh%2BH2KgKIsRl26avnrCpeWF9M5lLck0ngaqFX84w%2BgxmZu40IVU%2Ff0A%3D%3D" + & 7z x libintl-0.14.4-bin.zip + } + if (!(Test-Path bin\make.exe)) { + & appveyor DownloadFile "https://storage.googleapis.com/diffblue-mirror/appveyor-deps/make-3.81-bin.zip?GoogleAccessId=diffbluemaster@diffblue-cr.iam.gserviceaccount.com&Expires=1519839050&Signature=PRC97AWzJ2ZAyjEK4p7eCbA3RAEr8sTf8TUK5zoMBcrXPUHWYjnCwXRMnIxUUufBYjsAx8t1XnOQdlTuAPJYpcha%2FFJRlcxMmfQjNbpNEQFJuqEpA5c%2FGhFYxSD3a26vjpgReUW5MuQXeLeNh7PziLB0GP0sdRHN%2B1eDiHeCJWYNMYhrEY9BAkf5rXeRQWr1ZG0Hzq%2FxZEHceypx8xyaT%2BFzREYQOyKjGdre1QXtI%2FXo4ImA1xWt%2F8TnlGcAnCEaTltxuSRVB%2F7s1ShMr9KoagCb%2BjBWq6BgbcNGxyzyOZfi2Sjjo39mhudF9DNbKbkczes9Kp3ySgXmrXSWjIG4Iw%3D%3D" + & 7z x make-3.81-bin.zip + } + if (!(Test-Path bin\regex2.dll)) { + & appveyor DownloadFile "https://storage.googleapis.com/diffblue-mirror/appveyor-deps/regex-2.7-bin.zip?GoogleAccessId=diffbluemaster@diffblue-cr.iam.gserviceaccount.com&Expires=1519839050&Signature=bXRvFV%2Be4Dpm8vzp%2F1bJWwgkERE6WakcPTBN57n9vNh0dr42jDTXv8JF%2BWCmTIb%2Fy4XzxYl0faggt3g6TqTLYn5UDVUBYx%2FMLmNVVNEv%2BaBlDd87UAZGLi6fkEV5oAP4W4FYsqEnKRDfGPOBoL7D7CuW9Kcxy3Moubxdl%2Bmes%2BMI%2FzWJ6BgLD3Oj04GyD42zLCYVtAzkeDAX0UADoh06ExhpTjI4BNnQ%2FhzSlPtPG7mon4q81%2F2tDNskKVJS466eR%2F8XV6H4QT3LoCkh6dxQ9%2B9ZnkWJplundRbiIlpj43vmdvjIChczl4jbAgL6zFj5Gz6u58uvCV%2FbOuyx3Sw1fg%3D%3D" + & 7z x regex-2.7-bin.zip + } + if (!(Test-Path minisat2-2.2.1)) { + & appveyor DownloadFile http://ftp.debian.org/debian/pool/main/m/minisat2/minisat2_2.2.1.orig.tar.gz + & 7z x minisat2_2.2.1.orig.tar.gz + &7z x minisat2_2.2.1.orig.tar + } + cd .. + +cache: deps + +build_script: +- cmd: | + cp -r deps/minisat2-2.2.1 minisat-2.2.1 + patch -d minisat-2.2.1 -p1 < scripts/minisat-2.2.1-patch + call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x64 + sed -i "s/BUILD_ENV.*/BUILD_ENV = MSVC/" src/config.inc + make -C src -j2 + +test_script: +- cmd: | + cd regression + sed -i "s/goto-cc\/goto-cc/goto-cc\/goto-cl/" ansi-c/Makefile + sed -i "s/goto-cc\/goto-cc/goto-cc\/goto-cl/" cpp/Makefile + sed -i "s/goto-cc\/goto-cc/goto-cc\/goto-cl/" goto-instrument/chain.sh + sed -i "15s/.*/$goto_cc $name.c/" goto-instrument/chain.sh + sed -i "16i mv $name.exe $name.gb" goto-instrument/chain.sh + sed -i "23s/.*/ $goto_cc ${name}-mod.c/" goto-instrument/chain.sh + sed -i "24i mv ${name}-mod.exe $name-mod.gb" goto-instrument/chain.sh + cat goto-instrument/chain.sh + + sed -i "s/goto-cc\/goto-cc/goto-cc\/goto-cl/" goto-instrument-typedef/chain.sh || true + sed -i "12s/.*/$GC $NAME.c --function fun/" goto-instrument-typedef/chain.sh || true + sed -i "13i mv $NAME.exe $NAME.gb" goto-instrument-typedef/chain.sh || true + cat goto-instrument-typedef/chain.sh || true + + rem HACK disable failing tests + rmdir /s /q ansi-c\Forward_Declaration2 + rmdir /s /q ansi-c\Incomplete_Type1 + rmdir /s /q ansi-c\Union_Padding1 + rmdir /s /q ansi-c\Universal_characters1 + rmdir /s /q ansi-c\function_return1 + rmdir /s /q ansi-c\gcc_attributes7 + rmdir /s /q ansi-c\struct6 + rmdir /s /q ansi-c\struct7 + rmdir /s /q cbmc\Malloc23 + rmdir /s /q cbmc\byte_update2 + rmdir /s /q cbmc\byte_update3 + rmdir /s /q cbmc\byte_update4 + rmdir /s /q cbmc\byte_update5 + rmdir /s /q cbmc\byte_update6 + rmdir /s /q cbmc\byte_update7 + rmdir /s /q cbmc\pipe1 + rmdir /s /q cbmc\unsigned___int128 + rmdir /s /q cpp\Decltype1 + rmdir /s /q cpp\Decltype2 + rmdir /s /q cpp\Function_Overloading1 + rmdir /s /q cpp\enum2 + rmdir /s /q cpp\enum7 + rmdir /s /q cpp\enum8 + rmdir /s /q cpp\nullptr1 + rmdir /s /q cpp\sizeof1 + rmdir /s /q cpp\static_assert1 + rmdir /s /q cbmc-java\VarLengthArrayTrace1 + rmdir /s /q cbmc-java\classpath1 + rmdir /s /q cbmc-java\jar-file3 + rmdir /s /q cbmc-java\tableswitch2 + rmdir /s /q goto-instrument\slice08 + + make test From e7db8a33797c42b91aa32017b63dc985851f5fb6 Mon Sep 17 00:00:00 2001 From: Owen Jones Date: Mon, 10 Apr 2017 12:03:05 +0100 Subject: [PATCH 113/116] Document symbol table functions --- src/util/symbol_table.cpp | 70 +++++++++++++++++++++++++++------------ 1 file changed, 49 insertions(+), 21 deletions(-) diff --git a/src/util/symbol_table.cpp b/src/util/symbol_table.cpp index 970801802b4..37053b7737b 100644 --- a/src/util/symbol_table.cpp +++ b/src/util/symbol_table.cpp @@ -14,11 +14,14 @@ Author: Daniel Kroening, kroening@kroening.com Function: symbol_tablet::add - Inputs: + Inputs: + symbol - The symbol to be added to the symbol table - Outputs: + 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: + Purpose: Add a new symbol to the symbol table \*******************************************************************/ @@ -39,11 +42,28 @@ bool symbol_tablet::add(const symbolt &symbol) Function: symbol_tablet::move - Inputs: - - Outputs: - - Purpose: + 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 \*******************************************************************/ @@ -75,11 +95,12 @@ bool symbol_tablet::move(symbolt &symbol, symbolt *&new_symbol) Function: symbol_tablet::remove - Inputs: + Inputs: + name - The name of the symbol to remove - Outputs: + Outputs: Returns a boolean indicating whether the process failed - Purpose: + Purpose: Remove a symbol from the symbol table \*******************************************************************/ @@ -121,11 +142,12 @@ bool symbol_tablet::remove(const irep_idt &name) Function: symbol_tablet::show - Inputs: + Inputs: + out - The ostream to direct output to Outputs: - Purpose: + Purpose: Print the contents of the symbol table \*******************************************************************/ @@ -141,11 +163,13 @@ void symbol_tablet::show(std::ostream &out) const Function: symbol_tablet::lookup - Inputs: + Inputs: + identifier - The name of the symbol to look for - Outputs: + Outputs: The symbol in the symbol table with the correct name - Purpose: + Purpose: Find a symbol in the symbol table. Throws a string if no + such symbol is found. \*******************************************************************/ @@ -163,11 +187,13 @@ const symbolt &symbol_tablet::lookup(const irep_idt &identifier) const Function: symbol_tablet::lookup - Inputs: + Inputs: + identifier - The name of the symbol to look for - Outputs: + Outputs: The symbol in the symbol table with the correct name - Purpose: + Purpose: Find a symbol in the symbol table. Throws a string if no + such symbol is found. \*******************************************************************/ @@ -185,11 +211,13 @@ symbolt &symbol_tablet::lookup(const irep_idt &identifier) Function: operator << - Inputs: + Inputs: + out - The ostream to direct output to + symbol_table - The symbol table to print out Outputs: - Purpose: + Purpose: Print the contents of the symbol table \*******************************************************************/ From 783de4bb289851900c09a9e8b2cce6922b03248d Mon Sep 17 00:00:00 2001 From: Marius Melemciuc Date: Mon, 10 Apr 2017 13:54:02 +0100 Subject: [PATCH 114/116] Added 'C_cxx_alloc_type' irep id Added 'C_cxx_alloc_type' irep id and it's usages. --- src/goto-programs/builtin_functions.cpp | 4 ++-- src/pointer-analysis/value_set.cpp | 2 +- src/pointer-analysis/value_set_fivr.cpp | 2 +- src/pointer-analysis/value_set_fivrns.cpp | 2 +- src/util/irep_ids.def | 1 + 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/goto-programs/builtin_functions.cpp b/src/goto-programs/builtin_functions.cpp index b3d6d82f650..0cef3e382b4 100644 --- a/src/goto-programs/builtin_functions.cpp +++ b/src/goto-programs/builtin_functions.cpp @@ -580,7 +580,7 @@ void goto_convertt::do_cpp_new( if(new_array) new_call.arguments().push_back(count); new_call.arguments().push_back(object_size); - new_call.set("#type", lhs.type().subtype()); + new_call.set(ID_C_cxx_alloc_type, lhs.type().subtype()); new_call.lhs()=tmp_symbol_expr; new_call.add_source_location()=rhs.source_location(); @@ -612,7 +612,7 @@ void goto_convertt::do_cpp_new( new_call.arguments().push_back(count); new_call.arguments().push_back(object_size); new_call.arguments().push_back(rhs.op0()); // memory location - new_call.set("#type", lhs.type().subtype()); + new_call.set(ID_C_cxx_alloc_type, lhs.type().subtype()); new_call.lhs()=tmp_symbol_expr; new_call.add_source_location()=rhs.source_location(); diff --git a/src/pointer-analysis/value_set.cpp b/src/pointer-analysis/value_set.cpp index 1a6c639ff92..b35952dc064 100644 --- a/src/pointer-analysis/value_set.cpp +++ b/src/pointer-analysis/value_set.cpp @@ -796,7 +796,7 @@ void value_sett::get_value_set_rec( assert(suffix==""); const typet &dynamic_type= - static_cast(expr.find("#type")); + static_cast(expr.find(ID_C_cxx_alloc_type)); dynamic_object_exprt dynamic_object(dynamic_type); dynamic_object.set_instance(location_number); diff --git a/src/pointer-analysis/value_set_fivr.cpp b/src/pointer-analysis/value_set_fivr.cpp index e06d73b245b..45e721137e0 100644 --- a/src/pointer-analysis/value_set_fivr.cpp +++ b/src/pointer-analysis/value_set_fivr.cpp @@ -853,7 +853,7 @@ void value_set_fivrt::get_value_set_rec( assert(suffix==""); const typet &dynamic_type= - static_cast(expr.find("#type")); + static_cast(expr.find(ID_C_cxx_alloc_type)); dynamic_object_exprt dynamic_object(dynamic_type); // let's make up a `unique' number for this object... diff --git a/src/pointer-analysis/value_set_fivrns.cpp b/src/pointer-analysis/value_set_fivrns.cpp index 4591bdd938d..c94afc8f95d 100644 --- a/src/pointer-analysis/value_set_fivrns.cpp +++ b/src/pointer-analysis/value_set_fivrns.cpp @@ -627,7 +627,7 @@ void value_set_fivrnst::get_value_set_rec( assert(suffix==""); const typet &dynamic_type= - static_cast(expr.find("#type")); + static_cast(expr.find(ID_C_cxx_alloc_type)); dynamic_object_exprt dynamic_object(dynamic_type); // let's make up a `unique' number for this object... diff --git a/src/util/irep_ids.def b/src/util/irep_ids.def index 91379187bde..56153453d7c 100644 --- a/src/util/irep_ids.def +++ b/src/util/irep_ids.def @@ -205,6 +205,7 @@ IREP_ID_ONE(main) IREP_ID_ONE(expression) IREP_ID_ONE(free) IREP_ID_ONE(malloc) +IREP_ID_TWO(C_cxx_alloc_type, #cxx_alloc_type) IREP_ID_ONE(cpp_new) IREP_ID_ONE(cpp_delete) IREP_ID_TWO(cpp_new_array, cpp_new[]) From 1f1631a3ec4f6c8d07f4fa8ef89469f1385b7ce5 Mon Sep 17 00:00:00 2001 From: Vojtech Forejt Date: Wed, 12 Apr 2017 14:49:26 +0100 Subject: [PATCH 115/116] Travis fix: ccache limit was in the wrong section --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a2396927dab..7cebb781ff4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,10 +37,10 @@ matrix: before_install: - HOMEBREW_NO_AUTO_UPDATE=1 brew install ccache - export PATH=/usr/local/opt/ccache/libexec:$PATH + - ccache -M 1G env: - COMPILER="ccache clang++ -Qunused-arguments -fcolor-diagnostics" - CCACHE_CPP2=yes - - ccache -M 1G # Ubuntu Linux with glibc using g++-5 - os: linux From 70b2ba6a882512a1923679f337f907aeee3d097a Mon Sep 17 00:00:00 2001 From: Marius Melemciuc Date: Thu, 13 Apr 2017 11:49:23 +0100 Subject: [PATCH 116/116] Used ID_C_cxx_alloc_type in value_set_fi.cpp Replaced #type with ID_C_cxx_alloc_type in value_set_fi.cpp. --- src/pointer-analysis/value_set_fi.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pointer-analysis/value_set_fi.cpp b/src/pointer-analysis/value_set_fi.cpp index 0fbcd7dec00..1add85c924d 100644 --- a/src/pointer-analysis/value_set_fi.cpp +++ b/src/pointer-analysis/value_set_fi.cpp @@ -723,7 +723,7 @@ void value_set_fit::get_value_set_rec( assert(suffix==""); const typet &dynamic_type= - static_cast(expr.find("#type")); + static_cast(expr.find(ID_C_cxx_alloc_type)); dynamic_object_exprt dynamic_object(dynamic_type); // let's make up a `unique' number for this object...