diff --git a/.gitignore b/.gitignore index 7ba5ba011b4..a0ee758d6fa 100644 --- a/.gitignore +++ b/.gitignore @@ -28,9 +28,16 @@ src/ansi-c/gcc_builtin_headers_alpha.inc src/ansi-c/gcc_builtin_headers_arm.inc src/ansi-c/gcc_builtin_headers_generic.inc src/ansi-c/gcc_builtin_headers_ia32-2.inc +src/ansi-c/gcc_builtin_headers_ia32-3.inc +src/ansi-c/gcc_builtin_headers_ia32-4.inc src/ansi-c/gcc_builtin_headers_ia32.inc +src/ansi-c/gcc_builtin_headers_math.inc +src/ansi-c/gcc_builtin_headers_mem_string.inc +src/ansi-c/gcc_builtin_headers_omp.inc +src/ansi-c/gcc_builtin_headers_tm.inc src/ansi-c/gcc_builtin_headers_mips.inc src/ansi-c/gcc_builtin_headers_power.inc +src/ansi-c/gcc_builtin_headers_ubsan.inc # regression/test files *.out @@ -68,6 +75,10 @@ src/xmllang/xml_lex.yy.cpp src/xmllang/xml_y.output src/xmllang/xml_y.tab.cpp src/xmllang/xml_y.tab.h +src/memory-models/mm_lex.yy.cpp +src/memory-models/mm_y.output +src/memory-models/mm_y.tab.cpp +src/memory-models/mm_y.tab.h # binaries src/cbmc/cbmc @@ -99,3 +110,5 @@ src/ansi-c/library/converter src/ansi-c/library/converter.exe src/util/irep_ids_convert src/util/irep_ids_convert.exe + +*.pyc diff --git a/CHANGELOG b/CHANGELOG index 1718d32243d..44ac745be0d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ * GOTO-INSTRUMENT: New option --print-path-lenghts * GOTO-ANALYZER: New option --unreachable-functions, --reachable-functions * GOTO-INSTRUMENT: New option --undefined-function-is-assume-false +* GOTO-INSTRUMENT: New option --remove-function-body 5.7 diff --git a/CODING_STANDARD b/CODING_STANDARD index ebc2b31f594..0a86fd71b22 100644 --- a/CODING_STANDARD +++ b/CODING_STANDARD @@ -158,6 +158,9 @@ C++ features: - Use the auto keyword if and only if one of the following - The type is explictly repeated on the RHS (e.g. a constructor call) - Adding the type will increase confusion (e.g. iterators, function pointers) +- Avoid assert, if the condition is an actual invariant, use INVARIANT, + PRECONDITION, POSTCONDITION, CHECK_RETURN, UNREACHABLE or DATA_INVARIANT. + If there are possible reasons why it might fail, throw an exception. Architecture-specific code: - Avoid if possible. diff --git a/COMPILING b/COMPILING index 4b47b38b790..3df46849022 100644 --- a/COMPILING +++ b/COMPILING @@ -32,7 +32,7 @@ We assume that you have a Debian/Ubuntu or Red Hat-like distribution. The GNU Make needs to be version 3.81 or higher. On Debian-like distributions, do - apt-get install g++-6 gcc flex bison make git libwww-perl patch + apt-get install g++ gcc flex bison make git libwww-perl patch On Red Hat/Fedora or derivates, do @@ -44,13 +44,7 @@ We assume that you have a Debian/Ubuntu or Red Hat-like distribution. git clone https://github.com/diffblue/cbmc cbmc-git -2) On Debian, do - - cd cbmc-git/src - make minisat2-download - make CXX=g++-6 - - On Ubuntu, or other distributions with recent g++, do +2) On Debian or Ubuntu, do cd cbmc-git/src make minisat2-download diff --git a/appveyor.yml b/appveyor.yml index f1f66142620..3a7c2d5c363 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -75,6 +75,10 @@ test_script: cat goto-instrument-typedef/chain.sh || true rem HACK disable failing tests + rmdir /s /q ansi-c\arch_flags_mcpu_bad + rmdir /s /q ansi-c\arch_flags_mcpu_good + rmdir /s /q ansi-c\arch_flags_mthumb_bad + rmdir /s /q ansi-c\arch_flags_mthumb_good rmdir /s /q ansi-c\Forward_Declaration2 rmdir /s /q ansi-c\Incomplete_Type1 rmdir /s /q ansi-c\Union_Padding1 diff --git a/doc/html-manual/api.shtml b/doc/html-manual/api.shtml index 141ae88b80a..77b7edc1aef 100644 --- a/doc/html-manual/api.shtml +++ b/doc/html-manual/api.shtml @@ -299,17 +299,17 @@ extern unsigned char __CPROVER_memory[]; This array models the contents of integer-addressed memory.

-

__CPROVER::unsignedbv (C++ only)

+

__CPROVER::unsignedbv<N> (C++ only)

This type is the equivalent of unsigned __CPROVER_bitvector[N] in the C++ front-end.

-

__CPROVER::signedbv (C++ only)

+

__CPROVER::signedbv<N> (C++ only)

This type is the equivalent of signed __CPROVER_bitvector[N] in the C++ front-end.

-

__CPROVER::fixedbv (C++ only)

+

__CPROVER::fixedbv<N> (C++ only)

This type is the equivalent of __CPROVER_fixedbv[N,m] in the C++ front-end.

diff --git a/doc/html-manual/architecture.shtml b/doc/html-manual/architecture.shtml index d3cd0f612c3..18ef3e0b1fc 100644 --- a/doc/html-manual/architecture.shtml +++ b/doc/html-manual/architecture.shtml @@ -76,18 +76,18 @@ more subtle. Try the following program with --big-endian and --little-endian:


- +

 #include <stdio.h>
#include <assert.h>

int main() {
  int i=0x01020304;
-  char *p=(char *)&i;
+  char *p=(char *)&i;
  printf("Bytes of i: %d, %d, %d, %d\n",
         p[0], p[1], p[2], p[3]);
  assert(0);
} -
+

diff --git a/doc/html-manual/cbmc-loops.shtml b/doc/html-manual/cbmc-loops.shtml index f8e94175b3a..da4df1eaeea 100644 --- a/doc/html-manual/cbmc-loops.shtml +++ b/doc/html-manual/cbmc-loops.shtml @@ -1,8 +1,8 @@ - - + +

CPROVER Manual TOC

@@ -161,7 +161,7 @@ following loop-free program: BODY CODE COPY 4 if(cond) { BODY CODE COPY 5 - assert(!cond); + assert(!cond); } } } diff --git a/doc/html-manual/cbmc.shtml b/doc/html-manual/cbmc.shtml index 993ce452b62..a52f39a90f5 100644 --- a/doc/html-manual/cbmc.shtml +++ b/doc/html-manual/cbmc.shtml @@ -1,8 +1,8 @@ - - + +

CPROVER Manual TOC

@@ -29,7 +29,7 @@ the program.

As an example, consider the following simple program, named file1.c: -

+

int puts(const char *s) { }
 
@@ -356,7 +356,6 @@ representation.
 
diff --git a/doc/html-manual/cover.shtml b/doc/html-manual/cover.shtml
index 54480059399..3665121f0b9 100644
--- a/doc/html-manual/cover.shtml
+++ b/doc/html-manual/cover.shtml
@@ -1,8 +1,8 @@
 
 
 
-
-
+
+
 
 

CPROVER Manual TOC

@@ -215,7 +215,6 @@ Test 5. (iteration 5) desired_climb=-1.000000f, estimator_z_dot=1.000000f (iteration 6) desired_climb=-1.000000f, estimator_z_dot=1.000000f
-

The option --unwind 6 unwinds the loop inside the main diff --git a/doc/html-manual/cprover-source.shtml b/doc/html-manual/cprover-source.shtml index dd4de2a1b66..29f273ceeab 100644 --- a/doc/html-manual/cprover-source.shtml +++ b/doc/html-manual/cprover-source.shtml @@ -1,8 +1,8 @@ - - + +

CPROVER Manual TOC

@@ -114,8 +114,8 @@ The excerpt below gives some details of the class irept:
class irept
 {
 public:
-  typedef std::vector subt;
-  typedef std::map named_subt;
+  typedef std::vector<irept> subt;
+  typedef std::map<irep_name_string, irept> named_subt;
   ...
 
 public:
@@ -134,7 +134,7 @@ protected:
   dt *data;
   ...
 };
-
+

Every node of any tree is an object of class irept. Each node has a @@ -692,20 +692,20 @@ declaration of the interface: { public: // Insert the symbol - bool add(const symbolt &symb); + bool add(const symbolt &symb); // Insert symb into the // table and erase it. // New_symbol points to the // newly inserted element. - bool move(symbolt &symbol, symbolt *&new_symbol); + bool move(symbolt &symbol, symbolt *&new_symbol); // Insert symb into the // table. Then symb is erased. - bool move(symbolt &symb); + bool move(symbolt &syb); // Return the entry of the // symbol with given name. - const irept &value(const std::string &name) const; + const irept &value(const std::string &name) const; }; @@ -815,7 +815,7 @@ public: instructionst instructions; typedef typename - std::map target_numberst; + std::map<const_targett, unsigned> target_numberst; //A map containing the unique number of each target target_numberst target_numbers; diff --git a/doc/html-manual/goto-cc-variants.shtml b/doc/html-manual/goto-cc-variants.shtml index f31a6eabd79..a7c5844325d 100644 --- a/doc/html-manual/goto-cc-variants.shtml +++ b/doc/html-manual/goto-cc-variants.shtml @@ -12,24 +12,23 @@ The goto-cc utility comes in several variants, summarised in the following table

- + - + - + - + - + - + -
ExecutableEnvironmentPreprocessor
goto-cc
goto-cc gcc (control-flow graph only) gcc -E
goto-gcc
goto-gcc gcc ("hybrid" executable) gcc -E
goto-armcc
goto-armcc ARM RVDS armcc -E
goto-cl
goto-cl Visual Studio cl /E
goto-cw
goto-cw Freescale CodeWarrior mwcceppc
diff --git a/doc/html-manual/highlight/CHANGES.md b/doc/html-manual/highlight/CHANGES.md index 377202d8bd8..38cd2733c3d 100644 --- a/doc/html-manual/highlight/CHANGES.md +++ b/doc/html-manual/highlight/CHANGES.md @@ -1,3 +1,184 @@ +## Version 9.11.0 + +New languages: + +- *Shell* by [Tsuyusato Kitsune][] +- *jboss-cli* by [Raphaël Parrëe][] + +Improvements: + +- [Joël Porquet] has [greatly improved the definition of *makefile*][5b3e0e6]. +- *C++* class titles are now highlighted as in other languages with classes. +- [Jordi Petit][] added rarely used `or`, `and` and `not` keywords to *C++*. +- [Pieter Vantorre][] fixed highlighting of negative floating point values. + + +[Tsuyusato Kitsune]: https://github.com/MakeNowJust +[Jordi Petit]: https://github.com/jordi-petit +[Raphaël Parrëe]: https://github.com/rparree +[Pieter Vantorre]: https://github.com/NuclearCookie +[5b3e0e6]: https://github.com/isagalaev/highlight.js/commit/5b3e0e68bfaae282faff6697d6a490567fa9d44b + + +## Version 9.10.0 + +Apologies for missing the previous release cycle. Some thing just can't be +automated… Anyway, we're back! + +New languages: + +- *Hy* by [Sergey Sobko][] +- *Leaf* by [Hale Chan][] +- *N1QL* by [Andres Täht][] and [Rene Saarsoo][] + +Improvements: + +- *Rust* got updated with new keywords by [Kasper Andersen][] and then + significantly modernized even more by [Eduard-Mihai Burtescu][] (yes, @eddyb, + Rust core team member!) +- *Python* updated with f-literals by [Philipp A][]. +- *YAML* updated with unquoted strings support. +- *Gauss* updated with new keywords by [Matt Evans][]. +- *Lua* updated with new keywords by [Joe Blow][]. +- *Kotlin* updated with new keywords by [Philipp Hauer][]. +- *TypeScript* got highlighting of function params and updated keywords by + [Ike Ku][]. +- *Scheme* now correctly handles \`-quoted lists thanks to [Guannan Wei]. +- [Sam Wu][] fixed handling of `<<` in *C++* defines. + +[Philipp A]: https://github.com/flying-sheep +[Philipp Hauer]: https://github.com/phauer +[Sergey Sobko]: https://github.com/profitware +[Hale Chan]: https://github.com/halechan +[Matt Evans]: https://github.com/matthewevans +[Joe Blow]: https://github.com/mossarelli +[Kasper Andersen]: https://github.com/kasma1990 +[Eduard-Mihai Burtescu]: https://github.com/eddyb +[Andres Täht]: https://github.com/andrestaht +[Rene Saarsoo]: https://github.com/nene +[Philipp Hauer]: https://github.com/phauer +[Ike Ku]: https://github.com/dempfi +[Guannan Wei]: https://github.com/Kraks +[Sam Wu]: https://github.com/samsam2310 + + +## Version 9.9.0 + +New languages + +- *LLVM* by [Michael Rodler][] + +Improvements: + +- *TypeScript* updated with annotations and param lists inside constructors, by + [Raphael Parree][]. +- *CoffeeScript* updated with new keywords and fixed to recognize JavaScript + in \`\`\`, thanks to thanks to [Geoffrey Booth][]. +- Compiler directives in *Delphi* are now correctly highlighted as "meta". + +[Raphael Parree]: https://github.com/rparree +[Michael Rodler]: https://github.com/f0rki +[Geoffrey Booth]: https://github.com/GeoffreyBooth + + +## Version 9.8.0 "New York" + +This version is the second one that deserved a name. Because I'm in New York, +and the release isn't missing the deadline only because it's still Tuesday on +West Coast. + +New languages: + +- *Clean* by [Camil Staps][] +- *Flix* by [Magnus Madsen][] + +Improvements: + +- [Kenton Hamaluik][] did a comprehensive update for *Haxe*. +- New commands for *PowerShell* from [Nicolas Le Gall][]. +- [Jan T. Sott][] updated *NSIS*. +- *Java* and *Swift* support unicode characters in identifiers thanks to + [Alexander Lichter][]. + +[Camil Staps]: https://github.com/camilstaps +[Magnus Madsen]: https://github.com/magnus-madsen +[Kenton Hamaluik]: https://github.com/FuzzyWuzzie +[Nicolas Le Gall]: https://github.com/darkitty +[Jan T. Sott]: https://github.com/idleberg +[Alexander Lichter]: https://github.com/manniL + + +## Version 9.7.0 + +A comprehensive bugfix release. This is one of the best things about +highlight.js: even boring things keep getting better (even if slow). + +- VHDL updated with PSL keywords and uses more consistent styling. +- Nested C-style comments no longer break highlighting in many languages. +- JavaScript updated with `=>` functions, highlighted object attributes and + parsing within template string substitution blocks (`${...}`). +- Fixed another corner case with self-closing `` in JSX. +- Added `HEALTHCHECK` directive in Docker. +- Delphi updated with new Free Pascal keywords. +- Fixed digit separator parsing in C++. +- C# updated with new keywords and fixed to allow multiple identifiers within + generics `<...>`. +- Fixed another slow regex in Less. + + +## Version 9.6.0 + +New languages: + +- *ABNF* and *EBNF* by [Alex McKibben][] +- *Awk* by [Matthew Daly][] +- *SubUnit* by [Sergey Bronnikov][] + +New styles: + +- *Atom One* in both Dark and Light variants by [Daniel Gamage][] + +Plus, a few smaller updates for *Lasso*, *Elixir*, *C++* and *SQL*. + +[Alex McKibben]: https://github.com/mckibbenta +[Daniel Gamage]: https://github.com/danielgamage +[Matthew Daly]: https://github.com/matthewbdaly +[Sergey Bronnikov]: https://github.com/ligurio + + +## Version 9.5.0 + +New languages: + +- *Excel* by [Victor Zhou][] +- *Linden Scripting Language* by [Builder's Brewery][] +- *TAP* (Test Anything Protocol) by [Sergey Bronnikov][] +- *Pony* by [Joe Eli McIlvain][] +- *Coq* by [Stephan Boyer][] +- *dsconfig* and *LDIF* by [Jacob Childress][] + +New styles: + +- *Ocean Dark* by [Gavin Siu][] + +Notable changes: + +- [Minh Nguyễn][] added more built-ins to Objective C. +- [Jeremy Hull][] fixed corner cases in C++ preprocessor directives and Diff + comments. +- [Victor Zhou][] added support for digit separators in C++ numbers. + +[Gavin Siu]: https://github.com/gavsiu +[Builder's Brewery]: https://github.com/buildersbrewery +[Victor Zhou]: https://github.com/OiCMudkips +[Sergey Bronnikov]: https://github.com/ligurio +[Joe Eli McIlvain]: https://github.com/jemc +[Stephan Boyer]: https://github.com/boyers +[Jacob Childress]: https://github.com/braveulysses +[Minh Nguyễn]: https://github.com/1ec5 +[Jeremy Hull]: https://github.com/sourrust + + ## Version 9.4.0 New languages: @@ -349,7 +530,7 @@ New languages: New styles: - *Agate* by [Taufik Nurrohman][] -- *Darkula* by [Jet Brains][] +- *Darcula* by [JetBrains][] - *Atelier Sulphurpool* by [Bram de Haan][] - *Android Studio* by [Pedro Oliveira][] diff --git a/doc/html-manual/highlight/README.md b/doc/html-manual/highlight/README.md index 3afbde3127c..9f76e6bd56e 100644 --- a/doc/html-manual/highlight/README.md +++ b/doc/html-manual/highlight/README.md @@ -106,17 +106,26 @@ works perfectly fine with Browserify, but there is the option to use a build specific to browsers rather than something meant for a server. Head over to the [download page][5] for all the options. -**Note:** the library is not supposed to work straight from the source -on GitHub; it requires building. If none of the pre-packaged options +**Don't link to GitHub directly.** The library is not supposed to work straight +from the source, it requires building. If none of the pre-packaged options work for you refer to the [building documentation][6]. -Also, if you are using something like almond, you need to use the -optimizer to give the module a name. The basic example would be: +**The CDN-hosted package doesn't have all the languages.** Otherwise it'd be +too big. If you don't see the language you need in the ["Common" section][5], +it can be added manually: + +```html + +``` + +**On Almond.** You need to use the optimizer to give the module a name. For +example: ``` r.js -o name=hljs paths.hljs=/path/to/highlight out=highlight.js ``` + ## License Highlight.js is released under the BSD License. See [LICENSE][7] file @@ -127,15 +136,15 @@ for details. The official site for the library is at . Further in-depth documentation for the API and other topics is at -. +. Authors and contributors are listed in the [AUTHORS.en.txt][8] file. -[1]: http://highlightjs.readthedocs.org/en/latest/api.html#inithighlightingonload -[2]: http://highlightjs.readthedocs.org/en/latest/css-classes-reference.html -[3]: http://highlightjs.readthedocs.org/en/latest/api.html#highlightblock-block -[4]: http://highlightjs.readthedocs.org/en/latest/api.html#configure-options +[1]: http://highlightjs.readthedocs.io/en/latest/api.html#inithighlightingonload +[2]: http://highlightjs.readthedocs.io/en/latest/css-classes-reference.html +[3]: http://highlightjs.readthedocs.io/en/latest/api.html#highlightblock-block +[4]: http://highlightjs.readthedocs.io/en/latest/api.html#configure-options [5]: https://highlightjs.org/download/ -[6]: http://highlightjs.readthedocs.org/en/latest/building-testing.html +[6]: http://highlightjs.readthedocs.io/en/latest/building-testing.html [7]: https://github.com/isagalaev/highlight.js/blob/master/LICENSE [8]: https://github.com/isagalaev/highlight.js/blob/master/AUTHORS.en.txt diff --git a/doc/html-manual/highlight/README.ru.md b/doc/html-manual/highlight/README.ru.md index c429d7dda4c..ac481d07181 100644 --- a/doc/html-manual/highlight/README.ru.md +++ b/doc/html-manual/highlight/README.ru.md @@ -24,7 +24,7 @@ Highlight.js — это инструмент для подсветки синт
...
``` -Список поддерживаемых классов языков доступен в [справочнике по классам][8]. +Список поддерживаемых классов языков доступен в [справочнике по классам][2]. Класс также можно предварить префиксами `language-` или `lang-`. Чтобы отключить подсветку для какого-то блока, используйте класс `nohighlight`: @@ -36,7 +36,7 @@ Highlight.js — это инструмент для подсветки синт ## Инициализация вручную Чтобы иметь чуть больше контроля за инициализацией подсветки, вы можете -использовать функции [`highlightBlock`][2] и [`configure`][3]. Таким образом +использовать функции [`highlightBlock`][3] и [`configure`][4]. Таким образом можно управлять тем, *что* и *когда* подсвечивать. Вот пример инициализации, эквивалентной вызову [`initHighlightingOnLoad`][1], но @@ -62,7 +62,7 @@ $('div.code').each(function(i, block) { }); ``` -Другие опции можно найти в документации функции [`configure`][3]. +Другие опции можно найти в документации функции [`configure`][4]. ## Web Workers @@ -96,17 +96,31 @@ onmessage = function(event) { Highlight.js можно использовать в браузере прямо с CDN хостинга или скачать индивидуальную сборку, а также установив модуль на сервере. На -[странице загрузки][4] подробно описаны все варианты. +[странице загрузки][5] подробно описаны все варианты. -Обратите внимание, что библиотека не предназначена для использования в виде -исходного кода на GitHub, а требует отдельной сборки. Если вам не подходит ни -один из готовых вариантов, читайте [документацию по сборке][5]. +**Не подключайте GitHub напрямую.** Библиотека не предназначена для +использования в виде исходного кода, а требует отдельной сборки. Если вам не +подходит ни один из готовых вариантов, читайте [документацию по сборке][6]. + +**Файл на CDN содержит не все языки.** Иначе он будет слишком большого размера. +Если нужного вам языка нет в [категории "Common"][5], можно дообавить его +вручную: + +```html + +``` + +**Про Almond.** Нужно задать имя модуля в оптимизаторе, например: + +``` +r.js -o name=hljs paths.hljs=/path/to/highlight out=highlight.js +``` ## Лицензия Highlight.js распространяется под лицензией BSD. Подробнее читайте файл -[LICENSE][10]. +[LICENSE][7]. ## Ссылки @@ -114,15 +128,15 @@ Highlight.js распространяется под лицензией BSD. П Официальный сайт билиотеки расположен по адресу . Более подробная документация по API и другим темам расположена на -. - -Авторы и контрибьюторы перечислены в файле [AUTHORS.ru.txt][9] file. - -[1]: http://highlightjs.readthedocs.org/en/latest/api.html#inithighlightingonload -[2]: http://highlightjs.readthedocs.org/en/latest/api.html#highlightblock-block -[3]: http://highlightjs.readthedocs.org/en/latest/api.html#configure-options -[4]: https://highlightjs.org/download/ -[5]: http://highlightjs.readthedocs.org/en/latest/building-testing.html -[8]: http://highlightjs.readthedocs.org/en/latest/css-classes-reference.html -[9]: https://github.com/isagalaev/highlight.js/blob/master/AUTHORS.ru.txt -[10]: https://github.com/isagalaev/highlight.js/blob/master/LICENSE +. + +Авторы и контрибьюторы перечислены в файле [AUTHORS.ru.txt][8] file. + +[1]: http://highlightjs.readthedocs.io/en/latest/api.html#inithighlightingonload +[2]: http://highlightjs.readthedocs.io/en/latest/css-classes-reference.html +[3]: http://highlightjs.readthedocs.io/en/latest/api.html#highlightblock-block +[4]: http://highlightjs.readthedocs.io/en/latest/api.html#configure-options +[5]: https://highlightjs.org/download/ +[6]: http://highlightjs.readthedocs.io/en/latest/building-testing.html +[7]: https://github.com/isagalaev/highlight.js/blob/master/LICENSE +[8]: https://github.com/isagalaev/highlight.js/blob/master/AUTHORS.ru.txt diff --git a/doc/html-manual/highlight/highlight.pack.js b/doc/html-manual/highlight/highlight.pack.js index fa635608228..e93b5ee1ce9 100644 --- a/doc/html-manual/highlight/highlight.pack.js +++ b/doc/html-manual/highlight/highlight.pack.js @@ -1,2 +1,2 @@ -/*! highlight.js v9.4.0 | BSD3 License | git.io/hljslicense */ -!function(e){var n="object"==typeof window&&window||"object"==typeof self&&self;"undefined"!=typeof exports?e(exports):n&&(n.hljs=e({}),"function"==typeof define&&define.amd&&define([],function(){return n.hljs}))}(function(e){function n(e){return e.replace(/&/gm,"&").replace(//gm,">")}function t(e){return e.nodeName.toLowerCase()}function r(e,n){var t=e&&e.exec(n);return t&&0==t.index}function a(e){return/^(no-?highlight|plain|text)$/i.test(e)}function i(e){var n,t,r,i=e.className+" ";if(i+=e.parentNode?e.parentNode.className:"",t=/\blang(?:uage)?-([\w-]+)\b/i.exec(i))return w(t[1])?t[1]:"no-highlight";for(i=i.split(/\s+/),n=0,r=i.length;r>n;n++)if(w(i[n])||a(i[n]))return i[n]}function o(e,n){var t,r={};for(t in e)r[t]=e[t];if(n)for(t in n)r[t]=n[t];return r}function u(e){var n=[];return function r(e,a){for(var i=e.firstChild;i;i=i.nextSibling)3==i.nodeType?a+=i.nodeValue.length:1==i.nodeType&&(n.push({event:"start",offset:a,node:i}),a=r(i,a),t(i).match(/br|hr|img|input/)||n.push({event:"stop",offset:a,node:i}));return a}(e,0),n}function c(e,r,a){function i(){return e.length&&r.length?e[0].offset!=r[0].offset?e[0].offset"}function u(e){f+=""}function c(e){("start"==e.event?o:u)(e.node)}for(var s=0,f="",l=[];e.length||r.length;){var g=i();if(f+=n(a.substr(s,g[0].offset-s)),s=g[0].offset,g==e){l.reverse().forEach(u);do c(g.splice(0,1)[0]),g=i();while(g==e&&g.length&&g[0].offset==s);l.reverse().forEach(o)}else"start"==g[0].event?l.push(g[0].node):l.pop(),c(g.splice(0,1)[0])}return f+n(a.substr(s))}function s(e){function n(e){return e&&e.source||e}function t(t,r){return new RegExp(n(t),"m"+(e.cI?"i":"")+(r?"g":""))}function r(a,i){if(!a.compiled){if(a.compiled=!0,a.k=a.k||a.bK,a.k){var u={},c=function(n,t){e.cI&&(t=t.toLowerCase()),t.split(" ").forEach(function(e){var t=e.split("|");u[t[0]]=[n,t[1]?Number(t[1]):1]})};"string"==typeof a.k?c("keyword",a.k):Object.keys(a.k).forEach(function(e){c(e,a.k[e])}),a.k=u}a.lR=t(a.l||/\w+/,!0),i&&(a.bK&&(a.b="\\b("+a.bK.split(" ").join("|")+")\\b"),a.b||(a.b=/\B|\b/),a.bR=t(a.b),a.e||a.eW||(a.e=/\B|\b/),a.e&&(a.eR=t(a.e)),a.tE=n(a.e)||"",a.eW&&i.tE&&(a.tE+=(a.e?"|":"")+i.tE)),a.i&&(a.iR=t(a.i)),void 0===a.r&&(a.r=1),a.c||(a.c=[]);var s=[];a.c.forEach(function(e){e.v?e.v.forEach(function(n){s.push(o(e,n))}):s.push("self"==e?a:e)}),a.c=s,a.c.forEach(function(e){r(e,a)}),a.starts&&r(a.starts,i);var f=a.c.map(function(e){return e.bK?"\\.?("+e.b+")\\.?":e.b}).concat([a.tE,a.i]).map(n).filter(Boolean);a.t=f.length?t(f.join("|"),!0):{exec:function(){return null}}}}r(e)}function f(e,t,a,i){function o(e,n){for(var t=0;t";return i+=e+'">',i+n+o}function h(){if(!k.k)return n(M);var e="",t=0;k.lR.lastIndex=0;for(var r=k.lR.exec(M);r;){e+=n(M.substr(t,r.index-t));var a=g(k,r);a?(B+=a[1],e+=p(a[0],n(r[0]))):e+=n(r[0]),t=k.lR.lastIndex,r=k.lR.exec(M)}return e+n(M.substr(t))}function d(){var e="string"==typeof k.sL;if(e&&!R[k.sL])return n(M);var t=e?f(k.sL,M,!0,y[k.sL]):l(M,k.sL.length?k.sL:void 0);return k.r>0&&(B+=t.r),e&&(y[k.sL]=t.top),p(t.language,t.value,!1,!0)}function b(){L+=void 0!==k.sL?d():h(),M=""}function v(e,n){L+=e.cN?p(e.cN,"",!0):"",k=Object.create(e,{parent:{value:k}})}function m(e,n){if(M+=e,void 0===n)return b(),0;var t=o(n,k);if(t)return t.skip?M+=n:(t.eB&&(M+=n),b(),t.rB||t.eB||(M=n)),v(t,n),t.rB?0:n.length;var r=u(k,n);if(r){var a=k;a.skip?M+=n:(a.rE||a.eE||(M+=n),b(),a.eE&&(M=n));do k.cN&&(L+=""),k.skip||(B+=k.r),k=k.parent;while(k!=r.parent);return r.starts&&v(r.starts,""),a.rE?0:n.length}if(c(n,k))throw new Error('Illegal lexeme "'+n+'" for mode "'+(k.cN||"")+'"');return M+=n,n.length||1}var N=w(e);if(!N)throw new Error('Unknown language: "'+e+'"');s(N);var x,k=i||N,y={},L="";for(x=k;x!=N;x=x.parent)x.cN&&(L=p(x.cN,"",!0)+L);var M="",B=0;try{for(var C,j,I=0;;){if(k.t.lastIndex=I,C=k.t.exec(t),!C)break;j=m(t.substr(I,C.index-I),C[0]),I=C.index+j}for(m(t.substr(I)),x=k;x.parent;x=x.parent)x.cN&&(L+="");return{r:B,value:L,language:e,top:k}}catch(O){if(-1!=O.message.indexOf("Illegal"))return{r:0,value:n(t)};throw O}}function l(e,t){t=t||E.languages||Object.keys(R);var r={r:0,value:n(e)},a=r;return t.filter(w).forEach(function(n){var t=f(n,e,!1);t.language=n,t.r>a.r&&(a=t),t.r>r.r&&(a=r,r=t)}),a.language&&(r.second_best=a),r}function g(e){return E.tabReplace&&(e=e.replace(/^((<[^>]+>|\t)+)/gm,function(e,n){return n.replace(/\t/g,E.tabReplace)})),E.useBR&&(e=e.replace(/\n/g,"
")),e}function p(e,n,t){var r=n?x[n]:t,a=[e.trim()];return e.match(/\bhljs\b/)||a.push("hljs"),-1===e.indexOf(r)&&a.push(r),a.join(" ").trim()}function h(e){var n=i(e);if(!a(n)){var t;E.useBR?(t=document.createElementNS("http://www.w3.org/1999/xhtml","div"),t.innerHTML=e.innerHTML.replace(/\n/g,"").replace(//g,"\n")):t=e;var r=t.textContent,o=n?f(n,r,!0):l(r),s=u(t);if(s.length){var h=document.createElementNS("http://www.w3.org/1999/xhtml","div");h.innerHTML=o.value,o.value=c(s,u(h),r)}o.value=g(o.value),e.innerHTML=o.value,e.className=p(e.className,n,o.language),e.result={language:o.language,re:o.r},o.second_best&&(e.second_best={language:o.second_best.language,re:o.second_best.r})}}function d(e){E=o(E,e)}function b(){if(!b.called){b.called=!0;var e=document.querySelectorAll("pre code");Array.prototype.forEach.call(e,h)}}function v(){addEventListener("DOMContentLoaded",b,!1),addEventListener("load",b,!1)}function m(n,t){var r=R[n]=t(e);r.aliases&&r.aliases.forEach(function(e){x[e]=n})}function N(){return Object.keys(R)}function w(e){return e=(e||"").toLowerCase(),R[e]||R[x[e]]}var E={classPrefix:"hljs-",tabReplace:null,useBR:!1,languages:void 0},R={},x={};return e.highlight=f,e.highlightAuto=l,e.fixMarkup=g,e.highlightBlock=h,e.configure=d,e.initHighlighting=b,e.initHighlightingOnLoad=v,e.registerLanguage=m,e.listLanguages=N,e.getLanguage=w,e.inherit=o,e.IR="[a-zA-Z]\\w*",e.UIR="[a-zA-Z_]\\w*",e.NR="\\b\\d+(\\.\\d+)?",e.CNR="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",e.BNR="\\b(0b[01]+)",e.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",e.BE={b:"\\\\[\\s\\S]",r:0},e.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[e.BE]},e.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[e.BE]},e.PWM={b:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|like)\b/},e.C=function(n,t,r){var a=e.inherit({cN:"comment",b:n,e:t,c:[]},r||{});return a.c.push(e.PWM),a.c.push({cN:"doctag",b:"(?:TODO|FIXME|NOTE|BUG|XXX):",r:0}),a},e.CLCM=e.C("//","$"),e.CBCM=e.C("/\\*","\\*/"),e.HCM=e.C("#","$"),e.NM={cN:"number",b:e.NR,r:0},e.CNM={cN:"number",b:e.CNR,r:0},e.BNM={cN:"number",b:e.BNR,r:0},e.CSSNM={cN:"number",b:e.NR+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",r:0},e.RM={cN:"regexp",b:/\//,e:/\/[gimuy]*/,i:/\n/,c:[e.BE,{b:/\[/,e:/\]/,r:0,c:[e.BE]}]},e.TM={cN:"title",b:e.IR,r:0},e.UTM={cN:"title",b:e.UIR,r:0},e.METHOD_GUARD={b:"\\.\\s*"+e.UIR,r:0},e});hljs.registerLanguage("json",function(e){var i={literal:"true false null"},n=[e.QSM,e.CNM],r={e:",",eW:!0,eE:!0,c:n,k:i},t={b:"{",e:"}",c:[{cN:"attr",b:/"/,e:/"/,c:[e.BE],i:"\\n"},e.inherit(r,{b:/:/})],i:"\\S"},c={b:"\\[",e:"\\]",c:[e.inherit(r)],i:"\\S"};return n.splice(n.length,0,t,c),{c:n,k:i,i:"\\S"}});hljs.registerLanguage("java",function(e){var t=e.UIR+"(<"+e.UIR+"(\\s*,\\s*"+e.UIR+")*>)?",a="false synchronized int abstract float private char boolean static null if const for true while long strictfp finally protected import native final void enum else break transient catch instanceof byte super volatile case assert short package default double public try this switch continue throws protected public private module requires exports",r="\\b(0[bB]([01]+[01_]+[01]+|[01]+)|0[xX]([a-fA-F0-9]+[a-fA-F0-9_]+[a-fA-F0-9]+|[a-fA-F0-9]+)|(([\\d]+[\\d_]+[\\d]+|[\\d]+)(\\.([\\d]+[\\d_]+[\\d]+|[\\d]+))?|\\.([\\d]+[\\d_]+[\\d]+|[\\d]+))([eE][-+]?\\d+)?)[lLfF]?",s={cN:"number",b:r,r:0};return{aliases:["jsp"],k:a,i:/<\/|#/,c:[e.C("/\\*\\*","\\*/",{r:0,c:[{b:/\w+@/,r:0},{cN:"doctag",b:"@[A-Za-z]+"}]}),e.CLCM,e.CBCM,e.ASM,e.QSM,{cN:"class",bK:"class interface",e:/[{;=]/,eE:!0,k:"class interface",i:/[:"\[\]]/,c:[{bK:"extends implements"},e.UTM]},{bK:"new throw return else",r:0},{cN:"function",b:"("+t+"\\s+)+"+e.UIR+"\\s*\\(",rB:!0,e:/[{;=]/,eE:!0,k:a,c:[{b:e.UIR+"\\s*\\(",rB:!0,r:0,c:[e.UTM]},{cN:"params",b:/\(/,e:/\)/,k:a,r:0,c:[e.ASM,e.QSM,e.CNM,e.CBCM]},e.CLCM,e.CBCM]},s,{cN:"meta",b:"@[A-Za-z]+"}]}});hljs.registerLanguage("verilog",function(e){var n={keyword:"accept_on alias always always_comb always_ff always_latch and assert assign assume automatic before begin bind bins binsof bit break buf|0 bufif0 bufif1 byte case casex casez cell chandle checker class clocking cmos config const constraint context continue cover covergroup coverpoint cross deassign default defparam design disable dist do edge else end endcase endchecker endclass endclocking endconfig endfunction endgenerate endgroup endinterface endmodule endpackage endprimitive endprogram endproperty endspecify endsequence endtable endtask enum event eventually expect export extends extern final first_match for force foreach forever fork forkjoin function generate|5 genvar global highz0 highz1 if iff ifnone ignore_bins illegal_bins implements implies import incdir include initial inout input inside instance int integer interconnect interface intersect join join_any join_none large let liblist library local localparam logic longint macromodule matches medium modport module nand negedge nettype new nexttime nmos nor noshowcancelled not notif0 notif1 or output package packed parameter pmos posedge primitive priority program property protected pull0 pull1 pulldown pullup pulsestyle_ondetect pulsestyle_onevent pure rand randc randcase randsequence rcmos real realtime ref reg reject_on release repeat restrict return rnmos rpmos rtran rtranif0 rtranif1 s_always s_eventually s_nexttime s_until s_until_with scalared sequence shortint shortreal showcancelled signed small soft solve specify specparam static string strong strong0 strong1 struct super supply0 supply1 sync_accept_on sync_reject_on table tagged task this throughout time timeprecision timeunit tran tranif0 tranif1 tri tri0 tri1 triand trior trireg type typedef union unique unique0 unsigned until until_with untyped use uwire var vectored virtual void wait wait_order wand weak weak0 weak1 while wildcard wire with within wor xnor xor",literal:"null",built_in:"$finish $stop $exit $fatal $error $warning $info $realtime $time $printtimescale $bitstoreal $bitstoshortreal $itor $signed $cast $bits $stime $timeformat $realtobits $shortrealtobits $rtoi $unsigned $asserton $assertkill $assertpasson $assertfailon $assertnonvacuouson $assertoff $assertcontrol $assertpassoff $assertfailoff $assertvacuousoff $isunbounded $sampled $fell $changed $past_gclk $fell_gclk $changed_gclk $rising_gclk $steady_gclk $coverage_control $coverage_get $coverage_save $set_coverage_db_name $rose $stable $past $rose_gclk $stable_gclk $future_gclk $falling_gclk $changing_gclk $display $coverage_get_max $coverage_merge $get_coverage $load_coverage_db $typename $unpacked_dimensions $left $low $increment $clog2 $ln $log10 $exp $sqrt $pow $floor $ceil $sin $cos $tan $countbits $onehot $isunknown $fatal $warning $dimensions $right $high $size $asin $acos $atan $atan2 $hypot $sinh $cosh $tanh $asinh $acosh $atanh $countones $onehot0 $error $info $random $dist_chi_square $dist_erlang $dist_exponential $dist_normal $dist_poisson $dist_t $dist_uniform $q_initialize $q_remove $q_exam $async$and$array $async$nand$array $async$or$array $async$nor$array $sync$and$array $sync$nand$array $sync$or$array $sync$nor$array $q_add $q_full $psprintf $async$and$plane $async$nand$plane $async$or$plane $async$nor$plane $sync$and$plane $sync$nand$plane $sync$or$plane $sync$nor$plane $system $display $displayb $displayh $displayo $strobe $strobeb $strobeh $strobeo $write $readmemb $readmemh $writememh $value$plusargs $dumpvars $dumpon $dumplimit $dumpports $dumpportson $dumpportslimit $writeb $writeh $writeo $monitor $monitorb $monitorh $monitoro $writememb $dumpfile $dumpoff $dumpall $dumpflush $dumpportsoff $dumpportsall $dumpportsflush $fclose $fdisplay $fdisplayb $fdisplayh $fdisplayo $fstrobe $fstrobeb $fstrobeh $fstrobeo $swrite $swriteb $swriteh $swriteo $fscanf $fread $fseek $fflush $feof $fopen $fwrite $fwriteb $fwriteh $fwriteo $fmonitor $fmonitorb $fmonitorh $fmonitoro $sformat $sformatf $fgetc $ungetc $fgets $sscanf $rewind $ftell $ferror"};return{aliases:["v","sv","svh"],cI:!1,k:n,l:/[\w\$]+/,c:[e.CBCM,e.CLCM,e.QSM,{cN:"number",c:[e.BE],v:[{b:"\\b((\\d+'(b|h|o|d|B|H|O|D))[0-9xzXZa-fA-F_]+)"},{b:"\\B(('(b|h|o|d|B|H|O|D))[0-9xzXZa-fA-F_]+)"},{b:"\\b([0-9_])+",r:0}]},{cN:"variable",v:[{b:"#\\((?!parameter).+\\)"},{b:"\\.\\w+",r:0}]},{cN:"meta",b:"`",e:"$",k:{"meta-keyword":"define __FILE__ __LINE__ begin_keywords celldefine default_nettype define else elsif end_keywords endcelldefine endif ifdef ifndef include line nounconnected_drive pragma resetall timescale unconnected_drive undef undefineall"},r:0}]}});hljs.registerLanguage("bash",function(e){var t={cN:"variable",v:[{b:/\$[\w\d#@][\w\d_]*/},{b:/\$\{(.*?)}/}]},s={cN:"string",b:/"/,e:/"/,c:[e.BE,t,{cN:"variable",b:/\$\(/,e:/\)/,c:[e.BE]}]},a={cN:"string",b:/'/,e:/'/};return{aliases:["sh","zsh"],l:/-?[a-z\.]+/,k:{keyword:"if then else elif fi for while in do done case esac function",literal:"true false",built_in:"break cd continue eval exec exit export getopts hash pwd readonly return shift test times trap umask unset alias bind builtin caller command declare echo enable help let local logout mapfile printf read readarray source type typeset ulimit unalias set shopt autoload bg bindkey bye cap chdir clone comparguments compcall compctl compdescribe compfiles compgroups compquote comptags comptry compvalues dirs disable disown echotc echoti emulate fc fg float functions getcap getln history integer jobs kill limit log noglob popd print pushd pushln rehash sched setcap setopt stat suspend ttyctl unfunction unhash unlimit unsetopt vared wait whence where which zcompile zformat zftp zle zmodload zparseopts zprof zpty zregexparse zsocket zstyle ztcp",_:"-ne -eq -lt -gt -f -d -e -s -l -a"},c:[{cN:"meta",b:/^#![^\n]+sh\s*$/,r:10},{cN:"function",b:/\w[\w\d_]*\s*\(\s*\)\s*\{/,rB:!0,c:[e.inherit(e.TM,{b:/\w[\w\d_]*/})],r:0},e.HCM,s,a,t]}});hljs.registerLanguage("cpp",function(t){var e={cN:"keyword",b:"\\b[a-z\\d_]*_t\\b"},r={cN:"string",v:[t.inherit(t.QSM,{b:'((u8?|U)|L)?"'}),{b:'(u8?|U)?R"',e:'"',c:[t.BE]},{b:"'\\\\?.",e:"'",i:"."}]},s={cN:"number",v:[{b:"\\b(\\d+(\\.\\d*)?|\\.\\d+)(u|U|l|L|ul|UL|f|F)"},{b:t.CNR}],r:0},i={cN:"meta",b:/#[a-z]+\b/,e:/$/,k:{"meta-keyword":"if else elif endif define undef warning error line pragma ifdef ifndef include"},c:[{b:/\\\n/,r:0},t.inherit(r,{cN:"meta-string"}),{cN:"meta-string",b:"<",e:">",i:"\\n"},t.CLCM,t.CBCM]},a=t.IR+"\\s*\\(",c={keyword:"int float while private char catch export virtual operator sizeof dynamic_cast|10 typedef const_cast|10 const struct for static_cast|10 union namespace unsigned long volatile static protected bool template mutable if public friend do goto auto void enum else break extern using class asm case typeid short reinterpret_cast|10 default double register explicit signed typename try this switch continue inline delete alignof constexpr decltype noexcept static_assert thread_local restrict _Bool complex _Complex _Imaginary atomic_bool atomic_char atomic_schar atomic_uchar atomic_short atomic_ushort atomic_int atomic_uint atomic_long atomic_ulong atomic_llong atomic_ullong new throw return",built_in:"std string cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap array shared_ptr abort abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr",literal:"true false nullptr NULL"},n=[e,t.CLCM,t.CBCM,s,r];return{aliases:["c","cc","h","c++","h++","hpp"],k:c,i:"",k:c,c:["self",e]},{b:t.IR+"::",k:c},{v:[{b:/=/,e:/;/},{b:/\(/,e:/\)/},{bK:"new throw return else",e:/;/}],k:c,c:n.concat([{b:/\(/,e:/\)/,k:c,c:n.concat(["self"]),r:0}]),r:0},{cN:"function",b:"("+t.IR+"[\\*&\\s]+)+"+a,rB:!0,e:/[{;=]/,eE:!0,k:c,i:/[^\w\s\*&]/,c:[{b:a,rB:!0,c:[t.TM],r:0},{cN:"params",b:/\(/,e:/\)/,k:c,r:0,c:[t.CLCM,t.CBCM,r,s,e]},t.CLCM,t.CBCM,i]}]),exports:{preprocessor:i,strings:r,k:c}}}); \ No newline at end of file +/*! highlight.js v9.11.0 | BSD3 License | git.io/hljslicense */ +!function(e){var n="object"==typeof window&&window||"object"==typeof self&&self;"undefined"!=typeof exports?e(exports):n&&(n.hljs=e({}),"function"==typeof define&&define.amd&&define([],function(){return n.hljs}))}(function(e){function n(e){return e.replace(/&/g,"&").replace(//g,">")}function t(e){return e.nodeName.toLowerCase()}function r(e,n){var t=e&&e.exec(n);return t&&0===t.index}function a(e){return k.test(e)}function i(e){var n,t,r,i,o=e.className+" ";if(o+=e.parentNode?e.parentNode.className:"",t=B.exec(o))return w(t[1])?t[1]:"no-highlight";for(o=o.split(/\s+/),n=0,r=o.length;r>n;n++)if(i=o[n],a(i)||w(i))return i}function o(e){var n,t={},r=Array.prototype.slice.call(arguments,1);for(n in e)t[n]=e[n];return r.forEach(function(e){for(n in e)t[n]=e[n]}),t}function u(e){var n=[];return function r(e,a){for(var i=e.firstChild;i;i=i.nextSibling)3===i.nodeType?a+=i.nodeValue.length:1===i.nodeType&&(n.push({event:"start",offset:a,node:i}),a=r(i,a),t(i).match(/br|hr|img|input/)||n.push({event:"stop",offset:a,node:i}));return a}(e,0),n}function c(e,r,a){function i(){return e.length&&r.length?e[0].offset!==r[0].offset?e[0].offset"}function u(e){s+=""}function c(e){("start"===e.event?o:u)(e.node)}for(var l=0,s="",f=[];e.length||r.length;){var g=i();if(s+=n(a.substring(l,g[0].offset)),l=g[0].offset,g===e){f.reverse().forEach(u);do c(g.splice(0,1)[0]),g=i();while(g===e&&g.length&&g[0].offset===l);f.reverse().forEach(o)}else"start"===g[0].event?f.push(g[0].node):f.pop(),c(g.splice(0,1)[0])}return s+n(a.substr(l))}function l(e){return e.v&&!e.cached_variants&&(e.cached_variants=e.v.map(function(n){return o(e,{v:null},n)})),e.cached_variants||e.eW&&[o(e)]||[e]}function s(e){function n(e){return e&&e.source||e}function t(t,r){return new RegExp(n(t),"m"+(e.cI?"i":"")+(r?"g":""))}function r(a,i){if(!a.compiled){if(a.compiled=!0,a.k=a.k||a.bK,a.k){var o={},u=function(n,t){e.cI&&(t=t.toLowerCase()),t.split(" ").forEach(function(e){var t=e.split("|");o[t[0]]=[n,t[1]?Number(t[1]):1]})};"string"==typeof a.k?u("keyword",a.k):x(a.k).forEach(function(e){u(e,a.k[e])}),a.k=o}a.lR=t(a.l||/\w+/,!0),i&&(a.bK&&(a.b="\\b("+a.bK.split(" ").join("|")+")\\b"),a.b||(a.b=/\B|\b/),a.bR=t(a.b),a.e||a.eW||(a.e=/\B|\b/),a.e&&(a.eR=t(a.e)),a.tE=n(a.e)||"",a.eW&&i.tE&&(a.tE+=(a.e?"|":"")+i.tE)),a.i&&(a.iR=t(a.i)),null==a.r&&(a.r=1),a.c||(a.c=[]),a.c=Array.prototype.concat.apply([],a.c.map(function(e){return l("self"===e?a:e)})),a.c.forEach(function(e){r(e,a)}),a.starts&&r(a.starts,i);var c=a.c.map(function(e){return e.bK?"\\.?("+e.b+")\\.?":e.b}).concat([a.tE,a.i]).map(n).filter(Boolean);a.t=c.length?t(c.join("|"),!0):{exec:function(){return null}}}}r(e)}function f(e,t,a,i){function o(e,n){var t,a;for(t=0,a=n.c.length;a>t;t++)if(r(n.c[t].bR,e))return n.c[t]}function u(e,n){if(r(e.eR,n)){for(;e.endsParent&&e.parent;)e=e.parent;return e}return e.eW?u(e.parent,n):void 0}function c(e,n){return!a&&r(n.iR,e)}function l(e,n){var t=N.cI?n[0].toLowerCase():n[0];return e.k.hasOwnProperty(t)&&e.k[t]}function p(e,n,t,r){var a=r?"":I.classPrefix,i='',i+n+o}function h(){var e,t,r,a;if(!E.k)return n(k);for(a="",t=0,E.lR.lastIndex=0,r=E.lR.exec(k);r;)a+=n(k.substring(t,r.index)),e=l(E,r),e?(B+=e[1],a+=p(e[0],n(r[0]))):a+=n(r[0]),t=E.lR.lastIndex,r=E.lR.exec(k);return a+n(k.substr(t))}function d(){var e="string"==typeof E.sL;if(e&&!y[E.sL])return n(k);var t=e?f(E.sL,k,!0,x[E.sL]):g(k,E.sL.length?E.sL:void 0);return E.r>0&&(B+=t.r),e&&(x[E.sL]=t.top),p(t.language,t.value,!1,!0)}function b(){L+=null!=E.sL?d():h(),k=""}function v(e){L+=e.cN?p(e.cN,"",!0):"",E=Object.create(e,{parent:{value:E}})}function m(e,n){if(k+=e,null==n)return b(),0;var t=o(n,E);if(t)return t.skip?k+=n:(t.eB&&(k+=n),b(),t.rB||t.eB||(k=n)),v(t,n),t.rB?0:n.length;var r=u(E,n);if(r){var a=E;a.skip?k+=n:(a.rE||a.eE||(k+=n),b(),a.eE&&(k=n));do E.cN&&(L+=C),E.skip||(B+=E.r),E=E.parent;while(E!==r.parent);return r.starts&&v(r.starts,""),a.rE?0:n.length}if(c(n,E))throw new Error('Illegal lexeme "'+n+'" for mode "'+(E.cN||"")+'"');return k+=n,n.length||1}var N=w(e);if(!N)throw new Error('Unknown language: "'+e+'"');s(N);var R,E=i||N,x={},L="";for(R=E;R!==N;R=R.parent)R.cN&&(L=p(R.cN,"",!0)+L);var k="",B=0;try{for(var M,j,O=0;;){if(E.t.lastIndex=O,M=E.t.exec(t),!M)break;j=m(t.substring(O,M.index),M[0]),O=M.index+j}for(m(t.substr(O)),R=E;R.parent;R=R.parent)R.cN&&(L+=C);return{r:B,value:L,language:e,top:E}}catch(T){if(T.message&&-1!==T.message.indexOf("Illegal"))return{r:0,value:n(t)};throw T}}function g(e,t){t=t||I.languages||x(y);var r={r:0,value:n(e)},a=r;return t.filter(w).forEach(function(n){var t=f(n,e,!1);t.language=n,t.r>a.r&&(a=t),t.r>r.r&&(a=r,r=t)}),a.language&&(r.second_best=a),r}function p(e){return I.tabReplace||I.useBR?e.replace(M,function(e,n){return I.useBR&&"\n"===e?"
":I.tabReplace?n.replace(/\t/g,I.tabReplace):""}):e}function h(e,n,t){var r=n?L[n]:t,a=[e.trim()];return e.match(/\bhljs\b/)||a.push("hljs"),-1===e.indexOf(r)&&a.push(r),a.join(" ").trim()}function d(e){var n,t,r,o,l,s=i(e);a(s)||(I.useBR?(n=document.createElementNS("http://www.w3.org/1999/xhtml","div"),n.innerHTML=e.innerHTML.replace(/\n/g,"").replace(//g,"\n")):n=e,l=n.textContent,r=s?f(s,l,!0):g(l),t=u(n),t.length&&(o=document.createElementNS("http://www.w3.org/1999/xhtml","div"),o.innerHTML=r.value,r.value=c(t,u(o),l)),r.value=p(r.value),e.innerHTML=r.value,e.className=h(e.className,s,r.language),e.result={language:r.language,re:r.r},r.second_best&&(e.second_best={language:r.second_best.language,re:r.second_best.r}))}function b(e){I=o(I,e)}function v(){if(!v.called){v.called=!0;var e=document.querySelectorAll("pre code");E.forEach.call(e,d)}}function m(){addEventListener("DOMContentLoaded",v,!1),addEventListener("load",v,!1)}function N(n,t){var r=y[n]=t(e);r.aliases&&r.aliases.forEach(function(e){L[e]=n})}function R(){return x(y)}function w(e){return e=(e||"").toLowerCase(),y[e]||y[L[e]]}var E=[],x=Object.keys,y={},L={},k=/^(no-?highlight|plain|text)$/i,B=/\blang(?:uage)?-([\w-]+)\b/i,M=/((^(<[^>]+>|\t|)+|(?:\n)))/gm,C="
",I={classPrefix:"hljs-",tabReplace:null,useBR:!1,languages:void 0};return e.highlight=f,e.highlightAuto=g,e.fixMarkup=p,e.highlightBlock=d,e.configure=b,e.initHighlighting=v,e.initHighlightingOnLoad=m,e.registerLanguage=N,e.listLanguages=R,e.getLanguage=w,e.inherit=o,e.IR="[a-zA-Z]\\w*",e.UIR="[a-zA-Z_]\\w*",e.NR="\\b\\d+(\\.\\d+)?",e.CNR="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",e.BNR="\\b(0b[01]+)",e.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",e.BE={b:"\\\\[\\s\\S]",r:0},e.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[e.BE]},e.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[e.BE]},e.PWM={b:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},e.C=function(n,t,r){var a=e.inherit({cN:"comment",b:n,e:t,c:[]},r||{});return a.c.push(e.PWM),a.c.push({cN:"doctag",b:"(?:TODO|FIXME|NOTE|BUG|XXX):",r:0}),a},e.CLCM=e.C("//","$"),e.CBCM=e.C("/\\*","\\*/"),e.HCM=e.C("#","$"),e.NM={cN:"number",b:e.NR,r:0},e.CNM={cN:"number",b:e.CNR,r:0},e.BNM={cN:"number",b:e.BNR,r:0},e.CSSNM={cN:"number",b:e.NR+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",r:0},e.RM={cN:"regexp",b:/\//,e:/\/[gimuy]*/,i:/\n/,c:[e.BE,{b:/\[/,e:/\]/,r:0,c:[e.BE]}]},e.TM={cN:"title",b:e.IR,r:0},e.UTM={cN:"title",b:e.UIR,r:0},e.METHOD_GUARD={b:"\\.\\s*"+e.UIR,r:0},e});hljs.registerLanguage("verilog",function(e){var n={keyword:"accept_on alias always always_comb always_ff always_latch and assert assign assume automatic before begin bind bins binsof bit break buf|0 bufif0 bufif1 byte case casex casez cell chandle checker class clocking cmos config const constraint context continue cover covergroup coverpoint cross deassign default defparam design disable dist do edge else end endcase endchecker endclass endclocking endconfig endfunction endgenerate endgroup endinterface endmodule endpackage endprimitive endprogram endproperty endspecify endsequence endtable endtask enum event eventually expect export extends extern final first_match for force foreach forever fork forkjoin function generate|5 genvar global highz0 highz1 if iff ifnone ignore_bins illegal_bins implements implies import incdir include initial inout input inside instance int integer interconnect interface intersect join join_any join_none large let liblist library local localparam logic longint macromodule matches medium modport module nand negedge nettype new nexttime nmos nor noshowcancelled not notif0 notif1 or output package packed parameter pmos posedge primitive priority program property protected pull0 pull1 pulldown pullup pulsestyle_ondetect pulsestyle_onevent pure rand randc randcase randsequence rcmos real realtime ref reg reject_on release repeat restrict return rnmos rpmos rtran rtranif0 rtranif1 s_always s_eventually s_nexttime s_until s_until_with scalared sequence shortint shortreal showcancelled signed small soft solve specify specparam static string strong strong0 strong1 struct super supply0 supply1 sync_accept_on sync_reject_on table tagged task this throughout time timeprecision timeunit tran tranif0 tranif1 tri tri0 tri1 triand trior trireg type typedef union unique unique0 unsigned until until_with untyped use uwire var vectored virtual void wait wait_order wand weak weak0 weak1 while wildcard wire with within wor xnor xor",literal:"null",built_in:"$finish $stop $exit $fatal $error $warning $info $realtime $time $printtimescale $bitstoreal $bitstoshortreal $itor $signed $cast $bits $stime $timeformat $realtobits $shortrealtobits $rtoi $unsigned $asserton $assertkill $assertpasson $assertfailon $assertnonvacuouson $assertoff $assertcontrol $assertpassoff $assertfailoff $assertvacuousoff $isunbounded $sampled $fell $changed $past_gclk $fell_gclk $changed_gclk $rising_gclk $steady_gclk $coverage_control $coverage_get $coverage_save $set_coverage_db_name $rose $stable $past $rose_gclk $stable_gclk $future_gclk $falling_gclk $changing_gclk $display $coverage_get_max $coverage_merge $get_coverage $load_coverage_db $typename $unpacked_dimensions $left $low $increment $clog2 $ln $log10 $exp $sqrt $pow $floor $ceil $sin $cos $tan $countbits $onehot $isunknown $fatal $warning $dimensions $right $high $size $asin $acos $atan $atan2 $hypot $sinh $cosh $tanh $asinh $acosh $atanh $countones $onehot0 $error $info $random $dist_chi_square $dist_erlang $dist_exponential $dist_normal $dist_poisson $dist_t $dist_uniform $q_initialize $q_remove $q_exam $async$and$array $async$nand$array $async$or$array $async$nor$array $sync$and$array $sync$nand$array $sync$or$array $sync$nor$array $q_add $q_full $psprintf $async$and$plane $async$nand$plane $async$or$plane $async$nor$plane $sync$and$plane $sync$nand$plane $sync$or$plane $sync$nor$plane $system $display $displayb $displayh $displayo $strobe $strobeb $strobeh $strobeo $write $readmemb $readmemh $writememh $value$plusargs $dumpvars $dumpon $dumplimit $dumpports $dumpportson $dumpportslimit $writeb $writeh $writeo $monitor $monitorb $monitorh $monitoro $writememb $dumpfile $dumpoff $dumpall $dumpflush $dumpportsoff $dumpportsall $dumpportsflush $fclose $fdisplay $fdisplayb $fdisplayh $fdisplayo $fstrobe $fstrobeb $fstrobeh $fstrobeo $swrite $swriteb $swriteh $swriteo $fscanf $fread $fseek $fflush $feof $fopen $fwrite $fwriteb $fwriteh $fwriteo $fmonitor $fmonitorb $fmonitorh $fmonitoro $sformat $sformatf $fgetc $ungetc $fgets $sscanf $rewind $ftell $ferror"};return{aliases:["v","sv","svh"],cI:!1,k:n,l:/[\w\$]+/,c:[e.CBCM,e.CLCM,e.QSM,{cN:"number",c:[e.BE],v:[{b:"\\b((\\d+'(b|h|o|d|B|H|O|D))[0-9xzXZa-fA-F_]+)"},{b:"\\B(('(b|h|o|d|B|H|O|D))[0-9xzXZa-fA-F_]+)"},{b:"\\b([0-9_])+",r:0}]},{cN:"variable",v:[{b:"#\\((?!parameter).+\\)"},{b:"\\.\\w+",r:0}]},{cN:"meta",b:"`",e:"$",k:{"meta-keyword":"define __FILE__ __LINE__ begin_keywords celldefine default_nettype define else elsif end_keywords endcelldefine endif ifdef ifndef include line nounconnected_drive pragma resetall timescale unconnected_drive undef undefineall"},r:0}]}});hljs.registerLanguage("cpp",function(t){var e={cN:"keyword",b:"\\b[a-z\\d_]*_t\\b"},r={cN:"string",v:[{b:'(u8?|U)?L?"',e:'"',i:"\\n",c:[t.BE]},{b:'(u8?|U)?R"',e:'"',c:[t.BE]},{b:"'\\\\?.",e:"'",i:"."}]},s={cN:"number",v:[{b:"\\b(0b[01']+)"},{b:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{b:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],r:0},i={cN:"meta",b:/#\s*[a-z]+\b/,e:/$/,k:{"meta-keyword":"if else elif endif define undef warning error line pragma ifdef ifndef include"},c:[{b:/\\\n/,r:0},t.inherit(r,{cN:"meta-string"}),{cN:"meta-string",b:/<[^\n>]*>/,e:/$/,i:"\\n"},t.CLCM,t.CBCM]},a=t.IR+"\\s*\\(",c={keyword:"int float while private char catch import module export virtual operator sizeof dynamic_cast|10 typedef const_cast|10 const for static_cast|10 union namespace unsigned long volatile static protected bool template mutable if public friend do goto auto void enum else break extern using asm case typeid short reinterpret_cast|10 default double register explicit signed typename try this switch continue inline delete alignof constexpr decltype noexcept static_assert thread_local restrict _Bool complex _Complex _Imaginary atomic_bool atomic_char atomic_schar atomic_uchar atomic_short atomic_ushort atomic_int atomic_uint atomic_long atomic_ulong atomic_llong atomic_ullong new throw return and or not",built_in:"std string cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap array shared_ptr abort abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr",literal:"true false nullptr NULL"},n=[e,t.CLCM,t.CBCM,s,r];return{aliases:["c","cc","h","c++","h++","hpp"],k:c,i:"",k:c,c:["self",e]},{b:t.IR+"::",k:c},{v:[{b:/=/,e:/;/},{b:/\(/,e:/\)/},{bK:"new throw return else",e:/;/}],k:c,c:n.concat([{b:/\(/,e:/\)/,k:c,c:n.concat(["self"]),r:0}]),r:0},{cN:"function",b:"("+t.IR+"[\\*&\\s]+)+"+a,rB:!0,e:/[{;=]/,eE:!0,k:c,i:/[^\w\s\*&]/,c:[{b:a,rB:!0,c:[t.TM],r:0},{cN:"params",b:/\(/,e:/\)/,k:c,r:0,c:[t.CLCM,t.CBCM,r,s,e]},t.CLCM,t.CBCM,i]},{cN:"class",bK:"class struct",e:/[{;:]/,c:[{b://,c:["self"]},t.TM]}]),exports:{preprocessor:i,strings:r,k:c}}}); \ No newline at end of file diff --git a/doc/html-manual/highlight/styles/darkula.css b/doc/html-manual/highlight/styles/darkula.css index c01f9a7fced..f4646c3c5dc 100644 --- a/doc/html-manual/highlight/styles/darkula.css +++ b/doc/html-manual/highlight/styles/darkula.css @@ -1,74 +1,6 @@ /* - -Darkula color scheme from the JetBrains family of IDEs - + Deprecated due to a typo in the name and left here for compatibility purpose only. + Please use darcula.css instead. */ - -.hljs { - display: block; - overflow-x: auto; - padding: 0.5em; - background: #2b2b2b; -} - -.hljs { - color: #bababa; -} - -.hljs-strong, -.hljs-emphasis { - color: #a8a8a2; -} - -.hljs-bullet, -.hljs-quote, -.hljs-link, -.hljs-number, -.hljs-regexp, -.hljs-literal { - color: #6896ba; -} - -.hljs-code, -.hljs-selector-class { - color: #a6e22e; -} - -.hljs-emphasis { - font-style: italic; -} - -.hljs-keyword, -.hljs-selector-tag, -.hljs-section, -.hljs-attribute, -.hljs-name, -.hljs-variable { - color: #cb7832; -} - -.hljs-params { - color: #b9b9b9; -} - -.hljs-string, -.hljs-subst, -.hljs-type, -.hljs-built_in, -.hljs-builtin-name, -.hljs-symbol, -.hljs-selector-id, -.hljs-selector-attr, -.hljs-selector-pseudo, -.hljs-template-tag, -.hljs-template-variable, -.hljs-addition { - color: #e0c46c; -} - -.hljs-comment, -.hljs-deletion, -.hljs-meta { - color: #7f7f7f; -} +@import url('darcula.css'); diff --git a/doc/html-manual/hwsw-inputs.shtml b/doc/html-manual/hwsw-inputs.shtml index 9a63293ff4f..f1ffdbbeece 100644 --- a/doc/html-manual/hwsw-inputs.shtml +++ b/doc/html-manual/hwsw-inputs.shtml @@ -1,8 +1,8 @@ - - + +

CPROVER Manual TOC

diff --git a/doc/html-manual/hwsw-mapping.shtml b/doc/html-manual/hwsw-mapping.shtml index c206ca753ea..6c953dd28c9 100644 --- a/doc/html-manual/hwsw-mapping.shtml +++ b/doc/html-manual/hwsw-mapping.shtml @@ -1,8 +1,8 @@ - - + +

CPROVER Manual TOC

diff --git a/doc/html-manual/hwsw-tutorial.shtml b/doc/html-manual/hwsw-tutorial.shtml index 926264d81bf..bda19537597 100644 --- a/doc/html-manual/hwsw-tutorial.shtml +++ b/doc/html-manual/hwsw-tutorial.shtml @@ -1,8 +1,8 @@ - - + +

CPROVER Manual TOC

diff --git a/doc/html-manual/hwsw.shtml b/doc/html-manual/hwsw.shtml index 298b78f9a08..88fba4e5fe9 100644 --- a/doc/html-manual/hwsw.shtml +++ b/doc/html-manual/hwsw.shtml @@ -36,7 +36,7 @@ the consistency of the HDL implementation is highly desirable.

This motivates the verification problem: we want to verify the consistency of the HDL implementation, i.e., the product, - + using the ANSI-C implementation as a reference. Es­ta­bli­shing the consistency does not re­quire a formal specification. However, formal methods to verify either the hardware or software design are still desirable. @@ -90,13 +90,12 @@ methodology allows arbitrary loop constructs. tutorial and a description on how to synchronize inputs between the C model and the Verilog model. There is also a collection of -benchmark problems available. +benchmark problems available.

Further Reading
-

-

+
diff --git a/doc/html-manual/introduction.shtml b/doc/html-manual/introduction.shtml index 49d3af2b818..687e0564846 100644 --- a/doc/html-manual/introduction.shtml +++ b/doc/html-manual/introduction.shtml @@ -151,13 +151,11 @@ SATABS are described here. diff --git a/doc/html-manual/modeling-assertions.shtml b/doc/html-manual/modeling-assertions.shtml index d85909a6795..19ef6e65d16 100644 --- a/doc/html-manual/modeling-assertions.shtml +++ b/doc/html-manual/modeling-assertions.shtml @@ -1,8 +1,8 @@ - - + +

CPROVER Manual TOC

diff --git a/doc/html-manual/modeling-pointers.shtml b/doc/html-manual/modeling-pointers.shtml index d8cfa7f31c4..fb3a506cf80 100644 --- a/doc/html-manual/modeling-pointers.shtml +++ b/doc/html-manual/modeling-pointers.shtml @@ -1,8 +1,8 @@ - - + +

CPROVER Manual TOC

diff --git a/doc/html-manual/properties.shtml b/doc/html-manual/properties.shtml index aba408fc4c8..af493809980 100644 --- a/doc/html-manual/properties.shtml +++ b/doc/html-manual/properties.shtml @@ -185,7 +185,6 @@ we can obtain a counterexample trace for the NULL-pointer dereference: checks:

-

@@ -198,15 +197,12 @@ checks:
--no-assertions ignore user assertions
--bounds-check add array bounds checks
--uninitialized-check add checks for uninitialized locals (experimental)
--error-label labelcheck that given label is unreachable
-

diff --git a/doc/html-manual/satabs-aeon.shtml b/doc/html-manual/satabs-aeon.shtml index ac40245b830..3f078d406f2 100644 --- a/doc/html-manual/satabs-aeon.shtml +++ b/doc/html-manual/satabs-aeon.shtml @@ -1,8 +1,8 @@ - - + +

CPROVER Manual TOC

@@ -181,7 +181,7 @@ same function:

Claim getConfig.7:
  file lib_aeon.c line 19 function getConfig
  dereference failure: array `home' upper bound
-  !(POINTER_OFFSET(dst) + (int)i >= 512) || !(SAME-OBJECT(dst, &home[0]))
+  !(POINTER_OFFSET(dst) + (int)i >= 512) || !(SAME-OBJECT(dst, &home[0]))

@@ -258,7 +258,7 @@ overflow: Violated property:
  file stubs.c line 8 column 10 function c::strcpy
  dereference failure: array `home' upper bound
-  !(dest == \&home[0]) $\vert\vert$ !(i $>$= 512)} +  !(dest == &home[0]) $\vert\vert$ !(i $>$= 512)} --> diff --git a/doc/html-manual/satabs-driver.shtml b/doc/html-manual/satabs-driver.shtml index b4b34954986..2774b3fef68 100644 --- a/doc/html-manual/satabs-driver.shtml +++ b/doc/html-manual/satabs-driver.shtml @@ -1,8 +1,8 @@ - - + +

CPROVER Manual TOC

diff --git a/doc/html-manual/satabs.shtml b/doc/html-manual/satabs.shtml index 6ec21bb45b3..84180120471 100644 --- a/doc/html-manual/satabs.shtml +++ b/doc/html-manual/satabs.shtml @@ -1,8 +1,8 @@ - - + +

CPROVER Manual TOC

@@ -165,8 +165,6 @@ validity of the properties if SATABS did not run to completion!
Further Reading
- -

-

+
diff --git a/regression/Makefile b/regression/Makefile index 1079463d977..b2f31798489 100644 --- a/regression/Makefile +++ b/regression/Makefile @@ -13,3 +13,10 @@ DIRS = ansi-c \ test: $(foreach var,$(DIRS), $(MAKE) -C $(var) test || exit 1;) + +clean: + @for dir in *; do \ + if [ -d "$$dir" ]; then \ + $(MAKE) -C "$$dir" clean; \ + fi; \ + done; diff --git a/regression/ansi-c/arch_flags_mcpu_bad/object.intel b/regression/ansi-c/arch_flags_mcpu_bad/object.intel new file mode 100644 index 00000000000..cc6ea40a25e Binary files /dev/null and b/regression/ansi-c/arch_flags_mcpu_bad/object.intel differ diff --git a/regression/ansi-c/arch_flags_mcpu_bad/preproc.i b/regression/ansi-c/arch_flags_mcpu_bad/preproc.i new file mode 100644 index 00000000000..40378b80eb1 --- /dev/null +++ b/regression/ansi-c/arch_flags_mcpu_bad/preproc.i @@ -0,0 +1 @@ +int foo() { return 3; } diff --git a/regression/ansi-c/arch_flags_mcpu_bad/source.c b/regression/ansi-c/arch_flags_mcpu_bad/source.c new file mode 100644 index 00000000000..a7fc7966665 --- /dev/null +++ b/regression/ansi-c/arch_flags_mcpu_bad/source.c @@ -0,0 +1 @@ +int bar(){ return 9; } diff --git a/regression/ansi-c/arch_flags_mcpu_bad/test.desc b/regression/ansi-c/arch_flags_mcpu_bad/test.desc new file mode 100644 index 00000000000..c62fc66cad3 --- /dev/null +++ b/regression/ansi-c/arch_flags_mcpu_bad/test.desc @@ -0,0 +1,20 @@ +CORE +preproc.i +-mcpu=cortex-a15 -o linked-object.gb object.intel +^EXIT=(64|1)$ +^SIGNAL=0$ +-- +^warning: ignoring +^CONVERSION ERROR$ +-- +This tests the -mcpu=cortex=a15 flag that should activate ARM-32 mode. +The object file 'object.intel' was compiled from 'source.c' with goto-cc +on a 64-bit platform: + + goto-cc -c source.c + +preproc.i is already pre-processed so that it can be linked in without +needing to invoke a pre-processor from a cross-compile toolchain on your +local machine. Linking it together with the Intel object file, while +passing -mcpu=cortex-a15 on the command line, should fail because +-mcpu=cortex-a15 implies that we're trying to make an ARM executable. diff --git a/regression/ansi-c/arch_flags_mcpu_good/object.arm b/regression/ansi-c/arch_flags_mcpu_good/object.arm new file mode 100644 index 00000000000..7c14d169f62 Binary files /dev/null and b/regression/ansi-c/arch_flags_mcpu_good/object.arm differ diff --git a/regression/ansi-c/arch_flags_mcpu_good/preproc.i b/regression/ansi-c/arch_flags_mcpu_good/preproc.i new file mode 100644 index 00000000000..40378b80eb1 --- /dev/null +++ b/regression/ansi-c/arch_flags_mcpu_good/preproc.i @@ -0,0 +1 @@ +int foo() { return 3; } diff --git a/regression/ansi-c/arch_flags_mcpu_good/source.c b/regression/ansi-c/arch_flags_mcpu_good/source.c new file mode 100644 index 00000000000..a7fc7966665 --- /dev/null +++ b/regression/ansi-c/arch_flags_mcpu_good/source.c @@ -0,0 +1 @@ +int bar(){ return 9; } diff --git a/regression/ansi-c/arch_flags_mcpu_good/test.desc b/regression/ansi-c/arch_flags_mcpu_good/test.desc new file mode 100644 index 00000000000..c02992dcb8d --- /dev/null +++ b/regression/ansi-c/arch_flags_mcpu_good/test.desc @@ -0,0 +1,20 @@ +CORE +preproc.i +-mcpu=cortex-a15 -o linked-object.gb object.arm +^EXIT=0$ +^SIGNAL=0$ +-- +^warning: ignoring +^CONVERSION ERROR$ +-- +This tests the -mcpu=cortex-a15 flag that should activate ARM-32 mode. +The object file 'object.arm' was compiled from 'source.c' with goto-cc +along with an ARM cross-compiler on a 64-bit platform with the following +command line: + + goto-cc --native-compiler=arm-none-eabi-gcc -mcpu=cortex-a15 -c source.c + +preproc.i is already pre-processed so that it can be linked in without +needing to invoke a pre-processor from a cross-compile toolchain on your +local machine. Linking it together with the ARM object file, while +passing -mcpu=cortex-a15 on the command line, should succeed. diff --git a/regression/ansi-c/arch_flags_mthumb_bad/object.intel b/regression/ansi-c/arch_flags_mthumb_bad/object.intel new file mode 100644 index 00000000000..cc6ea40a25e Binary files /dev/null and b/regression/ansi-c/arch_flags_mthumb_bad/object.intel differ diff --git a/regression/ansi-c/arch_flags_mthumb_bad/preproc.i b/regression/ansi-c/arch_flags_mthumb_bad/preproc.i new file mode 100644 index 00000000000..40378b80eb1 --- /dev/null +++ b/regression/ansi-c/arch_flags_mthumb_bad/preproc.i @@ -0,0 +1 @@ +int foo() { return 3; } diff --git a/regression/ansi-c/arch_flags_mthumb_bad/source.c b/regression/ansi-c/arch_flags_mthumb_bad/source.c new file mode 100644 index 00000000000..a7fc7966665 --- /dev/null +++ b/regression/ansi-c/arch_flags_mthumb_bad/source.c @@ -0,0 +1 @@ +int bar(){ return 9; } diff --git a/regression/ansi-c/arch_flags_mthumb_bad/test.desc b/regression/ansi-c/arch_flags_mthumb_bad/test.desc new file mode 100644 index 00000000000..b3616051bd2 --- /dev/null +++ b/regression/ansi-c/arch_flags_mthumb_bad/test.desc @@ -0,0 +1,20 @@ +CORE +preproc.i +-mthumb -o linked-object.gb object.intel +^EXIT=(64|1)$ +^SIGNAL=0$ +-- +^warning: ignoring +^CONVERSION ERROR$ +-- +This tests the -mthumb flag that should activate ARM-32 mode. The object +file 'object.intel' was compiled from 'source.c' with goto-cc on a +64-bit platform: + + goto-cc -c source.c + +preproc.i is already pre-processed so that it can be linked in without +needing to invoke a pre-processor from a cross-compile toolchain on your +local machine. Linking it together with the Intel object file, while +passing -mthumb on the command line, should fail because -mthumb implies +that we're trying to make an ARM executable. diff --git a/regression/ansi-c/arch_flags_mthumb_good/object.arm b/regression/ansi-c/arch_flags_mthumb_good/object.arm new file mode 100644 index 00000000000..7c14d169f62 Binary files /dev/null and b/regression/ansi-c/arch_flags_mthumb_good/object.arm differ diff --git a/regression/ansi-c/arch_flags_mthumb_good/preproc.i b/regression/ansi-c/arch_flags_mthumb_good/preproc.i new file mode 100644 index 00000000000..40378b80eb1 --- /dev/null +++ b/regression/ansi-c/arch_flags_mthumb_good/preproc.i @@ -0,0 +1 @@ +int foo() { return 3; } diff --git a/regression/ansi-c/arch_flags_mthumb_good/source.c b/regression/ansi-c/arch_flags_mthumb_good/source.c new file mode 100644 index 00000000000..a7fc7966665 --- /dev/null +++ b/regression/ansi-c/arch_flags_mthumb_good/source.c @@ -0,0 +1 @@ +int bar(){ return 9; } diff --git a/regression/ansi-c/arch_flags_mthumb_good/test.desc b/regression/ansi-c/arch_flags_mthumb_good/test.desc new file mode 100644 index 00000000000..02a5c7389e3 --- /dev/null +++ b/regression/ansi-c/arch_flags_mthumb_good/test.desc @@ -0,0 +1,20 @@ +CORE +preproc.i +-mthumb -o linked-object.gb object.arm +^EXIT=0$ +^SIGNAL=0$ +-- +^warning: ignoring +^CONVERSION ERROR$ +-- +This tests the -mthumb flag that should activate ARM-32 mode. The object +file 'object.arm' was compiled from 'source.c' with goto-cc along with +an ARM cross-compiler on a 64-bit platform with the following command +line: + + goto-cc --native-compiler=arm-none-eabi-gcc -mthumb -c source.c + +preproc.i is already pre-processed so that it can be linked in without +needing to invoke a pre-processor from a cross-compile toolchain on your +local machine. Linking it together with the ARM object file, while +passing -mthumb on the command line, should succeed. diff --git a/regression/ansi-c/gcc_builtins6/main.c b/regression/ansi-c/gcc_builtins6/main.c new file mode 100644 index 00000000000..706dd6196be --- /dev/null +++ b/regression/ansi-c/gcc_builtins6/main.c @@ -0,0 +1,23 @@ +#include + +struct S +{ + int x; + union { + int y; + struct S2 + { + int z; + } s[1]; + } u[2]; +}; + +int main() +{ + int A[offsetof(struct S, u[0].y)==sizeof(int)?1:-1]; +#if defined(__GNUC__) && !defined(__clang__) + int B[offsetof(struct S, u->y)==sizeof(int)?1:-1]; + int C[offsetof(struct S, u->s[0].z)==sizeof(int)?1:-1]; +#endif + return 0; +} diff --git a/regression/ansi-c/gcc_builtins6/test.desc b/regression/ansi-c/gcc_builtins6/test.desc new file mode 100644 index 00000000000..466da18b2b5 --- /dev/null +++ b/regression/ansi-c/gcc_builtins6/test.desc @@ -0,0 +1,8 @@ +CORE +main.c + +^EXIT=0$ +^SIGNAL=0$ +-- +^warning: ignoring +^CONVERSION ERROR$ diff --git a/regression/ansi-c/message_handling1/main.c b/regression/ansi-c/message_handling1/main.c new file mode 100644 index 00000000000..00193b44b77 --- /dev/null +++ b/regression/ansi-c/message_handling1/main.c @@ -0,0 +1,9 @@ +int main() +{ + goto bla; + + for(int i=0; i<5; ++i) + { +bla: i=10; + } +} diff --git a/regression/ansi-c/message_handling1/test.desc b/regression/ansi-c/message_handling1/test.desc new file mode 100644 index 00000000000..277edf65161 --- /dev/null +++ b/regression/ansi-c/message_handling1/test.desc @@ -0,0 +1,7 @@ +CORE +main.c +--verbosity 2 +^EXIT=0$ +^SIGNAL=0$ +-- +encountered goto `bla' that enters one or more lexical blocks diff --git a/regression/cbmc-java/NondetArray2/test.desc b/regression/cbmc-java/NondetArray2/test.desc index 5e84e0dbf7c..2a274211c6c 100644 --- a/regression/cbmc-java/NondetArray2/test.desc +++ b/regression/cbmc-java/NondetArray2/test.desc @@ -3,4 +3,6 @@ NondetArray2.class --function NondetArray2.main --unwind 5 ^VERIFICATION SUCCESSFUL$ -- +-- +Disabled pending fixing warnings for array-of with zero length: ^warning: ignoring diff --git a/regression/cbmc-java/NondetArray3/test.desc b/regression/cbmc-java/NondetArray3/test.desc index a0f68ce5a41..de192436903 100644 --- a/regression/cbmc-java/NondetArray3/test.desc +++ b/regression/cbmc-java/NondetArray3/test.desc @@ -3,4 +3,6 @@ NondetArray3.class --function NondetArray3.main --unwind 5 ^VERIFICATION SUCCESSFUL$ -- +-- +Disabled pending fixing warnings for array-of with zero length: ^warning: ignoring diff --git a/regression/cbmc-java/NondetGenericArray/test.desc b/regression/cbmc-java/NondetGenericArray/test.desc index e9ace0bad35..9abfffc4b9f 100644 --- a/regression/cbmc-java/NondetGenericArray/test.desc +++ b/regression/cbmc-java/NondetGenericArray/test.desc @@ -3,4 +3,6 @@ NondetGenericArray.class --function NondetGenericArray.main ^VERIFICATION SUCCESSFUL$ -- +-- +Disabled pending fixing warnings for array-of with zero length: ^warning: ignoring diff --git a/regression/cbmc/Linking5/test.desc b/regression/cbmc/Linking5/test.desc index 14350cd4399..d88e6744dbd 100644 --- a/regression/cbmc/Linking5/test.desc +++ b/regression/cbmc/Linking5/test.desc @@ -1,4 +1,4 @@ -KNOWNBUG +CORE link1.c link2.c ^EXIT=0$ diff --git a/regression/cbmc/Linking6/main.c b/regression/cbmc/Linking6/main.c new file mode 100644 index 00000000000..ff1234d5cd4 --- /dev/null +++ b/regression/cbmc/Linking6/main.c @@ -0,0 +1,23 @@ +#include + +void set(); + +char buffer[10]; + +void init() { + int i; + for (i = 0; i < 10; i++) {buffer[i] = 0;} +} + +void print() { + printf("buffer = %s\n",buffer); +} + +void main () { + init(); + set(); + print(); +} + + + diff --git a/regression/cbmc/Linking6/module.c b/regression/cbmc/Linking6/module.c new file mode 100644 index 00000000000..a4353324f3d --- /dev/null +++ b/regression/cbmc/Linking6/module.c @@ -0,0 +1,9 @@ +#include + +extern char buffer[]; + +static size_t _debug_tempBufferHead = ((size_t)(&buffer)); + +void set() { + *(char *)_debug_tempBufferHead = 'a'; +} diff --git a/regression/cbmc/Linking6/test.desc b/regression/cbmc/Linking6/test.desc new file mode 100644 index 00000000000..67f1dd7303f --- /dev/null +++ b/regression/cbmc/Linking6/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +module.c --pointer-check +^EXIT=0$ +^SIGNAL=0$ +^VERIFICATION SUCCESSFUL$ +-- +^warning: ignoring diff --git a/regression/cbmc/Malloc19/test.desc b/regression/cbmc/Malloc19/test.desc index a27d6e3414c..9c96469df12 100644 --- a/regression/cbmc/Malloc19/test.desc +++ b/regression/cbmc/Malloc19/test.desc @@ -1,4 +1,4 @@ -KNOWNBUG +CORE main.c ^EXIT=0$ diff --git a/regression/cbmc/Malloc20/test.desc b/regression/cbmc/Malloc20/test.desc index a27d6e3414c..9c96469df12 100644 --- a/regression/cbmc/Malloc20/test.desc +++ b/regression/cbmc/Malloc20/test.desc @@ -1,4 +1,4 @@ -KNOWNBUG +CORE main.c ^EXIT=0$ diff --git a/regression/cbmc/byte_update8/main.c b/regression/cbmc/byte_update8/main.c new file mode 100644 index 00000000000..85b3582585c --- /dev/null +++ b/regression/cbmc/byte_update8/main.c @@ -0,0 +1,12 @@ +#include + +int main() +{ + int x=0x01020304; + short *p=((short*)&x)+1; + *p=0xABCD; + assert(x==0xABCD0304); + p=(short*)(((char*)&x)+1); + *p=0xABCD; + assert(x==0xABABCD04); +} diff --git a/regression/cbmc/byte_update8/test.desc b/regression/cbmc/byte_update8/test.desc new file mode 100644 index 00000000000..9efefbc7362 --- /dev/null +++ b/regression/cbmc/byte_update8/test.desc @@ -0,0 +1,8 @@ +CORE +main.c + +^EXIT=0$ +^SIGNAL=0$ +^VERIFICATION SUCCESSFUL$ +-- +^warning: ignoring diff --git a/regression/cbmc/byte_update9/main.c b/regression/cbmc/byte_update9/main.c new file mode 100644 index 00000000000..21e0a4d3a46 --- /dev/null +++ b/regression/cbmc/byte_update9/main.c @@ -0,0 +1,12 @@ +#include + +int main() +{ + int x=0x01020304; + short *p=((short*)&x)+1; + *p=0xABCD; + assert(x==0x0102ABCD); + p=(short*)(((char*)&x)+1); + *p=0xABCD; + assert(x==0x01ABCDCD); +} diff --git a/regression/cbmc/byte_update9/test.desc b/regression/cbmc/byte_update9/test.desc new file mode 100644 index 00000000000..81ceb4c6dc0 --- /dev/null +++ b/regression/cbmc/byte_update9/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--big-endian +^EXIT=0$ +^SIGNAL=0$ +^VERIFICATION SUCCESSFUL$ +-- +^warning: ignoring diff --git a/regression/cbmc/constructor1/main.c b/regression/cbmc/constructor1/main.c new file mode 100644 index 00000000000..868b7f4d268 --- /dev/null +++ b/regression/cbmc/constructor1/main.c @@ -0,0 +1,22 @@ +#include + +#ifdef __GNUC__ +int x; + +static __attribute__((constructor)) void format_init(void); + +static __attribute__((constructor)) +void format_init(void) +{ + x=42; + return; +} +#endif + +int main() +{ +#ifdef __GNUC__ + assert(x==42); +#endif + return 0; +} diff --git a/regression/cbmc/constructor1/test.desc b/regression/cbmc/constructor1/test.desc new file mode 100644 index 00000000000..9efefbc7362 --- /dev/null +++ b/regression/cbmc/constructor1/test.desc @@ -0,0 +1,8 @@ +CORE +main.c + +^EXIT=0$ +^SIGNAL=0$ +^VERIFICATION SUCCESSFUL$ +-- +^warning: ignoring diff --git a/regression/cbmc/coverage_report1/main.c b/regression/cbmc/coverage_report1/main.c new file mode 100644 index 00000000000..f8f25fab97f --- /dev/null +++ b/regression/cbmc/coverage_report1/main.c @@ -0,0 +1,23 @@ +int main(int argc, char* argv[]) +{ + if(argc>2) + { + argc=1; + } + else + { + argc=2; + } + + switch(argc) + { + case 0: + argc=3; + break; + case 1: + argc=2; + break; + } + + return 0; +} diff --git a/regression/cbmc/coverage_report1/test.desc b/regression/cbmc/coverage_report1/test.desc new file mode 100644 index 00000000000..81ec99da0b5 --- /dev/null +++ b/regression/cbmc/coverage_report1/test.desc @@ -0,0 +1,9 @@ +CORE +main.c +--symex-coverage-report - + +^EXIT=0$ +^SIGNAL=0$ +^VERIFICATION SUCCESSFUL$ +-- +^warning: ignoring diff --git a/regression/cbmc/full_slice1/main.c b/regression/cbmc/full_slice1/main.c new file mode 100644 index 00000000000..144b1ec60b5 --- /dev/null +++ b/regression/cbmc/full_slice1/main.c @@ -0,0 +1,51 @@ +#include + +typedef enum { + A, + B, + C +} node_t; + +void doit(node_t *node); + +static inline void foo(node_t *node) { } +static inline void bar(node_t *node) { } + +void doit(node_t *node) +{ + switch (*node) + { + case A: + foo(node); + *node=B; + bar(node); + return; + case C: + *node=B; + bar(node); + return; + } +} + +int main() +{ + node_t node=A; + + char count=0; + while(count++<10) + { + char c; + + doit(&node); + + static char q=0; + q=0; + + if(c==0) + { + assert(node == A); + } + } + + return 0; +} diff --git a/regression/cbmc/full_slice1/test.desc b/regression/cbmc/full_slice1/test.desc new file mode 100644 index 00000000000..77b2ad2d1a8 --- /dev/null +++ b/regression/cbmc/full_slice1/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--full-slice --property main.assertion.1 --unwind 1 +^EXIT=10$ +^SIGNAL=0$ +^VERIFICATION FAILED +-- +^warning: ignoring diff --git a/regression/cbmc/full_slice2/main.c b/regression/cbmc/full_slice2/main.c new file mode 100644 index 00000000000..5f129867516 --- /dev/null +++ b/regression/cbmc/full_slice2/main.c @@ -0,0 +1,53 @@ +#include + +typedef enum { + A, + B, + C +} node_t; + +void doit(node_t *node); + +static inline void foo(node_t *node) { } +static inline void bar(node_t *node) { } + +void doit(node_t *node) +{ + switch (*node) + { + case A: + foo(node); + *node=B; + bar(node); + return; + case C: + *node=B; + bar(node); + return; + } +} + +int main() +{ + node_t node=A; + + assert(&node); + + char count=0; + while(count++<10) + { + char c; + + doit(&node); + + static char q=0; + q=0; + + if(c==0) + { + assert(node==A); + } + } + + return 0; +} diff --git a/regression/cbmc/full_slice2/test.desc b/regression/cbmc/full_slice2/test.desc new file mode 100644 index 00000000000..ab7f16df02b --- /dev/null +++ b/regression/cbmc/full_slice2/test.desc @@ -0,0 +1,10 @@ +CORE +main.c +--full-slice --property main.assertion.2 --unwind 1 +^EXIT=10$ +^SIGNAL=0$ +^VERIFICATION FAILED +-- +^warning: ignoring +-- +Tests whether properties are not relabelled after slicing. \ No newline at end of file diff --git a/regression/cbmc/hex_string1/main.c b/regression/cbmc/hex_string1/main.c new file mode 100644 index 00000000000..77b163df8b4 --- /dev/null +++ b/regression/cbmc/hex_string1/main.c @@ -0,0 +1,16 @@ +#include + +#define static_assert(x) ((struct { char some[(x)?1:-1]; }*)0) + +int main() +{ + static_assert('\xe8'==(char)0xe8); + static_assert(sizeof("abc")==4); + static_assert(sizeof("\u0201")==3); + static_assert(sizeof("\xe8")==2); + static_assert(sizeof("\u0201\xe8")==4); + + if("\xe8"[0]!=(char)0xe8) + assert(0); + return 0; +} diff --git a/regression/cbmc/hex_string1/test.desc b/regression/cbmc/hex_string1/test.desc new file mode 100644 index 00000000000..12fc8ce06e1 --- /dev/null +++ b/regression/cbmc/hex_string1/test.desc @@ -0,0 +1,9 @@ +CORE +main.c + +^EXIT=0$ +^SIGNAL=0$ +^VERIFICATION SUCCESSFUL$ +-- +^warning: ignoring +^CONVERSION ERROR$ diff --git a/regression/cbmc/invariant-failure/main.c b/regression/cbmc/invariant-failure/main.c new file mode 100644 index 00000000000..f8b643afbf2 --- /dev/null +++ b/regression/cbmc/invariant-failure/main.c @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/regression/cbmc/invariant-failure/test.desc b/regression/cbmc/invariant-failure/test.desc new file mode 100644 index 00000000000..9966d66547a --- /dev/null +++ b/regression/cbmc/invariant-failure/test.desc @@ -0,0 +1,10 @@ +CORE +main.c +--test-invariant-failure +^EXIT=(0|127|134|137)$ +^SIGNAL=0$ +Invariant check failed +^(Backtrace)|(Backtraces not supported)$ +-- +^warning: ignoring +^VERIFICATION SUCCESSFUL$ diff --git a/regression/cbmc/little-endian-array1/main.c b/regression/cbmc/little-endian-array1/main.c new file mode 100644 index 00000000000..5919db3e3c1 --- /dev/null +++ b/regression/cbmc/little-endian-array1/main.c @@ -0,0 +1,30 @@ +#include + +int *array; + +int main() +{ + unsigned size; + __CPROVER_assume(size==1); + + // produce unbounded array that does not have byte granularity + array=malloc(size*sizeof(int)); + array[0]=0x01020304; + + int array0=array[0]; + __CPROVER_assert(array0==0x01020304, "array[0] matches"); + + char *p=(char *)array; + char p0=p[0]; + char p1=p[1]; + char p2=p[2]; + char p3=p[3]; + __CPROVER_assert(p0==4, "p[0] matches"); + __CPROVER_assert(p1==3, "p[1] matches"); + __CPROVER_assert(p2==2, "p[2] matches"); + __CPROVER_assert(p3==1, "p[3] matches"); + + unsigned short *q=(unsigned short *)array; + unsigned short q0=q[0]; + __CPROVER_assert(q0==0x0304, "p[0,1] matches"); +} diff --git a/regression/cbmc/little-endian-array1/test.desc b/regression/cbmc/little-endian-array1/test.desc new file mode 100644 index 00000000000..9845e70d84b --- /dev/null +++ b/regression/cbmc/little-endian-array1/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--little-endian +^EXIT=0$ +^SIGNAL=0$ +^VERIFICATION SUCCESSFUL$ +-- +^warning: ignoring diff --git a/regression/cbmc/memory_allocation1/main.c b/regression/cbmc/memory_allocation1/main.c new file mode 100644 index 00000000000..3d9a3e59810 --- /dev/null +++ b/regression/cbmc/memory_allocation1/main.c @@ -0,0 +1,14 @@ +#include + +int main() +{ + int *p=0x10; + + __CPROVER_allocated_memory(0x10, sizeof(int)); + *p=42; + assert(*p==42); + *(p+1)=42; + assert(*(p+1)==42); + + return 0; +} diff --git a/regression/cbmc/memory_allocation1/test.desc b/regression/cbmc/memory_allocation1/test.desc new file mode 100644 index 00000000000..afe3420ce0b --- /dev/null +++ b/regression/cbmc/memory_allocation1/test.desc @@ -0,0 +1,12 @@ +CORE +main.c +--pointer-check +^EXIT=10$ +^SIGNAL=0$ +\[main.pointer_dereference.2\] dereference failure: pointer invalid in \*p: SUCCESS +\[main.assertion.1\] assertion \*p==42: SUCCESS +\[main.pointer_dereference.14\] dereference failure: pointer invalid in p\[\(signed( long)? long int\)1\]: FAILURE +\[main.assertion.2\] assertion \*\(p\+1\)==42: SUCCESS +\*\* 12 of 26 failed \(2 iterations\) +-- +^warning: ignoring diff --git a/regression/cbmc/memset1/main.c b/regression/cbmc/memset1/main.c new file mode 100644 index 00000000000..bd42b5e256e --- /dev/null +++ b/regression/cbmc/memset1/main.c @@ -0,0 +1,29 @@ +#include +#include +#include + +int main() +{ + int A[5]; + memset(A, 0, sizeof(int)*5); + assert(A[0]==0); + assert(A[1]==0); + assert(A[2]==0); + assert(A[3]==0); + assert(A[4]==0); + + A[3]=42; + memset(A, 0xFFFFFF01, sizeof(int)*3); + assert(A[0]==0x01010101); + assert(A[1]==0x01010111); + assert(A[2]==0x01010101); + assert(A[3]==42); + assert(A[4]==0); + + int *B=malloc(sizeof(int)*2); + memset(B, 2, sizeof(int)*2); + assert(B[0]==0x02020202); + assert(B[1]==0x02020202); + + return 0; +} diff --git a/regression/cbmc/memset1/test.desc b/regression/cbmc/memset1/test.desc new file mode 100644 index 00000000000..aef7e29d151 --- /dev/null +++ b/regression/cbmc/memset1/test.desc @@ -0,0 +1,10 @@ +CORE +main.c + +^EXIT=10$ +^SIGNAL=0$ +^VERIFICATION FAILED$ +\[main.assertion.7\] assertion A\[1\]==0x01010111: FAILURE +\*\* 1 of 12 failed \(2 iterations\) +-- +^warning: ignoring diff --git a/regression/cbmc/mm_io1/main.c b/regression/cbmc/mm_io1/main.c new file mode 100644 index 00000000000..2f1638f63c3 --- /dev/null +++ b/regression/cbmc/mm_io1/main.c @@ -0,0 +1,32 @@ +char __CPROVER_mm_io_r(void *a, unsigned s) +{ + if((long)a==0x10) + return 1; + else if((long)a==0x11) + return 2; +} + +void __CPROVER_mm_io_w(void *a, unsigned s, char value) +{ + if((long)a==0x10) + __CPROVER_assert(value==2, "correct value written"); +} + +int main() +{ + long i=0x10; + char *p=(char *)i; + char some_var=100; + + char z; + z=p[1]; + __CPROVER_assert(z==2, "reading 0x11"); + + // write + p[0]=2; + + p=&some_var; + z=p[0]; + __CPROVER_assert(z==100, "reading &some_var"); +} + diff --git a/regression/cbmc/mm_io1/test.desc b/regression/cbmc/mm_io1/test.desc new file mode 100644 index 00000000000..9efefbc7362 --- /dev/null +++ b/regression/cbmc/mm_io1/test.desc @@ -0,0 +1,8 @@ +CORE +main.c + +^EXIT=0$ +^SIGNAL=0$ +^VERIFICATION SUCCESSFUL$ +-- +^warning: ignoring diff --git a/regression/cbmc/void_pointer1/main.c b/regression/cbmc/void_pointer1/main.c new file mode 100644 index 00000000000..db79440d471 --- /dev/null +++ b/regression/cbmc/void_pointer1/main.c @@ -0,0 +1,12 @@ +char buffer[2]; +int length = 2; + +void func(void* buf, int len) +{ + while( len-- ) + *(char *)buf++; +} + +void main(){ + func(buffer,length); +} diff --git a/regression/cbmc/void_pointer1/test.desc b/regression/cbmc/void_pointer1/test.desc new file mode 100644 index 00000000000..39c491ba8bb --- /dev/null +++ b/regression/cbmc/void_pointer1/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--pointer-check +^EXIT=0$ +^SIGNAL=0$ +^VERIFICATION SUCCESSFUL$ +-- +^warning: ignoring diff --git a/regression/cbmc/void_pointer2/main.c b/regression/cbmc/void_pointer2/main.c new file mode 100644 index 00000000000..db79440d471 --- /dev/null +++ b/regression/cbmc/void_pointer2/main.c @@ -0,0 +1,12 @@ +char buffer[2]; +int length = 2; + +void func(void* buf, int len) +{ + while( len-- ) + *(char *)buf++; +} + +void main(){ + func(buffer,length); +} diff --git a/regression/cbmc/void_pointer2/test.desc b/regression/cbmc/void_pointer2/test.desc new file mode 100644 index 00000000000..3556481d977 --- /dev/null +++ b/regression/cbmc/void_pointer2/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--pointer-check --no-simplify --unwind 3 +^EXIT=0$ +^SIGNAL=0$ +^VERIFICATION SUCCESSFUL$ +-- +^warning: ignoring diff --git a/regression/cpp-linter/assert/main.cpp b/regression/cpp-linter/assert/main.cpp new file mode 100644 index 00000000000..cceff0cb2ea --- /dev/null +++ b/regression/cpp-linter/assert/main.cpp @@ -0,0 +1,10 @@ +// Author: Martin Brain, martin.brain@diffblue.com + +#include +#include + +int main(int argc, char **argv) +{ + assert(0); + return 0; +} diff --git a/regression/cpp-linter/assert/test.desc b/regression/cpp-linter/assert/test.desc new file mode 100644 index 00000000000..cda85742156 --- /dev/null +++ b/regression/cpp-linter/assert/test.desc @@ -0,0 +1,6 @@ +CORE +main.cpp + +^main\.cpp:8: assert is deprecated, use INVARIANT instead \[build/deprecated\] \[4\] +^Total errors found: 1$ +^SIGNAL=0$ diff --git a/regression/goto-analyzer/constant_propagation_10/constant_propagation_10.c b/regression/goto-analyzer/constant_propagation_10/constant_propagation_10.c index 169f7965b9d..f0dea39a424 100644 --- a/regression/goto-analyzer/constant_propagation_10/constant_propagation_10.c +++ b/regression/goto-analyzer/constant_propagation_10/constant_propagation_10.c @@ -4,7 +4,7 @@ int main() signed int i; signed int j; i = 0; - if(!(i >= 2)) + if(!(i >= 2)) { j = j + 1; i = i + 1; diff --git a/regression/goto-instrument/remove-function-body1/main.c b/regression/goto-instrument/remove-function-body1/main.c new file mode 100644 index 00000000000..14e576db99f --- /dev/null +++ b/regression/goto-instrument/remove-function-body1/main.c @@ -0,0 +1,21 @@ +#include + +int foo() +{ + int a; + assert(a>0); + return a; +} + +int bar() +{ + int b; + assert(b>0); + return b; +} + +int main() +{ + foo(); + bar(); +} diff --git a/regression/goto-instrument/remove-function-body1/test.desc b/regression/goto-instrument/remove-function-body1/test.desc new file mode 100644 index 00000000000..45369a31184 --- /dev/null +++ b/regression/goto-instrument/remove-function-body1/test.desc @@ -0,0 +1,10 @@ +CORE +main.c +--remove-function-body foo --remove-function-body bar +^EXIT=0$ +^SIGNAL=0$ +^VERIFICATION SUCCESSFUL$ +-- +^warning: ignoring +^bar +^foo diff --git a/regression/test.pl b/regression/test.pl index d27c663b0aa..0bf364b86c3 100755 --- a/regression/test.pl +++ b/regression/test.pl @@ -35,7 +35,6 @@ ($$$$$) print LOG " Core: $dumped_core\n"; if($signal_num != 0) { - $failed = 1; print "Killed by signal $signal_num"; if($dumped_core) { print " (code dumped)"; diff --git a/scripts/compare_postprocessor_output.py b/scripts/compare_postprocessor_output.py new file mode 100644 index 00000000000..10dcb0f2709 --- /dev/null +++ b/scripts/compare_postprocessor_output.py @@ -0,0 +1,99 @@ +import difflib, argparse, subprocess, sys, os, multiprocessing, itertools + + +def preprocess(compiler, file_contents): + """ Get output from the preprocessing pass on a file. """ + output = subprocess.Popen( + [compiler, '-E', '-'], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + stdin=subprocess.PIPE).communicate(input=file_contents)[0] + + def should_keep(line): + return str.strip(line) and line[0] != '#' + + return filter(should_keep, output.splitlines()) + + +def preprocess_file(compiler, filename): + """ Open a file and get the preprocessor output. """ + with open(filename, 'rb') as f: + return preprocess(compiler, f.read()) + + +def file_contents_from_branch(filename, branch): + """ Get a copy of a file from another branch and return its contents. """ + return subprocess.check_output( + ['git', 'show', '%s:%s' % (branch, filename)]) + + +def equal_to_file_on_branch(filename, branch, compiler): + """ + Open a file on this branch and preprocess it. Preprocess the same file + from another branch, and return a diff. + """ + with open(filename, 'rb') as f: + def p(text): + return preprocess(compiler, text) + return difflib.unified_diff(p(f.read()), + p(file_contents_from_branch(filename, branch)), + fromfile=filename, + tofile=filename, + lineterm='') + + +def is_source(filename): + """ Return whether the file appears to be a C++ source file. """ + _, ext = os.path.splitext(filename) + return ext == '.h' or ext == '.cpp' + + +def process(tup): + """ + Check a single file, and return its name if the check fails, otherwise + return None. + """ + filename, branch, compiler = tup + failed = '\n'.join(equal_to_file_on_branch(filename, branch, compiler)) + return failed if failed else None + + +def main(): + """ + Open a file and compare its preprocessor output to the output from the same + file on a different branch. Return 0 if the outputs match, or 1 otherwise. + """ + parser = argparse.ArgumentParser() + parser.add_argument( + '--branch', type=str, default='upstream/master', + help='The branch to compare') + parser.add_argument( + '--compiler', type=str, default='g++', + help='The compiler to use') + args = parser.parse_args() + + all_files = [os.path.join(root, file) + for root, _, files in os.walk('.') for file in files] + source_files = filter(is_source, all_files) + + zipped = zip( + source_files, + itertools.cycle([args.branch]), + itertools.cycle([args.compiler])) + + pool = multiprocessing.Pool(10) + + results = filter(None, pool.map(process, zipped)) + + pool.close() + pool.join() + + if results: + print('\n\n'.join(results)) + return 1 + + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/scripts/cpplint.py b/scripts/cpplint.py index 4346bd7a4ae..64fab3758f9 100755 --- a/scripts/cpplint.py +++ b/scripts/cpplint.py @@ -235,6 +235,7 @@ 'readability/function_comment' 'runtime/arrays', 'runtime/casting', + 'runtime/endl', 'runtime/explicit', 'runtime/int', 'runtime/init', @@ -4628,6 +4629,27 @@ def CheckAltTokens(filename, clean_lines, linenum, error): _ALT_TOKEN_REPLACEMENT[match.group(1)], match.group(1))) +def CheckAssert(filename, clean_lines, linenum, error): + """Check for uses of assert. + + Args: + filename: The name of the current file. + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + error: The function to call with any errors found. + """ + line = clean_lines.elided[linenum] + match = Match(r'.*\s+assert\(.*\).*', line) + if match: + if Match(r'.*\s+assert\((0|false)\).*', line): + error(filename, linenum, 'build/deprecated', 4, + 'assert is deprecated, use UNREACHABLE instead') + else: + error(filename, linenum, 'build/deprecated', 4, + 'assert is deprecated, use INVARIANT, PRECONDITION, CHECK_RETURN, etc. instead') + + + def GetLineWidth(line): """Determines the width of the line in column positions. @@ -4852,6 +4874,7 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state, CheckSpacingForFunctionCall(filename, clean_lines, linenum, error) CheckCheck(filename, clean_lines, linenum, error) CheckAltTokens(filename, clean_lines, linenum, error) + CheckAssert(filename, clean_lines, linenum, error) classinfo = nesting_state.InnermostClass() if classinfo: CheckSectionSpacing(filename, clean_lines, classinfo, linenum, error) @@ -6198,6 +6221,12 @@ def CheckNamespaceOrUsing(filename, clean_lines, linenum, error): error(filename, linenum, 'readability/namespace', 4, 'Do not use using') +def CheckForEndl(filename, clean_lines, linenum, error): + """Check that the line does not contain std::endl.""" + line = clean_lines.elided[linenum] + if Match(r'[^a-zA-Z0-9_]*std::endl[^a-zA-Z0-9_]*', line): + error(filename, linenum, 'runtime/endl', 4, 'Do not use std::endl') + def ProcessLine(filename, file_extension, clean_lines, line, include_state, function_state, nesting_state, error, extra_check_functions=[]): @@ -6239,6 +6268,7 @@ def ProcessLine(filename, file_extension, clean_lines, line, CheckMakePairUsesDeduction(filename, clean_lines, line, error) CheckRedundantVirtual(filename, clean_lines, line, error) CheckNamespaceOrUsing(filename, clean_lines, line, error) + CheckForEndl(filename, clean_lines, line, error) for check_fn in extra_check_functions: check_fn(filename, clean_lines, line, error) @@ -6463,7 +6493,10 @@ def ProcessFile(filename, vlevel, extra_check_functions=[]): _BackupFilters() #exclude these files: - if Search(r'(\.l|\.y|\.inc|\.d|\.o|y\.tab\.cpp|\.tab\.h|\.yy\.cpp|builtin_headers)$', filename): + if Search(r'(\.l|\.y|\.inc|\.d|\.o|y\.tab\.cpp|\.tab\.h|\.yy\.cpp)$', filename): + return + + if Search(r'_builtin_headers_[a-z0-9_-]+\.h$', filename): return if not ProcessConfigOverrides(filename): diff --git a/scripts/do_doc_convert.py b/scripts/do_doc_convert.py new file mode 100644 index 00000000000..bf7f47fa953 --- /dev/null +++ b/scripts/do_doc_convert.py @@ -0,0 +1,40 @@ +from reformat_docs import convert_file +from os import walk +from os.path import join +from sys import exit +from re import match + +""" +Run this from CBMC's top-level directory. +""" + +def main(): + IGNORE_LIST = [ + r'src/big-int/.*', + r'src/miniz/.*', + r'src/ansi-c/arm_builtin_headers.h', + r'src/ansi-c/clang_builtin_headers.h', + r'src/ansi-c/cw_builtin_headers.h', + r'src/ansi-c/gcc_builtin_headers_alpha.h', + r'src/ansi-c/gcc_builtin_headers_arm.h', + r'src/ansi-c/gcc_builtin_headers_generic.h', + r'src/ansi-c/gcc_builtin_headers_ia32-2.h', + r'src/ansi-c/gcc_builtin_headers_ia32.h', + r'src/ansi-c/gcc_builtin_headers_mips.h', + r'src/ansi-c/gcc_builtin_headers_power.h', + r'src/ansi-c/library/cprover.h'] + + MATCH_EXPR = r'.*\.(h|cpp)' + + for root, dirs, files in walk('src'): + for file in files: + path = join(root, file) + if any(map(lambda x: match(x, path), IGNORE_LIST)): + print 'ignoring', path + continue + if not match(MATCH_EXPR, path): + continue + convert_file(path, True) + +if __name__ == '__main__': + exit(main()) diff --git a/scripts/reformat_docs.py b/scripts/reformat_docs.py new file mode 100644 index 00000000000..35dc6e12809 --- /dev/null +++ b/scripts/reformat_docs.py @@ -0,0 +1,260 @@ +import re, collections, textwrap, sys, argparse, platform + +Field = collections.namedtuple('Field', ['name', 'contents']) + +Header = collections.namedtuple('Header', ['module']) + +Function = collections.namedtuple('Function', + ['name', 'purpose', 'inputs', 'returns']) + +Class = collections.namedtuple('Class', ['name', 'purpose']) + + +def warn(message): + """ Print a labelled message to stderr. """ + sys.stderr.write('Warning: %s\n' % message) + + +def header_from_block(block): + """ Create a Header structure from a parsed Block. """ + return Header(block.fields['Module']) + + +def function_from_block(block): + """ Create a Function structure from a parsed Block. """ + return Function(block.fields.get('Function', None), + block.fields.get('Purpose', None), block.fields.get('Inputs', None), + block.fields.get('Outputs', None)) + + +def make_field(name, contents): + return Field(name, contents if contents.strip() else None) + + +def class_from_block(block): + """ Create a Class structure from a parsed Block. """ + return Class(block.fields.get('Class', None), + block.fields.get('Purpose', None)) + + +def parse_fields(block_contents): + """ Extract the named fields of an old-style comment block. """ + + field_re = re.compile( + r'(?:\n *(Purpose):(.*))|(?:\n *([a-zA-Z0-9]+?):\n?(.*?)?^$)', + re.MULTILINE | re.DOTALL) + for m in field_re.finditer(block_contents): + # If the field is a Purpose field + if m.lastindex == 2: + yield make_field(m.group(1), textwrap.dedent(m.group(2))) + # If the field is any other field + elif m.lastindex == 3 or m.lastindex == 4: + yield make_field(m.group(3), textwrap.dedent(m.group(4))) + + +Block = collections.namedtuple('Block', ['fields']) + + +def has_field(block, field_name): + """ Return whether the block has a field with the given name. """ + return field_name in block.fields + + +def make_doxy_comment(text): + text = re.sub(r'^(?!$)', r'/// ', text, flags=re.MULTILINE) + return re.sub(r'^(?=$)', r'///' , text, flags=re.MULTILINE) + + +class GenericFormatter(object): + def __init__(self, doc_width): + self.text_wrapper = textwrap.TextWrapper(width=doc_width) + self.indented_wrapper = textwrap.TextWrapper(width=doc_width, + subsequent_indent=r' ') + self.whitespace_re = re.compile(r'\n\s*', re.MULTILINE | re.DOTALL) + + def convert(self, block): + sections = filter(None, self.convert_sections(block)) + if sections: + return make_doxy_comment('\n'.join(sections)) + '\n' + return '' + + +class HeaderFormatter(GenericFormatter): + def format_module(self, header): + if not header.module: + return None + + subbed = self.whitespace_re.sub(' ', header.module) + # The file directive must be followed by a newline in order to refer to + # the current file + return '\\file\n' + self.indented_wrapper.fill(subbed) + + def is_block_valid(self, block): + return has_field(block, 'Module') + + def convert_sections(self, block): + return [self.format_module(block)] + + +class FunctionFormatter(GenericFormatter): + def __init__(self, doc_width): + super(FunctionFormatter, self).__init__(doc_width) + self.paragraph_re = re.compile(r'(.*?)^$(.*)', re.MULTILINE | re.DOTALL) + + def format_purpose(self, function): + if not function.purpose: + return None + + match = self.paragraph_re.match(function.purpose) + first_paragraph = match.group(1) + first_paragraph = self.whitespace_re.sub(' ', + first_paragraph) if first_paragraph else '' + + tail_paragraphs = (('\n' + match.group(2)) if match.group(2) else '') + formatted_purpose = (self.text_wrapper.fill(first_paragraph) + + tail_paragraphs) + + return formatted_purpose.strip() + + def format_inputs(self, function): + if not function.inputs: + return None + + if re.match(r'^\s*\S+\s*$', function.inputs): + return None + + def param_replacement(match): + return r'\param %s:' % match.group(1) + + lines = function.inputs.split('\n') + tail = '\n'.join(lines[1:]) + + dedented = lines[0] + '\n' + textwrap.dedent(tail) + + text = re.sub(r'\n\s+', ' ', dedented, flags=re.MULTILINE) + text, num_replacements = re.subn(r'^([a-zA-Z0-9_]+)\s*[:-]', + param_replacement, text, flags=re.MULTILINE) + + if num_replacements == 0: + text = r'\par parameters: %s' % text + + text = '\n'.join( + self.indented_wrapper.fill(t) for t in text.split('\n')) + return text.strip() + + def format_returns(self, function): + if not function.returns: + return None + + subbed = self.whitespace_re.sub(' ', function.returns) + return self.indented_wrapper.fill(r'\return %s' % subbed) + + def is_block_valid(self, block): + return has_field(block, 'Function') + + def convert_sections(self, block): + return [ + self.format_purpose(block), + self.format_inputs(block), + self.format_returns(block)] + + +class ClassFormatter(GenericFormatter): + def __init__(self, doc_width): + super(ClassFormatter, self).__init__(doc_width) + self.paragraph_re = re.compile(r'(.*?)^$(.*)', re.MULTILINE | re.DOTALL) + + def format_purpose(self, klass): + if not klass.purpose: + return None + + match = self.paragraph_re.match(klass.purpose) + first_paragraph = match.group(1) + first_paragraph = self.whitespace_re.sub(' ', + first_paragraph) if first_paragraph else '' + + tail_paragraphs = (('\n' + match.group(2)) if match.group(2) else '') + formatted_purpose = (self.text_wrapper.fill(first_paragraph) + + tail_paragraphs) + + return formatted_purpose.strip() + + def is_block_valid(self, block): + return has_field(block, 'Class') + + def convert_sections(self, block): + return [self.format_purpose(block)] + + +def replace_block( + block_contents, + file, + header_formatter, + class_formatter, + function_formatter): + """ + Replace an old-style documentation block with the doxygen equivalent + """ + block = Block( + {f.name: f.contents for f in parse_fields(block_contents.group(1))}) + + if header_formatter.is_block_valid(block): + return '%s%s\n' % ( + block_contents.group(0), + header_formatter.convert(header_from_block(block))) + + if class_formatter.is_block_valid(block): + return class_formatter.convert(class_from_block(block)) + + if function_formatter.is_block_valid(block): + return function_formatter.convert(function_from_block(block)) + + warn('block in "%s" has unrecognised format:\n%s' % + (file, block_contents.group(1))) + + return '' + + +def convert_file(file, inplace): + """ Replace documentation in file with doxygen-styled comments. """ + with open(file) as f: + contents = f.read() + + doc_width = 76 + + header_formatter = HeaderFormatter(doc_width) + class_formatter = ClassFormatter(doc_width) + function_formatter = FunctionFormatter(doc_width) + + block_re = re.compile( + r'^/\*+\\$(.*?)^\\\*+/$\s*', re.MULTILINE | re.DOTALL) + new_contents = block_re.sub( + lambda match: replace_block( + match, + file, + header_formatter, + class_formatter, + function_formatter), contents) + + if inplace: + with open(file, 'w') as f: + f.write(new_contents) + else: + sys.stdout.write(new_contents) + + +def main(): + """ Run convert_file from the command-line. """ + parser = argparse.ArgumentParser() + parser.add_argument('file', type=str, help='The file to process') + parser.add_argument('-i', '--inplace', action='store_true', + help='Process in place') + args = parser.parse_args() + + convert_file(args.file, args.inplace) + + return 0 + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/src/analyses/ai.cpp b/src/analyses/ai.cpp index 45d4b83c92c..1eca272c19d 100644 --- a/src/analyses/ai.cpp +++ b/src/analyses/ai.cpp @@ -6,9 +6,14 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Abstract Interpretation + #include #include +#include +#include #include #include @@ -16,17 +21,69 @@ Author: Daniel Kroening, kroening@kroening.com #include "ai.h" -/*******************************************************************\ +jsont ai_domain_baset::output_json( + const ai_baset &ai, + const namespacet &ns) const +{ + std::ostringstream out; + output(out, ai, ns); + json_stringt json(out.str()); + return json; +} -Function: ai_baset::output +xmlt ai_domain_baset::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; +} - Inputs: +/// Use the information in the domain to simplify the expression on the LHS of +/// an assignment. This for example won't simplify symbols to their values, but +/// does simplify indices in arrays, members of structs and dereferencing of +/// pointers +/// \param condition: the expression to simplify +/// \param ns: the namespace +/// \return True if condition did not change. False otherwise. condition will be +/// updated with the simplified condition if it has worked +bool ai_domain_baset::ai_simplify_lhs( + exprt &condition, const namespacet &ns) const +{ + // Care must be taken here to give something that is still writable + if(condition.id()==ID_index) + { + index_exprt ie=to_index_expr(condition); + bool changed=ai_simplify(ie.index(), ns); + if(changed) + condition=simplify_expr(ie, ns); - Outputs: + return !changed; + } + else if(condition.id()==ID_dereference) + { + dereference_exprt de=to_dereference_expr(condition); + bool changed=ai_simplify(de.pointer(), ns); + if(changed) + condition=simplify_expr(de, ns); // So *(&x) -> x - Purpose: + return !changed; + } + else if(condition.id()==ID_member) + { + member_exprt me=to_member_expr(condition); + bool changed=ai_simplify_lhs(me.compound(), ns); // <-- lhs! + if(changed) + condition=simplify_expr(me, ns); -\*******************************************************************/ + return !changed; + } + else + return true; +} void ai_baset::output( const namespacet &ns, @@ -47,18 +104,6 @@ void ai_baset::output( } } -/*******************************************************************\ - -Function: ai_baset::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ai_baset::output( const namespacet &ns, const goto_programt &goto_program, @@ -79,18 +124,9 @@ 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 - -\*******************************************************************/ - +/// Output the domains for the whole program as JSON +/// \par parameters: The namespace and goto_functions +/// \return The JSON object jsont ai_baset::output_json( const namespacet &ns, const goto_functionst &goto_functions) const @@ -113,18 +149,9 @@ jsont ai_baset::output_json( 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 - -\*******************************************************************/ - +/// Output the domains for a single function as JSON +/// \par parameters: The namespace, goto_program and it's identifier +/// \return The JSON object jsont ai_baset::output_json( const namespacet &ns, const goto_programt &goto_program, @@ -152,18 +179,9 @@ jsont ai_baset::output_json( 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 - -\*******************************************************************/ - +/// Output the domains for the whole program as XML +/// \par parameters: The namespace and goto_functions +/// \return The XML object xmlt ai_baset::output_xml( const namespacet &ns, const goto_functionst &goto_functions) const @@ -189,18 +207,9 @@ xmlt ai_baset::output_xml( 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 - -\*******************************************************************/ - +/// Output the domains for a single function as XML +/// \par parameters: The namespace, goto_program and it's identifier +/// \return The XML object xmlt ai_baset::output_xml( const namespacet &ns, const goto_programt &goto_program, @@ -231,18 +240,6 @@ xmlt ai_baset::output_xml( return function_body; } -/*******************************************************************\ - -Function: ai_baset::entry_state - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ai_baset::entry_state(const goto_functionst &goto_functions) { // find the 'entry function' @@ -254,53 +251,17 @@ void ai_baset::entry_state(const goto_functionst &goto_functions) entry_state(f_it->second.body); } -/*******************************************************************\ - -Function: ai_baset::entry_state - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ai_baset::entry_state(const goto_programt &goto_program) { // The first instruction of 'goto_program' is the entry point get_state(goto_program.instructions.begin()).make_entry(); } -/*******************************************************************\ - -Function: ai_baset::initialize - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ai_baset::initialize(const goto_functionst::goto_functiont &goto_function) { initialize(goto_function.body); } -/*******************************************************************\ - -Function: ai_baset::initialize - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ai_baset::initialize(const goto_programt &goto_program) { // we mark everything as unreachable as starting point @@ -309,36 +270,12 @@ void ai_baset::initialize(const goto_programt &goto_program) get_state(i_it).make_bottom(); } -/*******************************************************************\ - -Function: ai_baset::initialize - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ai_baset::initialize(const goto_functionst &goto_functions) { forall_goto_functions(it, goto_functions) initialize(it->second); } -/*******************************************************************\ - -Function: ai_baset::get_next - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - ai_baset::locationt ai_baset::get_next( working_sett &working_set) { @@ -351,18 +288,6 @@ ai_baset::locationt ai_baset::get_next( return l; } -/*******************************************************************\ - -Function: ai_baset::fixedpoint - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool ai_baset::fixedpoint( const goto_programt &goto_program, const goto_functionst &goto_functions, @@ -389,18 +314,6 @@ bool ai_baset::fixedpoint( return new_data; } -/*******************************************************************\ - -Function: ai_baset::visit - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool ai_baset::visit( locationt l, working_sett &working_set, @@ -459,18 +372,6 @@ bool ai_baset::visit( return new_data; } -/*******************************************************************\ - -Function: ai_baset::do_function_call - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool ai_baset::do_function_call( locationt l_call, locationt l_return, const goto_functionst &goto_functions, @@ -534,18 +435,6 @@ bool ai_baset::do_function_call( } } -/*******************************************************************\ - -Function: ai_baset::do_function_call_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool ai_baset::do_function_call_rec( locationt l_call, locationt l_return, const exprt &function, @@ -630,18 +519,6 @@ bool ai_baset::do_function_call_rec( return new_data; } -/*******************************************************************\ - -Function: ai_baset::sequential_fixedpoint - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ai_baset::sequential_fixedpoint( const goto_functionst &goto_functions, const namespacet &ns) @@ -653,18 +530,6 @@ void ai_baset::sequential_fixedpoint( fixedpoint(f_it->second.body, goto_functions, ns); } -/*******************************************************************\ - -Function: ai_baset::concurrent_fixedpoint - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ai_baset::concurrent_fixedpoint( const goto_functionst &goto_functions, const namespacet &ns) diff --git a/src/analyses/ai.h b/src/analyses/ai.h index 2894cde3b10..3c078d2a9bb 100644 --- a/src/analyses/ai.h +++ b/src/analyses/ai.h @@ -6,15 +6,18 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Abstract Interpretation + #ifndef CPROVER_ANALYSES_AI_H #define CPROVER_ANALYSES_AI_H #include #include -#include #include #include +#include #include @@ -59,24 +62,11 @@ 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; - } + const namespacet &ns) const; 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; - } + const namespacet &ns) const; // no states virtual void make_bottom()=0; @@ -94,6 +84,23 @@ class ai_domain_baset // // This computes the join between "this" and "b". // Return true if "this" has changed. + + // This method allows an expression to be simplified / evaluated using the + // current state. It is used to evaluate assertions and in program + // simplification + + // return true if unchanged + virtual bool ai_simplify( + exprt &condition, + const namespacet &ns) const + { + return true; + } + + // Simplifies the expression but keeps it as an l-value + virtual bool ai_simplify_lhs( + exprt &condition, + const namespacet &ns) const; }; // don't use me -- I am just a base class diff --git a/src/analyses/call_graph.cpp b/src/analyses/call_graph.cpp index c226e2c73ab..2d91e502a3f 100644 --- a/src/analyses/call_graph.cpp +++ b/src/analyses/call_graph.cpp @@ -6,39 +6,18 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Function Call Graphs + #include #include #include "call_graph.h" -/*******************************************************************\ - -Function: call_grapht::call_grapht - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - call_grapht::call_grapht() { } -/*******************************************************************\ - -Function: call_grapht::call_grapht - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - call_grapht::call_grapht(const goto_functionst &goto_functions) { forall_goto_functions(f_it, goto_functions) @@ -48,18 +27,6 @@ call_grapht::call_grapht(const goto_functionst &goto_functions) } } -/*******************************************************************\ - -Function: call_grapht::add - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void call_grapht::add( const irep_idt &function, const goto_programt &body) @@ -75,18 +42,6 @@ void call_grapht::add( } } -/*******************************************************************\ - -Function: call_grapht::add - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void call_grapht::add( const irep_idt &caller, const irep_idt &callee) @@ -94,18 +49,6 @@ void call_grapht::add( graph.insert(std::pair(caller, callee)); } -/*******************************************************************\ - -Function: call_grapht::output_dot - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void call_grapht::output_dot(std::ostream &out) const { out << "digraph call_graph {\n"; @@ -121,18 +64,6 @@ void call_grapht::output_dot(std::ostream &out) const out << "}\n"; } -/*******************************************************************\ - -Function: call_grapht::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void call_grapht::output(std::ostream &out) const { for(const auto &edge : graph) @@ -141,18 +72,6 @@ void call_grapht::output(std::ostream &out) const } } -/*******************************************************************\ - -Function: call_grapht::output_xml - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void call_grapht::output_xml(std::ostream &out) const { for(const auto &edge : graph) diff --git a/src/analyses/call_graph.h b/src/analyses/call_graph.h index 3410410f3d4..a93289f52bd 100644 --- a/src/analyses/call_graph.h +++ b/src/analyses/call_graph.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Function Call Graphs + #ifndef CPROVER_ANALYSES_CALL_GRAPH_H #define CPROVER_ANALYSES_CALL_GRAPH_H diff --git a/src/analyses/cfg_dominators.h b/src/analyses/cfg_dominators.h index 930d0ae69b9..fa7d23ccf0a 100644 --- a/src/analyses/cfg_dominators.h +++ b/src/analyses/cfg_dominators.h @@ -6,6 +6,9 @@ Author: Georg Weissenbacher, georg@weissenbacher.name \*******************************************************************/ +/// \file +/// Compute dominators for CFG of goto_function + #ifndef CPROVER_ANALYSES_CFG_DOMINATORS_H #define CPROVER_ANALYSES_CFG_DOMINATORS_H @@ -44,18 +47,7 @@ class cfg_dominators_templatet void fixedpoint(P &program); }; -/*******************************************************************\ - -Function: operator << - - Inputs: - - Outputs: - - Purpose: Print the result of the dominator computation - -\*******************************************************************/ - +/// Print the result of the dominator computation template std::ostream &operator << ( std::ostream &out, @@ -65,18 +57,7 @@ std::ostream &operator << ( return out; } -/*******************************************************************\ - -Function: operator () - - Inputs: - - Outputs: - - Purpose: Compute dominators - -\*******************************************************************/ - +/// Compute dominators template void cfg_dominators_templatet::operator()(P &program) { @@ -84,36 +65,14 @@ void cfg_dominators_templatet::operator()(P &program) fixedpoint(program); } -/*******************************************************************\ - -Function: cfg_dominators_templatet::initialise - - Inputs: - - Outputs: - - Purpose: Initialises the elements of the fixed point analysis - -\*******************************************************************/ - +/// Initialises the elements of the fixed point analysis template void cfg_dominators_templatet::initialise(P &program) { cfg(program); } -/*******************************************************************\ - -Function: cfg_dominators_templatet::fixedpoint - - Inputs: - - Outputs: - - Purpose: Computes the MOP for the dominator analysis - -\*******************************************************************/ - +/// Computes the MOP for the dominator analysis template void cfg_dominators_templatet::fixedpoint(P &program) { @@ -205,19 +164,9 @@ void cfg_dominators_templatet::fixedpoint(P &program) } } -/*******************************************************************\ - -Function: dominators_pretty_print_node - - Inputs: `node` to print and stream `out` to pretty-print it to - - Outputs: - - Purpose: Pretty-print a single node in the dominator tree. - Supply a specialisation if operator<< is not sufficient. - -\*******************************************************************/ - +/// Pretty-print a single node in the dominator tree. Supply a specialisation if +/// operator<< is not sufficient. +/// \par parameters: `node` to print and stream `out` to pretty-print it to template void dominators_pretty_print_node(const T &node, std::ostream &out) { @@ -231,18 +180,7 @@ inline void dominators_pretty_print_node( out << target->code.pretty(); } -/*******************************************************************\ - -Function: cfg_dominators_templatet::output - - Inputs: - - Outputs: - - Purpose: Print the result of the dominator computation - -\*******************************************************************/ - +/// Print the result of the dominator computation template void cfg_dominators_templatet::output(std::ostream &out) const { diff --git a/src/analyses/constant_propagator.cpp b/src/analyses/constant_propagator.cpp index 6735d558cc3..15cda33e864 100644 --- a/src/analyses/constant_propagator.cpp +++ b/src/analyses/constant_propagator.cpp @@ -6,6 +6,9 @@ Author: Peter Schrammel \*******************************************************************/ +/// \file +/// Constant Propagation + #ifdef DEBUG #include #endif @@ -16,18 +19,6 @@ Author: Peter Schrammel #include "constant_propagator.h" -/*******************************************************************\ - -Function: concatenate_array_id - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt concatenate_array_id( const exprt &array, const exprt &index, const typet &type) @@ -47,18 +38,6 @@ exprt concatenate_array_id( return new_expr; } -/*******************************************************************\ - -Function: concatenate_array_id - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt concatenate_array_id( const exprt &array, const mp_integer &index, const typet &type) @@ -71,18 +50,6 @@ exprt concatenate_array_id( return new_expr; } -/*******************************************************************\ - -Function: constant_propagator_domaint::assign_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void constant_propagator_domaint::assign_rec( valuest &values, const exprt &lhs, const exprt &rhs, @@ -93,7 +60,7 @@ void constant_propagator_domaint::assign_rec( #ifdef DEBUG std::cout << "assign: " << from_expr(ns, "", lhs) - << " := " << from_type(ns, "", rhs_type) << std::endl; + << " := " << from_type(ns, "", rhs_type) << '\n'; #endif if(lhs.id()==ID_symbol && rhs.id()==ID_if) @@ -154,18 +121,6 @@ void constant_propagator_domaint::assign_rec( #endif } -/*******************************************************************\ - -Function: constant_propagator_domaint::transform - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void constant_propagator_domaint::transform( locationt from, locationt to, @@ -255,18 +210,7 @@ void constant_propagator_domaint::transform( } -/*******************************************************************\ - -Function: constant_propagator_domaint::two_way_propagate_rec - - Inputs: - - Outputs: - - Purpose: handles equalities and conjunctions containing equalities - -\*******************************************************************/ - +/// handles equalities and conjunctions containing equalities bool constant_propagator_domaint::two_way_propagate_rec( const exprt &expr, const namespacet &ns) @@ -308,18 +252,6 @@ bool constant_propagator_domaint::two_way_propagate_rec( return change; } -/*******************************************************************\ - -Function: constant_propagator_domaint::assign - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void constant_propagator_domaint::assign( valuest &dest, const symbol_exprt &lhs, @@ -331,17 +263,19 @@ void constant_propagator_domaint::assign( dest.set_to(lhs, rhs); } -/*******************************************************************\ - -Function: constant_propagator_domaint::is_array_constant - - Inputs: - - Outputs: - - Purpose: +/// Simplify the condition given context-sensitive knowledge from the abstract +/// state. +/// \par parameters: The condition to simplify and its namespace. +/// \return The simplified condition. +bool constant_propagator_domaint::ai_simplify( + exprt &condition, + const namespacet &ns) const +{ + bool b=values.replace_const.replace(condition); + b&=simplify(condition, ns); -\*******************************************************************/ + return b; +} bool constant_propagator_domaint::valuest::is_array_constant(const exprt &expr) const { @@ -355,18 +289,6 @@ bool constant_propagator_domaint::valuest::is_array_constant(const exprt &expr) return true; } -/*******************************************************************\ - -Function: constant_propagator_domaint::valuest::is_constant - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool constant_propagator_domaint::valuest::is_constant(const exprt &expr) const { if(expr.id()==ID_side_effect && @@ -395,18 +317,6 @@ bool constant_propagator_domaint::valuest::is_constant(const exprt &expr) const return true; } -/*******************************************************************\ - -Function: constant_propagator_domaint::valuest::is_constant_address_of - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool constant_propagator_domaint::valuest::is_constant_address_of( const exprt &expr) const { @@ -426,18 +336,7 @@ bool constant_propagator_domaint::valuest::is_constant_address_of( return true; } -/*******************************************************************\ - -Function: constant_propagator_domaint::valuest::set_to_top - - Inputs: - - Outputs: - - Purpose: Do not call this when iterating over replace_const.expr_map! - -\*******************************************************************/ - +/// Do not call this when iterating over replace_const.expr_map! bool constant_propagator_domaint::valuest::set_to_top(const irep_idt &id) { bool result = false; @@ -455,18 +354,6 @@ bool constant_propagator_domaint::valuest::set_to_top(const irep_idt &id) return result; } -/*******************************************************************\ - -Function: constant_propagator_domaint::valuest::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void constant_propagator_domaint::valuest::output( std::ostream &out, const namespacet &ns) const @@ -481,18 +368,6 @@ void constant_propagator_domaint::valuest::output( << from_expr(ns, "", replace_pair.second) << '\n'; } -/*******************************************************************\ - -Function: constant_propagator_domaint::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void constant_propagator_domaint::output( std::ostream &out, const ai_baset &ai, @@ -501,18 +376,8 @@ void constant_propagator_domaint::output( values.output(out, ns); } -/*******************************************************************\ - -Function: constant_propagator_domaint::valuest::merge - - Inputs: - - Outputs: Return true if "this" has changed. - - Purpose: join - -\*******************************************************************/ - +/// join +/// \return Return true if "this" has changed. bool constant_propagator_domaint::valuest::merge(const valuest &src) { // nothing to do @@ -557,18 +422,8 @@ bool constant_propagator_domaint::valuest::merge(const valuest &src) return changed; } -/*******************************************************************\ - -Function: constant_propagator_domaint::valuest::meet - - Inputs: - - Outputs: Return true if "this" has changed. - - Purpose: meet - -\*******************************************************************/ - +/// meet +/// \return Return true if "this" has changed. bool constant_propagator_domaint::valuest::meet(const valuest &src) { if(src.is_bottom || is_bottom) @@ -600,18 +455,7 @@ bool constant_propagator_domaint::valuest::meet(const valuest &src) return changed; } -/*******************************************************************\ - -Function: constant_propagator_domaint::merge - - Inputs: - - Outputs: Return true if "this" has changed. - - Purpose: - -\*******************************************************************/ - +/// \return Return true if "this" has changed. bool constant_propagator_domaint::merge( const constant_propagator_domaint &other, locationt from, @@ -620,18 +464,6 @@ bool constant_propagator_domaint::merge( return values.merge(other.values); } -/*******************************************************************\ - -Function: constant_propagator_ait::replace - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void constant_propagator_ait::replace( goto_functionst &goto_functions, const namespacet &ns) @@ -640,18 +472,6 @@ void constant_propagator_ait::replace( replace(f_it->second, ns); } -/*******************************************************************\ - -Function: constant_propagator_ait::replace_array_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void constant_propagator_ait::replace_array_symbol(exprt &expr) { if (expr.id()==ID_index) @@ -668,18 +488,6 @@ void constant_propagator_ait::replace_array_symbol(exprt &expr) } -/*******************************************************************\ - -Function: constant_propagator_ait::replace - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void constant_propagator_ait::replace( goto_functionst::goto_functiont &goto_function, const namespacet &ns) @@ -732,18 +540,6 @@ void constant_propagator_ait::replace( } } -/*******************************************************************\ - -Function: constant_propagator_ait::replace_types_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void constant_propagator_ait::replace_types_rec( const replace_symbolt &replace_const, exprt &expr) diff --git a/src/analyses/constant_propagator.h b/src/analyses/constant_propagator.h index 0766b458f7d..0b54c79bdb8 100644 --- a/src/analyses/constant_propagator.h +++ b/src/analyses/constant_propagator.h @@ -6,6 +6,9 @@ Author: Peter Schrammel \*******************************************************************/ +/// \file +/// Constant propagation + #ifndef CPROVER_ANALYSES_CONSTANT_PROPAGATOR_H #define CPROVER_ANALYSES_CONSTANT_PROPAGATOR_H @@ -30,6 +33,10 @@ class constant_propagator_domaint:public ai_domain_baset void make_entry() final { values.set_to_top(); } bool merge(const constant_propagator_domaint &, locationt, locationt); + virtual bool ai_simplify( + exprt &condition, + const namespacet &ns) const override; + struct valuest { public: diff --git a/src/analyses/custom_bitvector_analysis.cpp b/src/analyses/custom_bitvector_analysis.cpp index 0a3f0306471..face9d8ae67 100644 --- a/src/analyses/custom_bitvector_analysis.cpp +++ b/src/analyses/custom_bitvector_analysis.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Field-insensitive, location-sensitive bitvector analysis + #include #include @@ -13,18 +16,6 @@ Author: Daniel Kroening, kroening@kroening.com #include -/*******************************************************************\ - -Function: custom_bitvector_domaint::set_bit - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void custom_bitvector_domaint::set_bit( const irep_idt &identifier, unsigned bit_nr, @@ -50,18 +41,6 @@ void custom_bitvector_domaint::set_bit( } } -/*******************************************************************\ - -Function: custom_bitvector_domaint::set_bit - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void custom_bitvector_domaint::set_bit( const exprt &lhs, unsigned bit_nr, @@ -72,18 +51,6 @@ void custom_bitvector_domaint::set_bit( set_bit(id, bit_nr, mode); } -/*******************************************************************\ - -Function: custom_bitvector_domaint::object2id - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - irep_idt custom_bitvector_domaint::object2id(const exprt &src) { if(src.id()==ID_symbol) @@ -117,18 +84,6 @@ irep_idt custom_bitvector_domaint::object2id(const exprt &src) return irep_idt(); } -/*******************************************************************\ - -Function: custom_bitvector_domaint::assign_lhs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void custom_bitvector_domaint::assign_lhs( const exprt &lhs, const vectorst &vectors) @@ -138,18 +93,6 @@ void custom_bitvector_domaint::assign_lhs( assign_lhs(id, vectors); } -/*******************************************************************\ - -Function: custom_bitvector_domaint::assign_lhs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void custom_bitvector_domaint::assign_lhs( const irep_idt &identifier, const vectorst &vectors) @@ -167,18 +110,6 @@ void custom_bitvector_domaint::assign_lhs( may_bits[identifier]=vectors.may_bits; } -/*******************************************************************\ - -Function: custom_bitvector_domaint::get_rhs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - custom_bitvector_domaint::vectorst custom_bitvector_domaint::get_rhs(const irep_idt &identifier) const { @@ -195,18 +126,6 @@ custom_bitvector_domaint::vectorst return vectors; } -/*******************************************************************\ - -Function: custom_bitvector_domaint::get_rhs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - custom_bitvector_domaint::vectorst custom_bitvector_domaint::get_rhs(const exprt &rhs) const { @@ -231,18 +150,6 @@ custom_bitvector_domaint::vectorst return vectorst(); } -/*******************************************************************\ - -Function: custom_bitvector_analysist::get_bit_nr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - unsigned custom_bitvector_analysist::get_bit_nr( const exprt &string_expr) { @@ -261,18 +168,6 @@ unsigned custom_bitvector_analysist::get_bit_nr( return bits("(unknown)"); } -/*******************************************************************\ - -Function: custom_bitvector_domaint::aliases - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::set custom_bitvector_analysist::aliases( const exprt &src, locationt loc) @@ -309,18 +204,6 @@ std::set custom_bitvector_analysist::aliases( return std::set(); } -/*******************************************************************\ - -Function: custom_bitvector_domaint::transform - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void custom_bitvector_domaint::transform( locationt from, locationt to, @@ -549,18 +432,6 @@ void custom_bitvector_domaint::transform( } } -/*******************************************************************\ - -Function: custom_bitvector_domaint::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void custom_bitvector_domaint::output( std::ostream &out, const ai_baset &ai, @@ -608,18 +479,6 @@ void custom_bitvector_domaint::output( } } -/*******************************************************************\ - -Function: custom_bitvector_domaint::merge - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool custom_bitvector_domaint::merge( const custom_bitvector_domaint &b, locationt from, @@ -673,18 +532,7 @@ bool custom_bitvector_domaint::merge( return changed; } -/*******************************************************************\ - -Function: custom_bitvector_domaint::erase_blank_vectors - - Inputs: - - Outputs: - - Purpose: erase blank bitvectors - -\*******************************************************************/ - +/// erase blank bitvectors void custom_bitvector_domaint::erase_blank_vectors(bitst &bits) { for(bitst::iterator a_it=bits.begin(); @@ -698,18 +546,6 @@ void custom_bitvector_domaint::erase_blank_vectors(bitst &bits) } } -/*******************************************************************\ - -Function: custom_bitvector_domaint::has_get_must_or_may - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool custom_bitvector_domaint::has_get_must_or_may(const exprt &src) { if(src.id()=="get_must" || @@ -723,18 +559,6 @@ bool custom_bitvector_domaint::has_get_must_or_may(const exprt &src) return false; } -/*******************************************************************\ - -Function: custom_bitvector_domaint::eval - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt custom_bitvector_domaint::eval( const exprt &src, custom_bitvector_analysist &custom_bitvector_analysis) const @@ -797,34 +621,10 @@ exprt custom_bitvector_domaint::eval( } } -/*******************************************************************\ - -Function: custom_bitvector_analysist::instrument - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void custom_bitvector_analysist::instrument(goto_functionst &) { } -/*******************************************************************\ - -Function: custom_bitvector_analysist::check - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void custom_bitvector_analysist::check( const namespacet &ns, const goto_functionst &goto_functions, diff --git a/src/analyses/custom_bitvector_analysis.h b/src/analyses/custom_bitvector_analysis.h index e77cb6fc58b..ff2884cc2ec 100644 --- a/src/analyses/custom_bitvector_analysis.h +++ b/src/analyses/custom_bitvector_analysis.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Field-insensitive, location-sensitive bitvector analysis + #ifndef CPROVER_ANALYSES_CUSTOM_BITVECTOR_ANALYSIS_H #define CPROVER_ANALYSES_CUSTOM_BITVECTOR_ANALYSIS_H @@ -15,14 +18,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "ai.h" #include "local_may_alias.h" -/*******************************************************************\ - - Class: custom_bitvector_domaint - - Purpose: - -\*******************************************************************/ - class custom_bitvector_analysist; class custom_bitvector_domaint:public ai_domain_baset diff --git a/src/analyses/dependence_graph.cpp b/src/analyses/dependence_graph.cpp index 730ec0266e4..4d9d37eae6d 100644 --- a/src/analyses/dependence_graph.cpp +++ b/src/analyses/dependence_graph.cpp @@ -9,24 +9,18 @@ Date: August 2013 \*******************************************************************/ +/// \file +/// Field-Sensitive Program Dependence Analysis, Litvak et al., FSE 2010 + #include +#include +#include + #include "goto_rw.h" #include "dependence_graph.h" -/*******************************************************************\ - -Function: dep_graph_domaint::merge - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool dep_graph_domaint::merge( const dep_graph_domaint &src, goto_programt::const_targett from, @@ -66,18 +60,6 @@ bool dep_graph_domaint::merge( return changed; } -/*******************************************************************\ - -Function: dep_graph_domaint::control_dependencies - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dep_graph_domaint::control_dependencies( goto_programt::const_targett from, goto_programt::const_targett to, @@ -144,18 +126,6 @@ void dep_graph_domaint::control_dependencies( dep_graph.add_dep(dep_edget::kindt::CTRL, c_dep, to); } -/*******************************************************************\ - -Function: may_be_def_use_pair - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static bool may_be_def_use_pair( const mp_integer &w_start, const mp_integer &w_end, @@ -177,18 +147,6 @@ static bool may_be_def_use_pair( return false; } -/*******************************************************************\ - -Function: dep_graph_domaint::data_depdendencies - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dep_graph_domaint::data_dependencies( goto_programt::const_targett from, goto_programt::const_targett to, @@ -238,18 +196,6 @@ void dep_graph_domaint::data_dependencies( } } -/*******************************************************************\ - -Function: dep_graph_domaint::transform - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dep_graph_domaint::transform( goto_programt::const_targett from, goto_programt::const_targett to, @@ -297,18 +243,6 @@ void dep_graph_domaint::transform( data_dependencies(from, to, *dep_graph, ns); } -/*******************************************************************\ - -Function: dep_graph_domaint::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dep_graph_domaint::output( std::ostream &out, const ai_baset &ai, @@ -326,7 +260,7 @@ void dep_graph_domaint::output( out << ","; out << (*it)->location_number; } - out << std::endl; + out << '\n'; } if(!data_deps.empty()) @@ -341,21 +275,40 @@ void dep_graph_domaint::output( out << ","; out << (*it)->location_number; } - out << std::endl; + out << '\n'; } } -/*******************************************************************\ - -Function: dependence_grapht::add_dep - - Inputs: +/// Outputs the current value of the domain. +/// \par parameters: The abstract interpreter and the namespace. +/// \return The domain, formatted as a JSON object. +jsont dep_graph_domaint::output_json( + const ai_baset &ai, + const namespacet &ns) const +{ + json_arrayt graph; - Outputs: + for(const auto &cd : control_deps) + { + json_objectt &link=graph.push_back().make_object(); + link["locationNumber"]= + json_numbert(std::to_string(cd->location_number)); + link["sourceLocation"]=json(cd->source_location); + link["type"]=json_stringt("control"); + } - Purpose: + for(const auto &dd : data_deps) + { + json_objectt &link=graph.push_back().make_object(); + link["locationNumber"]= + json_numbert(std::to_string(dd->location_number)); + link["sourceLocation"]=json(dd->source_location); + json_stringt(dd->source_location.as_string()); + link["type"]=json_stringt("data"); + } -\*******************************************************************/ + return graph; +} void dependence_grapht::add_dep( dep_edget::kindt kind, diff --git a/src/analyses/dependence_graph.h b/src/analyses/dependence_graph.h index fae7c7adbd4..4cd7be4c589 100644 --- a/src/analyses/dependence_graph.h +++ b/src/analyses/dependence_graph.h @@ -9,6 +9,9 @@ Date: August 2013 \*******************************************************************/ +/// \file +/// Field-Sensitive Program Dependence Analysis, Litvak et al., FSE 2010 + #ifndef CPROVER_ANALYSES_DEPENDENCE_GRAPH_H #define CPROVER_ANALYSES_DEPENDENCE_GRAPH_H @@ -87,7 +90,11 @@ class dep_graph_domaint:public ai_domain_baset const ai_baset &ai, const namespacet &ns) const final; - void make_top() final + jsont output_json( + const ai_baset &ai, + const namespacet &ns) const override; + + void make_top() final override { assert(node_id!=std::numeric_limits::max()); diff --git a/src/analyses/dirty.cpp b/src/analyses/dirty.cpp index a159f6ddef2..9a42e7f0a0f 100644 --- a/src/analyses/dirty.cpp +++ b/src/analyses/dirty.cpp @@ -8,22 +8,13 @@ Date: March 2013 \*******************************************************************/ +/// \file +/// Local variables whose address is taken + #include #include "dirty.h" -/*******************************************************************\ - -Function: dirtyt::build - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dirtyt::build(const goto_functiont &goto_function) { forall_goto_program_instructions(it, goto_function.body) @@ -33,18 +24,6 @@ void dirtyt::build(const goto_functiont &goto_function) } } -/*******************************************************************\ - -Function: dirtyt::find_dirty - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dirtyt::find_dirty(const exprt &expr) { if(expr.id()==ID_address_of) @@ -58,18 +37,6 @@ void dirtyt::find_dirty(const exprt &expr) find_dirty(*it); } -/*******************************************************************\ - -Function: dirtyt::find_dirty_address_of - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dirtyt::find_dirty_address_of(const exprt &expr) { if(expr.id()==ID_symbol) @@ -100,20 +67,8 @@ void dirtyt::find_dirty_address_of(const exprt &expr) } } -/*******************************************************************\ - -Function: dirtyt::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dirtyt::output(std::ostream &out) const { for(const auto &d : dirty) - out << d << std::endl; + out << d << '\n'; } diff --git a/src/analyses/dirty.h b/src/analyses/dirty.h index f60b86703c4..52801d05281 100644 --- a/src/analyses/dirty.h +++ b/src/analyses/dirty.h @@ -8,6 +8,9 @@ Date: March 2013 \*******************************************************************/ +/// \file +/// Variables whose address is taken + #ifndef CPROVER_ANALYSES_DIRTY_H #define CPROVER_ANALYSES_DIRTY_H diff --git a/src/analyses/does_remove_const.cpp b/src/analyses/does_remove_const.cpp index fcccd8219c9..90d82f99e19 100644 --- a/src/analyses/does_remove_const.cpp +++ b/src/analyses/does_remove_const.cpp @@ -6,6 +6,9 @@ \*******************************************************************/ +/// \file +/// Analyses + #include #include #include @@ -15,21 +18,10 @@ #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. - -\*******************************************************************/ - +/// A naive analysis to look for casts that remove const-ness from pointers. +/// \param goto_program: the goto program to check +/// \param ns: the namespace of the goto program (used for checking type +/// equality) does_remove_constt::does_remove_constt( const goto_programt &goto_program, const namespacet &ns): @@ -37,19 +29,8 @@ does_remove_constt::does_remove_constt( ns(ns) {} -/*******************************************************************\ - -Function: does_remove_constt::operator() - - Inputs: - - Outputs: Returns true if the program contains a const-removing cast - - Purpose: A naive analysis to look for casts that remove const-ness from - pointers. - -\*******************************************************************/ - +/// A naive analysis to look for casts that remove const-ness from pointers. +/// \return Returns true if the program contains a const-removing cast bool does_remove_constt::operator()() const { for(const goto_programt::instructiont &instruction : @@ -80,22 +61,12 @@ bool does_remove_constt::operator()() const return false; } -/*******************************************************************\ - -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. - -\*******************************************************************/ - +/// Search the expression tree to look for any children that have the same base +/// type, but a less strict const qualification. If one is found, we return +/// true. +/// \param expr: The expression to check +/// \return Returns true if somewhere in the passed expression tree the const- +/// ness is lost. bool does_remove_constt::does_expr_lose_const(const exprt &expr) const { const typet &root_type=expr.type(); @@ -122,29 +93,20 @@ bool does_remove_constt::does_expr_lose_const(const exprt &expr) const 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 - -\*******************************************************************/ - +/// A recursive check to check the type_more_const is at least as const as type +/// compare. +/// +/// type_more_const | type_compare || result +/// ---------------------------------------- +/// const int * | const int * -> true +/// int * | const int * -> false +/// const int * | int * -> true +/// int * | int * const -> false +/// \param type_more_const: the type we are expecting to be at least as const +/// qualified +/// \param type_compare: the type we are comparing against which may be less +/// const qualified +/// \return Returns true if type_more_const is at least as const as type_compare bool does_remove_constt::is_type_at_least_as_const_as( const typet *type_more_const, const typet *type_compare) const { diff --git a/src/analyses/does_remove_const.h b/src/analyses/does_remove_const.h index 594682c7d50..f0cf2a25799 100644 --- a/src/analyses/does_remove_const.h +++ b/src/analyses/does_remove_const.h @@ -5,6 +5,9 @@ Author: DiffBlue Limited. All rights reserved. \*******************************************************************/ +/// \file +/// Analyses + #ifndef CPROVER_ANALYSES_DOES_REMOVE_CONST_H #define CPROVER_ANALYSES_DOES_REMOVE_CONST_H diff --git a/src/analyses/escape_analysis.cpp b/src/analyses/escape_analysis.cpp index 1382e9d1689..3b0e7fc3f5c 100644 --- a/src/analyses/escape_analysis.cpp +++ b/src/analyses/escape_analysis.cpp @@ -6,22 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Field-insensitive, location-sensitive escape analysis + #include #include "escape_analysis.h" -/*******************************************************************\ - -Function: escape_domaint::is_tracked - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool escape_domaint::is_tracked(const symbol_exprt &symbol) { const irep_idt &identifier=symbol.get_identifier(); @@ -34,18 +25,6 @@ bool escape_domaint::is_tracked(const symbol_exprt &symbol) return true; } -/*******************************************************************\ - -Function: escape_domaint::get_function - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - irep_idt escape_domaint::get_function(const exprt &lhs) { if(lhs.id()==ID_address_of) @@ -61,18 +40,6 @@ irep_idt escape_domaint::get_function(const exprt &lhs) return irep_idt(); } -/*******************************************************************\ - -Function: escape_domaint::assign_lhs_cleanup - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void escape_domaint::assign_lhs_cleanup( const exprt &lhs, const std::set &cleanup_functions) @@ -92,18 +59,6 @@ void escape_domaint::assign_lhs_cleanup( } } -/*******************************************************************\ - -Function: escape_domaint::assign_lhs_aliases - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void escape_domaint::assign_lhs_aliases( const exprt &lhs, const std::set &alias_set) @@ -125,18 +80,6 @@ void escape_domaint::assign_lhs_aliases( } } -/*******************************************************************\ - -Function: escape_domaint::get_rhs_cleanup - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void escape_domaint::get_rhs_cleanup( const exprt &rhs, std::set &cleanup_functions) @@ -167,18 +110,6 @@ void escape_domaint::get_rhs_cleanup( } } -/*******************************************************************\ - -Function: escape_domaint::get_rhs_aliases - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void escape_domaint::get_rhs_aliases( const exprt &rhs, std::set &alias_set) @@ -211,18 +142,6 @@ void escape_domaint::get_rhs_aliases( } } -/*******************************************************************\ - -Function: escape_domaint::get_rhs_aliases_address_of - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void escape_domaint::get_rhs_aliases_address_of( const exprt &rhs, std::set &alias_set) @@ -242,18 +161,6 @@ void escape_domaint::get_rhs_aliases_address_of( } } -/*******************************************************************\ - -Function: escape_domaint::transform - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void escape_domaint::transform( locationt from, locationt to, @@ -346,18 +253,6 @@ void escape_domaint::transform( } } -/*******************************************************************\ - -Function: escape_domaint::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void escape_domaint::output( std::ostream &out, const ai_baset &ai, @@ -404,18 +299,6 @@ void escape_domaint::output( } } -/*******************************************************************\ - -Function: escape_domaint::merge - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool escape_domaint::merge( const escape_domaint &b, locationt from, @@ -480,18 +363,6 @@ bool escape_domaint::merge( return changed; } -/*******************************************************************\ - -Function: escape_domaint::check_lhs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void escape_domaint::check_lhs( const exprt &lhs, std::set &cleanup_functions) @@ -527,18 +398,6 @@ void escape_domaint::check_lhs( } } -/*******************************************************************\ - -Function: escape_analysist::insert_cleanup - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void escape_analysist::insert_cleanup( goto_functionst::goto_functiont &goto_function, goto_programt::targett location, @@ -576,18 +435,6 @@ void escape_analysist::insert_cleanup( } } -/*******************************************************************\ - -Function: escape_analysist::instrument - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void escape_analysist::instrument( goto_functionst &goto_functions, const namespacet &ns) diff --git a/src/analyses/escape_analysis.h b/src/analyses/escape_analysis.h index 948bed3fea8..00f865b45e4 100644 --- a/src/analyses/escape_analysis.h +++ b/src/analyses/escape_analysis.h @@ -7,6 +7,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Field-insensitive, location-sensitive, over-approximative escape analysis + #ifndef CPROVER_ANALYSES_ESCAPE_ANALYSIS_H #define CPROVER_ANALYSES_ESCAPE_ANALYSIS_H @@ -16,14 +19,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "ai.h" -/*******************************************************************\ - - Class: escape_domaint - - Purpose: - -\*******************************************************************/ - class escape_analysist; class escape_domaint:public ai_domain_baset diff --git a/src/analyses/flow_insensitive_analysis.cpp b/src/analyses/flow_insensitive_analysis.cpp index bc4dd11e889..f6766038eba 100644 --- a/src/analyses/flow_insensitive_analysis.cpp +++ b/src/analyses/flow_insensitive_analysis.cpp @@ -7,6 +7,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Flow Insensitive Static Analysis + #include #include @@ -14,18 +17,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "flow_insensitive_analysis.h" -/*******************************************************************\ - -Function: flow_insensitive_abstract_domain_baset::get_guard - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt flow_insensitive_abstract_domain_baset::get_guard( locationt from, locationt to) const @@ -46,18 +37,6 @@ exprt flow_insensitive_abstract_domain_baset::get_guard( return from->guard; } -/*******************************************************************\ - -Function: flow_insensitive_abstract_domain_baset::get_return_lhs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt flow_insensitive_abstract_domain_baset::get_return_lhs(locationt to) const { // get predecessor of "to" @@ -76,18 +55,6 @@ exprt flow_insensitive_abstract_domain_baset::get_return_lhs(locationt to) const return code.lhs(); } -/*******************************************************************\ - -Function: flow_insensitive_analysis_baset::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void flow_insensitive_analysis_baset::operator()( const goto_functionst &goto_functions) { @@ -95,18 +62,6 @@ void flow_insensitive_analysis_baset::operator()( fixedpoint(goto_functions); } -/*******************************************************************\ - -Function: flow_insensitive_analysis_baset::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void flow_insensitive_analysis_baset::operator()( const goto_programt &goto_program) { @@ -115,45 +70,18 @@ void flow_insensitive_analysis_baset::operator()( fixedpoint(goto_program, goto_functions); } -/*******************************************************************\ - -Function: flow_insensitive_analysis_baset::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void flow_insensitive_analysis_baset::output( const goto_functionst &goto_functions, std::ostream &out) { forall_goto_functions(f_it, goto_functions) { - out << "////" << std::endl; - out << "//// Function: " << f_it->first << std::endl; - out << "////" << std::endl; - out << std::endl; + out << "////\n" << "//// Function: " << f_it->first << "\n////\n\n"; output(f_it->second.body, f_it->first, out); } } -/*******************************************************************\ - -Function: flow_insensitive_analysis_baset::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void flow_insensitive_analysis_baset::output( const goto_programt &goto_program, const irep_idt &identifier, @@ -162,18 +90,6 @@ void flow_insensitive_analysis_baset::output( get_state().output(ns, out); } -/*******************************************************************\ - -Function: flow_insensitive_analysis_baset::get_next - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - flow_insensitive_analysis_baset::locationt flow_insensitive_analysis_baset::get_next( working_sett &working_set) @@ -191,18 +107,6 @@ flow_insensitive_analysis_baset::get_next( return l; } -/*******************************************************************\ - -Function: flow_insensitive_analysis_baset::fixedpoint - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool flow_insensitive_analysis_baset::fixedpoint( const goto_programt &goto_program, const goto_functionst &goto_functions) @@ -231,18 +135,6 @@ bool flow_insensitive_analysis_baset::fixedpoint( return new_data; } -/*******************************************************************\ - -Function: flow_insensitive_analysis_baset::visit - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool flow_insensitive_analysis_baset::visit( locationt l, working_sett &working_set, @@ -253,7 +145,7 @@ bool flow_insensitive_analysis_baset::visit( #if 0 std::cout << "Visiting: " << l->function << " " << - l->location_number << std::endl; + l->location_number << '\n'; #endif seen_locations.insert(l); @@ -294,14 +186,14 @@ bool flow_insensitive_analysis_baset::visit( } // if (id2string(l->function).find("debug")!=std::string::npos) -// std::cout << l->function << std::endl; //=="messages::debug") +// std::cout << l->function << '\n'; //=="messages::debug") // { // static unsigned state_cntr=0; // std::string s("pastate"); s += std::to_string(state_cntr); // std::ofstream f(s.c_str()); // goto_program.output_instruction(ns, "", f, l); -// f << std::endl; +// f << '\n'; // get_state().output(ns, f); // f.close(); // state_cntr++; @@ -310,18 +202,6 @@ bool flow_insensitive_analysis_baset::visit( return new_data; } -/*******************************************************************\ - -Function: flow_insensitive_analysis_baset::do_function_call - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool flow_insensitive_analysis_baset::do_function_call( locationt l_call, const goto_functionst &goto_functions, @@ -402,18 +282,6 @@ bool flow_insensitive_analysis_baset::do_function_call( return new_data; } -/*******************************************************************\ - -Function: flow_insensitive_analysis_baset::do_function_call_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool flow_insensitive_analysis_baset::do_function_call_rec( locationt l_call, const exprt &function, @@ -523,18 +391,6 @@ bool flow_insensitive_analysis_baset::do_function_call_rec( return new_data; } -/*******************************************************************\ - -Function: flow_insensitive_analysis_baset::fixedpoint - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void flow_insensitive_analysis_baset::fixedpoint( const goto_functionst &goto_functions) { @@ -548,18 +404,6 @@ void flow_insensitive_analysis_baset::fixedpoint( } } -/*******************************************************************\ - -Function: flow_insensitive_analysis_baset::fixedpoint - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool flow_insensitive_analysis_baset::fixedpoint( const goto_functionst::function_mapt::const_iterator it, const goto_functionst &goto_functions) @@ -568,36 +412,12 @@ bool flow_insensitive_analysis_baset::fixedpoint( return fixedpoint(it->second.body, goto_functions); } -/*******************************************************************\ - -Function: flow_insensitive_analysis_baset::update - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void flow_insensitive_analysis_baset::update( const goto_functionst &goto_functions) { // no need to copy value sets around } -/*******************************************************************\ - -Function: flow_insensitive_analysis_baset::update - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void flow_insensitive_analysis_baset::update( const goto_programt &goto_program) { diff --git a/src/analyses/flow_insensitive_analysis.h b/src/analyses/flow_insensitive_analysis.h index 07d1f0f77cd..bf06cf90cdf 100644 --- a/src/analyses/flow_insensitive_analysis.h +++ b/src/analyses/flow_insensitive_analysis.h @@ -7,6 +7,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Flow Insensitive Static Analysis + #ifndef CPROVER_ANALYSES_FLOW_INSENSITIVE_ANALYSIS_H #define CPROVER_ANALYSES_FLOW_INSENSITIVE_ANALYSIS_H diff --git a/src/analyses/global_may_alias.cpp b/src/analyses/global_may_alias.cpp index 33ad0f7f186..28fabae92b4 100644 --- a/src/analyses/global_may_alias.cpp +++ b/src/analyses/global_may_alias.cpp @@ -6,19 +6,10 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "global_may_alias.h" - -/*******************************************************************\ - -Function: global_may_alias_domaint::assign_lhs_aliases - - Inputs: - - Outputs: - - Purpose: +/// \file +/// Field-insensitive, location-sensitive gobal may alias analysis -\*******************************************************************/ +#include "global_may_alias.h" void global_may_alias_domaint::assign_lhs_aliases( const exprt &lhs, @@ -37,18 +28,6 @@ void global_may_alias_domaint::assign_lhs_aliases( } } -/*******************************************************************\ - -Function: global_may_alias_domaint::get_rhs_aliases - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void global_may_alias_domaint::get_rhs_aliases( const exprt &rhs, std::set &alias_set) @@ -77,18 +56,6 @@ void global_may_alias_domaint::get_rhs_aliases( } } -/*******************************************************************\ - -Function: global_may_alias_domaint::get_rhs_aliases_address_of - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void global_may_alias_domaint::get_rhs_aliases_address_of( const exprt &rhs, std::set &alias_set) @@ -108,18 +75,6 @@ void global_may_alias_domaint::get_rhs_aliases_address_of( } } -/*******************************************************************\ - -Function: global_may_alias_domaint::transform - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void global_may_alias_domaint::transform( locationt from, locationt to, @@ -163,18 +118,6 @@ void global_may_alias_domaint::transform( } } -/*******************************************************************\ - -Function: global_may_alias_domaint::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void global_may_alias_domaint::output( std::ostream &out, const ai_baset &ai, @@ -213,18 +156,6 @@ void global_may_alias_domaint::output( } } -/*******************************************************************\ - -Function: global_may_alias_domaint::merge - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool global_may_alias_domaint::merge( const global_may_alias_domaint &b, locationt from, diff --git a/src/analyses/global_may_alias.h b/src/analyses/global_may_alias.h index 2f4a49b2d0a..d946b371c05 100644 --- a/src/analyses/global_may_alias.h +++ b/src/analyses/global_may_alias.h @@ -7,6 +7,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Field-insensitive, location-sensitive, over-approximative escape analysis + #ifndef CPROVER_ANALYSES_GLOBAL_MAY_ALIAS_H #define CPROVER_ANALYSES_GLOBAL_MAY_ALIAS_H @@ -16,14 +19,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "ai.h" -/*******************************************************************\ - - Class: global_may_alias_domaint - - Purpose: - -\*******************************************************************/ - class global_may_alias_analysist; class global_may_alias_domaint:public ai_domain_baset diff --git a/src/analyses/goto_check.cpp b/src/analyses/goto_check.cpp index a6871b94d23..3b05797c858 100644 --- a/src/analyses/goto_check.cpp +++ b/src/analyses/goto_check.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// GOTO Programs + #include #include @@ -64,6 +67,8 @@ class goto_checkt void goto_check(goto_functiont &goto_function, const irep_idt &mode); + void collect_allocations(const goto_functionst &goto_functions); + protected: const namespacet &ns; local_bitvector_analysist *local_bitvector_analysis; @@ -134,19 +139,43 @@ class goto_checkt typedef optionst::value_listt error_labelst; error_labelst error_labels; -}; - -/*******************************************************************\ - -Function: goto_checkt::invalidate - Inputs: - - Outputs: + typedef std::pair allocationt; + typedef std::list allocationst; + allocationst allocations; +}; - Purpose: +void goto_checkt::collect_allocations( + const goto_functionst &goto_functions) +{ + if(!enable_pointer_check) + return; -\*******************************************************************/ + forall_goto_functions(itf, goto_functions) + forall_goto_program_instructions(it, itf->second.body) + { + const goto_programt::instructiont &instruction=*it; + if(!instruction.is_function_call()) + continue; + + const code_function_callt &call= + to_code_function_call(instruction.code); + if(call.function().id()!=ID_symbol || + to_symbol_expr(call.function()).get_identifier()!= + CPROVER_PREFIX "allocated_memory") + continue; + + const code_function_callt::argumentst &args= call.arguments(); + if(args.size()!=2 || + args[0].type().id()!=ID_unsignedbv || + args[1].type().id()!=ID_unsignedbv) + throw "expected two unsigned arguments to " + CPROVER_PREFIX "allocated_memory"; + + assert(args[0].type()==args[1].type()); + allocations.push_back({args[0], args[1]}); + } +} void goto_checkt::invalidate(const exprt &lhs) { @@ -182,18 +211,6 @@ void goto_checkt::invalidate(const exprt &lhs) } } -/*******************************************************************\ - -Function: goto_checkt::div_by_zero_check - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_checkt::div_by_zero_check( const div_exprt &expr, const guardt &guard) @@ -220,18 +237,6 @@ void goto_checkt::div_by_zero_check( guard); } -/*******************************************************************\ - -Function: goto_checkt::undefined_shift_check - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_checkt::undefined_shift_check( const shift_exprt &expr, const guardt &guard) @@ -283,18 +288,6 @@ void goto_checkt::undefined_shift_check( } } -/*******************************************************************\ - -Function: goto_checkt::mod_by_zero_check - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_checkt::mod_by_zero_check( const mod_exprt &expr, const guardt &guard) @@ -321,18 +314,6 @@ void goto_checkt::mod_by_zero_check( guard); } -/*******************************************************************\ - -Function: goto_checkt::conversion_check - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_checkt::conversion_check( const exprt &expr, const guardt &guard) @@ -512,18 +493,6 @@ void goto_checkt::conversion_check( } } -/*******************************************************************\ - -Function: goto_checkt::integer_overflow_check - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_checkt::integer_overflow_check( const exprt &expr, const guardt &guard) @@ -645,18 +614,6 @@ void goto_checkt::integer_overflow_check( } } -/*******************************************************************\ - -Function: goto_checkt::float_overflow_check - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_checkt::float_overflow_check( const exprt &expr, const guardt &guard) @@ -779,18 +736,6 @@ void goto_checkt::float_overflow_check( } } -/*******************************************************************\ - -Function: goto_checkt::nan_check - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_checkt::nan_check( const exprt &expr, const guardt &guard) @@ -900,18 +845,6 @@ void goto_checkt::nan_check( guard); } -/*******************************************************************\ - -Function: goto_checkt::pointer_rel_check - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_checkt::pointer_rel_check( const exprt &expr, const guardt &guard) @@ -942,18 +875,6 @@ void goto_checkt::pointer_rel_check( } } -/*******************************************************************\ - -Function: goto_checkt::pointer_overflow_check - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_checkt::pointer_overflow_check( const exprt &expr, const guardt &guard) @@ -980,18 +901,6 @@ void goto_checkt::pointer_overflow_check( } } -/*******************************************************************\ - -Function: goto_checkt::pointer_validity_check - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_checkt::pointer_validity_check( const dereference_exprt &expr, const guardt &guard, @@ -1031,10 +940,49 @@ void goto_checkt::pointer_validity_check( } else { + exprt allocs=false_exprt(); + + if(!allocations.empty()) + { + exprt::operandst disjuncts; + + for(const auto &a : allocations) + { + typecast_exprt int_ptr(pointer, a.first.type()); + + exprt lb(int_ptr); + if(access_lb.is_not_nil()) + { + if(!base_type_eq(lb.type(), access_lb.type(), ns)) + lb=plus_exprt(lb, typecast_exprt(access_lb, lb.type())); + else + lb=plus_exprt(lb, access_lb); + } + + binary_relation_exprt lb_check(a.first, ID_le, lb); + + exprt ub(int_ptr); + if(access_ub.is_not_nil()) + { + if(!base_type_eq(ub.type(), access_ub.type(), ns)) + ub=plus_exprt(ub, typecast_exprt(access_ub, ub.type())); + else + ub=plus_exprt(ub, access_ub); + } + + binary_relation_exprt ub_check( + ub, ID_le, plus_exprt(a.first, a.second)); + + disjuncts.push_back(and_exprt(lb_check, ub_check)); + } + + allocs=disjunction(disjuncts); + } + if(flags.is_unknown() || flags.is_null()) { add_guarded_claim( - not_exprt(null_pointer(pointer)), + or_exprt(allocs, not_exprt(null_pointer(pointer))), "dereference failure: pointer NULL", "pointer dereference", expr.find_source_location(), @@ -1044,7 +992,7 @@ void goto_checkt::pointer_validity_check( if(flags.is_unknown()) add_guarded_claim( - not_exprt(invalid_pointer(pointer)), + or_exprt(allocs, not_exprt(invalid_pointer(pointer))), "dereference failure: pointer invalid", "pointer dereference", expr.find_source_location(), @@ -1053,7 +1001,7 @@ void goto_checkt::pointer_validity_check( if(flags.is_uninitialized()) add_guarded_claim( - not_exprt(invalid_pointer(pointer)), + or_exprt(allocs, not_exprt(invalid_pointer(pointer))), "dereference failure: pointer uninitialized", "pointer dereference", expr.find_source_location(), @@ -1062,7 +1010,7 @@ void goto_checkt::pointer_validity_check( if(flags.is_unknown() || flags.is_dynamic_heap()) add_guarded_claim( - not_exprt(deallocated(pointer, ns)), + or_exprt(allocs, not_exprt(deallocated(pointer, ns))), "dereference failure: deallocated dynamic object", "pointer dereference", expr.find_source_location(), @@ -1071,7 +1019,7 @@ void goto_checkt::pointer_validity_check( if(flags.is_unknown() || flags.is_dynamic_local()) add_guarded_claim( - not_exprt(dead_object(pointer, ns)), + or_exprt(allocs, not_exprt(dead_object(pointer, ns))), "dereference failure: dead object", "pointer dereference", expr.find_source_location(), @@ -1089,7 +1037,11 @@ void goto_checkt::pointer_validity_check( access_ub)); add_guarded_claim( - implies_exprt(malloc_object(pointer, ns), not_exprt(dynamic_bounds)), + or_exprt( + allocs, + implies_exprt( + malloc_object(pointer, ns), + not_exprt(dynamic_bounds))), "dereference failure: pointer outside dynamic object bounds", "pointer dereference", expr.find_source_location(), @@ -1110,7 +1062,7 @@ void goto_checkt::pointer_validity_check( access_ub)); add_guarded_claim( - or_exprt(dynamic_object(pointer), not_exprt(object_bounds)), + or_exprt(allocs, dynamic_object(pointer), not_exprt(object_bounds)), "dereference failure: pointer outside object bounds", "pointer dereference", expr.find_source_location(), @@ -1120,35 +1072,11 @@ void goto_checkt::pointer_validity_check( } } -/*******************************************************************\ - -Function: goto_checkt::array_name - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string goto_checkt::array_name(const exprt &expr) { return ::array_name(ns, expr); } -/*******************************************************************\ - -Function: goto_checkt::bounds_check - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_checkt::bounds_check( const index_exprt &expr, const guardt &guard) @@ -1238,7 +1166,8 @@ void goto_checkt::bounds_check( plus_exprt effective_offset(ode.offset(), pointer_offset(pointer)); assert(effective_offset.op0().type()==effective_offset.op1().type()); - assert(effective_offset.type()==size.type()); + if(effective_offset.type()!=size.type()) + size.make_typecast(effective_offset.type()); binary_relation_exprt inequality(effective_offset, ID_lt, size); @@ -1303,18 +1232,6 @@ void goto_checkt::bounds_check( } } -/*******************************************************************\ - -Function: goto_checkt::add_guarded_claim - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_checkt::add_guarded_claim( const exprt &_expr, const std::string &comment, @@ -1362,18 +1279,6 @@ void goto_checkt::add_guarded_claim( } } -/*******************************************************************\ - -Function: goto_checkt::check_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_checkt::check_rec( const exprt &expr, guardt &guard, @@ -1554,36 +1459,12 @@ void goto_checkt::check_rec( mode); } -/*******************************************************************\ - -Function: goto_checkt::check - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_checkt::check(const exprt &expr, const irep_idt &mode) { guardt guard; check_rec(expr, guard, false, mode); } -/*******************************************************************\ - -Function: goto_checkt::goto_check - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_checkt::goto_check( goto_functiont &goto_function, const irep_idt &mode) @@ -1808,17 +1689,17 @@ void goto_checkt::goto_check( { i_it->source_location.id(irep_idt()); - if(it->source_location.get_file()!=irep_idt()) + if(!it->source_location.get_file().empty()) i_it->source_location.set_file(it->source_location.get_file()); - if(it->source_location.get_line()!=irep_idt()) + if(!it->source_location.get_line().empty()) i_it->source_location.set_line(it->source_location.get_line()); - if(it->source_location.get_function()!=irep_idt()) + if(!it->source_location.get_function().empty()) i_it->source_location.set_function( it->source_location.get_function()); - if(it->source_location.get_column()!=irep_idt()) + if(!it->source_location.get_column().empty()) i_it->source_location.set_column(it->source_location.get_column()); if(it->source_location.get_java_bytecode_index()!=irep_idt()) @@ -1826,7 +1707,7 @@ void goto_checkt::goto_check( it->source_location.get_java_bytecode_index()); } - if(i_it->function==irep_idt()) + if(i_it->function.empty()) i_it->function=it->function; } @@ -1841,18 +1722,6 @@ void goto_checkt::goto_check( } } -/*******************************************************************\ - -Function: goto_check - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_check( const namespacet &ns, const optionst &options, @@ -1862,18 +1731,6 @@ void goto_check( goto_check.goto_check(goto_function, irep_idt()); } -/*******************************************************************\ - -Function: goto_check - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_check( const namespacet &ns, const optionst &options, @@ -1881,6 +1738,8 @@ void goto_check( { goto_checkt goto_check(ns, options); + goto_check.collect_allocations(goto_functions); + Forall_goto_functions(it, goto_functions) { irep_idt mode=ns.lookup(it->first).mode; @@ -1888,18 +1747,6 @@ void goto_check( } } -/*******************************************************************\ - -Function: goto_check - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_check( const optionst &options, goto_modelt &goto_model) diff --git a/src/analyses/goto_check.h b/src/analyses/goto_check.h index 2089d744fd2..44d98069de9 100644 --- a/src/analyses/goto_check.h +++ b/src/analyses/goto_check.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Program Transformation + #ifndef CPROVER_ANALYSES_GOTO_CHECK_H #define CPROVER_ANALYSES_GOTO_CHECK_H diff --git a/src/analyses/goto_rw.cpp b/src/analyses/goto_rw.cpp index e5df484cb9c..73b7a8c3520 100644 --- a/src/analyses/goto_rw.cpp +++ b/src/analyses/goto_rw.cpp @@ -8,6 +8,7 @@ Date: April 2010 \*******************************************************************/ + #include #include @@ -25,34 +26,10 @@ Date: April 2010 #include "goto_rw.h" -/*******************************************************************\ - -Function: range_domain_baset::~range_domain_baset - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - range_domain_baset::~range_domain_baset() { } -/*******************************************************************\ - -Function: range_domaint::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void range_domaint::output( const namespacet &ns, std::ostream &out) const { @@ -68,18 +45,6 @@ void range_domaint::output( out << "]"; } -/*******************************************************************\ - -Function: rw_range_sett::~rw_range_sett - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - rw_range_sett::~rw_range_sett() { for(rw_range_sett::objectst::iterator it=r_range_set.begin(); @@ -93,51 +58,27 @@ rw_range_sett::~rw_range_sett() delete it->second; } -/*******************************************************************\ - -Function: rw_range_sett::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rw_range_sett::output(std::ostream &out) const { - out << "READ:" << std::endl; + out << "READ:\n"; forall_rw_range_set_r_objects(it, *this) { out << " " << it->first; it->second->output(ns, out); - out << std::endl; + out << '\n'; } - out << std::endl; + out << '\n'; - out << "WRITE:" << std::endl; + out << "WRITE:\n"; forall_rw_range_set_w_objects(it, *this) { out << " " << it->first; it->second->output(ns, out); - out << std::endl; + out << '\n'; } } -/*******************************************************************\ - -Function: rw_range_sett::get_objects_complex - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rw_range_sett::get_objects_complex( get_modet mode, const exprt &expr, @@ -149,24 +90,13 @@ void rw_range_sett::get_objects_complex( range_spect sub_size= to_range_spect(pointer_offset_bits(op.type().subtype(), ns)); + assert(sub_size>0); range_spect offset= (range_start==-1 || expr.id()==ID_complex_real) ? 0 : sub_size; get_objects_rec(mode, op, range_start+offset, size); } -/*******************************************************************\ - -Function: rw_range_sett::get_objects_if - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rw_range_sett::get_objects_if( get_modet mode, const if_exprt &if_expr, @@ -186,18 +116,6 @@ void rw_range_sett::get_objects_if( } } -/*******************************************************************\ - -Function: rw_range_sett::get_objects_dereference - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rw_range_sett::get_objects_dereference( get_modet mode, const dereference_exprt &deref, @@ -210,18 +128,6 @@ void rw_range_sett::get_objects_dereference( get_objects_rec(mode, pointer); } -/*******************************************************************\ - -Function: rw_range_sett::get_objects_byte_extract - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rw_range_sett::get_objects_byte_extract( get_modet mode, const byte_extract_exprt &be, @@ -249,18 +155,6 @@ void rw_range_sett::get_objects_byte_extract( } } -/*******************************************************************\ - -Function: rw_range_sett::get_objects_shift - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rw_range_sett::get_objects_shift( get_modet mode, const shift_exprt &shift, @@ -309,18 +203,6 @@ void rw_range_sett::get_objects_shift( } } -/*******************************************************************\ - -Function: rw_range_sett::get_objects_member - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rw_range_sett::get_objects_member( get_modet mode, const member_exprt &expr, @@ -351,18 +233,6 @@ void rw_range_sett::get_objects_member( get_objects_rec(mode, expr.struct_op(), offset, size); } -/*******************************************************************\ - -Function: rw_range_sett::get_objects_index - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rw_range_sett::get_objects_index( get_modet mode, const index_exprt &expr, @@ -411,18 +281,6 @@ void rw_range_sett::get_objects_index( size); } -/*******************************************************************\ - -Function: rw_range_sett::get_objects_array - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rw_range_sett::get_objects_array( get_modet mode, const array_exprt &expr, @@ -463,18 +321,6 @@ void rw_range_sett::get_objects_array( } } -/*******************************************************************\ - -Function: rw_range_sett::get_objects_struct - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rw_range_sett::get_objects_struct( get_modet mode, const struct_exprt &expr, @@ -535,18 +381,6 @@ void rw_range_sett::get_objects_struct( } } -/*******************************************************************\ - -Function: rw_range_sett::get_objects_typecast - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rw_range_sett::get_objects_typecast( get_modet mode, const typecast_exprt &tc, @@ -572,18 +406,6 @@ void rw_range_sett::get_objects_typecast( get_objects_rec(mode, op, range_start, new_size); } -/*******************************************************************\ - -Function: rw_range_sett::get_objects_address_of - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rw_range_sett::get_objects_address_of(const exprt &object) { if(object.id()==ID_string_constant || @@ -634,18 +456,6 @@ void rw_range_sett::get_objects_address_of(const exprt &object) throw "rw_range_sett: address_of `"+object.id_string()+"' not handled"; } -/*******************************************************************\ - -Function: rw_range_sett::add - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rw_range_sett::add( get_modet mode, const irep_idt &identifier, @@ -663,18 +473,6 @@ void rw_range_sett::add( std::make_pair(range_start, range_end)); } -/*******************************************************************\ - -Function: rw_range_sett::get_objects_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rw_range_sett::get_objects_rec( get_modet mode, const exprt &expr, @@ -766,18 +564,6 @@ void rw_range_sett::get_objects_rec( throw "rw_range_sett: assignment to `"+expr.id_string()+"' not handled"; } -/*******************************************************************\ - -Function: rw_range_sett::get_objects_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rw_range_sett::get_objects_rec(get_modet mode, const exprt &expr) { range_spect size= @@ -785,18 +571,6 @@ void rw_range_sett::get_objects_rec(get_modet mode, const exprt &expr) get_objects_rec(mode, expr, 0, size); } -/*******************************************************************\ - -Function: rw_range_sett::get_objects_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rw_range_sett::get_objects_rec(const typet &type) { // TODO should recurse into various composite types @@ -807,18 +581,6 @@ void rw_range_sett::get_objects_rec(const typet &type) } } -/*******************************************************************\ - -Function: rw_range_set_value_sett::get_objects_dereference - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rw_range_set_value_sett::get_objects_dereference( get_modet mode, const dereference_exprt &deref, @@ -852,18 +614,6 @@ void rw_range_set_value_sett::get_objects_dereference( get_objects_rec(mode, object, range_start, new_size); } -/*******************************************************************\ - -Function: guarded_range_domaint::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void guarded_range_domaint::output( const namespacet &ns, std::ostream &out) const { @@ -880,18 +630,6 @@ void guarded_range_domaint::output( out << "]"; } -/*******************************************************************\ - -Function: rw_guarded_range_set_value_sett::get_objects_if - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rw_guarded_range_set_value_sett::get_objects_if( get_modet mode, const if_exprt &if_expr, @@ -918,18 +656,6 @@ void rw_guarded_range_set_value_sett::get_objects_if( } } -/*******************************************************************\ - -Function: rw_guarded_range_set_value_sett::add - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rw_guarded_range_set_value_sett::add( get_modet mode, const irep_idt &identifier, @@ -948,18 +674,6 @@ void rw_guarded_range_set_value_sett::add( std::make_pair(range_end, guard.as_expr()))); } -/*******************************************************************\ - -Function: goto_rw - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_rw(goto_programt::const_targett target, const code_assignt &assign, rw_range_sett &rw_set) @@ -968,18 +682,6 @@ void goto_rw(goto_programt::const_targett target, rw_set.get_objects_rec(target, rw_range_sett::get_modet::READ, assign.rhs()); } -/*******************************************************************\ - -Function: goto_rw - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_rw(goto_programt::const_targett target, const code_function_callt &function_call, rw_range_sett &rw_set) @@ -999,18 +701,6 @@ void goto_rw(goto_programt::const_targett target, rw_set.get_objects_rec(target, rw_range_sett::get_modet::READ, *it); } -/*******************************************************************\ - -Function: goto_rw - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_rw(goto_programt::const_targett target, rw_range_sett &rw_set) { @@ -1088,36 +778,12 @@ void goto_rw(goto_programt::const_targett target, } } -/*******************************************************************\ - -Function: goto_rw - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_rw(const goto_programt &goto_program, rw_range_sett &rw_set) { forall_goto_program_instructions(i_it, goto_program) goto_rw(i_it, rw_set); } -/*******************************************************************\ - -Function: goto_rw - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_rw(const goto_functionst &goto_functions, const irep_idt &function, rw_range_sett &rw_set) diff --git a/src/analyses/goto_rw.h b/src/analyses/goto_rw.h index 2e826da7728..06b7a7ab411 100644 --- a/src/analyses/goto_rw.h +++ b/src/analyses/goto_rw.h @@ -8,6 +8,7 @@ Date: April 2010 \*******************************************************************/ + #ifndef CPROVER_ANALYSES_GOTO_RW_H #define CPROVER_ANALYSES_GOTO_RW_H diff --git a/src/analyses/interval_analysis.cpp b/src/analyses/interval_analysis.cpp index 17c3dd68562..d81d857b1f8 100644 --- a/src/analyses/interval_analysis.cpp +++ b/src/analyses/interval_analysis.cpp @@ -6,23 +6,14 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Interval Analysis + #include #include "interval_domain.h" #include "interval_analysis.h" -/*******************************************************************\ - -Function: instrument_intervals - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void instrument_intervals( const ait &interval_analysis, goto_functionst::goto_functiont &goto_function) @@ -84,18 +75,6 @@ void instrument_intervals( } } -/*******************************************************************\ - -Function: interval_analysis - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void interval_analysis( const namespacet &ns, goto_functionst &goto_functions) diff --git a/src/analyses/interval_analysis.h b/src/analyses/interval_analysis.h index be86a6c65f8..1c85fc9a193 100644 --- a/src/analyses/interval_analysis.h +++ b/src/analyses/interval_analysis.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Interval Analysis + #ifndef CPROVER_ANALYSES_INTERVAL_ANALYSIS_H #define CPROVER_ANALYSES_INTERVAL_ANALYSIS_H diff --git a/src/analyses/interval_domain.cpp b/src/analyses/interval_domain.cpp index 1faf8c52364..6dc4fd37fab 100644 --- a/src/analyses/interval_domain.cpp +++ b/src/analyses/interval_domain.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Interval Domain + #ifdef DEBUG #include #endif @@ -16,18 +19,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "interval_domain.h" -/*******************************************************************\ - -Function: interval_domaint::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void interval_domaint::output( std::ostream &out, const ai_baset &ai, @@ -64,18 +55,6 @@ void interval_domaint::output( } } -/*******************************************************************\ - -Function: interval_domaint::transform - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void interval_domaint::transform( locationt from, locationt to, @@ -127,22 +106,20 @@ void interval_domaint::transform( } } -/*******************************************************************\ - -Function: interval_domaint::merge - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -bool interval_domaint::merge( - const interval_domaint &b, - locationt from, - locationt to) +/// Sets *this to the mathematical join between the two domains. This can be +/// thought of as an abstract version of union; *this is increased so that it +/// contains all of the values that are represented by b as well as its original +/// intervals. The result is an overapproximation, for example: +/// "[0,1]".join("[3,4]") --> "[0,4]" includes 2 which isn't in [0,1] or [3,4]. +/// +/// Join is used in several places, the most significant being +/// merge, which uses it to bring together two different paths +/// of analysis. +/// \par parameters: The interval domain, b, to join to this domain. +/// \return True if the join increases the set represented by *this, False if +/// there is no change. +bool interval_domaint::join( + const interval_domaint &b) { if(b.bottom) return false; @@ -157,8 +134,8 @@ bool interval_domaint::merge( for(int_mapt::iterator it=int_map.begin(); it!=int_map.end(); ) // no it++ { - //search for the variable that needs to be merged - //containers have different size and variable order + // 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()) { @@ -199,36 +176,12 @@ bool interval_domaint::merge( return result; } -/*******************************************************************\ - -Function: interval_domaint::assign - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void interval_domaint::assign(const code_assignt &code_assign) { havoc_rec(code_assign.lhs()); assume_rec(code_assign.lhs(), ID_equal, code_assign.rhs()); } -/*******************************************************************\ - -Function: interval_domaint::havoc_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void interval_domaint::havoc_rec(const exprt &lhs) { if(lhs.id()==ID_if) @@ -251,18 +204,6 @@ void interval_domaint::havoc_rec(const exprt &lhs) } } -/*******************************************************************\ - -Function: interval_domaint::assume_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void interval_domaint::assume_rec( const exprt &lhs, irep_idt id, const exprt &rhs) { @@ -377,18 +318,6 @@ void interval_domaint::assume_rec( } } -/*******************************************************************\ - -Function: interval_domaint::assume_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void interval_domaint::assume( const exprt &cond, const namespacet &ns) @@ -396,18 +325,6 @@ void interval_domaint::assume( assume_rec(simplify_expr(cond, ns), false); } -/*******************************************************************\ - -Function: interval_domaint::assume_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void interval_domaint::assume_rec( const exprt &cond, bool negation) @@ -454,18 +371,6 @@ void interval_domaint::assume_rec( } } -/*******************************************************************\ - -Function: interval_domaint::make_expression - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt interval_domaint::make_expression(const symbol_exprt &src) const { if(is_int(src.type())) @@ -527,3 +432,58 @@ exprt interval_domaint::make_expression(const symbol_exprt &src) const else return true_exprt(); } + +/// Uses the abstract state to simplify a given expression using context- +/// specific information. +/// \par parameters: The expression to simplify. +/// \return A simplified version of the expression. +/* + * This implementation is aimed at reducing assertions to true, particularly + * range checks for arrays and other bounds checks. + * + * Rather than work with the various kinds of exprt directly, we use assume, + * join and is_bottom. It is sufficient for the use case and avoids duplicating + * functionality that is in assume anyway. + * + * As some expressions (1<=a && a<=2) can be represented exactly as intervals + * and some can't (a<1 || a>2), the way these operations are used varies + * depending on the structure of the expression to try to give the best results. + * For example negating a disjunction makes it easier for assume to handle. + */ + +bool interval_domaint::ai_simplify( + exprt &condition, + const namespacet &ns) const +{ + bool unchanged=true; + interval_domaint d(*this); + + // merge intervals to properly handle conjunction + if(condition.id()==ID_and) // May be directly representable + { + interval_domaint a; + a.make_top(); // a is everything + a.assume(condition, ns); // Restrict a to an over-approximation + // of when condition is true + if(!a.join(d)) // If d (this) is included in a... + { // Then the condition is always true + unchanged=condition.is_true(); + condition.make_true(); + } + } + else if(condition.id()==ID_symbol) + { + // TODO: we have to handle symbol expression + } + else // Less likely to be representable + { + d.assume(not_exprt(condition), ns); // Restrict to when condition is false + if(d.is_bottom()) // If there there are none... + { // Then the condition is always true + unchanged=condition.is_true(); + condition.make_true(); + } + } + + return unchanged; +} diff --git a/src/analyses/interval_domain.h b/src/analyses/interval_domain.h index 7e95c65e9de..3076442a3ee 100644 --- a/src/analyses/interval_domain.h +++ b/src/analyses/interval_domain.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Interval Domain + #ifndef CPROVER_ANALYSES_INTERVAL_DOMAIN_H #define CPROVER_ANALYSES_INTERVAL_DOMAIN_H @@ -40,10 +43,17 @@ class interval_domaint:public ai_domain_baset const ai_baset &ai, const namespacet &ns) const final; +protected: + bool join(const interval_domaint &b); + +public: bool merge( const interval_domaint &b, locationt from, - locationt to); + locationt to) + { + return join(b); + } // no states void make_bottom() final @@ -85,7 +95,11 @@ class interval_domaint:public ai_domain_baset return bottom; } -private: + virtual bool ai_simplify( + exprt &condition, + const namespacet &ns) const override; + +protected: bool bottom; typedef std::map int_mapt; diff --git a/src/analyses/interval_template.h b/src/analyses/interval_template.h index f59d1da1f8f..b06013af53e 100644 --- a/src/analyses/interval_template.h +++ b/src/analyses/interval_template.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_ANALYSES_INTERVAL_TEMPLATE_H #define CPROVER_ANALYSES_INTERVAL_TEMPLATE_H diff --git a/src/analyses/invariant_propagation.cpp b/src/analyses/invariant_propagation.cpp index 2da2d7278f4..8e93ce4ee17 100644 --- a/src/analyses/invariant_propagation.cpp +++ b/src/analyses/invariant_propagation.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Invariant Propagation + #include #include #include @@ -13,54 +16,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "invariant_propagation.h" -/*******************************************************************\ - -Function: invariant_propagationt::make_all_true - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void invariant_propagationt::make_all_true() { for(auto &state : state_map) state.second.invariant_set.make_true(); } -/*******************************************************************\ - -Function: invariant_propagationt::make_all_false - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void invariant_propagationt::make_all_false() { for(auto &state : state_map) state.second.invariant_set.make_false(); } -/*******************************************************************\ - -Function: invariant_propagationt::add_objects - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void invariant_propagationt::add_objects( const goto_programt &goto_program) { @@ -108,18 +75,6 @@ void invariant_propagationt::add_objects( } } -/*******************************************************************\ - -Function: invariant_propagationt::get_objects - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void invariant_propagationt::get_objects( const symbolt &symbol, object_listt &dest) @@ -132,18 +87,6 @@ void invariant_propagationt::get_objects( dest.push_back(object_store.add(expr)); } -/*******************************************************************\ - -Function: invariant_propagationt::get_objects_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void invariant_propagationt::get_objects_rec( const exprt &src, std::list &dest) @@ -179,18 +122,6 @@ void invariant_propagationt::get_objects_rec( } } -/*******************************************************************\ - -Function: invariant_propagationt::add_vars - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void invariant_propagationt::add_objects( const goto_functionst &goto_functions) { @@ -243,18 +174,6 @@ void invariant_propagationt::add_objects( } } -/*******************************************************************\ - -Function: invariant_propagationt::get_globals - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void invariant_propagationt::get_globals( object_listt &dest) { @@ -265,18 +184,6 @@ void invariant_propagationt::get_globals( get_objects(it->second, dest); } -/*******************************************************************\ - -Function: invariant_propagationt::check_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool invariant_propagationt::check_type(const typet &type) const { if(type.id()==ID_pointer) @@ -297,18 +204,6 @@ bool invariant_propagationt::check_type(const typet &type) const return false; } -/*******************************************************************\ - -Function: invariant_propagationt::initialize - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void invariant_propagationt::initialize(const goto_programt &goto_program) { baset::initialize(goto_program); @@ -330,18 +225,6 @@ void invariant_propagationt::initialize(const goto_programt &goto_program) add_objects(goto_program); } -/*******************************************************************\ - -Function: invariant_propagationt::initialize - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void invariant_propagationt::initialize(const goto_functionst &goto_functions) { baset::initialize(goto_functions); @@ -350,36 +233,12 @@ void invariant_propagationt::initialize(const goto_functionst &goto_functions) initialize(f_it->second.body); } -/*******************************************************************\ - -Function: invariant_propagationt::simplify - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void invariant_propagationt::simplify(goto_functionst &goto_functions) { Forall_goto_functions(it, goto_functions) simplify(it->second.body); } -/*******************************************************************\ - -Function: invariant_propagationt::simplify - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void invariant_propagationt::simplify(goto_programt &goto_program) { Forall_goto_program_instructions(i_it, goto_program) diff --git a/src/analyses/invariant_propagation.h b/src/analyses/invariant_propagation.h index 0884ba85d07..d21f6373bcb 100644 --- a/src/analyses/invariant_propagation.h +++ b/src/analyses/invariant_propagation.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Invariant Propagation + #ifndef CPROVER_ANALYSES_INVARIANT_PROPAGATION_H #define CPROVER_ANALYSES_INVARIANT_PROPAGATION_H diff --git a/src/analyses/invariant_set.cpp b/src/analyses/invariant_set.cpp index 15c350f0e0f..425842a86f9 100644 --- a/src/analyses/invariant_set.cpp +++ b/src/analyses/invariant_set.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Invariant Set + #include #include @@ -16,41 +19,17 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -#include +#include #include #include "invariant_set.h" -/*******************************************************************\ - -Function: inv_object_storet::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void inv_object_storet::output(std::ostream &out) const { for(unsigned i=0; iget(expr, n); } -/*******************************************************************\ - -Function: inv_object_storet::is_constant_address - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool inv_object_storet::is_constant_address(const exprt &expr) { if(expr.id()==ID_address_of) @@ -250,18 +157,6 @@ bool inv_object_storet::is_constant_address(const exprt &expr) return false; } -/*******************************************************************\ - -Function: inv_object_storet::is_constant_address_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool inv_object_storet::is_constant_address_rec(const exprt &expr) { if(expr.id()==ID_symbol) @@ -281,18 +176,6 @@ bool inv_object_storet::is_constant_address_rec(const exprt &expr) return false; } -/*******************************************************************\ - -Function: invariant_sett::add - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void invariant_sett::add( const std::pair &p, ineq_sett &dest) @@ -315,18 +198,6 @@ void invariant_sett::add( } } -/*******************************************************************\ - -Function: invariant_sett::add_eq - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void invariant_sett::add_eq(const std::pair &p) { eq_set.make_union(p.first, p.second); @@ -364,18 +235,6 @@ void invariant_sett::add_eq(const std::pair &p) add_eq(ne_set, p, ne); } -/*******************************************************************\ - -Function: invariant_sett::add_eq - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void invariant_sett::add_eq( ineq_sett &dest, const std::pair &eq, @@ -414,18 +273,6 @@ void invariant_sett::add_eq( } } -/*******************************************************************\ - -Function: invariant_sett::is_eq - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - tvt invariant_sett::is_eq(std::pair p) const { std::pair s=p; @@ -440,18 +287,6 @@ tvt invariant_sett::is_eq(std::pair p) const return tvt::unknown(); } -/*******************************************************************\ - -Function: invariant_sett::is_le - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - tvt invariant_sett::is_le(std::pair p) const { std::pair s=p; @@ -470,25 +305,13 @@ tvt invariant_sett::is_le(std::pair p) const return tvt::unknown(); } -/*******************************************************************\ - -Function: invariant_sett::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void invariant_sett::output( const irep_idt &identifier, std::ostream &out) const { if(is_false) { - out << "FALSE" << std::endl; + out << "FALSE\n"; return; } @@ -510,43 +333,31 @@ void invariant_sett::output( out << to_string(j, identifier); } - out << std::endl; + out << '\n'; } for(const auto &bounds : bounds_map) { out << to_string(bounds.first, identifier) << " in " << bounds.second - << std::endl; + << '\n'; } for(const auto &le : le_set) { out << to_string(le.first, identifier) << " <= " << to_string(le.second, identifier) - << std::endl; + << '\n'; } for(const auto &ne : ne_set) { out << to_string(ne.first, identifier) << " != " << to_string(ne.second, identifier) - << std::endl; + << '\n'; } } -/*******************************************************************\ - -Function: invariant_sett::strengthen - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void invariant_sett::add_type_bounds(const exprt &expr, const typet &type) { if(expr.type()==type) @@ -567,18 +378,6 @@ void invariant_sett::add_type_bounds(const exprt &expr, const typet &type) } } -/*******************************************************************\ - -Function: invariant_sett::strengthen - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void invariant_sett::strengthen(const exprt &expr) { exprt tmp(expr); @@ -586,25 +385,13 @@ void invariant_sett::strengthen(const exprt &expr) strengthen_rec(tmp); } -/*******************************************************************\ - -Function: invariant_sett::strengthen_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void invariant_sett::strengthen_rec(const exprt &expr) { if(expr.type().id()!=ID_bool) throw "non-Boolean argument to strengthen()"; #if 0 - std::cout << "S: " << from_expr(*ns, "", expr) << std::endl; + std::cout << "S: " << from_expr(*ns, "", expr) << '\n'; #endif if(is_false) @@ -799,18 +586,6 @@ void invariant_sett::strengthen_rec(const exprt &expr) } } -/*******************************************************************\ - -Function: invariant_sett::implies - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - tvt invariant_sett::implies(const exprt &expr) const { exprt tmp(expr); @@ -818,25 +593,13 @@ tvt invariant_sett::implies(const exprt &expr) const return implies_rec(tmp); } -/*******************************************************************\ - -Function: invariant_sett::implies - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - tvt invariant_sett::implies_rec(const exprt &expr) const { if(expr.type().id()!=ID_bool) throw "implies: non-Boolean expression"; #if 0 - std::cout << "I: " << from_expr(*ns, "", expr) << std::endl; + std::cout << "I: " << from_expr(*ns, "", expr) << '\n'; #endif if(is_false) // can't get any stronger @@ -914,18 +677,6 @@ tvt invariant_sett::implies_rec(const exprt &expr) const return tvt::unknown(); } -/*******************************************************************\ - -Function: invariant_sett::get_bounds - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void invariant_sett::get_bounds(unsigned a, boundst &bounds) const { // unbounded @@ -950,18 +701,6 @@ void invariant_sett::get_bounds(unsigned a, boundst &bounds) const bounds=it->second; } -/*******************************************************************\ - -Function: invariant_sett::nnf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void invariant_sett::nnf(exprt &expr, bool negate) { if(expr.type().id()!=ID_bool) @@ -1075,18 +814,6 @@ void invariant_sett::nnf(exprt &expr, bool negate) } } -/*******************************************************************\ - -Function: invariant_sett::simplify - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void invariant_sett::simplify( exprt &expr) const { @@ -1105,18 +832,6 @@ void invariant_sett::simplify( } } -/*******************************************************************\ - -Function: invariant_sett::get_constant - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt invariant_sett::get_constant(const exprt &expr) const { unsigned a; @@ -1172,18 +887,6 @@ exprt invariant_sett::get_constant(const exprt &expr) const return static_cast(get_nil_irep()); } -/*******************************************************************\ - -Function: inv_object_storet::to_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string inv_object_storet::to_string( unsigned a, const irep_idt &identifier) const @@ -1192,18 +895,6 @@ std::string inv_object_storet::to_string( return id2string(map[a]); } -/*******************************************************************\ - -Function: invariant_sett::to_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string invariant_sett::to_string( unsigned a, const irep_idt &identifier) const @@ -1212,18 +903,6 @@ std::string invariant_sett::to_string( return object_store->to_string(a, identifier); } -/*******************************************************************\ - -Function: invariant_sett::make_union - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool invariant_sett::make_union(const invariant_sett &other) { if(other.threaded && @@ -1275,18 +954,6 @@ bool invariant_sett::make_union(const invariant_sett &other) return false; // no change } -/*******************************************************************\ - -Function: invariant_sett::make_union_bounds_map - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool invariant_sett::make_union_bounds_map(const bounds_mapt &other) { bool changed=false; @@ -1319,18 +986,6 @@ bool invariant_sett::make_union_bounds_map(const bounds_mapt &other) return changed; } -/*******************************************************************\ - -Function: invariant_sett::modifies - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void invariant_sett::modifies(unsigned a) { eq_set.isolate(a); @@ -1339,18 +994,6 @@ void invariant_sett::modifies(unsigned a) bounds_map.erase(a); } -/*******************************************************************\ - -Function: invariant_sett::modifies - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void invariant_sett::modifies(const exprt &lhs) { if(lhs.id()==ID_symbol || @@ -1411,18 +1054,6 @@ void invariant_sett::modifies(const exprt &lhs) throw "modifies: unexpected lhs: "+lhs.id_string(); } -/*******************************************************************\ - -Function: invariant_sett::assignment - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void invariant_sett::assignment( const exprt &lhs, const exprt &rhs) @@ -1442,18 +1073,6 @@ void invariant_sett::assignment( strengthen(equality); } -/*******************************************************************\ - -Function: invariant_sett::apply_code - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void invariant_sett::apply_code(const codet &code) { const irep_idt &statement=code.get(ID_statement); @@ -1508,7 +1127,7 @@ void invariant_sett::apply_code(const codet &code) } else { - std::cerr << code.pretty() << std::endl; + std::cerr << code.pretty() << '\n'; throw "invariant_sett: unexpected statement: "+id2string(statement); } } diff --git a/src/analyses/invariant_set.h b/src/analyses/invariant_set.h index d5f0a31003c..6def40f54a8 100644 --- a/src/analyses/invariant_set.h +++ b/src/analyses/invariant_set.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Value Set + #ifndef CPROVER_ANALYSES_INVARIANT_SET_H #define CPROVER_ANALYSES_INVARIANT_SET_H diff --git a/src/analyses/invariant_set_domain.cpp b/src/analyses/invariant_set_domain.cpp index 5f8512c55b5..6dec2f9ff70 100644 --- a/src/analyses/invariant_set_domain.cpp +++ b/src/analyses/invariant_set_domain.cpp @@ -6,22 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Invariant Set Domain + #include #include "invariant_set_domain.h" -/*******************************************************************\ - -Function: invariant_set_domaint::transform - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void invariant_set_domaint::transform( locationt from_l, locationt to_l, diff --git a/src/analyses/invariant_set_domain.h b/src/analyses/invariant_set_domain.h index 2e231524cbb..4d38b6b2657 100644 --- a/src/analyses/invariant_set_domain.h +++ b/src/analyses/invariant_set_domain.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Value Set + #ifndef CPROVER_ANALYSES_INVARIANT_SET_DOMAIN_H #define CPROVER_ANALYSES_INVARIANT_SET_DOMAIN_H diff --git a/src/analyses/is_threaded.cpp b/src/analyses/is_threaded.cpp index 905cd6b91ac..64b1e48f959 100644 --- a/src/analyses/is_threaded.cpp +++ b/src/analyses/is_threaded.cpp @@ -8,6 +8,9 @@ Date: October 2012 \*******************************************************************/ +/// \file +/// Over-approximate Concurrency for Threaded Goto Programs + #include "ai.h" #include "is_threaded.h" @@ -78,18 +81,6 @@ class is_threaded_domaint:public ai_domain_baset } }; -/*******************************************************************\ - -Function: is_threadedt::compute - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void is_threadedt::compute(const goto_functionst &goto_functions) { // the analysis doesn't actually use the namespace, fake one diff --git a/src/analyses/is_threaded.h b/src/analyses/is_threaded.h index 738857b8b8a..5a3823b867e 100644 --- a/src/analyses/is_threaded.h +++ b/src/analyses/is_threaded.h @@ -8,6 +8,9 @@ Date: October 2012 \*******************************************************************/ +/// \file +/// Over-approximate Concurrency for Threaded Goto Programs + #ifndef CPROVER_ANALYSES_IS_THREADED_H #define CPROVER_ANALYSES_IS_THREADED_H diff --git a/src/analyses/local_bitvector_analysis.cpp b/src/analyses/local_bitvector_analysis.cpp index 3fc0d10bb09..219d446eea2 100644 --- a/src/analyses/local_bitvector_analysis.cpp +++ b/src/analyses/local_bitvector_analysis.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Field-insensitive, location-sensitive may-alias analysis + #include #include @@ -13,23 +16,11 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -#include +#include #include #include "local_bitvector_analysis.h" -/*******************************************************************\ - -Function: local_bitvector_analysist::flagst::print - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void local_bitvector_analysist::flagst::print(std::ostream &out) const { if(is_unknown()) @@ -50,18 +41,6 @@ void local_bitvector_analysist::flagst::print(std::ostream &out) const out << "+integer_address"; } -/*******************************************************************\ - -Function: local_bitvector_analysist::loc_infot::merge - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool local_bitvector_analysist::loc_infot::merge(const loc_infot &src) { bool result=false; @@ -78,19 +57,7 @@ bool local_bitvector_analysist::loc_infot::merge(const loc_infot &src) return result; } -/*******************************************************************\ - -Function: local_bitvector_analysist::is_tracked - - Inputs: - - Outputs: return 'true' iff we track the object with given - identifier - - Purpose: - -\*******************************************************************/ - +/// \return return 'true' iff we track the object with given identifier bool local_bitvector_analysist::is_tracked(const irep_idt &identifier) { localst::locals_mapt::const_iterator it=locals.locals_map.find(identifier); @@ -102,18 +69,6 @@ bool local_bitvector_analysist::is_tracked(const irep_idt &identifier) return true; } -/*******************************************************************\ - -Function: local_bitvector_analysist::assign_lhs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void local_bitvector_analysist::assign_lhs( const exprt &lhs, const exprt &rhs, @@ -154,18 +109,6 @@ void local_bitvector_analysist::assign_lhs( } } -/*******************************************************************\ - -Function: local_bitvector_analysist::get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - local_bitvector_analysist::flagst local_bitvector_analysist::get( const goto_programt::const_targett t, const exprt &rhs) @@ -179,18 +122,6 @@ local_bitvector_analysist::flagst local_bitvector_analysist::get( return get_rec(rhs, loc_info_src); } -/*******************************************************************\ - -Function: local_bitvector_analysist::get_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - local_bitvector_analysist::flagst local_bitvector_analysist::get_rec( const exprt &rhs, const loc_infot &loc_info_src) @@ -312,18 +243,6 @@ local_bitvector_analysist::flagst local_bitvector_analysist::get_rec( return flagst::mk_unknown(); } -/*******************************************************************\ - -Function: local_bitvector_analysist::build - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void local_bitvector_analysist::build(const goto_functiont &goto_function) { if(cfg.nodes.empty()) @@ -400,24 +319,13 @@ void local_bitvector_analysist::build(const goto_functiont &goto_function) for(const auto &succ : node.successors) { + assert(succ #include @@ -14,25 +17,13 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -#include +#include #include #endif #include "local_cfg.h" -/*******************************************************************\ - -Function: local_cfgt::build - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void local_cfgt::build(const goto_programt &goto_program) { nodes.resize(goto_program.instructions.size()); diff --git a/src/analyses/local_cfg.h b/src/analyses/local_cfg.h index a0187be8177..d2e53cfdab0 100644 --- a/src/analyses/local_cfg.h +++ b/src/analyses/local_cfg.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// CFG for One Function + #ifndef CPROVER_ANALYSES_LOCAL_CFG_H #define CPROVER_ANALYSES_LOCAL_CFG_H @@ -13,14 +16,6 @@ Author: Daniel Kroening, kroening@kroening.com #include -/*******************************************************************\ - - Class: local_cfgt - - Purpose: - -\*******************************************************************/ - class local_cfgt { public: diff --git a/src/analyses/local_may_alias.cpp b/src/analyses/local_may_alias.cpp index ffaefe73667..02a5c698186 100644 --- a/src/analyses/local_may_alias.cpp +++ b/src/analyses/local_may_alias.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Field-insensitive, location-sensitive may-alias analysis + #include #include @@ -13,23 +16,12 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -#include +#include #include #include "local_may_alias.h" -/*******************************************************************\ - -Function: local_may_aliast::loc_infot::merge - - Inputs: - - Outputs: return 'true' iff changed - - Purpose: - -\*******************************************************************/ - +/// \return return 'true' iff changed bool local_may_aliast::loc_infot::merge(const loc_infot &src) { bool changed=false; @@ -49,18 +41,6 @@ bool local_may_aliast::loc_infot::merge(const loc_infot &src) return changed; } -/*******************************************************************\ - -Function: local_may_aliast::assign_lhs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void local_may_aliast::assign_lhs( const exprt &lhs, const exprt &rhs, @@ -132,18 +112,6 @@ void local_may_aliast::assign_lhs( } } -/*******************************************************************\ - -Function: local_may_aliast::get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::set local_may_aliast::get( const goto_programt::const_targett t, const exprt &rhs) const @@ -170,18 +138,6 @@ std::set local_may_aliast::get( return result; } -/*******************************************************************\ - -Function: local_may_aliast::aliases - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool local_may_aliast::aliases( const goto_programt::const_targett t, const exprt &src1, const exprt &src2) const @@ -210,18 +166,6 @@ bool local_may_aliast::aliases( return !result.empty(); } -/*******************************************************************\ - -Function: local_may_aliast::get_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void local_may_aliast::get_rec( object_sett &dest, const exprt &rhs, @@ -369,18 +313,6 @@ void local_may_aliast::get_rec( dest.insert(unknown_object); } -/*******************************************************************\ - -Function: local_may_aliast::build - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void local_may_aliast::build(const goto_functiont &goto_function) { if(cfg.nodes.empty()) @@ -502,18 +434,6 @@ void local_may_aliast::build(const goto_functiont &goto_function) } } -/*******************************************************************\ - -Function: local_may_aliast::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void local_may_aliast::output( std::ostream &out, const goto_functiont &goto_function, diff --git a/src/analyses/local_may_alias.h b/src/analyses/local_may_alias.h index 109ca2b5e19..b54cf4e9e88 100644 --- a/src/analyses/local_may_alias.h +++ b/src/analyses/local_may_alias.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Field-insensitive, location-sensitive may-alias analysis + #ifndef CPROVER_ANALYSES_LOCAL_MAY_ALIAS_H #define CPROVER_ANALYSES_LOCAL_MAY_ALIAS_H @@ -18,14 +21,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "dirty.h" #include "local_cfg.h" -/*******************************************************************\ - - Class: local_may_aliast - - Purpose: - -\*******************************************************************/ - class local_may_aliast { public: diff --git a/src/analyses/locals.cpp b/src/analyses/locals.cpp index 7f30c1c008b..09d7ebfe7c3 100644 --- a/src/analyses/locals.cpp +++ b/src/analyses/locals.cpp @@ -8,22 +8,13 @@ Date: March 2013 \*******************************************************************/ +/// \file +/// Local variables + #include #include "locals.h" -/*******************************************************************\ - -Function: localst::build - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void localst::build(const goto_functiont &goto_function) { forall_goto_program_instructions(it, goto_function.body) @@ -39,18 +30,6 @@ void localst::build(const goto_functiont &goto_function) symbol_exprt(param.get_identifier(), param.type()); } -/*******************************************************************\ - -Function: localst::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void localst::output(std::ostream &out) const { for(const auto &local : locals_map) diff --git a/src/analyses/locals.h b/src/analyses/locals.h index 3cd52254c41..c9c59aaf340 100644 --- a/src/analyses/locals.h +++ b/src/analyses/locals.h @@ -8,6 +8,9 @@ Date: March 2013 \*******************************************************************/ +/// \file +/// Local variables whose address is taken + #ifndef CPROVER_ANALYSES_LOCALS_H #define CPROVER_ANALYSES_LOCALS_H diff --git a/src/analyses/natural_loops.cpp b/src/analyses/natural_loops.cpp index 593fc78006d..57e835d7efe 100644 --- a/src/analyses/natural_loops.cpp +++ b/src/analyses/natural_loops.cpp @@ -6,32 +6,23 @@ Author: Georg Weissenbacher, georg@weissenbacher.name \*******************************************************************/ +/// \file +/// Dominators + #include #include "natural_loops.h" -/*******************************************************************\ - -Function: show_natural_loops - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void show_natural_loops(const goto_functionst &goto_functions) { forall_goto_functions(it, goto_functions) { - std::cout << "*** " << it->first << std::endl; + std::cout << "*** " << it->first << '\n'; natural_loopst natural_loops; natural_loops(it->second.body); natural_loops.output(std::cout); - std::cout << std::endl; + std::cout << '\n'; } } diff --git a/src/analyses/natural_loops.h b/src/analyses/natural_loops.h index ff56c687c93..ce27a306882 100644 --- a/src/analyses/natural_loops.h +++ b/src/analyses/natural_loops.h @@ -6,6 +6,9 @@ Author: Georg Weissenbacher, georg@weissenbacher.name \*******************************************************************/ +/// \file +/// Compute natural loops in a goto_function + #ifndef CPROVER_ANALYSES_NATURAL_LOOPS_H #define CPROVER_ANALYSES_NATURAL_LOOPS_H @@ -69,18 +72,7 @@ typedef natural_loops_templatet void show_natural_loops(const goto_functionst &goto_functions); -/*******************************************************************\ - -Function: natural_loops_templatet::compute - - Inputs: - - Outputs: - - Purpose: Finds all back-edges and computes the natural loops - -\*******************************************************************/ - +/// Finds all back-edges and computes the natural loops #ifdef DEBUG #include #endif @@ -123,19 +115,7 @@ void natural_loops_templatet::compute(P &program) } } -/*******************************************************************\ - -Function: natural_loops_templatet::compute_natural_loop - - Inputs: - - Outputs: - - Purpose: Computes the natural loop for a given back-edge - (see Muchnick section 7.4) - -\*******************************************************************/ - +/// Computes the natural loop for a given back-edge (see Muchnick section 7.4) template void natural_loops_templatet::compute_natural_loop(T m, T n) { @@ -170,18 +150,7 @@ void natural_loops_templatet::compute_natural_loop(T m, T n) } } -/*******************************************************************\ - -Function: natural_loops_templatet::output - - Inputs: - - Outputs: - - Purpose: Print all natural loops that were found - -\*******************************************************************/ - +/// Print all natural loops that were found template void natural_loops_templatet::output(std::ostream &out) const { diff --git a/src/analyses/reaching_definitions.cpp b/src/analyses/reaching_definitions.cpp index 81c3c1c5069..70ea10b79ca 100644 --- a/src/analyses/reaching_definitions.cpp +++ b/src/analyses/reaching_definitions.cpp @@ -9,6 +9,10 @@ Date: February 2013 \*******************************************************************/ +/// \file +/// Range-based reaching definitions analysis (following Field- Sensitive +/// Program Dependence Analysis, Litvak et al., FSE 2010) + #include #include @@ -19,18 +23,6 @@ Date: February 2013 #include "reaching_definitions.h" -/*******************************************************************\ - -Function: rd_range_domaint::populate_cache - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rd_range_domaint::populate_cache(const irep_idt &identifier) const { assert(bv_container); @@ -51,18 +43,6 @@ void rd_range_domaint::populate_cache(const irep_idt &identifier) const } } -/*******************************************************************\ - -Function: rd_range_domaint::transform - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rd_range_domaint::transform( locationt from, locationt to, @@ -129,18 +109,6 @@ void rd_range_domaint::transform( #endif } -/*******************************************************************\ - -Function: rd_range_domaint::transform_dead - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rd_range_domaint::transform_dead( const namespacet &ns, locationt from) @@ -157,18 +125,6 @@ void rd_range_domaint::transform_dead( } } -/*******************************************************************\ - -Function: rd_range_domaint::transform_start_thread - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rd_range_domaint::transform_start_thread( const namespacet &ns, reaching_definitions_analysist &rd) @@ -194,18 +150,6 @@ void rd_range_domaint::transform_start_thread( } } -/*******************************************************************\ - -Function: rd_range_domaint::transform_function_call - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rd_range_domaint::transform_function_call( const namespacet &ns, locationt from, @@ -269,18 +213,6 @@ void rd_range_domaint::transform_function_call( } } -/*******************************************************************\ - -Function: rd_range_domaint::transform_end_function - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rd_range_domaint::transform_end_function( const namespacet &ns, locationt from, @@ -349,18 +281,6 @@ void rd_range_domaint::transform_end_function( } } -/*******************************************************************\ - -Function: rd_range_domaint::transform_assign - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rd_range_domaint::transform_assign( const namespacet &ns, locationt from, @@ -394,18 +314,6 @@ void rd_range_domaint::transform_assign( } } -/*******************************************************************\ - -Function: rd_range_domaint::kill - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rd_range_domaint::kill( const irep_idt &identifier, const range_spect &range_start, @@ -506,18 +414,6 @@ void rd_range_domaint::kill( } } -/*******************************************************************\ - -Function: rd_range_domaint::kill_inf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rd_range_domaint::kill_inf( const irep_idt &identifier, const range_spect &range_start) @@ -552,18 +448,6 @@ void rd_range_domaint::kill_inf( #endif } -/*******************************************************************\ - -Function: rd_range_domaint::gen - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool rd_range_domaint::gen( locationt from, const irep_idt &identifier, @@ -636,21 +520,9 @@ bool rd_range_domaint::gen( return true; } -/*******************************************************************\ - -Function: rd_range_domaint::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rd_range_domaint::output(std::ostream &out) const { - out << "Reaching definitions:" << std::endl; + out << "Reaching definitions:\n"; if(has_values.is_known()) { @@ -681,24 +553,13 @@ void rd_range_domaint::output(std::ostream &out) const out << "@" << itl->first->location_number; } - out << "]" << std::endl; + out << "]\n"; clear_cache(identifier); } } -/*******************************************************************\ - -Function: rd_range_domaint::merge_inner - - Inputs: - - Outputs: returns true iff there is s.th. new - - Purpose: - -\*******************************************************************/ - +/// \return returns true iff there is s.th. new bool rd_range_domaint::merge_inner( values_innert &dest, const values_innert &other) @@ -749,18 +610,7 @@ bool rd_range_domaint::merge_inner( return more; } -/*******************************************************************\ - -Function: rd_range_domaint::merge - - Inputs: - - Outputs: returns true iff there is s.th. new - - Purpose: - -\*******************************************************************/ - +/// \return returns true iff there is s.th. new bool rd_range_domaint::merge( const rd_range_domaint &other, locationt from, @@ -796,18 +646,7 @@ bool rd_range_domaint::merge( return changed; } -/*******************************************************************\ - -Function: rd_range_domaint::merge_shared - - Inputs: - - Outputs: returns true iff there is s.th. new - - Purpose: - -\*******************************************************************/ - +/// \return returns true iff there is s.th. new bool rd_range_domaint::merge_shared( const rd_range_domaint &other, goto_programt::const_targett from, @@ -857,18 +696,6 @@ bool rd_range_domaint::merge_shared( return changed; } -/*******************************************************************\ - -Function: rd_range_domaint::get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const rd_range_domaint::ranges_at_loct &rd_range_domaint::get( const irep_idt &identifier) const { @@ -884,18 +711,6 @@ const rd_range_domaint::ranges_at_loct &rd_range_domaint::get( return entry->second; } -/*******************************************************************\ - -Function: reaching_definitions_analysist::~reaching_definitions_analysist - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - reaching_definitions_analysist::~reaching_definitions_analysist() { if(is_dirty) @@ -906,18 +721,6 @@ reaching_definitions_analysist::~reaching_definitions_analysist() delete value_sets; } -/*******************************************************************\ - -Function: reaching_definitions_analysist::initialize - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void reaching_definitions_analysist::initialize( const goto_functionst &goto_functions) { diff --git a/src/analyses/reaching_definitions.h b/src/analyses/reaching_definitions.h index a48a271a9a6..2cc7d815fa3 100644 --- a/src/analyses/reaching_definitions.h +++ b/src/analyses/reaching_definitions.h @@ -9,6 +9,10 @@ Date: February 2013 \*******************************************************************/ +/// \file +/// Range-based reaching definitions analysis (following Field- Sensitive +/// Program Dependence Analysis, Litvak et al., FSE 2010) + #ifndef CPROVER_ANALYSES_REACHING_DEFINITIONS_H #define CPROVER_ANALYSES_REACHING_DEFINITIONS_H diff --git a/src/analyses/replace_symbol_ext.cpp b/src/analyses/replace_symbol_ext.cpp index 568ea45e090..75c697030b7 100644 --- a/src/analyses/replace_symbol_ext.cpp +++ b/src/analyses/replace_symbol_ext.cpp @@ -6,23 +6,15 @@ Author: Peter Schrammel \*******************************************************************/ +/// \file +/// Modified expression replacement for constant propagator + #include #include #include "replace_symbol_ext.h" -/*******************************************************************\ - -Function: replace_symbol_extt::replace - - Inputs: - - Outputs: - - Purpose: does not replace object in address_of expressions - -\*******************************************************************/ - +/// does not replace object in address_of expressions bool replace_symbol_extt::replace(exprt &dest) const { bool result=true; diff --git a/src/analyses/replace_symbol_ext.h b/src/analyses/replace_symbol_ext.h index 5a2152db17f..05d7226be40 100644 --- a/src/analyses/replace_symbol_ext.h +++ b/src/analyses/replace_symbol_ext.h @@ -6,6 +6,9 @@ Author: Peter Schrammel \*******************************************************************/ +/// \file +/// Modified expression replacement for constant propagator + #ifndef CPROVER_ANALYSES_REPLACE_SYMBOL_EXT_H #define CPROVER_ANALYSES_REPLACE_SYMBOL_EXT_H diff --git a/src/analyses/static_analysis.cpp b/src/analyses/static_analysis.cpp index 8309566f27d..dd6b8ac0f54 100644 --- a/src/analyses/static_analysis.cpp +++ b/src/analyses/static_analysis.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Value Set Propagation + #include #include @@ -17,18 +20,6 @@ Author: Daniel Kroening, kroening@kroening.com #define USE_DEPRECATED_STATIC_ANALYSIS_H #include "static_analysis.h" -/*******************************************************************\ - -Function: static_analysis_baset::get_guard - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt static_analysis_baset::get_guard( locationt from, locationt to) @@ -49,18 +40,6 @@ exprt static_analysis_baset::get_guard( return from->guard; } -/*******************************************************************\ - -Function: static_analysis_baset::get_return_lhs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt static_analysis_baset::get_return_lhs(locationt to) { // get predecessor of "to" @@ -79,18 +58,6 @@ exprt static_analysis_baset::get_return_lhs(locationt to) return code.lhs(); } -/*******************************************************************\ - -Function: static_analysis_baset::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void static_analysis_baset::operator()( const goto_functionst &goto_functions) { @@ -98,18 +65,6 @@ void static_analysis_baset::operator()( fixedpoint(goto_functions); } -/*******************************************************************\ - -Function: static_analysis_baset::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void static_analysis_baset::operator()( const goto_programt &goto_program) { @@ -118,18 +73,6 @@ void static_analysis_baset::operator()( fixedpoint(goto_program, goto_functions); } -/*******************************************************************\ - -Function: static_analysis_baset::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void static_analysis_baset::output( const goto_functionst &goto_functions, std::ostream &out) const @@ -148,18 +91,6 @@ void static_analysis_baset::output( } } -/*******************************************************************\ - -Function: static_analysis_baset::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void static_analysis_baset::output( const goto_programt &goto_program, const irep_idt &identifier, @@ -179,18 +110,6 @@ void static_analysis_baset::output( } } -/*******************************************************************\ - -Function: static_analysis_baset::generate_states - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void static_analysis_baset::generate_states( const goto_functionst &goto_functions) { @@ -198,18 +117,6 @@ void static_analysis_baset::generate_states( generate_states(f_it->second.body); } -/*******************************************************************\ - -Function: static_analysis_baset::generate_states - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void static_analysis_baset::generate_states( const goto_programt &goto_program) { @@ -217,18 +124,6 @@ void static_analysis_baset::generate_states( generate_state(i_it); } -/*******************************************************************\ - -Function: static_analysis_baset::update - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void static_analysis_baset::update( const goto_functionst &goto_functions) { @@ -236,18 +131,6 @@ void static_analysis_baset::update( update(f_it->second.body); } -/*******************************************************************\ - -Function: static_analysis_baset::generate_states - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void static_analysis_baset::update( const goto_programt &goto_program) { @@ -270,18 +153,6 @@ void static_analysis_baset::update( } } -/*******************************************************************\ - -Function: static_analysis_baset::get_next - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static_analysis_baset::locationt static_analysis_baset::get_next( working_sett &working_set) { @@ -294,18 +165,6 @@ static_analysis_baset::locationt static_analysis_baset::get_next( return l; } -/*******************************************************************\ - -Function: static_analysis_baset::fixedpoint - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool static_analysis_baset::fixedpoint( const goto_programt &goto_program, const goto_functionst &goto_functions) @@ -332,18 +191,6 @@ bool static_analysis_baset::fixedpoint( return new_data; } -/*******************************************************************\ - -Function: static_analysis_baset::visit - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool static_analysis_baset::visit( locationt l, working_sett &working_set, @@ -397,18 +244,6 @@ bool static_analysis_baset::visit( return new_data; } -/*******************************************************************\ - -Function: static_analysis_baset::do_function_call - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void static_analysis_baset::do_function_call( locationt l_call, locationt l_return, const goto_functionst &goto_functions, @@ -480,18 +315,6 @@ void static_analysis_baset::do_function_call( } } -/*******************************************************************\ - -Function: static_analysis_baset::do_function_call_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void static_analysis_baset::do_function_call_rec( locationt l_call, locationt l_return, const exprt &function, @@ -594,18 +417,6 @@ void static_analysis_baset::do_function_call_rec( } } -/*******************************************************************\ - -Function: static_analysis_baset::sequential_fixedpoint - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void static_analysis_baset::sequential_fixedpoint( const goto_functionst &goto_functions) { @@ -616,18 +427,6 @@ void static_analysis_baset::sequential_fixedpoint( fixedpoint(it->second.body, goto_functions); } -/*******************************************************************\ - -Function: static_analysis_baset::concurrent_fixedpoint - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void static_analysis_baset::concurrent_fixedpoint( const goto_functionst &goto_functions) { diff --git a/src/analyses/static_analysis.h b/src/analyses/static_analysis.h index 2a390fb7e61..17d8dced473 100644 --- a/src/analyses/static_analysis.h +++ b/src/analyses/static_analysis.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Static Analysis + #ifndef CPROVER_ANALYSES_STATIC_ANALYSIS_H #define CPROVER_ANALYSES_STATIC_ANALYSIS_H diff --git a/src/analyses/uncaught_exceptions_analysis.cpp b/src/analyses/uncaught_exceptions_analysis.cpp index 814fcaf3730..dfc012238ab 100644 --- a/src/analyses/uncaught_exceptions_analysis.cpp +++ b/src/analyses/uncaught_exceptions_analysis.cpp @@ -6,23 +6,15 @@ Author: Cristina David \*******************************************************************/ +/// \file +/// Over-approximating uncaught exceptions analysis + #ifdef DEBUG #include #endif #include "uncaught_exceptions_analysis.h" -/*******************************************************************\ - -Function: get_exception_type - - Inputs: - - Outputs: - - Purpose: Returns the compile type of an exception - -\*******************************************************************/ - +/// Returns the compile type of an exception irep_idt uncaught_exceptions_domaint::get_exception_type(const typet &type) { assert(type.id()==ID_pointer); @@ -34,18 +26,7 @@ irep_idt uncaught_exceptions_domaint::get_exception_type(const typet &type) return ID_empty; } -/*******************************************************************\ - -Function: get_exception_symbol - - Inputs: - - Outputs: - - Purpose: Returns the symbol corresponding to an exception - -\*******************************************************************/ - +/// Returns the symbol corresponding to an exception exprt uncaught_exceptions_domaint::get_exception_symbol(const exprt &expr) { if(expr.id()!=ID_symbol && expr.has_operands()) @@ -54,18 +35,7 @@ exprt uncaught_exceptions_domaint::get_exception_symbol(const exprt &expr) return expr; } -/*******************************************************************\ - -Function: uncaught_exceptions_domaint::join - - Inputs: - - Outputs: - - Purpose: The join operator for the uncaught exceptions domain - -\*******************************************************************/ - +/// The join operator for the uncaught exceptions domain void uncaught_exceptions_domaint::join( const irep_idt &element) { @@ -85,18 +55,7 @@ void uncaught_exceptions_domaint::join( } -/*******************************************************************\ - -Function: uncaught_exceptions_domaint::transform - - Inputs: - - Outputs: - - Purpose: The transformer for the uncaught exceptions domain - -\*******************************************************************/ - +/// The transformer for the uncaught exceptions domain void uncaught_exceptions_domaint::transform( const goto_programt::const_targett from, uncaught_exceptions_analysist &uea, @@ -175,54 +134,20 @@ void uncaught_exceptions_domaint::transform( } } -/*******************************************************************\ - -Function: uncaught_exceptions_domaint::get_elements - - Inputs: - - Outputs: - - Purpose: Returns the value of the private member thrown - -\*******************************************************************/ - +/// Returns the value of the private member thrown const std::set &uncaught_exceptions_domaint::get_elements() const { return thrown; } -/*******************************************************************\ - -Function: uncaught_exceptions_domaint::operator() - - Inputs: - - Outputs: - - Purpose: Constructs the class hierarchy - -\*******************************************************************/ - +/// Constructs the class hierarchy void uncaught_exceptions_domaint::operator()( const namespacet &ns) { class_hierarchy(ns.get_symbol_table()); } -/*******************************************************************\ - -Function: uncaught_exceptions_analysist::collect_uncaught_exceptions - - Inputs: - - Outputs: - - Purpose: Runs the uncaught exceptions analysis, which - populates the exceptions map - -\*******************************************************************/ - +/// Runs the uncaught exceptions analysis, which populates the exceptions map void uncaught_exceptions_analysist::collect_uncaught_exceptions( const goto_functionst &goto_functions, const namespacet &ns) @@ -256,19 +181,8 @@ void uncaught_exceptions_analysist::collect_uncaught_exceptions( } } -/*******************************************************************\ - -Function: uncaught_exceptions_analysist::output - - Inputs: - - Outputs: - - Purpose: Prints the exceptions map that maps each method to the - set of exceptions that may escape it - -\*******************************************************************/ - +/// Prints the exceptions map that maps each method to the set of exceptions +/// that may escape it void uncaught_exceptions_analysist::output( const goto_functionst &goto_functions) { @@ -288,19 +202,7 @@ void uncaught_exceptions_analysist::output( #endif } -/*******************************************************************\ - -Function: uncaught_exceptions_analysist::operator() - - Inputs: - - Outputs: - - Purpose: Applies the uncaught exceptions analysis and - outputs the result - -\*******************************************************************/ - +/// Applies the uncaught exceptions analysis and outputs the result void uncaught_exceptions_analysist::operator()( const goto_functionst &goto_functions, const namespacet &ns, @@ -312,19 +214,7 @@ void uncaught_exceptions_analysist::operator()( output(goto_functions); } -/*******************************************************************\ - -Function: uncaught_exceptions - - Inputs: - - Outputs: - - Purpose: Applies the uncaught exceptions analysis and - outputs the result - -\*******************************************************************/ - +/// Applies the uncaught exceptions analysis and outputs the result void uncaught_exceptions( const goto_functionst &goto_functions, const namespacet &ns, diff --git a/src/analyses/uncaught_exceptions_analysis.h b/src/analyses/uncaught_exceptions_analysis.h index 50ed75b202c..a53998b4bd2 100644 --- a/src/analyses/uncaught_exceptions_analysis.h +++ b/src/analyses/uncaught_exceptions_analysis.h @@ -6,6 +6,9 @@ Author: Cristina David \*******************************************************************/ +/// \file +/// Over-approximative uncaught exceptions analysis + #ifndef CPROVER_ANALYSES_UNCAUGHT_EXCEPTIONS_ANALYSIS_H #define CPROVER_ANALYSES_UNCAUGHT_EXCEPTIONS_ANALYSIS_H @@ -15,15 +18,7 @@ Author: Cristina David #include #include -/*******************************************************************\ - - Class: uncaught_exceptions_domaint - - Purpose: defines the domain used by the uncaught - exceptions analysis - -\*******************************************************************/ - +/// defines the domain used by the uncaught exceptions analysis class uncaught_exceptions_analysist; class uncaught_exceptions_domaint @@ -58,15 +53,8 @@ class uncaught_exceptions_domaint class_hierarchyt class_hierarchy; }; -/*******************************************************************\ - - Class: uncaught_exceptions_analysist - - Purpose: computes in exceptions_map an overapproximation of the - exceptions thrown by each method - -\*******************************************************************/ - +/// computes in exceptions_map an overapproximation of the exceptions thrown by +/// each method class uncaught_exceptions_analysist { public: diff --git a/src/analyses/uninitialized_domain.cpp b/src/analyses/uninitialized_domain.cpp index 8a6e8dd52a5..60f8c45c1bb 100644 --- a/src/analyses/uninitialized_domain.cpp +++ b/src/analyses/uninitialized_domain.cpp @@ -8,23 +8,14 @@ Date: January 2010 \*******************************************************************/ +/// \file +/// Detection for Uninitialized Local Variables + #include #include #include "uninitialized_domain.h" -/*******************************************************************\ - -Function: uninitialized_domaint::transform - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void uninitialized_domaint::transform( locationt from, locationt to, @@ -60,18 +51,6 @@ void uninitialized_domaint::transform( } } -/*******************************************************************\ - -Function: uninitialized_domaint::assign - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void uninitialized_domaint::assign(const exprt &lhs) { if(lhs.id()==ID_index) @@ -82,18 +61,6 @@ void uninitialized_domaint::assign(const exprt &lhs) uninitialized.erase(to_symbol_expr(lhs).get_identifier()); } -/*******************************************************************\ - -Function: uninitialized_domaint::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void uninitialized_domaint::output( std::ostream &out, const ai_baset &ai, @@ -108,18 +75,7 @@ void uninitialized_domaint::output( } } -/*******************************************************************\ - -Function: uninitialized_domaint::merge - - Inputs: - - Outputs: returns true iff there is s.th. new - - Purpose: - -\*******************************************************************/ - +/// \return returns true iff there is s.th. new bool uninitialized_domaint::merge( const uninitialized_domaint &other, locationt from, diff --git a/src/analyses/uninitialized_domain.h b/src/analyses/uninitialized_domain.h index 6ca27f341b0..a48f9954388 100644 --- a/src/analyses/uninitialized_domain.h +++ b/src/analyses/uninitialized_domain.h @@ -8,6 +8,9 @@ Date: January 2010 \*******************************************************************/ +/// \file +/// Detection for Uninitialized Local Variables + #ifndef CPROVER_ANALYSES_UNINITIALIZED_DOMAIN_H #define CPROVER_ANALYSES_UNINITIALIZED_DOMAIN_H diff --git a/src/ansi-c/Makefile b/src/ansi-c/Makefile index cfee8e68f07..90bdd1e6a56 100644 --- a/src/ansi-c/Makefile +++ b/src/ansi-c/Makefile @@ -24,7 +24,6 @@ SRC = anonymous_member.cpp \ c_typecheck_initializer.cpp \ c_typecheck_type.cpp \ c_typecheck_typecast.cpp \ - c_types.cpp \ cprover_library.cpp \ designator.cpp \ expr2c.cpp \ @@ -55,7 +54,11 @@ CLEANFILES = ansi-c$(LIBEXT) \ arm_builtin_headers.inc cw_builtin_headers.inc \ gcc_builtin_headers_arm.inc gcc_builtin_headers_alpha.inc \ gcc_builtin_headers_mips.inc gcc_builtin_headers_power.inc \ - clang_builtin_headers.inc gcc_builtin_headers_ia32-2.inc + clang_builtin_headers.inc gcc_builtin_headers_ia32-2.inc \ + gcc_builtin_headers_math.inc gcc_builtin_headers_omp.inc \ + gcc_builtin_headers_tm.inc gcc_builtin_headers_ubsan.inc \ + gcc_builtin_headers_mem_string.inc \ + gcc_builtin_headers_ia32-3.inc gcc_builtin_headers_ia32-4.inc all: ansi-c$(LIBEXT) @@ -116,10 +119,17 @@ cprover_library.cpp: cprover_library.inc ansi_c_internal_additions$(OBJEXT): gcc_builtin_headers_generic.inc ansi_c_internal_additions$(OBJEXT): gcc_builtin_headers_ia32.inc ansi_c_internal_additions$(OBJEXT): gcc_builtin_headers_ia32-2.inc +ansi_c_internal_additions$(OBJEXT): gcc_builtin_headers_ia32-3.inc +ansi_c_internal_additions$(OBJEXT): gcc_builtin_headers_ia32-4.inc ansi_c_internal_additions$(OBJEXT): gcc_builtin_headers_alpha.inc ansi_c_internal_additions$(OBJEXT): gcc_builtin_headers_arm.inc +ansi_c_internal_additions$(OBJEXT): gcc_builtin_headers_math.inc +ansi_c_internal_additions$(OBJEXT): gcc_builtin_headers_mem_string.inc ansi_c_internal_additions$(OBJEXT): gcc_builtin_headers_mips.inc +ansi_c_internal_additions$(OBJEXT): gcc_builtin_headers_omp.inc ansi_c_internal_additions$(OBJEXT): gcc_builtin_headers_power.inc +ansi_c_internal_additions$(OBJEXT): gcc_builtin_headers_tm.inc +ansi_c_internal_additions$(OBJEXT): gcc_builtin_headers_ubsan.inc ansi_c_internal_additions$(OBJEXT): arm_builtin_headers.inc ansi_c_internal_additions$(OBJEXT): cw_builtin_headers.inc ansi_c_internal_additions$(OBJEXT): clang_builtin_headers.inc @@ -129,7 +139,11 @@ generated_files: cprover_library.inc gcc_builtin_headers_generic.inc \ gcc_builtin_headers_arm.inc gcc_builtin_headers_mips.inc \ gcc_builtin_headers_power.inc arm_builtin_headers.inc \ cw_builtin_headers.inc ansi_c_y.tab.cpp ansi_c_lex.yy.cpp \ - ansi_c_y.tab.h clang_builtin_headers.inc gcc_builtin_headers_ia32-2.inc + ansi_c_y.tab.h clang_builtin_headers.inc gcc_builtin_headers_ia32-2.inc \ + gcc_builtin_headers_math.inc gcc_builtin_headers_omp.inc \ + gcc_builtin_headers_tm.inc gcc_builtin_headers_ubsan.inc \ + gcc_builtin_headers_mem_string.inc \ + gcc_builtin_headers_ia32-3.inc gcc_builtin_headers_ia32-4.inc ############################################################################### diff --git a/src/ansi-c/anonymous_member.cpp b/src/ansi-c/anonymous_member.cpp index adaff8d4680..197739f5941 100644 --- a/src/ansi-c/anonymous_member.cpp +++ b/src/ansi-c/anonymous_member.cpp @@ -6,23 +6,14 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// ANSI-C Language Type Checking + #include #include #include "anonymous_member.h" -/*******************************************************************\ - -Function: make_member_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static exprt make_member_expr( const exprt &struct_union, const struct_union_typet::componentt &component, @@ -46,18 +37,6 @@ static exprt make_member_expr( return result; } -/*******************************************************************\ - -Function: get_component_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt get_component_rec( const exprt &struct_union, const irep_idt &component_name, @@ -90,18 +69,6 @@ exprt get_component_rec( return nil_exprt(); } -/*******************************************************************\ - -Function: has_component_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool has_component_rec( const typet &type, const irep_idt &component_name, diff --git a/src/ansi-c/anonymous_member.h b/src/ansi-c/anonymous_member.h index d9b00394b6f..3c58ad70efb 100644 --- a/src/ansi-c/anonymous_member.h +++ b/src/ansi-c/anonymous_member.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// C Language Type Checking + #ifndef CPROVER_ANSI_C_ANONYMOUS_MEMBER_H #define CPROVER_ANSI_C_ANONYMOUS_MEMBER_H diff --git a/src/ansi-c/ansi_c_convert_type.cpp b/src/ansi-c/ansi_c_convert_type.cpp index 7dc6f2165cf..7f42f94c8a2 100644 --- a/src/ansi-c/ansi_c_convert_type.cpp +++ b/src/ansi-c/ansi_c_convert_type.cpp @@ -6,8 +6,12 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// SpecC Language Conversion + #include +#include #include #include #include @@ -16,18 +20,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "ansi_c_convert_type.h" -/*******************************************************************\ - -Function: ansi_c_convert_typet::convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ansi_c_convert_typet::read(const typet &type) { clear(); @@ -35,18 +27,6 @@ void ansi_c_convert_typet::read(const typet &type) read_rec(type); } -/*******************************************************************\ - -Function: ansi_c_convert_typet::read_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ansi_c_convert_typet::read_rec(const typet &type) { if(type.id()==ID_merged_type) @@ -240,18 +220,6 @@ void ansi_c_convert_typet::read_rec(const typet &type) other.push_back(type); } -/*******************************************************************\ - -Function: ansi_c_convert_typet::write - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ansi_c_convert_typet::write(typet &type) { type.clear(); @@ -271,6 +239,15 @@ void ansi_c_convert_typet::write(typet &type) throw 0; } + // asm blocks (cf. regression/ansi-c/asm1) - ignore the asm + if(other.size()==2) + { + if(other.front().id()==ID_asm && other.back().id()==ID_empty) + other.pop_front(); + else if(other.front().id()==ID_empty && other.back().id()==ID_asm) + other.pop_back(); + } + if(other.size()!=1) { error().source_location=source_location; @@ -463,14 +440,25 @@ void ansi_c_convert_typet::write(typet &type) } if(int8_cnt) - type=is_signed?signed_char_type():unsigned_char_type(); + if(is_signed) + type=signed_char_type(); + else + type=unsigned_char_type(); else if(int16_cnt) - type=is_signed?signed_short_int_type():unsigned_short_int_type(); + if(is_signed) + type=signed_short_int_type(); + else + type=unsigned_short_int_type(); else if(int32_cnt) - type=is_signed?signed_int_type():unsigned_int_type(); + if(is_signed) + type=signed_int_type(); + else + type=unsigned_int_type(); else if(int64_cnt) // Visual Studio: equivalent to long long int - type= - is_signed?signed_long_long_int_type():unsigned_long_long_int_type(); + if(is_signed) + type=signed_long_long_int_type(); + else + type=unsigned_long_long_int_type(); else assert(false); } @@ -508,19 +496,31 @@ void ansi_c_convert_typet::write(typet &type) throw 0; } - type=is_signed?signed_short_int_type():unsigned_short_int_type(); + if(is_signed) + type=signed_short_int_type(); + else + type=unsigned_short_int_type(); } else if(long_cnt==0) { - type=is_signed?signed_int_type():unsigned_int_type(); + if(is_signed) + type=signed_int_type(); + else + type=unsigned_int_type(); } else if(long_cnt==1) { - type=is_signed?signed_long_int_type():unsigned_long_int_type(); + if(is_signed) + type=signed_long_int_type(); + else + type=unsigned_long_int_type(); } else if(long_cnt==2) { - type=is_signed?signed_long_long_int_type():unsigned_long_long_int_type(); + if(is_signed) + type=signed_long_long_int_type(); + else + type=unsigned_long_long_int_type(); } else { diff --git a/src/ansi-c/ansi_c_convert_type.h b/src/ansi-c/ansi_c_convert_type.h index 0fef20b4928..6ce1a7ebecf 100644 --- a/src/ansi-c/ansi_c_convert_type.h +++ b/src/ansi-c/ansi_c_convert_type.h @@ -6,12 +6,14 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// ANSI-C Language Conversion + #ifndef CPROVER_ANSI_C_ANSI_C_CONVERT_TYPE_H #define CPROVER_ANSI_C_ANSI_C_CONVERT_TYPE_H #include -#include "c_types.h" #include "c_qualifiers.h" #include "c_storage_spec.h" diff --git a/src/ansi-c/ansi_c_declaration.cpp b/src/ansi-c/ansi_c_declaration.cpp index 7f9d0980583..74915af0f42 100644 --- a/src/ansi-c/ansi_c_declaration.cpp +++ b/src/ansi-c/ansi_c_declaration.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// ANSI-C Language Type Checking + #include #include @@ -14,18 +17,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "ansi_c_declaration.h" -/*******************************************************************\ - -Function: ansi_c_declaratort::build - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ansi_c_declaratort::build(irept &src) { typet *p=static_cast(&src); @@ -42,7 +33,7 @@ void ansi_c_declaratort::build(irept &src) t.make_nil(); break; } - else if(t.id()==irep_idt() || + else if(t.id().empty() || t.is_nil()) { assert(0); @@ -66,18 +57,6 @@ void ansi_c_declaratort::build(irept &src) value().make_nil(); } -/*******************************************************************\ - -Function: ansi_c_declarationt::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ansi_c_declarationt::output(std::ostream &out) const { out << "Flags:"; @@ -109,18 +88,6 @@ void ansi_c_declarationt::output(std::ostream &out) const out << "Declarator: " << declarator.pretty() << "\n"; } -/*******************************************************************\ - -Function: ansi_c_declarationt::full_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet ansi_c_declarationt::full_type( const ansi_c_declaratort &declarator) const { @@ -153,18 +120,6 @@ typet ansi_c_declarationt::full_type( return result; } -/*******************************************************************\ - -Function: ansi_c_declarationt::to_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ansi_c_declarationt::to_symbol( const ansi_c_declaratort &declarator, symbolt &symbol) const diff --git a/src/ansi-c/ansi_c_declaration.h b/src/ansi-c/ansi_c_declaration.h index 3143c2090a5..af5db98e32e 100644 --- a/src/ansi-c/ansi_c_declaration.h +++ b/src/ansi-c/ansi_c_declaration.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// ANSI-CC Language Type Checking + #ifndef CPROVER_ANSI_C_ANSI_C_DECLARATION_H #define CPROVER_ANSI_C_ANSI_C_DECLARATION_H diff --git a/src/ansi-c/ansi_c_entry_point.cpp b/src/ansi-c/ansi_c_entry_point.cpp index ecb2dcc73cd..90f1fda46d4 100644 --- a/src/ansi-c/ansi_c_entry_point.cpp +++ b/src/ansi-c/ansi_c_entry_point.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -17,7 +18,7 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -#include +#include #include #include @@ -26,18 +27,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "ansi_c_entry_point.h" #include "c_nondet_symbol_factory.h" -/*******************************************************************\ - -Function: build_function_environment - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt::operandst build_function_environment( const code_typet::parameterst ¶meters, code_blockt &init_code, @@ -68,18 +57,6 @@ exprt::operandst build_function_environment( return main_arguments; } -/*******************************************************************\ - -Function: record_function_outputs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void record_function_outputs( const symbolt &function, code_blockt &init_code, @@ -141,18 +118,6 @@ void record_function_outputs( #endif } -/*******************************************************************\ - -Function: ansi_c_entry_point - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool ansi_c_entry_point( symbol_tablet &symbol_table, const std::string &standard_main, diff --git a/src/ansi-c/ansi_c_entry_point.h b/src/ansi-c/ansi_c_entry_point.h index 07d09ae2d44..835dd31845d 100644 --- a/src/ansi-c/ansi_c_entry_point.h +++ b/src/ansi-c/ansi_c_entry_point.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_ANSI_C_ANSI_C_ENTRY_POINT_H #define CPROVER_ANSI_C_ANSI_C_ENTRY_POINT_H diff --git a/src/ansi-c/ansi_c_internal_additions.cpp b/src/ansi-c/ansi_c_internal_additions.cpp index eb564038e2e..a29419961a0 100644 --- a/src/ansi-c/ansi_c_internal_additions.cpp +++ b/src/ansi-c/ansi_c_internal_additions.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "ansi_c_internal_additions.h" @@ -15,6 +16,31 @@ const char gcc_builtin_headers_generic[]= #include "gcc_builtin_headers_generic.inc" ; // NOLINT(whitespace/semicolon) +const char gcc_builtin_headers_math[]= +"# 1 \"gcc_builtin_headers_math.h\"\n" +#include "gcc_builtin_headers_math.inc" +; // NOLINT(whitespace/semicolon) + +const char gcc_builtin_headers_mem_string[]= +"# 1 \"gcc_builtin_headers_mem_string.h\"\n" +#include "gcc_builtin_headers_mem_string.inc" +; // NOLINT(whitespace/semicolon) + +const char gcc_builtin_headers_omp[]= +"# 1 \"gcc_builtin_headers_omp.h\"\n" +#include "gcc_builtin_headers_omp.inc" +; // NOLINT(whitespace/semicolon) + +const char gcc_builtin_headers_tm[]= +"# 1 \"gcc_builtin_headers_tm.h\"\n" +#include "gcc_builtin_headers_tm.inc" +; // NOLINT(whitespace/semicolon) + +const char gcc_builtin_headers_ubsan[]= +"# 1 \"gcc_builtin_headers_ubsan.h\"\n" +#include "gcc_builtin_headers_ubsan.inc" +; // NOLINT(whitespace/semicolon) + const char gcc_builtin_headers_ia32[]= "# 1 \"gcc_builtin_headers_ia32.h\"\n" #include "gcc_builtin_headers_ia32.inc" @@ -22,6 +48,12 @@ const char gcc_builtin_headers_ia32[]= const char gcc_builtin_headers_ia32_2[]= #include "gcc_builtin_headers_ia32-2.inc" ; // NOLINT(whitespace/semicolon) +const char gcc_builtin_headers_ia32_3[]= +#include "gcc_builtin_headers_ia32-3.inc" +; // NOLINT(whitespace/semicolon) +const char gcc_builtin_headers_ia32_4[]= +#include "gcc_builtin_headers_ia32-4.inc" +; // NOLINT(whitespace/semicolon) const char gcc_builtin_headers_alpha[]= "# 1 \"gcc_builtin_headers_alpha.h\"\n" @@ -58,18 +90,6 @@ const char clang_builtin_headers[]= #include "clang_builtin_headers.inc" ; // NOLINT(whitespace/semicolon) -/*******************************************************************\ - -Function: architecture_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static std::string architecture_string(const std::string &value, const char *s) { return std::string("const char *__CPROVER_architecture_")+ @@ -77,18 +97,6 @@ static std::string architecture_string(const std::string &value, const char *s) "=\""+value+"\";\n"; } -/*******************************************************************\ - -Function: architecture_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static std::string architecture_string(int value, const char *s) { return std::string("const int __CPROVER_architecture_")+ @@ -96,18 +104,6 @@ static std::string architecture_string(int value, const char *s) "="+std::to_string(value)+";\n"; } -/*******************************************************************\ - -Function: ansi_c_internal_additions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ansi_c_internal_additions(std::string &code) { code+= @@ -158,6 +154,8 @@ void ansi_c_internal_additions(std::string &code) "signed __CPROVER_POINTER_OFFSET(const void *p);\n" "__CPROVER_bool __CPROVER_DYNAMIC_OBJECT(const void *p);\n" "extern unsigned char __CPROVER_memory[__CPROVER_constant_infinity_uint];\n" + // NOLINTNEXTLINE(whitespace/line_length) + "void __CPROVER_allocated_memory(__CPROVER_size_t address, __CPROVER_size_t extent);\n" // malloc "void *__CPROVER_malloc(__CPROVER_size_t size);\n" @@ -211,7 +209,11 @@ void ansi_c_internal_additions(std::string &code) // arrays // NOLINTNEXTLINE(whitespace/line_length) "__CPROVER_bool __CPROVER_array_equal(const void *array1, const void *array2);\n" + // overwrite all of *dest (possibly using nondet values), even + // if *src is smaller "void __CPROVER_array_copy(const void *dest, const void *src);\n" + // replace at most size-of-*src bytes in *dest + "void __CPROVER_array_replace(const void *dest, const void *src);\n" "void __CPROVER_array_set(const void *dest, ...);\n" // k-induction @@ -242,6 +244,11 @@ void ansi_c_internal_additions(std::string &code) config.ansi_c.mode==configt::ansi_ct::flavourt::ARM) { code+=gcc_builtin_headers_generic; + code+=gcc_builtin_headers_math; + code+=gcc_builtin_headers_mem_string; + code+=gcc_builtin_headers_omp; + code+=gcc_builtin_headers_tm; + code+=gcc_builtin_headers_ubsan; code+=clang_builtin_headers; // there are many more, e.g., look at @@ -256,6 +263,8 @@ void ansi_c_internal_additions(std::string &code) code+=gcc_builtin_headers_ia32; code+=gcc_builtin_headers_ia32_2; + code+=gcc_builtin_headers_ia32_3; + code+=gcc_builtin_headers_ia32_4; } else if(config.ansi_c.arch=="arm64" || config.ansi_c.arch=="armel" || @@ -310,18 +319,6 @@ void ansi_c_internal_additions(std::string &code) ansi_c_architecture_strings(code); } -/*******************************************************************\ - -Function: architecture_strings - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ansi_c_architecture_strings(std::string &code) { // The following are CPROVER-specific. diff --git a/src/ansi-c/ansi_c_internal_additions.h b/src/ansi-c/ansi_c_internal_additions.h index 2b4a94f1d9b..a0977a35331 100644 --- a/src/ansi-c/ansi_c_internal_additions.h +++ b/src/ansi-c/ansi_c_internal_additions.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_ANSI_C_ANSI_C_INTERNAL_ADDITIONS_H #define CPROVER_ANSI_C_ANSI_C_INTERNAL_ADDITIONS_H @@ -15,7 +16,16 @@ void ansi_c_internal_additions(std::string &code); void ansi_c_architecture_strings(std::string &code); extern const char gcc_builtin_headers_generic[]; +extern const char gcc_builtin_headers_math[]; +extern const char gcc_builtin_headers_mem_string[]; +extern const char gcc_builtin_headers_omp[]; +extern const char gcc_builtin_headers_tm[]; +extern const char gcc_builtin_headers_ubsan[]; +extern const char clang_builtin_headers[]; extern const char gcc_builtin_headers_ia32[]; +extern const char gcc_builtin_headers_ia32_2[]; +extern const char gcc_builtin_headers_ia32_3[]; +extern const char gcc_builtin_headers_ia32_4[]; extern const char arm_builtin_headers[]; #endif // CPROVER_ANSI_C_ANSI_C_INTERNAL_ADDITIONS_H diff --git a/src/ansi-c/ansi_c_language.cpp b/src/ansi-c/ansi_c_language.cpp index 159b0d6df40..e4a005b7100 100644 --- a/src/ansi-c/ansi_c_language.cpp +++ b/src/ansi-c/ansi_c_language.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include @@ -25,52 +26,17 @@ Author: Daniel Kroening, kroening@kroening.com #include "ansi_c_internal_additions.h" #include "type2name.h" -/*******************************************************************\ - -Function: ansi_c_languaget::extensions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::set ansi_c_languaget::extensions() const { return { "c", "i" }; } -/*******************************************************************\ - -Function: ansi_c_languaget::modules_provided - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ansi_c_languaget::modules_provided(std::set &modules) { modules.insert(get_base_name(parse_path, true)); } -/*******************************************************************\ - -Function: ansi_c_languaget::preprocess - - Inputs: - - Outputs: - - Purpose: ANSI-C preprocessing - -\*******************************************************************/ - +/// ANSI-C preprocessing bool ansi_c_languaget::preprocess( std::istream &instream, const std::string &path, @@ -83,18 +49,6 @@ bool ansi_c_languaget::preprocess( return c_preprocess(path, outstream, get_message_handler()); } -/*******************************************************************\ - -Function: ansi_c_languaget::parse - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool ansi_c_languaget::parse( std::istream &instream, const std::string &path) @@ -147,18 +101,6 @@ bool ansi_c_languaget::parse( return result; } -/*******************************************************************\ - -Function: ansi_c_languaget::typecheck - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool ansi_c_languaget::typecheck( symbol_tablet &symbol_table, const std::string &module) @@ -182,18 +124,6 @@ bool ansi_c_languaget::typecheck( return false; } -/*******************************************************************\ - -Function: ansi_c_languaget::final - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool ansi_c_languaget::final(symbol_tablet &symbol_table) { generate_opaque_method_stubs(symbol_table); @@ -204,52 +134,16 @@ bool ansi_c_languaget::final(symbol_tablet &symbol_table) return false; } -/*******************************************************************\ - -Function: ansi_c_languaget::show_parse - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ansi_c_languaget::show_parse(std::ostream &out) { parse_tree.output(out); } -/*******************************************************************\ - -Function: new_ansi_c_language - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - languaget *new_ansi_c_language() { return new ansi_c_languaget; } -/*******************************************************************\ - -Function: ansi_c_languaget::from_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool ansi_c_languaget::from_expr( const exprt &expr, std::string &code, @@ -259,18 +153,6 @@ bool ansi_c_languaget::from_expr( return false; } -/*******************************************************************\ - -Function: ansi_c_languaget::from_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool ansi_c_languaget::from_type( const typet &type, std::string &code, @@ -280,18 +162,6 @@ bool ansi_c_languaget::from_type( return false; } -/*******************************************************************\ - -Function: ansi_c_languaget::type_to_name - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool ansi_c_languaget::type_to_name( const typet &type, std::string &name, @@ -301,18 +171,6 @@ bool ansi_c_languaget::type_to_name( return false; } -/*******************************************************************\ - -Function: ansi_c_languaget::to_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool ansi_c_languaget::to_expr( const std::string &code, const std::string &module, @@ -359,18 +217,6 @@ bool ansi_c_languaget::to_expr( return result; } -/*******************************************************************\ - -Function: ansi_c_languaget::~ansi_c_languaget - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - ansi_c_languaget::~ansi_c_languaget() { } diff --git a/src/ansi-c/ansi_c_language.h b/src/ansi-c/ansi_c_language.h index 9f6fba0cc9b..45b7d6aaa3f 100644 --- a/src/ansi-c/ansi_c_language.h +++ b/src/ansi-c/ansi_c_language.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_ANSI_C_ANSI_C_LANGUAGE_H #define CPROVER_ANSI_C_ANSI_C_LANGUAGE_H diff --git a/src/ansi-c/ansi_c_parse_tree.cpp b/src/ansi-c/ansi_c_parse_tree.cpp index 4f58d094563..4ae1f955ea0 100644 --- a/src/ansi-c/ansi_c_parse_tree.cpp +++ b/src/ansi-c/ansi_c_parse_tree.cpp @@ -6,56 +6,21 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "ansi_c_parse_tree.h" -/*******************************************************************\ - -Function: ansi_c_parse_treet::swap - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ansi_c_parse_treet::swap(ansi_c_parse_treet &ansi_c_parse_tree) { ansi_c_parse_tree.items.swap(items); } -/*******************************************************************\ - -Function: ansi_c_parse_treet::clear - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ansi_c_parse_treet::clear() { items.clear(); } -/*******************************************************************\ - -Function: ansi_c_parse_treet::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ansi_c_parse_treet::output(std::ostream &out) const { for(const auto &item : items) diff --git a/src/ansi-c/ansi_c_parse_tree.h b/src/ansi-c/ansi_c_parse_tree.h index e32d5a6ca20..c346b5853fe 100644 --- a/src/ansi-c/ansi_c_parse_tree.h +++ b/src/ansi-c/ansi_c_parse_tree.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_ANSI_C_ANSI_C_PARSE_TREE_H #define CPROVER_ANSI_C_ANSI_C_PARSE_TREE_H diff --git a/src/ansi-c/ansi_c_parser.cpp b/src/ansi-c/ansi_c_parser.cpp index 77a71b62dc2..6ce4f63b141 100644 --- a/src/ansi-c/ansi_c_parser.cpp +++ b/src/ansi-c/ansi_c_parser.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "ansi_c_parser.h" @@ -13,18 +14,6 @@ Author: Daniel Kroening, kroening@kroening.com ansi_c_parsert ansi_c_parser; -/*******************************************************************\ - -Function: ansi_c_parsert::lookup - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - ansi_c_id_classt ansi_c_parsert::lookup( const irep_idt &base_name, irep_idt &identifier, // output @@ -70,18 +59,6 @@ ansi_c_id_classt ansi_c_parsert::lookup( return ansi_c_id_classt::ANSI_C_UNKNOWN; } -/*******************************************************************\ - -Function: ansi_c_parsert::add_tag_with_body - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ansi_c_parsert::add_tag_with_body(irept &tag) { const std::string scope_name= @@ -100,18 +77,6 @@ void ansi_c_parsert::add_tag_with_body(irept &tag) } } -/*******************************************************************\ - -Function: yyansi_cerror - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - extern char *yyansi_ctext; int yyansi_cerror(const std::string &error) @@ -120,18 +85,6 @@ int yyansi_cerror(const std::string &error) return 0; } -/*******************************************************************\ - -Function: ansi_c_parsert::add_declarator - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ansi_c_parsert::add_declarator( exprt &declaration, irept &declarator) @@ -202,18 +155,6 @@ void ansi_c_parsert::add_declarator( ansi_c_declaration.declarators().push_back(new_declarator); } -/*******************************************************************\ - -Function: ansi_c_parsert::get_class - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - ansi_c_id_classt ansi_c_parsert::get_class(const typet &type) { if(type.id()==ID_typedef) diff --git a/src/ansi-c/ansi_c_parser.h b/src/ansi-c/ansi_c_parser.h index 579797db46a..2dc2c77001a 100644 --- a/src/ansi-c/ansi_c_parser.h +++ b/src/ansi-c/ansi_c_parser.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_ANSI_C_ANSI_C_PARSER_H #define CPROVER_ANSI_C_ANSI_C_PARSER_H diff --git a/src/ansi-c/ansi_c_scope.cpp b/src/ansi-c/ansi_c_scope.cpp index ffd3663e1fa..6a4a626b3f8 100644 --- a/src/ansi-c/ansi_c_scope.cpp +++ b/src/ansi-c/ansi_c_scope.cpp @@ -6,22 +6,11 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "ansi_c_scope.h" -/*******************************************************************\ - -Function: ansi_c_scopet::print - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ansi_c_scopet::print(std::ostream &out) const { out << "Prefix: " << prefix << "\n"; diff --git a/src/ansi-c/ansi_c_scope.h b/src/ansi-c/ansi_c_scope.h index 6f7b92b876c..0f9bc117729 100644 --- a/src/ansi-c/ansi_c_scope.h +++ b/src/ansi-c/ansi_c_scope.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_ANSI_C_ANSI_C_SCOPE_H #define CPROVER_ANSI_C_ANSI_C_SCOPE_H diff --git a/src/ansi-c/ansi_c_typecheck.cpp b/src/ansi-c/ansi_c_typecheck.cpp index 08da6bbae01..50bfe78dffb 100644 --- a/src/ansi-c/ansi_c_typecheck.cpp +++ b/src/ansi-c/ansi_c_typecheck.cpp @@ -6,19 +6,10 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "ansi_c_typecheck.h" - -/*******************************************************************\ - -Function: ansi_c_typecheckt::typecheck - - Inputs: - - Outputs: - - Purpose: +/// \file +/// ANSI-C Language Type Checking -\*******************************************************************/ +#include "ansi_c_typecheck.h" void ansi_c_typecheckt::typecheck() { @@ -32,18 +23,6 @@ void ansi_c_typecheckt::typecheck() } } -/*******************************************************************\ - -Function: ansi_c_typecheck - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool ansi_c_typecheck( ansi_c_parse_treet &ansi_c_parse_tree, symbol_tablet &symbol_table, @@ -55,23 +34,14 @@ bool ansi_c_typecheck( return ansi_c_typecheck.typecheck_main(); } -/*******************************************************************\ - -Function: ansi_c_typecheck - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool ansi_c_typecheck( exprt &expr, message_handlert &message_handler, const namespacet &ns) { + const unsigned errors_before= + message_handler.get_message_count(messaget::M_ERROR); + symbol_tablet symbol_table; ansi_c_parse_treet ansi_c_parse_tree; @@ -99,5 +69,5 @@ bool ansi_c_typecheck( ansi_c_typecheck.error() << e << messaget::eom; } - return ansi_c_typecheck.get_error_found(); + return message_handler.get_message_count(messaget::M_ERROR)!=errors_before; } diff --git a/src/ansi-c/ansi_c_typecheck.h b/src/ansi-c/ansi_c_typecheck.h index aa6672d0d01..fdb9a32f2fe 100644 --- a/src/ansi-c/ansi_c_typecheck.h +++ b/src/ansi-c/ansi_c_typecheck.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// ANSI-C Language Type Checking + #ifndef CPROVER_ANSI_C_ANSI_C_TYPECHECK_H #define CPROVER_ANSI_C_ANSI_C_TYPECHECK_H diff --git a/src/ansi-c/c_misc.cpp b/src/ansi-c/c_misc.cpp index 94baea10fa2..6af272c86a0 100644 --- a/src/ansi-c/c_misc.cpp +++ b/src/ansi-c/c_misc.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// ANSI-C Misc Utilities + #include #ifdef _WIN32 @@ -16,18 +19,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "c_misc.h" -/*******************************************************************\ - -Function: MetaChar - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static void MetaChar(std::string &out, char c, bool inString) { switch(c) @@ -102,18 +93,6 @@ static void MetaChar(std::string &out, char c, bool inString) } #if 0 -/*******************************************************************\ - -Function: MetaChar - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static std::string MetaChar(char c) { std::string result; @@ -122,18 +101,6 @@ static std::string MetaChar(char c) } #endif -/*******************************************************************\ - -Function: MetaString - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string MetaString(const std::string &in) { std::string result; diff --git a/src/ansi-c/c_misc.h b/src/ansi-c/c_misc.h index 40f9d0db5b8..5af7eb4754c 100644 --- a/src/ansi-c/c_misc.h +++ b/src/ansi-c/c_misc.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// ANSI-C Misc Utilities + #ifndef CPROVER_ANSI_C_C_MISC_H #define CPROVER_ANSI_C_C_MISC_H diff --git a/src/ansi-c/c_nondet_symbol_factory.cpp b/src/ansi-c/c_nondet_symbol_factory.cpp index 9149d6f8786..2b51ce8fb05 100644 --- a/src/ansi-c/c_nondet_symbol_factory.cpp +++ b/src/ansi-c/c_nondet_symbol_factory.cpp @@ -6,10 +6,14 @@ Author: DiffBlue Limited. All rights reserved. \*******************************************************************/ +/// \file +/// C Nondet Symbol Factory + #include #include #include +#include #include #include #include @@ -20,30 +24,19 @@ Author: DiffBlue Limited. All rights reserved. #include -#include #include #include #include "c_nondet_symbol_factory.h" -/*******************************************************************\ - -Function: declare_new_tmp_symbol - - Inputs: - symbol_table - The symbol table to create the symbol in - loc - The location to assign to the symbol - type - The type of symbol to create - static_lifetime - Whether the symbol should have a static lifetime - prefix - The prefix to use for the symbol's basename - - Outputs: Returns a reference to the new symbol - - Purpose: Create a new temporary static symbol - -\*******************************************************************/ - +/// Create a new temporary static symbol +/// \param symbol_table: The symbol table to create the symbol in +/// \param loc: The location to assign to the symbol +/// \param type: The type of symbol to create +/// \param static_lifetime: Whether the symbol should have a static lifetime +/// \param prefix: The prefix to use for the symbol's basename +/// \return Returns a reference to the new symbol static const symbolt &c_new_tmp_symbol( symbol_tablet &symbol_table, const source_locationt &loc, @@ -58,19 +51,8 @@ static const symbolt &c_new_tmp_symbol( return tmp_symbol; } -/*******************************************************************\ - -Function: c_get_nondet_bool - - Inputs: - type - Desired type (C_bool or plain bool) - - Outputs: nondet expr of that type - - Purpose: - -\*******************************************************************/ - +/// \param type: Desired type (C_bool or plain bool) +/// \return nondet expr of that type static exprt c_get_nondet_bool(const typet &type) { // We force this to 0 and 1 and won't consider other values @@ -107,23 +89,14 @@ class symbol_factoryt void gen_nondet_init(code_blockt &assignments, const exprt &expr); }; -/*******************************************************************\ - -Function: symbol_factoryt::allocate_object - - Inputs: - assignments - The code block to add code to - target_expr - The expression which we are allocating a symbol for - allocate_type - The type to use for the symbol. If this doesn't match - target_expr then a cast will be used for the assignment - static_lifetime - Whether the symbol created should have static lifetime - - Outputs: Returns the address of the allocated symbol - - Purpose: Create a symbol for a pointer to point to - -\*******************************************************************/ - +/// Create a symbol for a pointer to point to +/// \param assignments: The code block to add code to +/// \param target_expr: The expression which we are allocating a symbol for +/// \param allocate_type: The type to use for the symbol. If this doesn't match +/// target_expr then a cast will be used for the assignment +/// \param static_lifetime: Whether the symbol created should have static +/// lifetime +/// \return Returns the address of the allocated symbol exprt symbol_factoryt::allocate_object( code_blockt &assignments, const exprt &target_expr, @@ -157,21 +130,11 @@ exprt symbol_factoryt::allocate_object( return aoe; } -/*******************************************************************\ - -Function: symbol_factoryt::gen_nondet_init - - Inputs: - assignments - The code block to add code to - expr - The expression which we are generating a non-determinate value for - - Outputs: - - Purpose: Creates a nondet for expr, including calling itself recursively to - make appropriate symbols to point to if expr is a pointer. - -\*******************************************************************/ - +/// Creates a nondet for expr, including calling itself recursively to make +/// appropriate symbols to point to if expr is a pointer. +/// \param assignments: The code block to add code to +/// \param expr: The expression which we are generating a non-determinate value +/// for void symbol_factoryt::gen_nondet_init( code_blockt &assignments, const exprt &expr) @@ -243,26 +206,16 @@ void symbol_factoryt::gen_nondet_init( } } -/*******************************************************************\ - -Function: c_nondet_symbol_factory - - Inputs: - init_code - The code block to add generated code to - symbol_table - The symbol table - base_name - The name to use for the symbol created - type - The type for the symbol created - loc - The location to assign to generated code - allow_null - Whether to allow a null value when type is a pointer - - Outputs: Returns the symbol_exprt for the symbol created - - Purpose: Creates a symbol and generates code so that it can vary - over all possible values for its type. For pointers this - involves allocating symbols which it can point to. - -\*******************************************************************/ - +/// Creates a symbol and generates code so that it can vary over all possible +/// values for its type. For pointers this involves allocating symbols which it +/// can point to. +/// \param init_code: The code block to add generated code to +/// \param symbol_table: The symbol table +/// \param base_name: The name to use for the symbol created +/// \param type: The type for the symbol created +/// \param loc: The location to assign to generated code +/// \param allow_null: Whether to allow a null value when type is a pointer +/// \return Returns the symbol_exprt for the symbol created exprt c_nondet_symbol_factory( code_blockt &init_code, symbol_tablet &symbol_table, diff --git a/src/ansi-c/c_nondet_symbol_factory.h b/src/ansi-c/c_nondet_symbol_factory.h index 8760de6ac55..8d375663e73 100644 --- a/src/ansi-c/c_nondet_symbol_factory.h +++ b/src/ansi-c/c_nondet_symbol_factory.h @@ -6,6 +6,9 @@ Author: DiffBlue Limited. All rights reserved. \*******************************************************************/ +/// \file +/// C Nondet Symbol Factory + #ifndef CPROVER_ANSI_C_C_NONDET_SYMBOL_FACTORY_H #define CPROVER_ANSI_C_C_NONDET_SYMBOL_FACTORY_H diff --git a/src/ansi-c/c_preprocess.cpp b/src/ansi-c/c_preprocess.cpp index 9582d6f3b00..6ff6ec9cb21 100644 --- a/src/ansi-c/c_preprocess.cpp +++ b/src/ansi-c/c_preprocess.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include @@ -21,6 +22,7 @@ Author: Daniel Kroening, kroening@kroening.com #include +#include #include #include #include @@ -29,7 +31,6 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -#include "c_types.h" #include "c_preprocess.h" #define GCC_DEFINES_16 \ @@ -96,18 +97,7 @@ Author: Daniel Kroening, kroening@kroening.com " -D__INTPTR_TYPE__=\"long long int\""\ " -D__UINTPTR_TYPE__=\"long long unsigned int\"" -/*******************************************************************\ - -Function: type_max - - Inputs: - - Outputs: - - Purpose: produce a string with the maximum value of a given type - -\*******************************************************************/ - +/// produce a string with the maximum value of a given type static std::string type_max(const typet &src) { if(src.id()==ID_signedbv) @@ -120,18 +110,7 @@ static std::string type_max(const typet &src) assert(false); } -/*******************************************************************\ - -Function: shell_quote - - Inputs: - - Outputs: - - Purpose: quote a string for bash and CMD - -\*******************************************************************/ - +/// quote a string for bash and CMD static std::string shell_quote(const std::string &src) { #ifdef _WIN32 @@ -205,18 +184,6 @@ static std::string shell_quote(const std::string &src) #endif } -/*******************************************************************\ - -Function: error_parse_line - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static void error_parse_line( const std::string &line, bool warning_only, @@ -337,18 +304,6 @@ static void error_parse_line( m << error_msg << messaget::eom; } -/*******************************************************************\ - -Function: error_parse - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static void error_parse( std::istream &errors, bool warning_only, @@ -360,18 +315,7 @@ static void error_parse( error_parse_line(line, warning_only, message); } -/*******************************************************************\ - -Function: c_preprocess - - Inputs: - - Outputs: - - Purpose: ANSI-C preprocessing - -\*******************************************************************/ - +/// ANSI-C preprocessing bool c_preprocess( std::istream &instream, std::ostream &outstream, @@ -397,18 +341,7 @@ bool c_preprocess( return result; } -/*******************************************************************\ - -Function: is_dot_i_file - - Inputs: - - Outputs: - - Purpose: ANSI-C preprocessing - -\*******************************************************************/ - +/// ANSI-C preprocessing static bool is_dot_i_file(const std::string &path) { const char *ext=strrchr(path.c_str(), '.'); @@ -420,18 +353,7 @@ static bool is_dot_i_file(const std::string &path) return false; } -/*******************************************************************\ - -Function: c_preprocess - - Inputs: - - Outputs: - - Purpose: ANSI-C preprocessing - -\*******************************************************************/ - +/// ANSI-C preprocessing bool c_preprocess_codewarrior( const std::string &, std::ostream &, message_handlert &); bool c_preprocess_arm( @@ -480,18 +402,7 @@ bool c_preprocess( return true; } -/*******************************************************************\ - -Function: c_preprocess_visual_studio - - Inputs: - - Outputs: - - Purpose: ANSI-C preprocessing - -\*******************************************************************/ - +/// ANSI-C preprocessing bool c_preprocess_visual_studio( const std::string &file, std::ostream &outstream, @@ -598,18 +509,7 @@ bool c_preprocess_visual_studio( return false; } -/*******************************************************************\ - -Function: postprocess_codewarrior - - Inputs: - - Outputs: - - Purpose: post-processing specifically for CodeWarrior - -\*******************************************************************/ - +/// post-processing specifically for CodeWarrior void postprocess_codewarrior( std::istream &instream, std::ostream &outstream) @@ -645,18 +545,7 @@ void postprocess_codewarrior( } } -/*******************************************************************\ - -Function: c_preprocess_codewarrior - - Inputs: - - Outputs: - - Purpose: ANSI-C preprocessing - -\*******************************************************************/ - +/// ANSI-C preprocessing bool c_preprocess_codewarrior( const std::string &file, std::ostream &outstream, @@ -729,18 +618,7 @@ bool c_preprocess_codewarrior( return false; } -/*******************************************************************\ - -Function: c_preprocess_gcc_clang - - Inputs: - - Outputs: - - Purpose: ANSI-C preprocessing - -\*******************************************************************/ - +/// ANSI-C preprocessing bool c_preprocess_gcc_clang( const std::string &file, std::ostream &outstream, @@ -1044,18 +922,7 @@ bool c_preprocess_gcc_clang( return false; } -/*******************************************************************\ - -Function: c_preprocess_arm - - Inputs: - - Outputs: - - Purpose: ANSI-C preprocessing - -\*******************************************************************/ - +/// ANSI-C preprocessing bool c_preprocess_arm( const std::string &file, std::ostream &outstream, @@ -1177,18 +1044,7 @@ bool c_preprocess_arm( return false; } -/*******************************************************************\ - -Function: c_preprocess_none - - Inputs: - - Outputs: - - Purpose: ANSI-C preprocessing - -\*******************************************************************/ - +/// ANSI-C preprocessing bool c_preprocess_none( const std::string &file, std::ostream &outstream, @@ -1223,18 +1079,7 @@ bool c_preprocess_none( return false; } -/*******************************************************************\ - -Function: test_c_preprocessor - - Inputs: - - Outputs: - - Purpose: tests ANSI-C preprocessing - -\*******************************************************************/ - +/// tests ANSI-C preprocessing const char c_test_program[]= "#include \n" "\n" diff --git a/src/ansi-c/c_preprocess.h b/src/ansi-c/c_preprocess.h index 2a50e0bfa36..bdf273d2775 100644 --- a/src/ansi-c/c_preprocess.h +++ b/src/ansi-c/c_preprocess.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_ANSI_C_C_PREPROCESS_H #define CPROVER_ANSI_C_C_PREPROCESS_H diff --git a/src/ansi-c/c_qualifiers.cpp b/src/ansi-c/c_qualifiers.cpp index 75ca8bf9c05..b4ac5650bf2 100644 --- a/src/ansi-c/c_qualifiers.cpp +++ b/src/ansi-c/c_qualifiers.cpp @@ -6,22 +6,11 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "c_qualifiers.h" -/*******************************************************************\ - -Function: c_qualifierst::as_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string c_qualifierst::as_string() const { std::string qualifiers; @@ -50,18 +39,6 @@ std::string c_qualifierst::as_string() const return qualifiers; } -/*******************************************************************\ - -Function: c_qualifierst::read - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_qualifierst::read(const typet &src) { if(src.get_bool(ID_C_constant)) @@ -89,18 +66,6 @@ void c_qualifierst::read(const typet &src) is_noreturn=true; } -/*******************************************************************\ - -Function: c_qualifierst::write - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_qualifierst::write(typet &dest) const { if(is_constant) @@ -144,18 +109,6 @@ void c_qualifierst::write(typet &dest) const dest.remove(ID_C_noreturn); } -/*******************************************************************\ - -Function: c_qualifierst::clear - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_qualifierst::clear(typet &dest) { dest.remove(ID_C_constant); @@ -167,18 +120,7 @@ void c_qualifierst::clear(typet &dest) dest.remove(ID_C_noreturn); } -/*******************************************************************\ - -Function: operator << - - Inputs: - - Outputs: - - Purpose: pretty-print the qualifiers - -\*******************************************************************/ - +/// pretty-print the qualifiers std::ostream &operator << ( std::ostream &out, const c_qualifierst &c_qualifiers) diff --git a/src/ansi-c/c_qualifiers.h b/src/ansi-c/c_qualifiers.h index 45e5d01d782..2e9948e31e9 100644 --- a/src/ansi-c/c_qualifiers.h +++ b/src/ansi-c/c_qualifiers.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_ANSI_C_C_QUALIFIERS_H #define CPROVER_ANSI_C_C_QUALIFIERS_H diff --git a/src/ansi-c/c_sizeof.cpp b/src/ansi-c/c_sizeof.cpp index 85c91870208..63518a5db36 100644 --- a/src/ansi-c/c_sizeof.cpp +++ b/src/ansi-c/c_sizeof.cpp @@ -6,6 +6,10 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Conversion of sizeof Expressions + +#include #include #include #include @@ -13,19 +17,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "c_sizeof.h" #include "c_typecast.h" -#include "c_types.h" - -/*******************************************************************\ - -Function: c_sizeoft::sizeof_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ exprt c_sizeoft::sizeof_rec(const typet &type) { @@ -258,18 +249,6 @@ exprt c_sizeoft::sizeof_rec(const typet &type) return dest; } -/*******************************************************************\ - -Function: c_sizeoft::c_offsetof - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt c_sizeoft::c_offsetof( const struct_typet &type, const irep_idt &component_name) @@ -320,18 +299,6 @@ exprt c_sizeoft::c_offsetof( return nil_exprt(); } -/*******************************************************************\ - -Function: c_sizeof - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt c_sizeof(const typet &src, const namespacet &ns) { c_sizeoft c_sizeof_inst(ns); @@ -340,18 +307,6 @@ exprt c_sizeof(const typet &src, const namespacet &ns) return tmp; } -/*******************************************************************\ - -Function: c_offsetof - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt c_offsetof( const struct_typet &src, const irep_idt &component_name, diff --git a/src/ansi-c/c_sizeof.h b/src/ansi-c/c_sizeof.h index 40329726b75..de5421c0510 100644 --- a/src/ansi-c/c_sizeof.h +++ b/src/ansi-c/c_sizeof.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_ANSI_C_C_SIZEOF_H #define CPROVER_ANSI_C_C_SIZEOF_H diff --git a/src/ansi-c/c_storage_spec.cpp b/src/ansi-c/c_storage_spec.cpp index df4cdb2381c..993a93f724e 100644 --- a/src/ansi-c/c_storage_spec.cpp +++ b/src/ansi-c/c_storage_spec.cpp @@ -6,22 +6,11 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "c_storage_spec.h" -/*******************************************************************\ - -Function: c_storage_spect::read - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_storage_spect::read(const typet &type) { if(type.id()==ID_merged_type || diff --git a/src/ansi-c/c_storage_spec.h b/src/ansi-c/c_storage_spec.h index d735e578426..5b392fe4d05 100644 --- a/src/ansi-c/c_storage_spec.h +++ b/src/ansi-c/c_storage_spec.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_ANSI_C_C_STORAGE_SPEC_H #define CPROVER_ANSI_C_C_STORAGE_SPEC_H @@ -76,7 +77,13 @@ class c_storage_spect is_register |=other.is_register; is_inline |=other.is_inline; is_thread_local |=other.is_thread_local; - // attributes belong to the declarator, don't replace them + is_weak |=other.is_weak; + if(alias.empty()) + alias=other.alias; + if(asm_label.empty()) + asm_label=other.asm_label; + if(section.empty()) + section=other.section; return *this; } diff --git a/src/ansi-c/c_typecast.cpp b/src/ansi-c/c_typecast.cpp index 52070e29257..5b60bbda473 100644 --- a/src/ansi-c/c_typecast.cpp +++ b/src/ansi-c/c_typecast.cpp @@ -6,11 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include +#include #include #include #include @@ -19,21 +21,8 @@ Author: Daniel Kroening, kroening@kroening.com #include #include "c_typecast.h" -#include "c_types.h" #include "c_qualifiers.h" -/*******************************************************************\ - -Function: c_implicit_typecast - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool c_implicit_typecast( exprt &expr, const typet &dest_type, @@ -44,18 +33,6 @@ bool c_implicit_typecast( return !c_typecast.errors.empty(); } -/*******************************************************************\ - -Function: check_c_implicit_typecast - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool check_c_implicit_typecast( const typet &src_type, const typet &dest_type, @@ -68,18 +45,7 @@ bool check_c_implicit_typecast( return !c_typecast.errors.empty(); } -/*******************************************************************\ - -Function: c_implicit_typecast_arithmetic - - Inputs: - - Outputs: - - Purpose: perform arithmetic prompotions and conversions - -\*******************************************************************/ - +/// perform arithmetic prompotions and conversions bool c_implicit_typecast_arithmetic( exprt &expr1, exprt &expr2, const namespacet &ns) @@ -89,18 +55,6 @@ bool c_implicit_typecast_arithmetic( return !c_typecast.errors.empty(); } -/*******************************************************************\ - -Function: is_void_pointer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool is_void_pointer(const typet &type) { if(type.id()==ID_pointer) @@ -114,18 +68,6 @@ bool is_void_pointer(const typet &type) return false; } -/*******************************************************************\ - -Function: check_c_implicit_typecast - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool check_c_implicit_typecast( const typet &src_type, const typet &dest_type) @@ -308,18 +250,6 @@ bool check_c_implicit_typecast( return true; } -/*******************************************************************\ - -Function: c_typecastt::follow_with_qualifiers - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet c_typecastt::follow_with_qualifiers(const typet &src_type) { if(src_type.id()!=ID_symbol) @@ -344,18 +274,6 @@ typet c_typecastt::follow_with_qualifiers(const typet &src_type) return result_type; } -/*******************************************************************\ - -Function: c_typecastt::get_c_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - c_typecastt::c_typet c_typecastt::get_c_type( const typet &type) const { @@ -441,18 +359,6 @@ c_typecastt::c_typet c_typecastt::get_c_type( return OTHER; } -/*******************************************************************\ - -Function: c_typecastt::implicit_typecast_arithmetic - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecastt::implicit_typecast_arithmetic( exprt &expr, c_typet c_type) @@ -499,18 +405,6 @@ void c_typecastt::implicit_typecast_arithmetic( do_typecast(expr, new_type); } -/*******************************************************************\ - -Function: c_typecastt::implicit_typecast_arithmetic - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - c_typecastt::c_typet c_typecastt::minimum_promotion( const typet &type) const { @@ -544,36 +438,12 @@ c_typecastt::c_typet c_typecastt::minimum_promotion( return max_type; } -/*******************************************************************\ - -Function: c_typecastt::implicit_typecast_arithmetic - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecastt::implicit_typecast_arithmetic(exprt &expr) { c_typet c_type=minimum_promotion(expr.type()); implicit_typecast_arithmetic(expr, c_type); } -/*******************************************************************\ - -Function: c_typecastt::implicit_typecast - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecastt::implicit_typecast( exprt &expr, const typet &type) @@ -588,18 +458,6 @@ void c_typecastt::implicit_typecast( implicit_typecast_followed(expr, src_type, type_qual, dest_type); } -/*******************************************************************\ - -Function: c_typecastt::implicit_typecast_followed - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecastt::implicit_typecast_followed( exprt &expr, const typet &src_type, @@ -721,18 +579,6 @@ void c_typecastt::implicit_typecast_followed( do_typecast(expr, orig_dest_type); } -/*******************************************************************\ - -Function: c_typecastt::implicit_typecast_arithmetic - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecastt::implicit_typecast_arithmetic( exprt &expr1, exprt &expr2) @@ -847,18 +693,6 @@ void c_typecastt::implicit_typecast_arithmetic( #endif } -/*******************************************************************\ - -Function: c_typecastt::do_typecast - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecastt::do_typecast(exprt &expr, const typet &dest_type) { // special case: array -> pointer is actually diff --git a/src/ansi-c/c_typecast.h b/src/ansi-c/c_typecast.h index cfc3eb79aa5..56d0c832359 100644 --- a/src/ansi-c/c_typecast.h +++ b/src/ansi-c/c_typecast.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_ANSI_C_C_TYPECAST_H #define CPROVER_ANSI_C_C_TYPECAST_H diff --git a/src/ansi-c/c_typecheck_argc_argv.cpp b/src/ansi-c/c_typecheck_argc_argv.cpp index a528a630042..5b6b11c8c1f 100644 --- a/src/ansi-c/c_typecheck_argc_argv.cpp +++ b/src/ansi-c/c_typecheck_argc_argv.cpp @@ -6,22 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// ANSI-C Conversion / Type Checking + #include #include "c_typecheck_base.h" -/*******************************************************************\ - -Function: c_typecheck_baset::add_argc_argv - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::add_argc_argv(const symbolt &main_symbol) { const code_typet::parameterst ¶meters= diff --git a/src/ansi-c/c_typecheck_base.cpp b/src/ansi-c/c_typecheck_base.cpp index 8597eef3852..74a0f33f962 100644 --- a/src/ansi-c/c_typecheck_base.cpp +++ b/src/ansi-c/c_typecheck_base.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// ANSI-C Conversion / Type Checking + #include #include #include @@ -15,52 +18,16 @@ Author: Daniel Kroening, kroening@kroening.com #include "type2name.h" #include "c_storage_spec.h" -/*******************************************************************\ - -Function: c_typecheck_baset::to_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string c_typecheck_baset::to_string(const exprt &expr) { return expr2c(expr, *this); } -/*******************************************************************\ - -Function: c_typecheck_baset::to_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string c_typecheck_baset::to_string(const typet &type) { return type2c(type, *this); } -/*******************************************************************\ - -Function: c_typecheck_baset::move_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::move_symbol(symbolt &symbol, symbolt *&new_symbol) { symbol.mode=mode; @@ -75,18 +42,6 @@ void c_typecheck_baset::move_symbol(symbolt &symbol, symbolt *&new_symbol) } } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_symbol(symbolt &symbol) { current_symbol_id=symbol.name; @@ -173,18 +128,6 @@ void c_typecheck_baset::typecheck_symbol(symbolt &symbol) } } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_new_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_new_symbol(symbolt &symbol) { if(symbol.is_parameter) @@ -210,44 +153,11 @@ void c_typecheck_baset::typecheck_new_symbol(symbolt &symbol) } else { - if(symbol.type.id()==ID_array && - to_array_type(symbol.type).size().is_nil() && - !symbol.is_type) - { - // Insert a new type symbol for the array. - // We do this because we want a convenient way - // of adjusting the size of the type later on. - - type_symbolt new_symbol(symbol.type); - new_symbol.name=id2string(symbol.name)+"$type"; - new_symbol.base_name=id2string(symbol.base_name)+"$type"; - new_symbol.location=symbol.location; - new_symbol.mode=symbol.mode; - new_symbol.module=symbol.module; - - symbol.type=symbol_typet(new_symbol.name); - - symbolt *new_sp; - symbol_table.move(new_symbol, new_sp); - } - // check the initializer do_initializer(symbol); } } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_redefinition_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_redefinition_type( symbolt &old_symbol, symbolt &new_symbol) @@ -331,18 +241,6 @@ void c_typecheck_baset::typecheck_redefinition_type( } } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_redefinition_non_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_redefinition_non_type( symbolt &old_symbol, symbolt &new_symbol) @@ -615,18 +513,6 @@ void c_typecheck_baset::typecheck_redefinition_non_type( // mismatch. } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_function_body - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_function_body(symbolt &symbol) { code_typet &code_type=to_code_type(symbol.type); @@ -653,7 +539,7 @@ void c_typecheck_baset::typecheck_function_body(symbolt &symbol) p_it++) { // may be anonymous - if(p_it->get_base_name()==irep_idt()) + if(p_it->get_base_name().empty()) { irep_idt base_name="#anon"+std::to_string(anon_counter++); p_it->set_base_name(base_name); @@ -697,18 +583,6 @@ void c_typecheck_baset::typecheck_function_body(symbolt &symbol) } } -/*******************************************************************\ - -Function: c_typecheck_baset::apply_asm_label - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::apply_asm_label( const irep_idt &asm_label, symbolt &symbol) @@ -777,18 +651,6 @@ void c_typecheck_baset::apply_asm_label( } } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_declaration - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_declaration( ansi_c_declarationt &declaration) { diff --git a/src/ansi-c/c_typecheck_base.h b/src/ansi-c/c_typecheck_base.h index 68191f54fe9..684b0b64edc 100644 --- a/src/ansi-c/c_typecheck_base.h +++ b/src/ansi-c/c_typecheck_base.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// ANSI-C Language Type Checking + #ifndef CPROVER_ANSI_C_C_TYPECHECK_BASE_H #define CPROVER_ANSI_C_C_TYPECHECK_BASE_H diff --git a/src/ansi-c/c_typecheck_code.cpp b/src/ansi-c/c_typecheck_code.cpp index dfbac98940c..b02e6c29718 100644 --- a/src/ansi-c/c_typecheck_code.cpp +++ b/src/ansi-c/c_typecheck_code.cpp @@ -6,41 +6,20 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// C Language Type Checking + #include #include #include "ansi_c_declaration.h" #include "c_typecheck_base.h" -/*******************************************************************\ - -Function: c_typecheck_baset::start_typecheck_code - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::start_typecheck_code() { case_is_allowed=break_is_allowed=continue_is_allowed=false; } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_code - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_code(codet &code) { if(code.id()!=ID_code) @@ -152,18 +131,6 @@ void c_typecheck_baset::typecheck_code(codet &code) } } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_asm - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_asm(codet &code) { const irep_idt flavor=to_code_asm(code).get_flavor(); @@ -197,18 +164,6 @@ void c_typecheck_baset::typecheck_asm(codet &code) } } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_assign - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_assign(codet &code) { if(code.operands().size()!=2) @@ -225,18 +180,6 @@ void c_typecheck_baset::typecheck_assign(codet &code) implicit_typecast(code.op1(), code.op0().type()); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_block - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_block(codet &code) { Forall_operands(it, code) @@ -276,18 +219,6 @@ void c_typecheck_baset::typecheck_block(codet &code) code.operands().swap(new_ops.operands()); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_break - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_break(codet &code) { if(!break_is_allowed) @@ -298,18 +229,6 @@ void c_typecheck_baset::typecheck_break(codet &code) } } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_continue - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_continue(codet &code) { if(!continue_is_allowed) @@ -320,18 +239,6 @@ void c_typecheck_baset::typecheck_continue(codet &code) } } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_decl - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_decl(codet &code) { // this comes with 1 operand, which is a declaration @@ -452,18 +359,6 @@ void c_typecheck_baset::typecheck_decl(codet &code) } } -/*******************************************************************\ - -Function: c_typecheck_baset::is_complete_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool c_typecheck_baset::is_complete_type(const typet &type) const { if(type.id()==ID_incomplete_struct || @@ -494,18 +389,6 @@ bool c_typecheck_baset::is_complete_type(const typet &type) const return true; } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_expression - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_expression(codet &code) { if(code.operands().size()!=1) @@ -520,18 +403,6 @@ void c_typecheck_baset::typecheck_expression(codet &code) typecheck_expr(op); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_for - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_for(codet &code) { if(code.operands().size()!=4) @@ -623,18 +494,6 @@ void c_typecheck_baset::typecheck_for(codet &code) typecheck_spec_expr(code, ID_C_spec_loop_invariant); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_label - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_label(code_labelt &code) { // record the label @@ -643,18 +502,6 @@ void c_typecheck_baset::typecheck_label(code_labelt &code) typecheck_code(code.code()); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_switch_case - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_switch_case(code_switch_caset &code) { if(code.operands().size()!=2) @@ -690,18 +537,6 @@ void c_typecheck_baset::typecheck_switch_case(code_switch_caset &code) } } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_gcc_switch_case_range - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_gcc_switch_case_range(codet &code) { if(code.operands().size()!=3) @@ -727,54 +562,18 @@ void c_typecheck_baset::typecheck_gcc_switch_case_range(codet &code) implicit_typecast(code.op1(), switch_op_type); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_gcc_local_label - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_gcc_local_label(codet &code) { // these are just declarations, e.g., // __label__ here, there; } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_goto - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_goto(code_gotot &code) { // we record the label used labels_used[code.get_destination()]=code.source_location(); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_gcc_computed_goto - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_gcc_computed_goto(codet &code) { if(code.operands().size()!=1) @@ -800,18 +599,6 @@ void c_typecheck_baset::typecheck_gcc_computed_goto(codet &code) dest.type()=empty_typet(); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_ifthenelse - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_ifthenelse(code_ifthenelset &code) { if(code.operands().size()!=3) @@ -861,18 +648,6 @@ void c_typecheck_baset::typecheck_ifthenelse(code_ifthenelset &code) } } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_start_thread - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_start_thread(codet &code) { if(code.operands().size()!=1) @@ -885,23 +660,13 @@ void c_typecheck_baset::typecheck_start_thread(codet &code) typecheck_code(to_code(code.op0())); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_return - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_return(codet &code) { if(code.operands().empty()) { - if(follow(return_type).id()!=ID_empty) + if(follow(return_type).id()!=ID_empty && + return_type.id()!=ID_constructor && + return_type.id()!=ID_destructor) { // gcc doesn't actually complain, it just warns! // We'll put a zero here, which is dubious. @@ -941,18 +706,6 @@ void c_typecheck_baset::typecheck_return(codet &code) } } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_switch - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_switch(code_switcht &code) { if(code.operands().size()!=2) @@ -984,18 +737,6 @@ void c_typecheck_baset::typecheck_switch(code_switcht &code) switch_op_type=old_switch_op_type; } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_while - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_while(code_whilet &code) { if(code.operands().size()!=2) @@ -1031,18 +772,6 @@ void c_typecheck_baset::typecheck_while(code_whilet &code) typecheck_spec_expr(code, ID_C_spec_loop_invariant); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_dowhile - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_dowhile(code_dowhilet &code) { if(code.operands().size()!=2) @@ -1078,18 +807,6 @@ void c_typecheck_baset::typecheck_dowhile(code_dowhilet &code) typecheck_spec_expr(code, ID_C_spec_loop_invariant); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_spec_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_spec_expr( codet &code, const irep_idt &spec) diff --git a/src/ansi-c/c_typecheck_expr.cpp b/src/ansi-c/c_typecheck_expr.cpp index 5d4788e5145..185c576e401 100644 --- a/src/ansi-c/c_typecheck_expr.cpp +++ b/src/ansi-c/c_typecheck_expr.cpp @@ -6,9 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// ANSI-C Language Type Checking + #include #include +#include #include #include #include @@ -19,7 +23,6 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -#include "c_types.h" #include "c_typecast.h" #include "c_typecheck_base.h" #include "c_sizeof.h" @@ -28,18 +31,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "anonymous_member.h" #include "padding.h" -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_expr(exprt &expr) { if(expr.id()==ID_already_typechecked) @@ -58,18 +49,6 @@ void c_typecheck_baset::typecheck_expr(exprt &expr) typecheck_expr_main(expr); } -/*******************************************************************\ - -Function: c_typecheck_baset::add_rounding_mode - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::add_rounding_mode(exprt &expr) { for(auto &op : expr.operands()) @@ -104,18 +83,6 @@ void c_typecheck_baset::add_rounding_mode(exprt &expr) } } -/*******************************************************************\ - -Function: c_typecheck_baset::gcc_types_compatible_p - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool c_typecheck_baset::gcc_types_compatible_p( const typet &type1, const typet &type2) @@ -198,18 +165,6 @@ bool c_typecheck_baset::gcc_types_compatible_p( return false; } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_expr_main - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_expr_main(exprt &expr) { if(expr.id()==ID_side_effect) @@ -459,6 +414,11 @@ void c_typecheck_baset::typecheck_expr_main(exprt &expr) expr.id()==ID_gcc_asm_clobbered_register) { } + else if(expr.id()==ID_lshr || expr.id()==ID_ashr || + expr.id()==ID_assign_lshr || expr.id()==ID_assign_ashr) + { + // already type checked + } else { err_location(expr); @@ -467,18 +427,6 @@ void c_typecheck_baset::typecheck_expr_main(exprt &expr) } } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_expr_comma - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_expr_comma(exprt &expr) { if(expr.operands().size()!=2) @@ -495,18 +443,6 @@ void c_typecheck_baset::typecheck_expr_comma(exprt &expr) expr.set(ID_C_lvalue, true); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_expr_builtin_va_arg - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_expr_builtin_va_arg(exprt &expr) { // The first parameter is the va_list, and the second @@ -552,18 +488,6 @@ void c_typecheck_baset::typecheck_expr_builtin_va_arg(exprt &expr) symbol_table.move(symbol); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_expr_cw_va_arg_typeof - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_expr_cw_va_arg_typeof(exprt &expr) { // used in Code Warrior via @@ -581,18 +505,6 @@ void c_typecheck_baset::typecheck_expr_cw_va_arg_typeof(exprt &expr) expr.type()=signed_int_type(); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_expr_builtin_offsetof - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_expr_builtin_offsetof(exprt &expr) { // these need not be constant, due to array indices! @@ -754,18 +666,6 @@ void c_typecheck_baset::typecheck_expr_builtin_offsetof(exprt &expr) expr.swap(result); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_expr_operands - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_expr_operands(exprt &expr) { if(expr.id()==ID_side_effect && @@ -837,18 +737,6 @@ void c_typecheck_baset::typecheck_expr_operands(exprt &expr) } } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_expr_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_expr_symbol(exprt &expr) { irep_idt identifier=to_symbol_expr(expr).get_identifier(); @@ -954,18 +842,6 @@ void c_typecheck_baset::typecheck_expr_symbol(exprt &expr) } } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_side_effect_statement_expression - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_side_effect_statement_expression( side_effect_exprt &expr) { @@ -1042,18 +918,6 @@ void c_typecheck_baset::typecheck_side_effect_statement_expression( expr.type()=typet(ID_empty); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_expr_sizeof - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_expr_sizeof(exprt &expr) { typet type; @@ -1116,18 +980,6 @@ void c_typecheck_baset::typecheck_expr_sizeof(exprt &expr) } } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_expr_alignof - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_expr_alignof(exprt &expr) { typet argument_type; @@ -1150,18 +1002,6 @@ void c_typecheck_baset::typecheck_expr_alignof(exprt &expr) expr.swap(tmp); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_expr_typecast - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_expr_typecast(exprt &expr) { if(expr.operands().size()!=1) @@ -1318,8 +1158,8 @@ void c_typecheck_baset::typecheck_expr_typecast(exprt &expr) // an integer/float of the same size if((expr_type.id()==ID_signedbv || expr_type.id()==ID_unsignedbv) && - pointer_offset_size(expr_type, *this)== - pointer_offset_size(op_vector_type, *this)) + pointer_offset_bits(expr_type, *this)== + pointer_offset_bits(op_vector_type, *this)) { } else @@ -1354,35 +1194,11 @@ void c_typecheck_baset::typecheck_expr_typecast(exprt &expr) } } -/*******************************************************************\ - -Function: c_typecheck_baset::make_index_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::make_index_type(exprt &expr) { implicit_typecast(expr, index_type()); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_expr_index - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_expr_index(exprt &expr) { if(expr.operands().size()!=2) @@ -1443,18 +1259,6 @@ void c_typecheck_baset::typecheck_expr_index(exprt &expr) expr.type()=final_array_type.subtype(); } -/*******************************************************************\ - -Function: c_typecheck_baset::adjust_float_rel - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::adjust_float_rel(exprt &expr) { // equality and disequality on float is not mathematical equality! @@ -1469,18 +1273,6 @@ void c_typecheck_baset::adjust_float_rel(exprt &expr) } } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_expr_rel - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_expr_rel( binary_relation_exprt &expr) { @@ -1587,18 +1379,6 @@ void c_typecheck_baset::typecheck_expr_rel( throw 0; } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_expr_rel_vector - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_expr_rel_vector( binary_relation_exprt &expr) { @@ -1625,18 +1405,6 @@ void c_typecheck_baset::typecheck_expr_rel_vector( expr.type()=vector_typet(signed_int_type(), to_vector_type(o_type0).size()); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_expr_ptrmember - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_expr_ptrmember(exprt &expr) { if(expr.operands().size()!=1) @@ -1672,18 +1440,6 @@ void c_typecheck_baset::typecheck_expr_ptrmember(exprt &expr) typecheck_expr_member(expr); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_expr_member - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_expr_member(exprt &expr) { if(expr.operands().size()!=1) @@ -1766,7 +1522,7 @@ void c_typecheck_baset::typecheck_expr_member(exprt &expr) // copy method identifier const irep_idt &identifier=component.get(ID_C_identifier); - if(identifier!=irep_idt()) + if(!identifier.empty()) expr.set(ID_C_identifier, identifier); const irep_idt &access=component.get_access(); @@ -1780,18 +1536,6 @@ void c_typecheck_baset::typecheck_expr_member(exprt &expr) } } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_expr_trinary - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_expr_trinary(if_exprt &expr) { exprt::operandst &operands=expr.operands(); @@ -1885,18 +1629,6 @@ void c_typecheck_baset::typecheck_expr_trinary(if_exprt &expr) throw 0; } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_side_effect_gcc_conditional_expresssion - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_side_effect_gcc_conditional_expression( side_effect_exprt &expr) { @@ -1928,18 +1660,6 @@ void c_typecheck_baset::typecheck_side_effect_gcc_conditional_expression( expr.type()=if_expr.type(); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_expr_address_of - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_expr_address_of(exprt &expr) { if(expr.operands().size()!=1) @@ -2010,18 +1730,6 @@ void c_typecheck_baset::typecheck_expr_address_of(exprt &expr) expr.type()=pointer_type(op.type()); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_expr_dereference - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_expr_dereference(exprt &expr) { if(expr.operands().size()!=1) @@ -2065,18 +1773,6 @@ void c_typecheck_baset::typecheck_expr_dereference(exprt &expr) typecheck_expr_function_identifier(expr); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_expr_function_identifier - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_expr_function_identifier(exprt &expr) { if(expr.type().id()==ID_code) @@ -2089,18 +1785,6 @@ void c_typecheck_baset::typecheck_expr_function_identifier(exprt &expr) } } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_expr_side_effect - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_expr_side_effect(side_effect_exprt &expr) { const irep_idt &statement=expr.get_statement(); @@ -2192,18 +1876,6 @@ void c_typecheck_baset::typecheck_expr_side_effect(side_effect_exprt &expr) } } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_side_effect_function_call - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_side_effect_function_call( side_effect_expr_function_callt &expr) { @@ -2312,18 +1984,6 @@ void c_typecheck_baset::typecheck_side_effect_function_call( typecheck_function_call_arguments(expr); } -/*******************************************************************\ - -Function: c_typecheck_baset::do_special_functions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt c_typecheck_baset::do_special_functions( side_effect_expr_function_callt &expr) { @@ -2473,10 +2133,12 @@ exprt c_typecheck_baset::do_special_functions( throw 0; } - exprt pointer_offset_expr=exprt(ID_pointer_offset, expr.type()); - pointer_offset_expr.operands()=expr.arguments(); + exprt pointer_offset_expr=pointer_offset(expr.arguments().front()); pointer_offset_expr.add_source_location()=source_location; + if(expr.type()!=pointer_offset_expr.type()) + pointer_offset_expr.make_typecast(expr.type()); + return pointer_offset_expr; } else if(identifier==CPROVER_PREFIX "POINTER_OBJECT") @@ -2928,18 +2590,8 @@ exprt c_typecheck_baset::do_special_functions( return nil_exprt(); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_function_call_arguments - - Inputs: type-checked arguments, type-checked function - - Outputs: type-adjusted function arguments - - Purpose: - -\*******************************************************************/ - +/// \param type:checked arguments, type-checked function +/// \return type-adjusted function arguments void c_typecheck_baset::typecheck_function_call_arguments( side_effect_expr_function_callt &expr) { @@ -3022,35 +2674,11 @@ void c_typecheck_baset::typecheck_function_call_arguments( } } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_expr_constant - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_expr_constant(exprt &expr) { // nothing to do } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_expr_unary_arithmetic - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_expr_unary_arithmetic(exprt &expr) { if(expr.operands().size()!=1) @@ -3090,18 +2718,6 @@ void c_typecheck_baset::typecheck_expr_unary_arithmetic(exprt &expr) throw 0; } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_expr_unary_boolean - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_expr_unary_boolean(exprt &expr) { if(expr.operands().size()!=1) @@ -3124,18 +2740,6 @@ void c_typecheck_baset::typecheck_expr_unary_boolean(exprt &expr) expr.type()=bool_typet(); } -/*******************************************************************\ - -Function: c_typecheck_baset::gcc_vector_types_compatible - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool c_typecheck_baset::gcc_vector_types_compatible( const vector_typet &type0, const vector_typet &type1) @@ -3163,18 +2767,6 @@ bool c_typecheck_baset::gcc_vector_types_compatible( return type0.subtype()==type1.subtype(); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_expr_binary_arithmetic - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_expr_binary_arithmetic(exprt &expr) { if(expr.operands().size()!=2) @@ -3276,18 +2868,6 @@ void c_typecheck_baset::typecheck_expr_binary_arithmetic(exprt &expr) throw 0; } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_expr_shifts - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_expr_shifts(shift_exprt &expr) { assert(expr.id()==ID_shl || expr.id()==ID_shr); @@ -3357,18 +2937,6 @@ void c_typecheck_baset::typecheck_expr_shifts(shift_exprt &expr) throw 0; } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_arithmetic_pointer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_arithmetic_pointer(const exprt &expr) { const typet &type=expr.type(); @@ -3387,18 +2955,6 @@ void c_typecheck_baset::typecheck_arithmetic_pointer(const exprt &expr) } } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_expr_pointer_arithmetic - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_expr_pointer_arithmetic(exprt &expr) { assert(expr.operands().size()==2); @@ -3489,18 +3045,6 @@ void c_typecheck_baset::typecheck_expr_pointer_arithmetic(exprt &expr) throw 0; } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_expr_binary_boolean - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_expr_binary_boolean(exprt &expr) { if(expr.operands().size()!=2) @@ -3522,18 +3066,6 @@ void c_typecheck_baset::typecheck_expr_binary_boolean(exprt &expr) expr.type()=bool_typet(); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_side_effect_assignment - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_side_effect_assignment( side_effect_exprt &expr) { @@ -3728,18 +3260,6 @@ void c_typecheck_baset::typecheck_side_effect_assignment( throw 0; } -/*******************************************************************\ - -Function: c_typecheck_baset::make_constant - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::make_constant(exprt &expr) { make_constant_rec(expr); @@ -3755,18 +3275,6 @@ void c_typecheck_baset::make_constant(exprt &expr) } } -/*******************************************************************\ - -Function: c_typecheck_baset::make_constant_index - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::make_constant_index(exprt &expr) { make_constant(expr); @@ -3782,18 +3290,6 @@ void c_typecheck_baset::make_constant_index(exprt &expr) } } -/*******************************************************************\ - -Function: c_typecheck_baset::make_constant_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::make_constant_rec(exprt &expr) { } diff --git a/src/ansi-c/c_typecheck_initializer.cpp b/src/ansi-c/c_typecheck_initializer.cpp index 79dabc9f0e9..db3280f12a9 100644 --- a/src/ansi-c/c_typecheck_initializer.cpp +++ b/src/ansi-c/c_typecheck_initializer.cpp @@ -6,8 +6,11 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// ANSI-C Conversion / Type Checking + #include -#include +#include #include #include #include @@ -16,23 +19,10 @@ Author: Daniel Kroening, kroening@kroening.com #include -#include "c_types.h" #include "c_typecheck_base.h" #include "string_constant.h" #include "anonymous_member.h" -/*******************************************************************\ - -Function: c_typecheck_baset::do_initializer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::do_initializer( exprt &initializer, const typet &type, @@ -60,19 +50,7 @@ void c_typecheck_baset::do_initializer( initializer=result; } -/*******************************************************************\ - -Function: c_typecheck_baset::do_initializer_rec - - Inputs: - - Outputs: - - Purpose: initialize something of type `type' with given - value `value' - -\*******************************************************************/ - +/// initialize something of type `type' with given value `value' exprt c_typecheck_baset::do_initializer_rec( const exprt &value, const typet &type, @@ -230,18 +208,6 @@ exprt c_typecheck_baset::do_initializer_rec( return result; } -/*******************************************************************\ - -Function: c_typecheck_baset::do_initializer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::do_initializer(symbolt &symbol) { // this one doesn't need initialization @@ -285,18 +251,6 @@ void c_typecheck_baset::do_initializer(symbolt &symbol) } } -/*******************************************************************\ - -Function: c_typecheck_baset::designator_enter - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::designator_enter( const typet &type, designatort &designator) @@ -394,18 +348,8 @@ void c_typecheck_baset::designator_enter( designator.push_entry(entry); } -/*******************************************************************\ - -Function: c_typecheck_baset::do_designated_initializer - - Inputs: pre-initialized result, designator - - Outputs: sets result - - Purpose: - -\*******************************************************************/ - +/// \param pre:initialized result, designator +/// \return sets result void c_typecheck_baset::do_designated_initializer( exprt &result, designatort &designator, @@ -646,18 +590,6 @@ void c_typecheck_baset::do_designated_initializer( } } -/*******************************************************************\ - -Function: c_typecheck_baset::increment_designator - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::increment_designator(designatort &designator) { assert(!designator.empty()); @@ -706,18 +638,6 @@ void c_typecheck_baset::increment_designator(designatort &designator) } } -/*******************************************************************\ - -Function: c_typecheck_baset::make_designator - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - designatort c_typecheck_baset::make_designator( const typet &src_type, const exprt &src) @@ -865,18 +785,6 @@ designatort c_typecheck_baset::make_designator( return designator; } -/*******************************************************************\ - -Function: c_typecheck_baset::do_initializer_list - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt c_typecheck_baset::do_initializer_list( const exprt &value, const typet &type, diff --git a/src/ansi-c/c_typecheck_type.cpp b/src/ansi-c/c_typecheck_type.cpp index ac3fe7f2928..448df44cef4 100644 --- a/src/ansi-c/c_typecheck_type.cpp +++ b/src/ansi-c/c_typecheck_type.cpp @@ -6,8 +6,12 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include +#include #include #include #include @@ -15,7 +19,6 @@ Author: Daniel Kroening, kroening@kroening.com #include #include "c_typecheck_base.h" -#include "c_types.h" #include "c_sizeof.h" #include "c_qualifiers.h" #include "ansi_c_declaration.h" @@ -23,18 +26,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "type2name.h" #include "ansi_c_convert_type.h" -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_type(typet &type) { // we first convert, and then check @@ -134,39 +125,74 @@ void c_typecheck_baset::typecheck_type(typet &type) typet result; if(mode=="__QI__") // 8 bits - result=is_signed?signed_char_type():unsigned_char_type(); + if(is_signed) + result=signed_char_type(); + else + result=unsigned_char_type(); else if(mode=="__byte__") // 8 bits - result=is_signed?signed_char_type():unsigned_char_type(); + if(is_signed) + result=signed_char_type(); + else + result=unsigned_char_type(); else if(mode=="__HI__") // 16 bits - result=is_signed?signed_short_int_type():unsigned_short_int_type(); + if(is_signed) + result=signed_short_int_type(); + else + result=unsigned_short_int_type(); else if(mode=="__SI__") // 32 bits - result=is_signed?signed_int_type():unsigned_int_type(); + if(is_signed) + result=signed_int_type(); + else + result=unsigned_int_type(); else if(mode=="__word__") // long int, we think - result=is_signed?signed_long_int_type():unsigned_long_int_type(); + if(is_signed) + result=signed_long_int_type(); + else + result=unsigned_long_int_type(); else if(mode=="__pointer__") // we think this is size_t/ssize_t - result=is_signed?signed_size_type():size_type(); + if(is_signed) + result=signed_size_type(); + else + result=size_type(); else if(mode=="__DI__") // 64 bits { if(config.ansi_c.long_int_width==64) - result=is_signed?signed_long_int_type():unsigned_long_int_type(); + if(is_signed) + result=signed_long_int_type(); + else + result=unsigned_long_int_type(); else { assert(config.ansi_c.long_long_int_width==64); - result= - is_signed?signed_long_long_int_type():unsigned_long_long_int_type(); + + if(is_signed) + result=signed_long_long_int_type(); + else + result=unsigned_long_long_int_type(); } } else if(mode=="__TI__") // 128 bits - result=is_signed?gcc_signed_int128_type():gcc_unsigned_int128_type(); + if(is_signed) + result=gcc_signed_int128_type(); + else + result=gcc_unsigned_int128_type(); else if(mode=="__V2SI__") // vector of 2 ints, deprecated by gcc - result= - vector_typet( - is_signed?signed_int_type():unsigned_int_type(), + if(is_signed) + result=vector_typet( + signed_int_type(), + from_integer(2, size_type())); + else + result=vector_typet( + unsigned_int_type(), from_integer(2, size_type())); else if(mode=="__V4SI__") // vector of 4 ints, deprecated by gcc - result= - vector_typet( - is_signed?signed_int_type():unsigned_int_type(), + if(is_signed) + result=vector_typet( + signed_int_type(), + from_integer(4, size_type())); + else + result=vector_typet( + unsigned_int_type(), from_integer(4, size_type())); else // give up, just use subtype result=type.subtype(); @@ -255,18 +281,6 @@ void c_typecheck_baset::typecheck_type(typet &type) } } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_custom_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_custom_type(typet &type) { // they all have a width @@ -367,18 +381,6 @@ void c_typecheck_baset::typecheck_custom_type(typet &type) assert(false); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_code_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_code_type(code_typet &type) { // the return type is still 'subtype()' @@ -426,7 +428,7 @@ void c_typecheck_baset::typecheck_code_type(code_typet &type) irep_idt identifier=declaration.declarator().get_name(); // abstract or not? - if(identifier==irep_idt()) + if(identifier.empty()) { // abstract parameter.add_source_location()=declaration.type().source_location(); @@ -478,18 +480,6 @@ void c_typecheck_baset::typecheck_code_type(code_typet &type) } } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_array_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_array_type(array_typet &type) { exprt &size=type.size(); @@ -560,7 +550,7 @@ void c_typecheck_baset::typecheck_array_type(array_typet &type) { // not a constant and not infinity - assert(current_symbol_id!=irep_idt()); + assert(!current_symbol_id.empty()); const symbolt &base_symbol=lookup(current_symbol_id); @@ -616,18 +606,6 @@ void c_typecheck_baset::typecheck_array_type(array_typet &type) } } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_vector_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_vector_type(vector_typet &type) { exprt &size=type.size(); @@ -709,18 +687,6 @@ void c_typecheck_baset::typecheck_vector_type(vector_typet &type) type.size()=from_integer(s, signed_size_type()); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_compound_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_compound_type(struct_union_typet &type) { // These get replaced by symbol types later. @@ -833,18 +799,6 @@ void c_typecheck_baset::typecheck_compound_type(struct_union_typet &type) original_qualifiers.write(type); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_compound_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_compound_body( struct_union_typet &type) { @@ -908,7 +862,7 @@ void c_typecheck_baset::typecheck_compound_body( // scan for anonymous members, and name them for(auto &member : components) { - if(member.get_name()!=irep_idt()) + if(!member.get_name().empty()) continue; member.set_name("$anon"+std::to_string(anon_member_counter++)); @@ -1021,18 +975,6 @@ void c_typecheck_baset::typecheck_compound_body( } } -/*******************************************************************\ - -Function: c_typecheck_baset::enum_constant_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet c_typecheck_baset::enum_constant_type( const mp_integer &min_value, const mp_integer &max_value) const @@ -1065,18 +1007,6 @@ typet c_typecheck_baset::enum_constant_type( } } -/*******************************************************************\ - -Function: c_typecheck_baset::enum_underlying_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet c_typecheck_baset::enum_underlying_type( const mp_integer &min_value, const mp_integer &max_value, @@ -1135,18 +1065,6 @@ typet c_typecheck_baset::enum_underlying_type( } } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_c_enum_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_c_enum_type(typet &type) { // These come with the declarations @@ -1330,18 +1248,6 @@ void c_typecheck_baset::typecheck_c_enum_type(typet &type) type.set(ID_identifier, identifier); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_c_enum_tag_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_c_enum_tag_type(c_enum_tag_typet &type) { // It's just a tag. @@ -1401,18 +1307,6 @@ void c_typecheck_baset::typecheck_c_enum_tag_type(c_enum_tag_typet &type) type.set_identifier(identifier); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_c_bit_field_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_c_bit_field_type(c_bit_field_typet &type) { typecheck_type(type.subtype()); @@ -1493,18 +1387,6 @@ void c_typecheck_baset::typecheck_c_bit_field_type(c_bit_field_typet &type) } } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_typeof_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_typeof_type(typet &type) { // save location @@ -1542,18 +1424,6 @@ void c_typecheck_baset::typecheck_typeof_type(typet &type) c_qualifiers.write(type); } -/*******************************************************************\ - -Function: c_typecheck_baset::typecheck_symbol_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::typecheck_symbol_type(typet &type) { const irep_idt &identifier= @@ -1608,18 +1478,6 @@ void c_typecheck_baset::typecheck_symbol_type(typet &type) } } -/*******************************************************************\ - -Function: c_typecheck_baset::adjust_function_parameter - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::adjust_function_parameter(typet &type) const { if(type.id()==ID_array) diff --git a/src/ansi-c/c_typecheck_typecast.cpp b/src/ansi-c/c_typecheck_typecast.cpp index 5d1cfad1332..62069d90feb 100644 --- a/src/ansi-c/c_typecheck_typecast.cpp +++ b/src/ansi-c/c_typecheck_typecast.cpp @@ -6,21 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include "c_typecast.h" #include "c_typecheck_base.h" -#include "c_types.h" - -/*******************************************************************\ - -Function: c_typecheck_baset::implicit_typecast - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ void c_typecheck_baset::implicit_typecast( exprt &expr, @@ -62,18 +50,6 @@ void c_typecheck_baset::implicit_typecast( } } -/*******************************************************************\ - -Function: c_typecheck_baset::implicit_typecast_arithmetic - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::implicit_typecast_arithmetic( exprt &expr1, exprt &expr2) @@ -82,18 +58,6 @@ void c_typecheck_baset::implicit_typecast_arithmetic( c_typecast.implicit_typecast_arithmetic(expr1, expr2); } -/*******************************************************************\ - -Function: c_typecheck_baset::implicit_typecast_arithmetic - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void c_typecheck_baset::implicit_typecast_arithmetic(exprt &expr) { c_typecastt c_typecast(*this); diff --git a/src/ansi-c/c_types.cpp b/src/ansi-c/c_types.cpp deleted file mode 100644 index 6ba5ddaefb3..00000000000 --- a/src/ansi-c/c_types.cpp +++ /dev/null @@ -1,721 +0,0 @@ -/*******************************************************************\ - -Module: - -Author: Daniel Kroening, kroening@kroening.com - -\*******************************************************************/ - -#include -#include - -#include "c_types.h" - -/*******************************************************************\ - -Function: index_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -typet index_type() -{ - // same as signed size type - return signed_size_type(); -} - -/*******************************************************************\ - -Function: enum_constant_type - - Inputs: - - Outputs: - - Purpose: return type of enum constants - -\*******************************************************************/ - -typet enum_constant_type() -{ - // usually same as 'int', - // but might be unsigned, or shorter than 'int' - return signed_int_type(); -} - -/*******************************************************************\ - -Function: signed_int_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -typet signed_int_type() -{ - typet result=signedbv_typet(config.ansi_c.int_width); - result.set(ID_C_c_type, ID_signed_int); - return result; -} - -/*******************************************************************\ - -Function: signed_short_int_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -typet signed_short_int_type() -{ - typet result=signedbv_typet(config.ansi_c.short_int_width); - result.set(ID_C_c_type, ID_signed_short_int); - return result; -} - -/*******************************************************************\ - -Function: unsigned_int_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -typet unsigned_int_type() -{ - typet result=unsignedbv_typet(config.ansi_c.int_width); - result.set(ID_C_c_type, ID_unsigned_int); - return result; -} - -/*******************************************************************\ - -Function: unsigned_short_int_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -typet unsigned_short_int_type() -{ - typet result=unsignedbv_typet(config.ansi_c.short_int_width); - result.set(ID_C_c_type, ID_unsigned_short_int); - return result; -} - -/*******************************************************************\ - -Function: size_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -typet size_type() -{ - // The size type varies. This is unsigned int on some systems, - // and unsigned long int on others, - // and unsigned long long on say Windows 64. - - if(config.ansi_c.pointer_width==config.ansi_c.int_width) - return unsigned_int_type(); - else if(config.ansi_c.pointer_width==config.ansi_c.long_int_width) - return unsigned_long_int_type(); - else if(config.ansi_c.pointer_width==config.ansi_c.long_long_int_width) - return unsigned_long_long_int_type(); - else - assert(false); // aaah! -} - -/*******************************************************************\ - -Function: signed_size_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -typet signed_size_type() -{ - // we presume this is the same as pointer difference - return pointer_diff_type(); -} - -/*******************************************************************\ - -Function: signed_long_int_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -typet signed_long_int_type() -{ - typet result=signedbv_typet(config.ansi_c.long_int_width); - result.set(ID_C_c_type, ID_signed_long_int); - return result; -} - -/*******************************************************************\ - -Function: signed_long_long_int_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -typet signed_long_long_int_type() -{ - typet result=signedbv_typet(config.ansi_c.long_long_int_width); - result.set(ID_C_c_type, ID_signed_long_long_int); - return result; -} - -/*******************************************************************\ - -Function: unsigned_long_int_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -typet unsigned_long_int_type() -{ - typet result=unsignedbv_typet(config.ansi_c.long_int_width); - result.set(ID_C_c_type, ID_unsigned_long_int); - return result; -} - -/*******************************************************************\ - -Function: unsigned_long_long_int_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -typet unsigned_long_long_int_type() -{ - typet result=unsignedbv_typet(config.ansi_c.long_long_int_width); - result.set(ID_C_c_type, ID_unsigned_long_long_int); - return result; -} - -/*******************************************************************\ - -Function: c_bool_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -typet c_bool_type() -{ - typet result=c_bool_typet(config.ansi_c.bool_width); - return result; -} - -/*******************************************************************\ - -Function: char_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -typet char_type() -{ - typet result; - - // this can be signed or unsigned, depending on the architecture - - if(config.ansi_c.char_is_unsigned) - result=unsignedbv_typet(config.ansi_c.char_width); - else - result=signedbv_typet(config.ansi_c.char_width); - - // There are 3 char types, i.e., this one is - // different from either signed char or unsigned char! - - result.set(ID_C_c_type, ID_char); - - return result; -} - -/*******************************************************************\ - -Function: unsigned_char_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -typet unsigned_char_type() -{ - typet result=unsignedbv_typet(config.ansi_c.char_width); - - result.set(ID_C_c_type, ID_unsigned_char); - - return result; -} - -/*******************************************************************\ - -Function: signed_char_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -typet signed_char_type() -{ - typet result=signedbv_typet(config.ansi_c.char_width); - - result.set(ID_C_c_type, ID_signed_char); - - return result; -} - -/*******************************************************************\ - -Function: wchar_t_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -typet wchar_t_type() -{ - typet result; - - if(config.ansi_c.wchar_t_is_unsigned) - result=unsignedbv_typet(config.ansi_c.wchar_t_width); - else - result=signedbv_typet(config.ansi_c.wchar_t_width); - - result.set(ID_C_c_type, ID_wchar_t); - - return result; -} - -/*******************************************************************\ - -Function: char16_t_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -typet char16_t_type() -{ - typet result; - - // Types char16_t and char32_t denote distinct types with the same size, - // signedness, and alignment as uint_least16_t and uint_least32_t, - // respectively, in , called the underlying types. - result=unsignedbv_typet(16); - - result.set(ID_C_c_type, ID_char16_t); - - return result; -} - -/*******************************************************************\ - -Function: char32_t_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -typet char32_t_type() -{ - typet result; - - // Types char16_t and char32_t denote distinct types with the same size, - // signedness, and alignment as uint_least16_t and uint_least32_t, - // respectively, in , called the underlying types. - result=unsignedbv_typet(32); - - result.set(ID_C_c_type, ID_char32_t); - - return result; -} - -/*******************************************************************\ - -Function: float_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -typet float_type() -{ - typet result; - - if(config.ansi_c.use_fixed_for_float) - { - fixedbv_typet tmp; - tmp.set_width(config.ansi_c.single_width); - tmp.set_integer_bits(config.ansi_c.single_width/2); - result=tmp; - } - else - result=ieee_float_spect::single_precision().to_type(); - - result.set(ID_C_c_type, ID_float); - - return result; -} - -/*******************************************************************\ - -Function: double_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -typet double_type() -{ - typet result; - - if(config.ansi_c.use_fixed_for_float) - { - fixedbv_typet tmp; - tmp.set_width(config.ansi_c.double_width); - tmp.set_integer_bits(config.ansi_c.double_width/2); - result=tmp; - } - else - result=ieee_float_spect::double_precision().to_type(); - - result.set(ID_C_c_type, ID_double); - - return result; -} - -/*******************************************************************\ - -Function: long_double_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -typet long_double_type() -{ - typet result; - - if(config.ansi_c.use_fixed_for_float) - { - fixedbv_typet tmp; - tmp.set_width(config.ansi_c.long_double_width); - tmp.set_integer_bits(config.ansi_c.long_double_width/2); - result=tmp; - } - else - { - if(config.ansi_c.long_double_width==128) - result=ieee_float_spect::quadruple_precision().to_type(); - else if(config.ansi_c.long_double_width==64) - result=ieee_float_spect::double_precision().to_type(); - else if(config.ansi_c.long_double_width==80) - { - // x86 extended precision has 80 bits in total, and - // deviating from IEEE, does not use a hidden bit. - // We use the closest we have got, but the below isn't accurate. - result=ieee_float_spect(63, 15).to_type(); - } - else if(config.ansi_c.long_double_width==96) - { - result=ieee_float_spect(80, 15).to_type(); - // not quite right. The extra bits beyond 80 are usually padded. - } - else - assert(false); - } - - result.set(ID_C_c_type, ID_long_double); - - return result; -} - -/*******************************************************************\ - -Function: gcc_float128_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -typet gcc_float128_type() -{ - typet result; - - if(config.ansi_c.use_fixed_for_float) - { - fixedbv_typet tmp; - tmp.set_width(128); - tmp.set_integer_bits(128/2); - result=tmp; - } - else - { - result=ieee_float_spect::quadruple_precision().to_type(); - } - - // not same as long double! - result.set(ID_C_c_type, ID_gcc_float128); - - return result; -} - -/*******************************************************************\ - -Function: pointer_diff_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -typet pointer_diff_type() -{ - // The pointer-diff type varies. This is signed int on some systems, - // and signed long int on others, and signed long long on say Windows. - - if(config.ansi_c.pointer_width==config.ansi_c.int_width) - return signed_int_type(); - else if(config.ansi_c.pointer_width==config.ansi_c.long_int_width) - return signed_long_int_type(); - else if(config.ansi_c.pointer_width==config.ansi_c.long_long_int_width) - return signed_long_long_int_type(); - else - assert(false); // aaah! -} - -/*******************************************************************\ - -Function: pointer_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -typet pointer_type(const typet &subtype) -{ - return pointer_typet(subtype); -} - -/*******************************************************************\ - -Function: void_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -typet void_type() -{ - return empty_typet(); -} - -/*******************************************************************\ - -Function: gcc_unsigned_int128_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -typet gcc_unsigned_int128_type() -{ - typet result=unsignedbv_typet(128); - result.set(ID_C_c_type, ID_unsigned_int128); - return result; -} - -/*******************************************************************\ - -Function: gcc_signed_int128_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -typet gcc_signed_int128_type() -{ - typet result=signedbv_typet(128); - result.set(ID_C_c_type, ID_signed_int128); - return result; -} - -/*******************************************************************\ - -Function: c_type_as_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -std::string c_type_as_string(const irep_idt &c_type) -{ - if(c_type==ID_signed_int) - return "signed int"; - else if(c_type==ID_signed_short_int) - return "signed short int"; - else if(c_type==ID_unsigned_int) - return "unsigned int"; - else if(c_type==ID_unsigned_short_int) - return "unsigned short int"; - else if(c_type==ID_signed_long_int) - return "signed long int"; - else if(c_type==ID_signed_long_long_int) - return "signed long long int"; - else if(c_type==ID_unsigned_long_int) - return "unsigned long int"; - else if(c_type==ID_unsigned_long_long_int) - return "unsigned long long int"; - else if(c_type==ID_bool) - return "_Bool"; - else if(c_type==ID_char) - return "char"; - else if(c_type==ID_unsigned_char) - return "unsigned char"; - else if(c_type==ID_signed_char) - return "signed char"; - else if(c_type==ID_wchar_t) - return "wchar_t"; - else if(c_type==ID_char16_t) - return "char16_t"; - else if(c_type==ID_char32_t) - return "char32_t"; - else if(c_type==ID_float) - return "float"; - else if(c_type==ID_double) - return "double"; - else if(c_type==ID_long_double) - return "long double"; - else if(c_type==ID_gcc_float128) - return "__float128"; - else if(c_type==ID_unsigned_int128) - return "unsigned __int128"; - else if(c_type==ID_signed_int128) - return "signed __int128"; - else - return ""; -} diff --git a/src/ansi-c/c_types.h b/src/ansi-c/c_types.h deleted file mode 100644 index 6c571bd448b..00000000000 --- a/src/ansi-c/c_types.h +++ /dev/null @@ -1,47 +0,0 @@ -/*******************************************************************\ - -Module: - -Author: Daniel Kroening, kroening@kroening.com - -\*******************************************************************/ - -#ifndef CPROVER_ANSI_C_C_TYPES_H -#define CPROVER_ANSI_C_C_TYPES_H - -#include - -typet index_type(); -typet enum_constant_type(); -typet signed_int_type(); -typet unsigned_int_type(); -typet signed_long_int_type(); -typet signed_short_int_type(); -typet unsigned_short_int_type(); -typet signed_long_long_int_type(); -typet unsigned_long_int_type(); -typet unsigned_long_long_int_type(); -typet c_bool_type(); -typet char_type(); -typet unsigned_char_type(); -typet signed_char_type(); -typet wchar_t_type(); -typet char16_t_type(); -typet char32_t_type(); -typet float_type(); -typet double_type(); -typet long_double_type(); -typet gcc_float128_type(); -typet gcc_unsigned_int128_type(); -typet gcc_signed_int128_type(); -typet size_type(); -typet signed_size_type(); -typet pointer_diff_type(); -typet pointer_type(const typet &); -typet void_type(); - -// Turns an ID_C_c_type into a string, e.g., -// ID_signed_int gets "signed int". -std::string c_type_as_string(const irep_idt &); - -#endif // CPROVER_ANSI_C_C_TYPES_H diff --git a/src/ansi-c/cprover_library.cpp b/src/ansi-c/cprover_library.cpp index 382ec324636..6b7f05af994 100644 --- a/src/ansi-c/cprover_library.cpp +++ b/src/ansi-c/cprover_library.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -21,18 +22,6 @@ struct cprover_library_entryt #include "cprover_library.inc" ; // NOLINT(whitespace/semicolon) -/*******************************************************************\ - -Function: get_cprover_library_text - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string get_cprover_library_text( const std::set &functions, const symbol_tablet &symbol_table) @@ -74,18 +63,6 @@ std::string get_cprover_library_text( return library_text.str(); } -/*******************************************************************\ - -Function: add_cprover_library - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void add_cprover_library( const std::set &functions, symbol_tablet &symbol_table, @@ -101,18 +78,6 @@ void add_cprover_library( add_library(library_text, symbol_table, message_handler); } -/*******************************************************************\ - -Function: add_library - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void add_library( const std::string &src, symbol_tablet &symbol_table, diff --git a/src/ansi-c/cprover_library.h b/src/ansi-c/cprover_library.h index 9b6012cbeef..6f36eb5abca 100644 --- a/src/ansi-c/cprover_library.h +++ b/src/ansi-c/cprover_library.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_ANSI_C_CPROVER_LIBRARY_H #define CPROVER_ANSI_C_CPROVER_LIBRARY_H diff --git a/src/ansi-c/designator.cpp b/src/ansi-c/designator.cpp index 88657e71407..1d54f11d5f1 100644 --- a/src/ansi-c/designator.cpp +++ b/src/ansi-c/designator.cpp @@ -6,22 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// ANSI-C Language Type Checking + #include #include "designator.h" -/*******************************************************************\ - -Function: designatort::print - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void designatort::print(std::ostream &out) const { for(index_listt::const_iterator it=index_list.begin(); diff --git a/src/ansi-c/designator.h b/src/ansi-c/designator.h index 019f622ef63..d31d3bb3e66 100644 --- a/src/ansi-c/designator.h +++ b/src/ansi-c/designator.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// ANSI-C Language Type Checking + #ifndef CPROVER_ANSI_C_DESIGNATOR_H #define CPROVER_ANSI_C_DESIGNATOR_H diff --git a/src/ansi-c/expr2c.cpp b/src/ansi-c/expr2c.cpp index e8ccb805a76..4f18ea3db29 100644 --- a/src/ansi-c/expr2c.cpp +++ b/src/ansi-c/expr2c.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include @@ -20,6 +21,7 @@ Author: Daniel Kroening, kroening@kroening.com #include #include +#include #include #include #include @@ -37,7 +39,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "c_misc.h" #include "c_qualifiers.h" #include "expr2c.h" -#include "c_types.h" #include "expr2c_class.h" /* @@ -51,18 +52,6 @@ Precedences are as follows. Higher values mean higher precedence. */ -/*******************************************************************\ - -Function: expr2ct::id_shorthand - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - irep_idt expr2ct::id_shorthand(const irep_idt &identifier) const { const symbolt *symbol; @@ -81,18 +70,6 @@ irep_idt expr2ct::id_shorthand(const irep_idt &identifier) const return sh; } -/*******************************************************************\ - -Function: clean_identifier - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static std::string clean_identifier(const irep_idt &id) { std::string dest=id2string(id); @@ -115,18 +92,6 @@ static std::string clean_identifier(const irep_idt &id) return dest; } -/*******************************************************************\ - -Function: expr2ct::get_shorthands - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void expr2ct::get_shorthands(const exprt &expr) { find_symbols_sett symbols; @@ -190,35 +155,11 @@ void expr2ct::get_shorthands(const exprt &expr) } } -/*******************************************************************\ - -Function: expr2ct::convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert(const typet &src) { return convert_rec(src, c_qualifierst(), ""); } -/*******************************************************************\ - -Function: expr2ct::convert_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_rec( const typet &src, const c_qualifierst &qualifiers, @@ -706,21 +647,12 @@ std::string expr2ct::convert_rec( } } -/*******************************************************************\ - -Function: expr2ct::convert_struct_type - - Inputs: - src - the struct type being converted - qualifiers - any qualifiers on the type - declarator - the declarator on the type - - Outputs: Returns a type declaration for a struct, containing the - body of the struct and in that body the padding parameters. - - Purpose: To generate C-like string for defining the given struct - -\*******************************************************************/ +/// To generate C-like string for defining the given struct +/// \param src: the struct type being converted +/// \param qualifiers: any qualifiers on the type +/// \param declarator: the declarator on the type +/// \return Returns a type declaration for a struct, containing the body of the +/// struct and in that body the padding parameters. std::string expr2ct::convert_struct_type( const typet &src, const std::string &qualifiers_str, @@ -729,26 +661,16 @@ std::string expr2ct::convert_struct_type( return convert_struct_type(src, qualifiers_str, declarator_str, true, true); } -/*******************************************************************\ - -Function: expr2ct::convert_struct_type - - Inputs: - src - the struct type being converted - qualifiers - any qualifiers on the type - declarator - the declarator on the type - inc_struct_body - when generating the code, should we include - a complete definition of the struct - inc_padding_components - should the padding parameters be included - Note this only makes sense if inc_struct_body - - Outputs: Returns a type declaration for a struct, optionally containing the - body of the struct (and in that body, optionally the padding - parameters). - - Purpose: To generate C-like string for declaring (or defining) the given struct - -\*******************************************************************/ +/// To generate C-like string for declaring (or defining) the given struct +/// \param src: the struct type being converted +/// \param qualifiers: any qualifiers on the type +/// \param declarator: the declarator on the type +/// \param inc_struct_body: when generating the code, should we include a +/// complete definition of the struct +/// \param inc_padding_components: should the padding parameters be included +/// Note this only makes sense if inc_struct_body +/// \return Returns a type declaration for a struct, optionally containing the +/// body of the struct (and in that body, optionally the padding parameters). std::string expr2ct::convert_struct_type( const typet &src, const std::string &qualifiers, @@ -798,22 +720,12 @@ std::string expr2ct::convert_struct_type( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_array_type - - Inputs: - src - The array type to convert - qualifier - declarator_str - - Outputs: A C-like type declaration of an array - - Purpose: To generate a C-like type declaration of an array. Includes - the size of the array in the [] - -\*******************************************************************/ - +/// To generate a C-like type declaration of an array. Includes the size of the +/// array in the [] +/// \param src: The array type to convert +/// qualifier +/// declarator_str +/// \return A C-like type declaration of an array std::string expr2ct::convert_array_type( const typet &src, const c_qualifierst &qualifiers, @@ -822,24 +734,14 @@ std::string expr2ct::convert_array_type( return convert_array_type(src, qualifiers, declarator_str, true); } -/*******************************************************************\ - -Function: expr2ct::convert_array_type - - Inputs: - src - The array type to convert - qualifier - declarator_str - inc_size_if_possible - Should the generated string include - the size of the array (if it is known). - - Outputs: A C-like type declaration of an array - - Purpose: To generate a C-like type declaration of an array. Optionally - can include or exclude the size of the array in the [] - -\*******************************************************************/ - +/// To generate a C-like type declaration of an array. Optionally can include or +/// exclude the size of the array in the [] +/// \param src: The array type to convert +/// qualifier +/// declarator_str +/// \param inc_size_if_possible: Should the generated string include the size of +/// the array (if it is known). +/// \return A C-like type declaration of an array std::string expr2ct::convert_array_type( const typet &src, const c_qualifierst &qualifiers, @@ -860,18 +762,6 @@ std::string expr2ct::convert_array_type( src.subtype(), qualifiers, declarator_str+array_suffix); } -/*******************************************************************\ - -Function: expr2ct::convert_typecast - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_typecast( const typecast_exprt &src, unsigned &precedence) @@ -906,18 +796,6 @@ std::string expr2ct::convert_typecast( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_trinary - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_trinary( const exprt &src, const std::string &symbol1, @@ -969,18 +847,6 @@ std::string expr2ct::convert_trinary( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_quantifier - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_quantifier( const exprt &src, const std::string &symbol, @@ -1003,18 +869,6 @@ std::string expr2ct::convert_quantifier( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_with - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_with( const exprt &src, unsigned precedence) @@ -1083,18 +937,6 @@ std::string expr2ct::convert_with( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_update - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_update( const exprt &src, unsigned precedence) @@ -1139,18 +981,6 @@ std::string expr2ct::convert_update( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_cond - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_cond( const exprt &src, unsigned precedence) @@ -1185,18 +1015,6 @@ std::string expr2ct::convert_cond( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_binary - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_binary( const exprt &src, const std::string &symbol, @@ -1246,18 +1064,6 @@ std::string expr2ct::convert_binary( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_unary - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_unary( const exprt &src, const std::string &symbol, @@ -1281,18 +1087,6 @@ std::string expr2ct::convert_unary( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_pointer_object_has_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_pointer_object_has_type( const exprt &src, unsigned precedence) @@ -1313,18 +1107,6 @@ std::string expr2ct::convert_pointer_object_has_type( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_malloc - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_malloc( const exprt &src, unsigned &precedence) @@ -1351,18 +1133,6 @@ std::string expr2ct::convert_malloc( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_nondet - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_nondet( const exprt &src, unsigned &precedence) @@ -1373,18 +1143,6 @@ std::string expr2ct::convert_nondet( return "NONDET("+convert(src.type())+")"; } -/*******************************************************************\ - -Function: expr2ct::convert_statement_expression - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_statement_expression( const exprt &src, unsigned &precedence) @@ -1396,18 +1154,6 @@ std::string expr2ct::convert_statement_expression( return "("+convert_code(to_code_block(to_code(src.op0())), 0)+")"; } -/*******************************************************************\ - -Function: expr2ct::convert_prob_coin - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_prob_coin( const exprt &src, unsigned &precedence) @@ -1418,18 +1164,6 @@ std::string expr2ct::convert_prob_coin( return convert_norep(src, precedence); } -/*******************************************************************\ - -Function: expr2ct::convert_literal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_literal( const exprt &src, unsigned &precedence) @@ -1437,18 +1171,6 @@ std::string expr2ct::convert_literal( return "L("+src.get_string(ID_literal)+")"; } -/*******************************************************************\ - -Function: expr2ct::convert_prob_uniform - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_prob_uniform( const exprt &src, unsigned &precedence) @@ -1459,18 +1181,6 @@ std::string expr2ct::convert_prob_uniform( return convert_norep(src, precedence); } -/*******************************************************************\ - -Function: expr2ct::convert_function - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_function( const exprt &src, const std::string &name, @@ -1495,18 +1205,6 @@ std::string expr2ct::convert_function( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_comma - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_comma( const exprt &src, unsigned precedence) @@ -1531,18 +1229,6 @@ std::string expr2ct::convert_comma( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_complex - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_complex( const exprt &src, unsigned precedence) @@ -1594,18 +1280,6 @@ std::string expr2ct::convert_complex( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_array_of - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_array_of( const exprt &src, unsigned precedence) @@ -1616,18 +1290,6 @@ std::string expr2ct::convert_array_of( return "ARRAY_OF("+convert(src.op0())+')'; } -/*******************************************************************\ - -Function: expr2ct::convert_byte_extract - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_byte_extract( const exprt &src, unsigned precedence) @@ -1653,18 +1315,6 @@ std::string expr2ct::convert_byte_extract( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_byte_update - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_byte_update( const exprt &src, unsigned precedence) @@ -1695,18 +1345,6 @@ std::string expr2ct::convert_byte_update( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_unary_post - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_unary_post( const exprt &src, const std::string &symbol, @@ -1729,18 +1367,6 @@ std::string expr2ct::convert_unary_post( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_index - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_index( const exprt &src, unsigned precedence) @@ -1765,18 +1391,6 @@ std::string expr2ct::convert_index( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_pointer_arithmetic - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_pointer_arithmetic( const exprt &src, unsigned &precedence) { @@ -1814,18 +1428,6 @@ std::string expr2ct::convert_pointer_arithmetic( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_pointer_difference - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_pointer_difference( const exprt &src, unsigned &precedence) { @@ -1863,18 +1465,6 @@ std::string expr2ct::convert_pointer_difference( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_member_designator - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_member_designator(const exprt &src) { unsigned precedence; @@ -1885,18 +1475,6 @@ std::string expr2ct::convert_member_designator(const exprt &src) return "."+src.get_string(ID_component_name); } -/*******************************************************************\ - -Function: expr2ct::convert_index_designator - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_index_designator(const exprt &src) { unsigned precedence; @@ -1907,18 +1485,6 @@ std::string expr2ct::convert_index_designator(const exprt &src) return "["+convert(src.op0())+"]"; } -/*******************************************************************\ - -Function: expr2ct::convert_member - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_member( const member_exprt &src, unsigned precedence) @@ -1995,18 +1561,6 @@ std::string expr2ct::convert_member( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_array_member_value - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_array_member_value( const exprt &src, unsigned precedence) @@ -2017,18 +1571,6 @@ std::string expr2ct::convert_array_member_value( return "[]="+convert(src.op0()); } -/*******************************************************************\ - -Function: expr2ct::convert_struct_member_value - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_struct_member_value( const exprt &src, unsigned precedence) @@ -2039,18 +1581,6 @@ std::string expr2ct::convert_struct_member_value( return "."+src.get_string(ID_name)+"="+convert(src.op0()); } -/*******************************************************************\ - -Function: expr2ct::convert_norep - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_norep( const exprt &src, unsigned &precedence) @@ -2062,18 +1592,6 @@ std::string expr2ct::convert_norep( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_symbol( const exprt &src, unsigned &precedence) @@ -2116,18 +1634,6 @@ std::string expr2ct::convert_symbol( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_nondet_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_nondet_symbol( const exprt &src, unsigned &precedence) @@ -2136,18 +1642,6 @@ std::string expr2ct::convert_nondet_symbol( return "nondet_symbol("+id+")"; } -/*******************************************************************\ - -Function: expr2ct::convert_predicate_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_predicate_symbol( const exprt &src, unsigned &precedence) @@ -2156,18 +1650,6 @@ std::string expr2ct::convert_predicate_symbol( return "ps("+id+")"; } -/*******************************************************************\ - -Function: expr2ct::convert_predicate_next_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_predicate_next_symbol( const exprt &src, unsigned &precedence) @@ -2176,18 +1658,6 @@ std::string expr2ct::convert_predicate_next_symbol( return "pns("+id+")"; } -/*******************************************************************\ - -Function: expr2ct::convert_predicate_passive_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_predicate_passive_symbol( const exprt &src, unsigned &precedence) @@ -2196,18 +1666,6 @@ std::string expr2ct::convert_predicate_passive_symbol( return "pps("+id+")"; } -/*******************************************************************\ - -Function: expr2ct::convert_quantified_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_quantified_symbol( const exprt &src, unsigned &precedence) @@ -2216,18 +1674,6 @@ std::string expr2ct::convert_quantified_symbol( return id; } -/*******************************************************************\ - -Function: expr2ct::convert_nondet_bool - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_nondet_bool( const exprt &src, unsigned &precedence) @@ -2235,18 +1681,6 @@ std::string expr2ct::convert_nondet_bool( return "nondet_bool()"; } -/*******************************************************************\ - -Function: expr2ct::convert_object_descriptor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_object_descriptor( const exprt &src, unsigned &precedence) @@ -2271,18 +1705,6 @@ std::string expr2ct::convert_object_descriptor( return result; } -/*******************************************************************\ - -Function: expr2ct::convert_constant - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_constant( const constant_exprt &src, unsigned &precedence) @@ -2508,19 +1930,10 @@ std::string expr2ct::convert_constant( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_constant_bool - - Inputs: - boolean_value - The value of the constant bool expression - - Outputs: Returns a C-like representation of the boolean value, - e.g. TRUE or FALSE. - - Purpose: To get the C-like representation of a given boolean value. - -\*******************************************************************/ +/// To get the C-like representation of a given boolean value. +/// \param boolean_value: The value of the constant bool expression +/// \return Returns a C-like representation of the boolean value, e.g. TRUE or +/// FALSE. std::string expr2ct::convert_constant_bool(bool boolean_value) { // C doesn't really have these @@ -2530,18 +1943,6 @@ std::string expr2ct::convert_constant_bool(bool boolean_value) return "FALSE"; } -/*******************************************************************\ - -Function: expr2ct::convert_struct - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_struct( const exprt &src, unsigned &precedence) @@ -2549,23 +1950,13 @@ std::string expr2ct::convert_struct( return convert_struct(src, precedence, true); } -/*******************************************************************\ - -Function: expr2ct::convert_struct - - Inputs: - src - The struct declaration expression - precedence - include_padding_components - Should the generated C code - include the padding members added - to structs for GOTOs benifit - - Outputs: A string representation of the struct expression - - Purpose: To generate a C-like string representing a struct. Can optionally - include the padding parameters. - -\*******************************************************************/ +/// To generate a C-like string representing a struct. Can optionally include +/// the padding parameters. +/// \param src: The struct declaration expression +/// precedence +/// \param include_padding_components: Should the generated C code include the +/// padding members added to structs for GOTOs benifit +/// \return A string representation of the struct expression std::string expr2ct::convert_struct( const exprt &src, unsigned &precedence, @@ -2640,18 +2031,6 @@ std::string expr2ct::convert_struct( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_vector - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_vector( const exprt &src, unsigned &precedence) @@ -2699,18 +2078,6 @@ std::string expr2ct::convert_vector( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_union - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_union( const exprt &src, unsigned &precedence) @@ -2732,18 +2099,6 @@ std::string expr2ct::convert_union( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_array - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_array( const exprt &src, unsigned &precedence) @@ -2850,18 +2205,6 @@ std::string expr2ct::convert_array( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_array_list - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_array_list( const exprt &src, unsigned &precedence) @@ -2896,18 +2239,6 @@ std::string expr2ct::convert_array_list( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_initializer_list - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_initializer_list( const exprt &src, unsigned &precedence) @@ -2936,18 +2267,6 @@ std::string expr2ct::convert_initializer_list( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_designated_initializer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_designated_initializer( const exprt &src, unsigned &precedence) @@ -2966,18 +2285,6 @@ std::string expr2ct::convert_designated_initializer( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_function_application - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_function_application( const function_application_exprt &src, unsigned &precedence) @@ -3008,18 +2315,6 @@ std::string expr2ct::convert_function_application( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_side_effect_expr_function_call - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_side_effect_expr_function_call( const side_effect_expr_function_callt &src, unsigned &precedence) @@ -3050,18 +2345,6 @@ std::string expr2ct::convert_side_effect_expr_function_call( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_overflow - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_overflow( const exprt &src, unsigned &precedence) @@ -3093,35 +2376,11 @@ std::string expr2ct::convert_overflow( return dest; } -/*******************************************************************\ - -Function: expr2ct::indent_str - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::indent_str(unsigned indent) { return std::string(indent, ' '); } -/*******************************************************************\ - -Function: expr2ct::convert_code_asm - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code_asm( const code_asmt &src, unsigned indent) @@ -3200,18 +2459,6 @@ std::string expr2ct::convert_code_asm( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_code_while - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code_while( const code_whilet &src, unsigned indent) @@ -3238,18 +2485,6 @@ std::string expr2ct::convert_code_while( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_code_dowhile - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code_dowhile( const code_dowhilet &src, unsigned indent) @@ -3279,18 +2514,6 @@ std::string expr2ct::convert_code_dowhile( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_code_ifthenelse - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code_ifthenelse( const code_ifthenelset &src, unsigned indent) @@ -3328,18 +2551,6 @@ std::string expr2ct::convert_code_ifthenelse( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_code_return - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code_return( const codet &src, unsigned indent) @@ -3362,18 +2573,6 @@ std::string expr2ct::convert_code_return( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_code_goto - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code_goto( const codet &src, unsigned indent) @@ -3386,18 +2585,6 @@ std::string expr2ct::convert_code_goto( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_code_break - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code_break( const codet &src, unsigned indent) @@ -3409,18 +2596,6 @@ std::string expr2ct::convert_code_break( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_code_switch - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code_switch( const codet &src, unsigned indent) @@ -3464,18 +2639,6 @@ std::string expr2ct::convert_code_switch( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_code_continue - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code_continue( const codet &src, unsigned indent) @@ -3487,18 +2650,6 @@ std::string expr2ct::convert_code_continue( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_code_decl - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code_decl( const codet &src, unsigned indent) @@ -3536,20 +2687,8 @@ std::string expr2ct::convert_code_decl( dest+=';'; - return dest; -} - -/*******************************************************************\ - -Function: expr2ct::convert_code_dead - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ + return dest; +} std::string expr2ct::convert_code_dead( const codet &src, @@ -3565,18 +2704,6 @@ std::string expr2ct::convert_code_dead( return "dead "+convert(src.op0())+";"; } -/*******************************************************************\ - -Function: expr2ct::convert_code_for - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code_for( const code_fort &src, unsigned indent) @@ -3614,18 +2741,6 @@ std::string expr2ct::convert_code_for( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_code_block - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code_block( const code_blockt &src, unsigned indent) @@ -3649,18 +2764,6 @@ std::string expr2ct::convert_code_block( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_code_decl_block - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code_decl_block( const codet &src, unsigned indent) @@ -3676,18 +2779,6 @@ std::string expr2ct::convert_code_decl_block( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_code_expression - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code_expression( const codet &src, unsigned indent) @@ -3710,18 +2801,6 @@ std::string expr2ct::convert_code_expression( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_code - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code( const codet &src, unsigned indent) @@ -3836,6 +2915,9 @@ std::string expr2ct::convert_code( if(statement==ID_array_copy) return convert_code_array_copy(src, indent); + if(statement==ID_array_replace) + return convert_code_array_replace(src, indent); + if(statement=="set_may" || statement=="set_must") return @@ -3845,18 +2927,6 @@ std::string expr2ct::convert_code( return convert_norep(src, precedence); } -/*******************************************************************\ - -Function: expr2ct::convert_code_assign - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code_assign( const code_assignt &src, unsigned indent) @@ -3868,18 +2938,6 @@ std::string expr2ct::convert_code_assign( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_code_free - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code_free( const codet &src, unsigned indent) @@ -3893,18 +2951,6 @@ std::string expr2ct::convert_code_free( return indent_str(indent)+"FREE("+convert(src.op0())+");"; } -/*******************************************************************\ - -Function: expr2ct::convert_code_init - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code_init( const codet &src, unsigned indent) @@ -3914,18 +2960,6 @@ std::string expr2ct::convert_code_init( return indent_str(indent)+"INIT "+tmp+";"; } -/*******************************************************************\ - -Function: expr2ct::convert_code_lock - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code_lock( const codet &src, unsigned indent) @@ -3939,18 +2973,6 @@ std::string expr2ct::convert_code_lock( return indent_str(indent)+"LOCK("+convert(src.op0())+");"; } -/*******************************************************************\ - -Function: expr2ct::convert_code_unlock - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code_unlock( const codet &src, unsigned indent) @@ -3964,18 +2986,6 @@ std::string expr2ct::convert_code_unlock( return indent_str(indent)+"UNLOCK("+convert(src.op0())+");"; } -/*******************************************************************\ - -Function: expr2ct::convert_code_function_call - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code_function_call( const code_function_callt &src, unsigned indent) @@ -4024,18 +3034,6 @@ std::string expr2ct::convert_code_function_call( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_code_printf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code_printf( const codet &src, unsigned indent) @@ -4058,18 +3056,6 @@ std::string expr2ct::convert_code_printf( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_code_fence - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code_fence( const codet &src, unsigned indent) @@ -4100,18 +3086,6 @@ std::string expr2ct::convert_code_fence( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_code_input - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code_input( const codet &src, unsigned indent) @@ -4134,18 +3108,6 @@ std::string expr2ct::convert_code_input( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_code_output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code_output( const codet &src, unsigned indent) @@ -4167,18 +3129,6 @@ std::string expr2ct::convert_code_output( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_code_array_set - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code_array_set( const codet &src, unsigned indent) @@ -4201,18 +3151,6 @@ std::string expr2ct::convert_code_array_set( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_code_array_copy - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code_array_copy( const codet &src, unsigned indent) @@ -4235,17 +3173,26 @@ std::string expr2ct::convert_code_array_copy( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_code_assert +std::string expr2ct::convert_code_array_replace( + const codet &src, + unsigned indent) +{ + std::string dest=indent_str(indent)+"ARRAY_REPLACE("; - Inputs: + forall_operands(it, src) + { + unsigned p; + std::string arg_str=convert_with_precedence(*it, p); - Outputs: + if(it!=src.operands().begin()) + dest+=", "; + dest+=arg_str; + } - Purpose: + dest+=");"; -\*******************************************************************/ + return dest; +} std::string expr2ct::convert_code_assert( const codet &src, @@ -4260,18 +3207,6 @@ std::string expr2ct::convert_code_assert( return indent_str(indent)+"assert("+convert(src.op0())+");"; } -/*******************************************************************\ - -Function: expr2ct::convert_code_assume - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code_assume( const codet &src, unsigned indent) @@ -4285,18 +3220,6 @@ std::string expr2ct::convert_code_assume( return indent_str(indent)+"__CPROVER_assume("+convert(src.op0())+");"; } -/*******************************************************************\ - -Function: expr2ct::convert_code_label - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code_label( const code_labelt &src, unsigned indent) @@ -4315,18 +3238,6 @@ std::string expr2ct::convert_code_label( return labels_string+tmp; } -/*******************************************************************\ - -Function: expr2ct::convert_code_switch_case - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code_switch_case( const code_switch_caset &src, unsigned indent) @@ -4357,35 +3268,11 @@ std::string expr2ct::convert_code_switch_case( return labels_string+tmp; } -/*******************************************************************\ - -Function: expr2ct::convert_code - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_code(const codet &src) { return convert_code(src, 0); } -/*******************************************************************\ - -Function: expr2ct::convert_Hoare - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_Hoare(const exprt &src) { unsigned precedence; @@ -4429,18 +3316,6 @@ std::string expr2ct::convert_Hoare(const exprt &src) return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_extractbit - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_extractbit( const exprt &src, unsigned precedence) @@ -4456,18 +3331,6 @@ std::string expr2ct::convert_extractbit( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_extractbits - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_extractbits( const exprt &src, unsigned precedence) @@ -4485,18 +3348,6 @@ std::string expr2ct::convert_extractbits( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert_sizeof - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_sizeof( const exprt &src, unsigned &precedence) @@ -4511,18 +3362,6 @@ std::string expr2ct::convert_sizeof( return dest; } -/*******************************************************************\ - -Function: expr2ct::convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert_with_precedence( const exprt &src, unsigned &precedence) @@ -4685,9 +3524,6 @@ std::string expr2ct::convert_with_precedence( else if(src.id()=="buffer_size") return convert_function(src, "BUFFER_SIZE", precedence=16); - else if(src.id()==ID_pointer_offset) - return convert_function(src, "POINTER_OFFSET", precedence=16); - else if(src.id()==ID_isnan) return convert_function(src, "isnan", precedence=16); @@ -5027,36 +3863,12 @@ std::string expr2ct::convert_with_precedence( return convert_norep(src, precedence); } -/*******************************************************************\ - -Function: expr2ct::convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2ct::convert(const exprt &src) { unsigned precedence; return convert_with_precedence(src, precedence); } -/*******************************************************************\ - -Function: expr2c - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2c(const exprt &expr, const namespacet &ns) { std::string code; @@ -5065,18 +3877,6 @@ std::string expr2c(const exprt &expr, const namespacet &ns) return expr2c.convert(expr); } -/*******************************************************************\ - -Function: type2c - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string type2c(const typet &type, const namespacet &ns) { expr2ct expr2c(ns); diff --git a/src/ansi-c/expr2c.h b/src/ansi-c/expr2c.h index 6a1b24aa221..2bbcad3832e 100644 --- a/src/ansi-c/expr2c.h +++ b/src/ansi-c/expr2c.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_ANSI_C_EXPR2C_H #define CPROVER_ANSI_C_EXPR2C_H diff --git a/src/ansi-c/expr2c_class.h b/src/ansi-c/expr2c_class.h index 771f936afb8..a6c027c7735 100644 --- a/src/ansi-c/expr2c_class.h +++ b/src/ansi-c/expr2c_class.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_ANSI_C_EXPR2C_CLASS_H #define CPROVER_ANSI_C_EXPR2C_CLASS_H @@ -204,6 +205,7 @@ class expr2ct std::string convert_code_output(const codet &src, unsigned indent); std::string convert_code_array_set(const codet &src, unsigned indent); std::string convert_code_array_copy(const codet &src, unsigned indent); + std::string convert_code_array_replace(const codet &src, unsigned indent); virtual std::string convert_with_precedence( const exprt &src, unsigned &precedence); diff --git a/src/ansi-c/file_converter.cpp b/src/ansi-c/file_converter.cpp index 1a3aecab1a3..ce0dbd9ea36 100644 --- a/src/ansi-c/file_converter.cpp +++ b/src/ansi-c/file_converter.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Convert file contents to C strings + #include #include @@ -37,6 +40,6 @@ int main() std::cout << ch; } - std::cout << "\\n\"" << std::endl; + std::cout << "\\n\"\n"; } } diff --git a/src/ansi-c/gcc_builtin_headers_generic.h b/src/ansi-c/gcc_builtin_headers_generic.h index ce0e94a8bd7..17d997b8deb 100644 --- a/src/ansi-c/gcc_builtin_headers_generic.h +++ b/src/ansi-c/gcc_builtin_headers_generic.h @@ -1,109 +1,70 @@ typedef void ** __builtin_va_list; typedef void ** __builtin_ms_va_list; -void __builtin_va_start(void *ap, ...); -void __builtin_va_end(void *ap); -void __builtin_va_copy(__builtin_va_list dest, __builtin_va_list src); -void __builtin_ms_va_start(void *ap, ...); +// stdarg +void* __builtin_apply_args(); void __builtin_ms_va_end(void *ap); -void *__builtin_va_arg_pack(); +void __builtin_ms_va_start(void *ap, ...); +void* __builtin_next_arg(); +int __builtin_va_arg_pack(); int __builtin_va_arg_pack_len(); -int __builtin_constant_p(); -int __builtin_abs(int); -int __builtin_finite(double); -int __builtin_finitef(float); -int __builtin_finitel(long double); -int __builtin_fpclassify(int, int, int, int, int, ...); -int __builtin_isfinite(); -int __builtin_isinf_sign(); -int __builtin_isnanl(long double); -int __builtin_isnormal(); -int __builtin_isgreater(); -int __builtin_isgreaterequal(); -int __builtin_isless(); -int __builtin_islessequal(); -int __builtin_islessgreater(); -int __builtin_isunordered(); -long int __builtin_labs(long); -long long int __builtin_llabs(long long int); -double __builtin_cos(double); -float __builtin_cosf(float); -double __builtin_fabs(double); -float __builtin_fabsf(float); -int __builtin_memcmp(const void *s1, const void *s2, __CPROVER_size_t n); -void *__builtin_memcpy(void *dest, const void *src, __CPROVER_size_t n); -void *__builtin___memcpy_chk(void *dest, const void *src, __CPROVER_size_t n, __CPROVER_size_t size); -char *__builtin___memmove_chk(void *dest, const void *src, __CPROVER_size_t n, __CPROVER_size_t size); -double __builtin_sin(double); -float __builtin_sinf(float); -double __builtin_sqrt(double); -float __builtin_sqrtf(float); -int __builtin_strcmp(const char *s1, const char *s2); -__CPROVER_size_t __builtin_strlen(const char *s); -int __builtin_strncmp(const char *s1, const char *s2, __CPROVER_size_t n); +void __builtin_va_copy(__builtin_va_list dest, __builtin_va_list src); +void __builtin_va_end(void *ap); +void __builtin_va_start(void *ap, ...); + +// stdlib +void __builtin__Exit(int); +void __builtin__exit(int); void __builtin_abort(); -void __builtin_prefetch(void *, ...); -int __builtin_printf(const char *fmt, ...); +int __builtin_execl(const char*, const char*, ...); +int __builtin_execle(const char*, const char*, ...); +int __builtin_execlp(const char*, const char*, ...); +int __builtin_execv(const char*, const char**); +int __builtin_execve(const char*, const char**, const char**); +int __builtin_execvp(const char*, const char**); +void __builtin_exit(int); + +// stdio +int __builtin___fprintf_chk(void*, int, const char*, ...); +int __builtin___printf_chk(int, const char*, ...); +int __builtin___snprintf_chk(char*, __CPROVER_size_t, int, __CPROVER_size_t, const char*, ...); +int __builtin___sprintf_chk(char*, int, __CPROVER_size_t, const char*, ...); +int __builtin___vfprintf_chk(void*, int, const char*, __builtin_va_list); +int __builtin___vprintf_chk(int, const char*, __builtin_va_list); +int __builtin___vsnprintf_chk (char *s, __CPROVER_size_t maxlen, int flag, __CPROVER_size_t os, const char *fmt, __builtin_va_list ap); +int __builtin___vsnprintf_chk(char*, __CPROVER_size_t, int, __CPROVER_size_t, const char*, __builtin_va_list); +int __builtin___vsprintf_chk(char*, int, __CPROVER_size_t, const char*, __builtin_va_list); +long __builtin_expect(long, long); int __builtin_fprintf(void *stream, const char *fmt, ...); +int __builtin_fprintf_unlocked(void*, const char*, ...); +int __builtin_fputc(int, void*); +int __builtin_fputc_unlocked(int, void*); +int __builtin_fputs(const char *s, void *stream); +int __builtin_fputs_unlocked(const char*, void*); int __builtin_fscanf(void *stream, const char *fmt, ...); +__CPROVER_size_t __builtin_fwrite(const void*, __CPROVER_size_t, __CPROVER_size_t, void*); +__CPROVER_size_t __builtin_fwrite_unlocked(const void*, __CPROVER_size_t, __CPROVER_size_t, void*); +int __builtin_printf(const char*, ...); +int __builtin_printf_unlocked(const char*, ...); +int __builtin_putc(int, void*); +int __builtin_putc_unlocked(int, void*); +int __builtin_putchar(int); +int __builtin_putchar_unlocked(int); +int __builtin_puts(const char*); +int __builtin_puts_unlocked(const char*); int __builtin_scanf(const char *str, const char *fmt, ...); -int __builtin_fputs(const char *s, void *stream); -int __builtin_vsnprintf(char * restrict str, __CPROVER_size_t size, const char * restrict format, __builtin_va_list ap); -long __builtin_expect(long, long); -void *__builtin_memset(void *s, int c, __CPROVER_size_t n); -void *__builtin___memset_chk(void *s, int c, __CPROVER_size_t n, __CPROVER_size_t size); -void *__builtin_memchr(const void *s, int c, __CPROVER_size_t n); -void *__builtin_memmove(void *s1, const void *s2, __CPROVER_size_t n); -void *__builtin_mempcpy(void *, const void *, __CPROVER_size_t); -void *__builtin___mempcpy_chk(void *dest, const void *src, __CPROVER_size_t n, __CPROVER_size_t size); -char *__builtin_strcat(char *dest, const char *src); -char *__builtin___strcat_chk(char *dest, const char *src, __CPROVER_size_t size); -char *__builtin_strcpy(char *dest, const char *src); -char *__builtin___strcpy_chk(char *dest, const char *src, __CPROVER_size_t size); -char *__builtin_strncpy(char *dest, const char *src, __CPROVER_size_t n); -char *__builtin___strncpy_chk(char *dest, const char *src, __CPROVER_size_t n, __CPROVER_size_t size); -char *__builtin_stpcpy(char *dest, const char *src); -char *__builtin___stpcpy(char *s1, const char *s2); -char *__builtin___stpncpy_chk(char *s1, const char *s2, __CPROVER_size_t n, __CPROVER_size_t size); -int __builtin___sprintf_chk(char *s, int flag, __CPROVER_size_t os, const char *fmt, ...); -int __builtin___snprintf_chk(char *s, __CPROVER_size_t maxlen, int flag, __CPROVER_size_t os, const char *fmt, ...); -int __builtin___vsprintf_chk(char *s, int flag, __CPROVER_size_t os, const char *fmt, __builtin_va_list ap); -int __builtin___vsnprintf_chk (char *s, __CPROVER_size_t maxlen, int flag, __CPROVER_size_t os, const char *fmt, __builtin_va_list ap); -void __builtin_exit(int status); -char *__builtin_strchr(const char *s, int c); -__CPROVER_size_t __builtin_strspn(const char *s, const char *accept); -__CPROVER_size_t __builtin_strcspn(const char *s, const char *reject); -char *__builtin_strstr(const char *a, const char *b); -char *__builtin_strpbrk(const char *s, const char *accept); -char *__builtin_strrchr(const char *s, int c); -char *__builtin_strncat(char *dest, const char *src, __CPROVER_size_t n); -char *__builtin___strncat_chk(char *dest, const char *src, __CPROVER_size_t n, __CPROVER_size_t size); -char *__builtin___stpcpy_chk(char *dest, const char *src, __CPROVER_size_t size); -void *__builtin_alloca(__CPROVER_size_t s); -int __builtin_ffs(int i); -char *__builtin_index(const char *s, int c); -char *__builtin_rindex(const char *s, int c); -int __builtin_bcmp(const void *s1, const void *s2, __CPROVER_size_t n); -void __builtin_bzero(void *s, __CPROVER_size_t n); -long double __builtin_sinl(long double x); -long double __builtin_cosl(long double x); -long double __builtin_sqrtl(long double x); -long double __builtin_fabsl(long double x); -int __builtin_popcount(unsigned int x); -int __builtin_popcountll(unsigned long long int x); -float __builtin_huge_valf(); -double __builtin_huge_val(); -float __builtin_inff(); -double __builtin_inf(); -float __builtin_nanf(const char *); -double __builtin_nan(const char *); -float __builtin_nansf(const char *); -double __builtin_nans(const char *); -long double __builtin_infl(); -__CPROVER_size_t __builtin_object_size(); -void *__builtin_return_address(unsigned level); -void *__builtin_extract_return_addr(void *); -int __builtin_choose_expr(_Bool, ...); +int __builtin_snprintf(char*, __CPROVER_size_t, const char*, ...); +int __builtin_sprintf(char*, const char*, ...); +int __builtin_sscanf(const char*, const char*, ...); +int __builtin_vfprintf(void*, const char*, __builtin_va_list); +int __builtin_vfscanf(void*, const char*, __builtin_va_list); +int __builtin_vprintf(const char*, __builtin_va_list); +int __builtin_vscanf(const char*, __builtin_va_list); +int __builtin_vsnprintf(char*, __CPROVER_size_t, const char*, __builtin_va_list); +int __builtin_vsprintf(char*, const char*, __builtin_va_list); +int __builtin_vsscanf(const char*, const char*, __builtin_va_list); + +// atomics int __sync_fetch_and_add(); int __sync_fetch_and_sub(); int __sync_fetch_and_or(); @@ -121,81 +82,37 @@ int __sync_val_compare_and_swap(); void __sync_synchronize(); int __sync_lock_test_and_set(); void __sync_lock_release(); -float __builtin_acosf(float); -long double __builtin_acosl(long double); -float __builtin_asinf(float); -long double __builtin_asinl(long double); -float __builtin_atanf(float); -long double __builtin_atanl(long double); -float __builtin_atan2f(float, float); -long double __builtin_atan2l(long double, long double); -float __builtin_ceilf(float); -long double __builtin_ceill(long double); -float __builtin_coshf(float); -long double __builtin_coshl(long double); -float __builtin_expf(float); -long double __builtin_expl(long double); -float __builtin_floorf(float); -long double __builtin_floorl(long double); -float __builtin_fmodf(float, float); -long double __builtin_fmodl(long double, long double); -float __builtin_frexpf(float, int*); -long double __builtin_frexpl(long double, int*); -float __builtin_ldexpf(float , int exp); -long double __builtin_ldexpl(long double, int); -float __builtin_logf(float); -long double __builtin_logl(long double); -float __builtin_log10f(float); -double __builtin_log10(double); -long double __builtin_log10l(long double); -float __builtin_log2f(float); -double __builtin_log2(double); -long double __builtin_log2l(float); -float __builtin_modff(float, float*); -long double __builtin_modfl(long double, long double*); -float __builtin_powf(float, float); -long double __builtin_powl(long double, long double); -double __builtin_powi(double, int); -float __builtin_powif(float, int); -long double __builtin_powil(long double, int); -float __builtin_sinhf(float); -long double __builtin_sinhl(long double); -float __builtin_tanf(float); -long double __builtin_tanl(long double); -float __builtin_tanhf(float); -long double __builtin_tanhl(long double); -int __builtin_parityl(unsigned long); -int __builtin_parityll(unsigned long long); -void __builtin_trap(void); -void __builtin___clear_cache(char *begin, char *end); -int __builtin_clz(unsigned int); -int __builtin_clzll(unsigned long long); -int __builtin_ctz(unsigned int); -int __builtin_ctzll(unsigned long long); -int __builtin_parity(unsigned int); -int __builtin_ffsl(unsigned long); -int __builtin_clzl(unsigned long); -int __builtin_ctzl(unsigned long); -short unsigned int __builtin_bswap16(short unsigned int); -long unsigned int __builtin_bswap32(long unsigned int); -long long unsigned int __builtin_bswap64(long long unsigned int); -int __builtin_classify_type(); -int __builtin_isinf(double); -int __builtin_isinff(float); -int __builtin_isinfl(long double); -int __builtin_isnan(double); -int __builtin_isnanf(float); -int __builtin_signbit(double); -int __builtin_signbitf(float); -int __builtin_signbitl(long double); +// other +int __builtin_choose_expr(_Bool, ...); +int __builtin_classify_type(); +int __builtin_constant_p(int); +void __builtin_trap(void); void __builtin_unreachable(void); +void* __builtin_dwarf_cfa(); +unsigned __builtin_dwarf_sp_column(); +int __builtin_eh_return_data_regno(int); +void __builtin_init_dwarf_reg___CPROVER_size_table(void*); +void __builtin_unwind_init(); + +const char* __builtin_FILE(); +const char* __builtin_FUNCTION(); +int __builtin_LINE(); + +void __builtin_longjmp(void*, int); +void __builtin_return(void*); +void* __builtin_saveregs(); +int __builtin_setjmp(void*); +void __builtin_update_setjmp_buf(void*); + + typedef int __gcc_m64 __attribute__ ((__vector_size__ (8), __may_alias__)); typedef char __gcc_v8qi __attribute__ ((__vector_size__ (8))); typedef char __gcc_v16qi __attribute__ ((__vector_size__ (16))); typedef char __gcc_v32qi __attribute__ ((__vector_size__ (32))); +typedef char __gcc_v64qi __attribute__ ((__vector_size__ (64))); typedef int __gcc_v2si __attribute__ ((__vector_size__ (8))); typedef int __gcc_v4si __attribute__ ((__vector_size__ (16))); typedef int __gcc_v8si __attribute__ ((__vector_size__ (32))); diff --git a/src/ansi-c/gcc_builtin_headers_ia32-2.h b/src/ansi-c/gcc_builtin_headers_ia32-2.h index 91f5eb01549..d5000ec19da 100644 --- a/src/ansi-c/gcc_builtin_headers_ia32-2.h +++ b/src/ansi-c/gcc_builtin_headers_ia32-2.h @@ -1,4 +1,4 @@ -void __builtin_ia32_emms(void); +void __builtin_ia32_emms(); __gcc_v2si __builtin_ia32_pmaddwd(__gcc_v4hi, __gcc_v4hi); __gcc_v2si __builtin_ia32_vec_init_v2si(int, int); __gcc_v4hi __builtin_ia32_vec_init_v4hi(short, short, short, short); @@ -8,15 +8,15 @@ __gcc_v8hi __builtin_ia32_paddusw128(__gcc_v8hi, __gcc_v8hi); __gcc_v8hi __builtin_ia32_psubusw128(__gcc_v8hi, __gcc_v8hi); void __builtin_ia32_ldmxcsr(unsigned); unsigned __builtin_ia32_stmxcsr(void); -__gcc_v8hi __builtin_ia32_paddsw128(__gcc_v8hi,__gcc_v8hi); -__gcc_v8hi __builtin_ia32_psubsw128(__gcc_v8hi,__gcc_v8hi); -__gcc_v16qi __builtin_ia32_paddsb128(__gcc_v16qi,__gcc_v16qi); -__gcc_v16qi __builtin_ia32_psubsb128(__gcc_v16qi,__gcc_v16qi); -__gcc_v16qi __builtin_ia32_paddusb128(__gcc_v16qi,__gcc_v16qi); -__gcc_v16qi __builtin_ia32_psubusb128(__gcc_v16qi,__gcc_v16qi); -__gcc_di __builtin_ia32_cvtss2si64(__gcc_v4sf); -__gcc_di __builtin_ia32_cvttss2si64(__gcc_v4sf); -__gcc_v4sf __builtin_ia32_cvtsi642ss(__gcc_v4sf, __gcc_di); +__gcc_v8hi __builtin_ia32_paddsw128(__gcc_v8hi, __gcc_v8hi); +__gcc_v8hi __builtin_ia32_psubsw128(__gcc_v8hi, __gcc_v8hi); +__gcc_v16qi __builtin_ia32_paddsb128(__gcc_v16qi, __gcc_v16qi); +__gcc_v16qi __builtin_ia32_psubsb128(__gcc_v16qi, __gcc_v16qi); +__gcc_v16qi __builtin_ia32_paddusb128(__gcc_v16qi, __gcc_v16qi); +__gcc_v16qi __builtin_ia32_psubusb128(__gcc_v16qi, __gcc_v16qi); +long long __builtin_ia32_cvtss2si64(__gcc_v4sf); +long long __builtin_ia32_cvttss2si64(__gcc_v4sf); +__gcc_v4sf __builtin_ia32_cvtsi642ss(__gcc_v4sf, long long); __gcc_v4hi __builtin_ia32_pshufw(__gcc_v4hi, int); short __builtin_ia32_vec_ext_v4hi(__gcc_v4hi, int); @@ -32,12 +32,12 @@ __gcc_v16qi __builtin_ia32_vec_set_v16qi(__gcc_v16qi, char, int); __gcc_v4si __builtin_ia32_vec_set_v4si(__gcc_v4si, int, int); __gcc_v2di __builtin_ia32_vec_set_v2di(__gcc_v2di, __gcc_di, int); -unsigned long long __builtin_ia32_rdtsc(void); +unsigned long long __builtin_ia32_rdtsc(); unsigned long long __builtin_ia32_rdtscp(unsigned*); void __builtin_ia32_fnstenv(void*); void __builtin_ia32_fldenv(const void*); -unsigned short __builtin_ia32_fnstsw(void); -void __builtin_ia32_fnclex(void); +unsigned short __builtin_ia32_fnstsw(); +void __builtin_ia32_fnclex(); void __builtin_ia32_fxsave(void*); void __builtin_ia32_fxrstor(void*); void __builtin_ia32_xsave(void*, long long); @@ -57,63 +57,63 @@ void __builtin_ia32_xsavec64(void*, long long); void __builtin_ia32_movntdq256(__gcc_v4di*, __gcc_v4di); void __builtin_ia32_movntpd256(double*, __gcc_v4df); void __builtin_ia32_movntps256(float*, __gcc_v8sf); -void __builtin_ia32_compressstoresf512_mask(__gcc_v16sf*, __gcc_v16sf, short); -void __builtin_ia32_compressstoresi512_mask(__gcc_v16si*, __gcc_v16si, short); -void __builtin_ia32_compressstoredf512_mask(__gcc_v8df*, __gcc_v8df, char); -void __builtin_ia32_compressstoredi512_mask(__gcc_v8di*, __gcc_v8di, char); -__gcc_v16sf __builtin_ia32_expandloadsf512_mask(const __gcc_v16sf*, __gcc_v16sf, short); -__gcc_v16sf __builtin_ia32_expandloadsf512_maskz(const __gcc_v16sf*, __gcc_v16sf, short); -__gcc_v16si __builtin_ia32_expandloadsi512_mask(const __gcc_v16si*, __gcc_v16si, short); -__gcc_v16si __builtin_ia32_expandloadsi512_maskz(const __gcc_v16si*, __gcc_v16si, short); -__gcc_v8df __builtin_ia32_expandloaddf512_mask(const __gcc_v8df*, __gcc_v8df, char); -__gcc_v8df __builtin_ia32_expandloaddf512_maskz(const __gcc_v8df*, __gcc_v8df, char); -__gcc_v8di __builtin_ia32_expandloaddi512_mask(const __gcc_v8di*, __gcc_v8di, char); -__gcc_v8di __builtin_ia32_expandloaddi512_maskz(const __gcc_v8di*, __gcc_v8di, char); -__gcc_v16si __builtin_ia32_loaddqusi512_mask(const __gcc_v16si*, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_loaddqudi512_mask(const __gcc_v8di*, __gcc_v8di, char); -__gcc_v8df __builtin_ia32_loadupd512_mask(const __gcc_v8df*, __gcc_v8df, char); -__gcc_v16sf __builtin_ia32_loadups512_mask(const __gcc_v16sf*, __gcc_v16sf, short); -__gcc_v16sf __builtin_ia32_loadaps512_mask(const __gcc_v16sf*, __gcc_v16sf, short); -__gcc_v16si __builtin_ia32_movdqa32load512_mask(const __gcc_v16si*, __gcc_v16si, short); -__gcc_v8df __builtin_ia32_loadapd512_mask(const __gcc_v8df*, __gcc_v8df, char); -__gcc_v8di __builtin_ia32_movdqa64load512_mask(const __gcc_v8di*, __gcc_v8di, char); +void __builtin_ia32_compressstoresf512_mask(__gcc_v16sf*, __gcc_v16sf, unsigned short); +void __builtin_ia32_compressstoresi512_mask(__gcc_v16si*, __gcc_v16si, unsigned short); +void __builtin_ia32_compressstoredf512_mask(__gcc_v8df*, __gcc_v8df, unsigned char); +void __builtin_ia32_compressstoredi512_mask(__gcc_v8di*, __gcc_v8di, unsigned char); +__gcc_v16sf __builtin_ia32_expandloadsf512_mask(const __gcc_v16sf*, __gcc_v16sf, unsigned short); +__gcc_v16sf __builtin_ia32_expandloadsf512_maskz(const __gcc_v16sf*, __gcc_v16sf, unsigned short); +__gcc_v16si __builtin_ia32_expandloadsi512_mask(const __gcc_v16si*, __gcc_v16si, unsigned short); +__gcc_v16si __builtin_ia32_expandloadsi512_maskz(const __gcc_v16si*, __gcc_v16si, unsigned short); +__gcc_v8df __builtin_ia32_expandloaddf512_mask(const __gcc_v8df*, __gcc_v8df, unsigned char); +__gcc_v8df __builtin_ia32_expandloaddf512_maskz(const __gcc_v8df*, __gcc_v8df, unsigned char); +__gcc_v8di __builtin_ia32_expandloaddi512_mask(const __gcc_v8di*, __gcc_v8di, unsigned char); +__gcc_v8di __builtin_ia32_expandloaddi512_maskz(const __gcc_v8di*, __gcc_v8di, unsigned char); +__gcc_v16si __builtin_ia32_loaddqusi512_mask(const int*, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_loaddqudi512_mask(const long long*, __gcc_v8di, unsigned char); +__gcc_v8df __builtin_ia32_loadupd512_mask(const double*, __gcc_v8df, unsigned char); +__gcc_v16sf __builtin_ia32_loadups512_mask(const float*, __gcc_v16sf, unsigned short); +__gcc_v16sf __builtin_ia32_loadaps512_mask(const __gcc_v16sf*, __gcc_v16sf, unsigned short); +__gcc_v16si __builtin_ia32_movdqa32load512_mask(const __gcc_v16si*, __gcc_v16si, unsigned short); +__gcc_v8df __builtin_ia32_loadapd512_mask(const __gcc_v8df*, __gcc_v8df, unsigned char); +__gcc_v8di __builtin_ia32_movdqa64load512_mask(const __gcc_v8di*, __gcc_v8di, unsigned char); void __builtin_ia32_movntps512(float*, __gcc_v16sf); void __builtin_ia32_movntpd512(double*, __gcc_v8df); void __builtin_ia32_movntdq512(__gcc_v8di*, __gcc_v8di); __gcc_v8di __builtin_ia32_movntdqa512(__gcc_v8di*); -void __builtin_ia32_storedqusi512_mask(__gcc_v16si*, __gcc_v16si, short); -void __builtin_ia32_storedqudi512_mask(__gcc_v8di*, __gcc_v8di, char); -void __builtin_ia32_storeupd512_mask(__gcc_v8df*, __gcc_v8df, char); -void __builtin_ia32_pmovusqd512mem_mask(__gcc_v8si*, __gcc_v8di, char); -void __builtin_ia32_pmovsqd512mem_mask(__gcc_v8si*, __gcc_v8di, char); -void __builtin_ia32_pmovqd512mem_mask(__gcc_v8si*, __gcc_v8di, char); -void __builtin_ia32_pmovusqw512mem_mask(__gcc_v8hi*, __gcc_v8di, char); -void __builtin_ia32_pmovsqw512mem_mask(__gcc_v8hi*, __gcc_v8di, char); -void __builtin_ia32_pmovqw512mem_mask(__gcc_v8hi*, __gcc_v8di, char); -void __builtin_ia32_pmovusdw512mem_mask(__gcc_v16hi*, __gcc_v16si, short); -void __builtin_ia32_pmovsdw512mem_mask(__gcc_v16hi*, __gcc_v16si, short); -void __builtin_ia32_pmovdw512mem_mask(__gcc_v16hi*, __gcc_v16si, short); -void __builtin_ia32_pmovqb512mem_mask(__gcc_v16qi*, __gcc_v8di, char); -void __builtin_ia32_pmovusqb512mem_mask(__gcc_v16qi*, __gcc_v8di, char); -void __builtin_ia32_pmovsqb512mem_mask(__gcc_v16qi*, __gcc_v8di, char); -void __builtin_ia32_pmovusdb512mem_mask(__gcc_v16qi*, __gcc_v16si, short); -void __builtin_ia32_pmovsdb512mem_mask(__gcc_v16qi*, __gcc_v16si, short); -void __builtin_ia32_pmovdb512mem_mask(__gcc_v16qi*, __gcc_v16si, short); -void __builtin_ia32_storeups512_mask(__gcc_v16sf*, __gcc_v16sf, short); -void __builtin_ia32_storeaps512_mask(__gcc_v16sf*, __gcc_v16sf, short); -void __builtin_ia32_movdqa32store512_mask(__gcc_v16si*, __gcc_v16si, short); -void __builtin_ia32_storeapd512_mask(__gcc_v8df*, __gcc_v8df, char); -void __builtin_ia32_movdqa64store512_mask(__gcc_v8di*, __gcc_v8di, char); +void __builtin_ia32_storedqusi512_mask(int*, __gcc_v16si, unsigned short); +void __builtin_ia32_storedqudi512_mask(long long*, __gcc_v8di, unsigned char); +void __builtin_ia32_storeupd512_mask(double*, __gcc_v8df, unsigned char); +void __builtin_ia32_pmovusqd512mem_mask(__gcc_v8si*, __gcc_v8di, unsigned char); +void __builtin_ia32_pmovsqd512mem_mask(__gcc_v8si*, __gcc_v8di, unsigned char); +void __builtin_ia32_pmovqd512mem_mask(__gcc_v8si*, __gcc_v8di, unsigned char); +void __builtin_ia32_pmovusqw512mem_mask(__gcc_v8hi*, __gcc_v8di, unsigned char); +void __builtin_ia32_pmovsqw512mem_mask(__gcc_v8hi*, __gcc_v8di, unsigned char); +void __builtin_ia32_pmovqw512mem_mask(__gcc_v8hi*, __gcc_v8di, unsigned char); +void __builtin_ia32_pmovusdw512mem_mask(__gcc_v16hi*, __gcc_v16si, unsigned short); +void __builtin_ia32_pmovsdw512mem_mask(__gcc_v16hi*, __gcc_v16si, unsigned short); +void __builtin_ia32_pmovdw512mem_mask(__gcc_v16hi*, __gcc_v16si, unsigned short); +void __builtin_ia32_pmovqb512mem_mask(__gcc_v16qi*, __gcc_v8di, unsigned char); +void __builtin_ia32_pmovusqb512mem_mask(__gcc_v16qi*, __gcc_v8di, unsigned char); +void __builtin_ia32_pmovsqb512mem_mask(__gcc_v16qi*, __gcc_v8di, unsigned char); +void __builtin_ia32_pmovusdb512mem_mask(__gcc_v16qi*, __gcc_v16si, unsigned short); +void __builtin_ia32_pmovsdb512mem_mask(__gcc_v16qi*, __gcc_v16si, unsigned short); +void __builtin_ia32_pmovdb512mem_mask(__gcc_v16qi*, __gcc_v16si, unsigned short); +void __builtin_ia32_storeups512_mask(float*, __gcc_v16sf, unsigned short); +void __builtin_ia32_storeaps512_mask(__gcc_v16sf*, __gcc_v16sf, unsigned short); +void __builtin_ia32_movdqa32store512_mask(__gcc_v16si*, __gcc_v16si, unsigned short); +void __builtin_ia32_storeapd512_mask(__gcc_v8df*, __gcc_v8df, unsigned char); +void __builtin_ia32_movdqa64store512_mask(__gcc_v8di*, __gcc_v8di, unsigned char); void __builtin_ia32_llwpcb(void*); -void* __builtin_ia32_slwpcb(void); +void* __builtin_ia32_slwpcb(); void __builtin_ia32_wrfsbase32(unsigned); void __builtin_ia32_wrfsbase64(unsigned long long); void __builtin_ia32_wrgsbase32(unsigned); void __builtin_ia32_wrgsbase64(unsigned long long); -unsigned __builtin_ia32_xbegin(void); -void __builtin_ia32_xend(void); +unsigned __builtin_ia32_xbegin(); +void __builtin_ia32_xend(); void __builtin_ia32_xabort(unsigned); -int __builtin_ia32_xtest(void); +int __builtin_ia32_xtest(); int __builtin_ia32_bsrsi(int); long long __builtin_ia32_bsrdi(long long); unsigned long long __builtin_ia32_rdpmc(int); @@ -121,7 +121,7 @@ unsigned char __builtin_ia32_rolqi(unsigned char, int); unsigned short __builtin_ia32_rolhi(unsigned short, int); unsigned char __builtin_ia32_rorqi(unsigned char, int); unsigned short __builtin_ia32_rorhi(unsigned short, int); -__gcc_v2si __builtin_ia32_pfrsqit1(__gcc_v2sf, __gcc_v2sf); +__gcc_v2sf __builtin_ia32_pfrsqit1(__gcc_v2sf, __gcc_v2sf); __gcc_v4sf __builtin_ia32_sqrtps_nr(__gcc_v4sf); __gcc_v4sf __builtin_ia32_rsqrtps_nr(__gcc_v4sf); __gcc_v4sf __builtin_ia32_copysignps(__gcc_v4sf, __gcc_v4sf); @@ -184,197 +184,197 @@ unsigned __builtin_ia32_pdep_si(unsigned, unsigned); unsigned long long __builtin_ia32_pdep_di(unsigned long long, unsigned long long); unsigned __builtin_ia32_pext_si(unsigned, unsigned); unsigned long long __builtin_ia32_pext_di(unsigned long long, unsigned long long); -__gcc_v16si __builtin_ia32_alignd512_mask(__gcc_v16si, __gcc_v16si, int, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_alignq512_mask(__gcc_v8di, __gcc_v8di, int, __gcc_v8di, char); -__gcc_v16si __builtin_ia32_blendmd_512_mask(__gcc_v16si, __gcc_v16si, short); -__gcc_v8df __builtin_ia32_blendmpd_512_mask(__gcc_v8df, __gcc_v8df, char); -__gcc_v16sf __builtin_ia32_blendmps_512_mask(__gcc_v16sf, __gcc_v16sf, short); -__gcc_v8di __builtin_ia32_blendmq_512_mask(__gcc_v8di, __gcc_v8di, char); -__gcc_v16sf __builtin_ia32_broadcastf32x4_512(__gcc_v4sf, __gcc_v16sf, short); -__gcc_v8df __builtin_ia32_broadcastf64x4_512(__gcc_v4df, __gcc_v8df, char); -__gcc_v16si __builtin_ia32_broadcasti32x4_512(__gcc_v4si, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_broadcasti64x4_512(__gcc_v4di, __gcc_v8di, char); -__gcc_v8df __builtin_ia32_broadcastsd512(__gcc_v2df, __gcc_v8df, char); -__gcc_v16sf __builtin_ia32_broadcastss512(__gcc_v4sf, __gcc_v16sf, short); +__gcc_v16si __builtin_ia32_alignd512_mask(__gcc_v16si, __gcc_v16si, int, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_alignq512_mask(__gcc_v8di, __gcc_v8di, int, __gcc_v8di, unsigned char); +__gcc_v16si __builtin_ia32_blendmd_512_mask(__gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v8df __builtin_ia32_blendmpd_512_mask(__gcc_v8df, __gcc_v8df, unsigned char); +__gcc_v16sf __builtin_ia32_blendmps_512_mask(__gcc_v16sf, __gcc_v16sf, unsigned short); +__gcc_v8di __builtin_ia32_blendmq_512_mask(__gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v16sf __builtin_ia32_broadcastf32x4_512(__gcc_v4sf, __gcc_v16sf, unsigned short); +__gcc_v8df __builtin_ia32_broadcastf64x4_512(__gcc_v4df, __gcc_v8df, unsigned char); +__gcc_v16si __builtin_ia32_broadcasti32x4_512(__gcc_v4si, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_broadcasti64x4_512(__gcc_v4di, __gcc_v8di, unsigned char); +__gcc_v8df __builtin_ia32_broadcastsd512(__gcc_v2df, __gcc_v8df, unsigned char); +__gcc_v16sf __builtin_ia32_broadcastss512(__gcc_v4sf, __gcc_v16sf, unsigned short); short __builtin_ia32_cmpd512_mask(__gcc_v16si, __gcc_v16si, int, short); -char __builtin_ia32_cmpq512_mask(__gcc_v8di, __gcc_v8di, int, char); -__gcc_v8df __builtin_ia32_compressdf512_mask(__gcc_v8df, __gcc_v8df, char); -__gcc_v16sf __builtin_ia32_compresssf512_mask(__gcc_v16sf, __gcc_v16sf, short); -__gcc_v8df __builtin_ia32_cvtdq2pd512_mask(__gcc_v8si, __gcc_v8df, char); -__gcc_v16hi __builtin_ia32_vcvtps2ph512_mask(__gcc_v16sf, int, __gcc_v16hi, short); -__gcc_v8df __builtin_ia32_cvtudq2pd512_mask(__gcc_v8si, __gcc_v8df, char); +unsigned char __builtin_ia32_cmpq512_mask(__gcc_v8di, __gcc_v8di, int, unsigned char); +__gcc_v8df __builtin_ia32_compressdf512_mask(__gcc_v8df, __gcc_v8df, unsigned char); +__gcc_v16sf __builtin_ia32_compresssf512_mask(__gcc_v16sf, __gcc_v16sf, unsigned short); +__gcc_v8df __builtin_ia32_cvtdq2pd512_mask(__gcc_v8si, __gcc_v8df, unsigned char); +__gcc_v16hi __builtin_ia32_vcvtps2ph512_mask(__gcc_v16sf, int, __gcc_v16hi, unsigned short); +__gcc_v8df __builtin_ia32_cvtudq2pd512_mask(__gcc_v8si, __gcc_v8df, unsigned char); __gcc_v2df __builtin_ia32_cvtusi2sd32(__gcc_v2df, unsigned); -__gcc_v8df __builtin_ia32_expanddf512_mask(__gcc_v8df, __gcc_v8df, char); -__gcc_v8df __builtin_ia32_expanddf512_maskz(__gcc_v8df, __gcc_v8df, char); -__gcc_v16sf __builtin_ia32_expandsf512_mask(__gcc_v16sf, __gcc_v16sf, short); -__gcc_v16sf __builtin_ia32_expandsf512_maskz(__gcc_v16sf, __gcc_v16sf, short); -__gcc_v4sf __builtin_ia32_extractf32x4_mask(__gcc_v16sf, int, __gcc_v4sf, char); -__gcc_v4df __builtin_ia32_extractf64x4_mask(__gcc_v8df, int, __gcc_v4df, char); -__gcc_v4si __builtin_ia32_extracti32x4_mask(__gcc_v16si, int, __gcc_v4si, char); -__gcc_v4di __builtin_ia32_extracti64x4_mask(__gcc_v8di, int, __gcc_v4di, char); -__gcc_v16sf __builtin_ia32_insertf32x4_mask(__gcc_v16sf, __gcc_v4sf, int, __gcc_v16sf, short); -__gcc_v8df __builtin_ia32_insertf64x4_mask(__gcc_v8df, __gcc_v4df, int, __gcc_v8df, char); -__gcc_v16si __builtin_ia32_inserti32x4_mask(__gcc_v16si, __gcc_v4si, int, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_inserti64x4_mask(__gcc_v8di, __gcc_v4di, int, __gcc_v8di, char); -__gcc_v8df __builtin_ia32_movapd512_mask(__gcc_v8df, __gcc_v8df, char); -__gcc_v16sf __builtin_ia32_movaps512_mask(__gcc_v16sf, __gcc_v16sf, short); -__gcc_v8df __builtin_ia32_movddup512_mask(__gcc_v8df, __gcc_v8df, char); -__gcc_v16si __builtin_ia32_movdqa32_512_mask(__gcc_v16si, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_movdqa64_512_mask(__gcc_v8di, __gcc_v8di, char); -__gcc_v16sf __builtin_ia32_movshdup512_mask(__gcc_v16sf, __gcc_v16sf, short); -__gcc_v16sf __builtin_ia32_movsldup512_mask(__gcc_v16sf, __gcc_v16sf, short); -__gcc_v16si __builtin_ia32_pabsd512_mask(__gcc_v16si, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_pabsq512_mask(__gcc_v8di, __gcc_v8di, char); -__gcc_v16si __builtin_ia32_paddd512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_paddq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, char); -__gcc_v16si __builtin_ia32_pandd512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, short); -__gcc_v16si __builtin_ia32_pandnd512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_pandnq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, char); -__gcc_v8di __builtin_ia32_pandq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, char); -__gcc_v16si __builtin_ia32_pbroadcastd512(__gcc_v4si, __gcc_v16si, short); -__gcc_v16si __builtin_ia32_pbroadcastd512_gpr_mask(int, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_broadcastmb512(char); -__gcc_v16si __builtin_ia32_broadcastmw512(short); -__gcc_v8di __builtin_ia32_pbroadcastq512(__gcc_v2di, __gcc_v8di, char); -__gcc_v8di __builtin_ia32_pbroadcastq512_gpr_mask(long long, __gcc_v8di, char); +__gcc_v8df __builtin_ia32_expanddf512_mask(__gcc_v8df, __gcc_v8df, unsigned char); +__gcc_v8df __builtin_ia32_expanddf512_maskz(__gcc_v8df, __gcc_v8df, unsigned char); +__gcc_v16sf __builtin_ia32_expandsf512_mask(__gcc_v16sf, __gcc_v16sf, unsigned short); +__gcc_v16sf __builtin_ia32_expandsf512_maskz(__gcc_v16sf, __gcc_v16sf, unsigned short); +__gcc_v4sf __builtin_ia32_extractf32x4_mask(__gcc_v16sf, int, __gcc_v4sf, unsigned char); +__gcc_v4df __builtin_ia32_extractf64x4_mask(__gcc_v8df, int, __gcc_v4df, unsigned char); +__gcc_v4si __builtin_ia32_extracti32x4_mask(__gcc_v16si, int, __gcc_v4si, unsigned char); +__gcc_v4di __builtin_ia32_extracti64x4_mask(__gcc_v8di, int, __gcc_v4di, unsigned char); +__gcc_v16sf __builtin_ia32_insertf32x4_mask(__gcc_v16sf, __gcc_v4sf, int, __gcc_v16sf, unsigned short); +__gcc_v8df __builtin_ia32_insertf64x4_mask(__gcc_v8df, __gcc_v4df, int, __gcc_v8df, unsigned char); +__gcc_v16si __builtin_ia32_inserti32x4_mask(__gcc_v16si, __gcc_v4si, int, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_inserti64x4_mask(__gcc_v8di, __gcc_v4di, int, __gcc_v8di, unsigned char); +__gcc_v8df __builtin_ia32_movapd512_mask(__gcc_v8df, __gcc_v8df, unsigned char); +__gcc_v16sf __builtin_ia32_movaps512_mask(__gcc_v16sf, __gcc_v16sf, unsigned short); +__gcc_v8df __builtin_ia32_movddup512_mask(__gcc_v8df, __gcc_v8df, unsigned char); +__gcc_v16si __builtin_ia32_movdqa32_512_mask(__gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_movdqa64_512_mask(__gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v16sf __builtin_ia32_movshdup512_mask(__gcc_v16sf, __gcc_v16sf, unsigned short); +__gcc_v16sf __builtin_ia32_movsldup512_mask(__gcc_v16sf, __gcc_v16sf, unsigned short); +__gcc_v16si __builtin_ia32_pabsd512_mask(__gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_pabsq512_mask(__gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v16si __builtin_ia32_paddd512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_paddq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v16si __builtin_ia32_pandd512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v16si __builtin_ia32_pandnd512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_pandnq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v8di __builtin_ia32_pandq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v16si __builtin_ia32_pbroadcastd512(__gcc_v4si, __gcc_v16si, unsigned short); +__gcc_v16si __builtin_ia32_pbroadcastd512_gpr_mask(int, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_broadcastmb512(unsigned char); +__gcc_v16si __builtin_ia32_broadcastmw512(unsigned short); +__gcc_v8di __builtin_ia32_pbroadcastq512(__gcc_v2di, __gcc_v8di, unsigned char); +__gcc_v8di __builtin_ia32_pbroadcastq512_gpr_mask(long long, __gcc_v8di, unsigned char); __gcc_v8di __builtin_ia32_pbroadcastq512_mem_mask(long long, __gcc_v8di, char); -short __builtin_ia32_pcmpeqd512_mask(__gcc_v16si, __gcc_v16si, short); -char __builtin_ia32_pcmpeqq512_mask(__gcc_v8di, __gcc_v8di, char); -short __builtin_ia32_pcmpgtd512_mask(__gcc_v16si, __gcc_v16si, short); -char __builtin_ia32_pcmpgtq512_mask(__gcc_v8di, __gcc_v8di, char); -__gcc_v16si __builtin_ia32_compresssi512_mask(__gcc_v16si, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_compressdi512_mask(__gcc_v8di, __gcc_v8di, char); -__gcc_v16si __builtin_ia32_expandsi512_mask(__gcc_v16si, __gcc_v16si, short); -__gcc_v16si __builtin_ia32_expandsi512_maskz(__gcc_v16si, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_expanddi512_mask(__gcc_v8di, __gcc_v8di, char); -__gcc_v8di __builtin_ia32_expanddi512_maskz(__gcc_v8di, __gcc_v8di, char); -__gcc_v16si __builtin_ia32_pmaxsd512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_pmaxsq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, char); -__gcc_v16si __builtin_ia32_pmaxud512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_pmaxuq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, char); -__gcc_v16si __builtin_ia32_pminsd512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_pminsq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, char); -__gcc_v16si __builtin_ia32_pminud512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_pminuq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, char); -__gcc_v16qi __builtin_ia32_pmovdb512_mask(__gcc_v16si, __gcc_v16qi, short); -__gcc_v16hi __builtin_ia32_pmovdw512_mask(__gcc_v16si, __gcc_v16hi, short); -__gcc_v16qi __builtin_ia32_pmovqb512_mask(__gcc_v8di, __gcc_v16qi, char); -__gcc_v8si __builtin_ia32_pmovqd512_mask(__gcc_v8di, __gcc_v8si, char); -__gcc_v8hi __builtin_ia32_pmovqw512_mask(__gcc_v8di, __gcc_v8hi, char); -__gcc_v16qi __builtin_ia32_pmovsdb512_mask(__gcc_v16si, __gcc_v16qi, short); -__gcc_v16hi __builtin_ia32_pmovsdw512_mask(__gcc_v16si, __gcc_v16hi, short); -__gcc_v16qi __builtin_ia32_pmovsqb512_mask(__gcc_v8di, __gcc_v16qi, char); -__gcc_v8si __builtin_ia32_pmovsqd512_mask(__gcc_v8di, __gcc_v8si, char); -__gcc_v8hi __builtin_ia32_pmovsqw512_mask(__gcc_v8di, __gcc_v8hi, char); -__gcc_v16si __builtin_ia32_pmovsxbd512_mask(__gcc_v16qi, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_pmovsxbq512_mask(__gcc_v16qi, __gcc_v8di, char); -__gcc_v8di __builtin_ia32_pmovsxdq512_mask(__gcc_v8si, __gcc_v8di, char); -__gcc_v16si __builtin_ia32_pmovsxwd512_mask(__gcc_v16hi, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_pmovsxwq512_mask(__gcc_v8hi, __gcc_v8di, char); -__gcc_v16qi __builtin_ia32_pmovusdb512_mask(__gcc_v16si, __gcc_v16qi, short); -__gcc_v16hi __builtin_ia32_pmovusdw512_mask(__gcc_v16si, __gcc_v16hi, short); -__gcc_v16qi __builtin_ia32_pmovusqb512_mask(__gcc_v8di, __gcc_v16qi, char); -__gcc_v8si __builtin_ia32_pmovusqd512_mask(__gcc_v8di, __gcc_v8si, char); -__gcc_v8hi __builtin_ia32_pmovusqw512_mask(__gcc_v8di, __gcc_v8hi, char); -__gcc_v16si __builtin_ia32_pmovzxbd512_mask(__gcc_v16qi, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_pmovzxbq512_mask(__gcc_v16qi, __gcc_v8di, char); -__gcc_v8di __builtin_ia32_pmovzxdq512_mask(__gcc_v8si, __gcc_v8di, char); -__gcc_v16si __builtin_ia32_pmovzxwd512_mask(__gcc_v16hi, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_pmovzxwq512_mask(__gcc_v8hi, __gcc_v8di, char); -__gcc_v8di __builtin_ia32_pmuldq512_mask(__gcc_v16si, __gcc_v16si, __gcc_v8di, char); -__gcc_v16si __builtin_ia32_pmulld512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_pmuludq512_mask(__gcc_v16si, __gcc_v16si, __gcc_v8di, char); -__gcc_v16si __builtin_ia32_pord512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_porq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, char); -__gcc_v16si __builtin_ia32_prold512_mask(__gcc_v16si, int, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_prolq512_mask(__gcc_v8di, int, __gcc_v8di, char); -__gcc_v16si __builtin_ia32_prolvd512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_prolvq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, char); -__gcc_v16si __builtin_ia32_prord512_mask(__gcc_v16si, int, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_prorq512_mask(__gcc_v8di, int, __gcc_v8di, char); -__gcc_v16si __builtin_ia32_prorvd512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_prorvq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, char); -__gcc_v16si __builtin_ia32_pshufd512_mask(__gcc_v16si, int, __gcc_v16si, short); +unsigned short __builtin_ia32_pcmpeqd512_mask(__gcc_v16si, __gcc_v16si, unsigned short); +unsigned char __builtin_ia32_pcmpeqq512_mask(__gcc_v8di, __gcc_v8di, unsigned char); +unsigned short __builtin_ia32_pcmpgtd512_mask(__gcc_v16si, __gcc_v16si, unsigned short); +unsigned char __builtin_ia32_pcmpgtq512_mask(__gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v16si __builtin_ia32_compresssi512_mask(__gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_compressdi512_mask(__gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v16si __builtin_ia32_expandsi512_mask(__gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v16si __builtin_ia32_expandsi512_maskz(__gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_expanddi512_mask(__gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v8di __builtin_ia32_expanddi512_maskz(__gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v16si __builtin_ia32_pmaxsd512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_pmaxsq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v16si __builtin_ia32_pmaxud512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_pmaxuq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v16si __builtin_ia32_pminsd512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_pminsq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v16si __builtin_ia32_pminud512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_pminuq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v16qi __builtin_ia32_pmovdb512_mask(__gcc_v16si, __gcc_v16qi, unsigned short); +__gcc_v16hi __builtin_ia32_pmovdw512_mask(__gcc_v16si, __gcc_v16hi, unsigned short); +__gcc_v16qi __builtin_ia32_pmovqb512_mask(__gcc_v8di, __gcc_v16qi, unsigned char); +__gcc_v8si __builtin_ia32_pmovqd512_mask(__gcc_v8di, __gcc_v8si, unsigned char); +__gcc_v8hi __builtin_ia32_pmovqw512_mask(__gcc_v8di, __gcc_v8hi, unsigned char); +__gcc_v16qi __builtin_ia32_pmovsdb512_mask(__gcc_v16si, __gcc_v16qi, unsigned short); +__gcc_v16hi __builtin_ia32_pmovsdw512_mask(__gcc_v16si, __gcc_v16hi, unsigned short); +__gcc_v16qi __builtin_ia32_pmovsqb512_mask(__gcc_v8di, __gcc_v16qi, unsigned char); +__gcc_v8si __builtin_ia32_pmovsqd512_mask(__gcc_v8di, __gcc_v8si, unsigned char); +__gcc_v8hi __builtin_ia32_pmovsqw512_mask(__gcc_v8di, __gcc_v8hi, unsigned char); +__gcc_v16si __builtin_ia32_pmovsxbd512_mask(__gcc_v16qi, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_pmovsxbq512_mask(__gcc_v16qi, __gcc_v8di, unsigned char); +__gcc_v8di __builtin_ia32_pmovsxdq512_mask(__gcc_v8si, __gcc_v8di, unsigned char); +__gcc_v16si __builtin_ia32_pmovsxwd512_mask(__gcc_v16hi, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_pmovsxwq512_mask(__gcc_v8hi, __gcc_v8di, unsigned char); +__gcc_v16qi __builtin_ia32_pmovusdb512_mask(__gcc_v16si, __gcc_v16qi, unsigned short); +__gcc_v16hi __builtin_ia32_pmovusdw512_mask(__gcc_v16si, __gcc_v16hi, unsigned short); +__gcc_v16qi __builtin_ia32_pmovusqb512_mask(__gcc_v8di, __gcc_v16qi, unsigned char); +__gcc_v8si __builtin_ia32_pmovusqd512_mask(__gcc_v8di, __gcc_v8si, unsigned char); +__gcc_v8hi __builtin_ia32_pmovusqw512_mask(__gcc_v8di, __gcc_v8hi, unsigned char); +__gcc_v16si __builtin_ia32_pmovzxbd512_mask(__gcc_v16qi, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_pmovzxbq512_mask(__gcc_v16qi, __gcc_v8di, unsigned char); +__gcc_v8di __builtin_ia32_pmovzxdq512_mask(__gcc_v8si, __gcc_v8di, unsigned char); +__gcc_v16si __builtin_ia32_pmovzxwd512_mask(__gcc_v16hi, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_pmovzxwq512_mask(__gcc_v8hi, __gcc_v8di, unsigned char); +__gcc_v8di __builtin_ia32_pmuldq512_mask(__gcc_v16si, __gcc_v16si, __gcc_v8di, unsigned char); +__gcc_v16si __builtin_ia32_pmulld512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_pmuludq512_mask(__gcc_v16si, __gcc_v16si, __gcc_v8di, unsigned char); +__gcc_v16si __builtin_ia32_pord512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_porq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v16si __builtin_ia32_prold512_mask(__gcc_v16si, int, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_prolq512_mask(__gcc_v8di, int, __gcc_v8di, unsigned char); +__gcc_v16si __builtin_ia32_prolvd512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_prolvq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v16si __builtin_ia32_prord512_mask(__gcc_v16si, int, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_prorq512_mask(__gcc_v8di, int, __gcc_v8di, unsigned char); +__gcc_v16si __builtin_ia32_prorvd512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_prorvq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v16si __builtin_ia32_pshufd512_mask(__gcc_v16si, int, __gcc_v16si, unsigned short); __gcc_v16si __builtin_ia32_pslld512_mask(__gcc_v16si, __gcc_v4si, __gcc_v16si, short); __gcc_v16si __builtin_ia32_pslldi512_mask(__gcc_v16si, int, __gcc_v16si, short); __gcc_v8di __builtin_ia32_psllq512_mask(__gcc_v8di, __gcc_v2di, __gcc_v8di, char); __gcc_v8di __builtin_ia32_psllqi512_mask(__gcc_v8di, int, __gcc_v8di, char); -__gcc_v16si __builtin_ia32_psllv16si_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_psllv8di_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, char); +__gcc_v16si __builtin_ia32_psllv16si_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_psllv8di_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, unsigned char); __gcc_v16si __builtin_ia32_psrad512_mask(__gcc_v16si, __gcc_v4si, __gcc_v16si, short); __gcc_v16si __builtin_ia32_psradi512_mask(__gcc_v16si, int, __gcc_v16si, short); __gcc_v8di __builtin_ia32_psraq512_mask(__gcc_v8di, __gcc_v2di, __gcc_v8di, char); __gcc_v8di __builtin_ia32_psraqi512_mask(__gcc_v8di, int, __gcc_v8di, char); -__gcc_v16si __builtin_ia32_psrav16si_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_psrav8di_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, char); +__gcc_v16si __builtin_ia32_psrav16si_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_psrav8di_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, unsigned char); __gcc_v16si __builtin_ia32_psrld512_mask(__gcc_v16si, __gcc_v4si, __gcc_v16si, short); __gcc_v16si __builtin_ia32_psrldi512_mask(__gcc_v16si, int, __gcc_v16si, short); __gcc_v8di __builtin_ia32_psrlq512_mask(__gcc_v8di, __gcc_v2di, __gcc_v8di, char); __gcc_v8di __builtin_ia32_psrlqi512_mask(__gcc_v8di, int, __gcc_v8di, char); -__gcc_v16si __builtin_ia32_psrlv16si_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_psrlv8di_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, char); -__gcc_v16si __builtin_ia32_psubd512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_psubq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, char); -short __builtin_ia32_ptestmd512(__gcc_v16si, __gcc_v16si, short); -char __builtin_ia32_ptestmq512(__gcc_v8di, __gcc_v8di, char); -short __builtin_ia32_ptestnmd512(__gcc_v16si, __gcc_v16si, short); -char __builtin_ia32_ptestnmq512(__gcc_v8di, __gcc_v8di, char); -__gcc_v16si __builtin_ia32_punpckhdq512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_punpckhqdq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, char); -__gcc_v16si __builtin_ia32_punpckldq512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_punpcklqdq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, char); -__gcc_v16si __builtin_ia32_pxord512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_pxorq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, char); -__gcc_v8df __builtin_ia32_rcp14pd512_mask(__gcc_v8df, __gcc_v8df, char); -__gcc_v16sf __builtin_ia32_rcp14ps512_mask(__gcc_v16sf, __gcc_v16sf, short); +__gcc_v16si __builtin_ia32_psrlv16si_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_psrlv8di_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v16si __builtin_ia32_psubd512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_psubq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, unsigned char); +unsigned short __builtin_ia32_ptestmd512(__gcc_v16si, __gcc_v16si, unsigned short); +unsigned char __builtin_ia32_ptestmq512(__gcc_v8di, __gcc_v8di, unsigned char); +unsigned short __builtin_ia32_ptestnmd512(__gcc_v16si, __gcc_v16si, unsigned short); +unsigned char __builtin_ia32_ptestnmq512(__gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v16si __builtin_ia32_punpckhdq512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_punpckhqdq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v16si __builtin_ia32_punpckldq512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_punpcklqdq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v16si __builtin_ia32_pxord512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_pxorq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v8df __builtin_ia32_rcp14pd512_mask(__gcc_v8df, __gcc_v8df, unsigned char); +__gcc_v16sf __builtin_ia32_rcp14ps512_mask(__gcc_v16sf, __gcc_v16sf, unsigned short); __gcc_v2df __builtin_ia32_rcp14sd(__gcc_v2df, __gcc_v2df); __gcc_v4sf __builtin_ia32_rcp14ss(__gcc_v4sf, __gcc_v4sf); -__gcc_v8df __builtin_ia32_rsqrt14pd512_mask(__gcc_v8df, __gcc_v8df, char); -__gcc_v16sf __builtin_ia32_rsqrt14ps512_mask(__gcc_v16sf, __gcc_v16sf, short); +__gcc_v8df __builtin_ia32_rsqrt14pd512_mask(__gcc_v8df, __gcc_v8df, unsigned char); +__gcc_v16sf __builtin_ia32_rsqrt14ps512_mask(__gcc_v16sf, __gcc_v16sf, unsigned short); __gcc_v2df __builtin_ia32_rsqrt14sd(__gcc_v2df, __gcc_v2df); __gcc_v4sf __builtin_ia32_rsqrt14ss(__gcc_v4sf, __gcc_v4sf); -__gcc_v8df __builtin_ia32_shufpd512_mask(__gcc_v8df, __gcc_v8df, int, __gcc_v8df, char); -__gcc_v16sf __builtin_ia32_shufps512_mask(__gcc_v16sf, __gcc_v16sf, int, __gcc_v16sf, short); -__gcc_v16sf __builtin_ia32_shuf_f32x4_mask(__gcc_v16sf, __gcc_v16sf, int, __gcc_v16sf, short); -__gcc_v8df __builtin_ia32_shuf_f64x2_mask(__gcc_v8df, __gcc_v8df, int, __gcc_v8df, char); -__gcc_v16si __builtin_ia32_shuf_i32x4_mask(__gcc_v16si, __gcc_v16si, int, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_shuf_i64x2_mask(__gcc_v8di, __gcc_v8di, int, __gcc_v8di, char); +__gcc_v8df __builtin_ia32_shufpd512_mask(__gcc_v8df, __gcc_v8df, int, __gcc_v8df, unsigned char); +__gcc_v16sf __builtin_ia32_shufps512_mask(__gcc_v16sf, __gcc_v16sf, int, __gcc_v16sf, unsigned short); +__gcc_v16sf __builtin_ia32_shuf_f32x4_mask(__gcc_v16sf, __gcc_v16sf, int, __gcc_v16sf, unsigned short); +__gcc_v8df __builtin_ia32_shuf_f64x2_mask(__gcc_v8df, __gcc_v8df, int, __gcc_v8df, unsigned char); +__gcc_v16si __builtin_ia32_shuf_i32x4_mask(__gcc_v16si, __gcc_v16si, int, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_shuf_i64x2_mask(__gcc_v8di, __gcc_v8di, int, __gcc_v8di, unsigned char); short __builtin_ia32_ucmpd512_mask(__gcc_v16si, __gcc_v16si, int, short); -char __builtin_ia32_ucmpq512_mask(__gcc_v8di, __gcc_v8di, int, char); -__gcc_v8df __builtin_ia32_unpckhpd512_mask(__gcc_v8df, __gcc_v8df, __gcc_v8df, char); -__gcc_v16sf __builtin_ia32_unpckhps512_mask(__gcc_v16sf, __gcc_v16sf, __gcc_v16sf, short); -__gcc_v8df __builtin_ia32_unpcklpd512_mask(__gcc_v8df, __gcc_v8df, __gcc_v8df, char); -__gcc_v16sf __builtin_ia32_unpcklps512_mask(__gcc_v16sf, __gcc_v16sf, __gcc_v16sf, short); -__gcc_v16si __builtin_ia32_vplzcntd_512_mask(__gcc_v16si, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_vplzcntq_512_mask(__gcc_v8di, __gcc_v8di, char); -__gcc_v16si __builtin_ia32_vpconflictsi_512_mask(__gcc_v16si, __gcc_v16si, short); -__gcc_v8di __builtin_ia32_vpconflictdi_512_mask(__gcc_v8di, __gcc_v8di, char); -__gcc_v8df __builtin_ia32_permdf512_mask(__gcc_v8df, int, __gcc_v8df, char); -__gcc_v8di __builtin_ia32_permdi512_mask(__gcc_v8di, int, __gcc_v8di, char); -__gcc_v16si __builtin_ia32_vpermi2vard512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, short); -__gcc_v8df __builtin_ia32_vpermi2varpd512_mask(__gcc_v8df, __gcc_v8di, __gcc_v8df, char); -__gcc_v16sf __builtin_ia32_vpermi2varps512_mask(__gcc_v16sf, __gcc_v16si, __gcc_v16sf, short); -__gcc_v8di __builtin_ia32_vpermi2varq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, char); -__gcc_v8df __builtin_ia32_vpermilpd512_mask(__gcc_v8df, int, __gcc_v8df, char); -__gcc_v16sf __builtin_ia32_vpermilps512_mask(__gcc_v16sf, int, __gcc_v16sf, short); -__gcc_v8df __builtin_ia32_vpermilvarpd512_mask(__gcc_v8df, __gcc_v8di, __gcc_v8df, char); -__gcc_v16sf __builtin_ia32_vpermilvarps512_mask(__gcc_v16sf, __gcc_v16si, __gcc_v16sf, short); -__gcc_v16si __builtin_ia32_vpermt2vard512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, short); -__gcc_v16si __builtin_ia32_vpermt2vard512_maskz(__gcc_v16si, __gcc_v16si, __gcc_v16si, short); -__gcc_v8df __builtin_ia32_vpermt2varpd512_mask(__gcc_v8di, __gcc_v8df, __gcc_v8df, char); -__gcc_v8df __builtin_ia32_vpermt2varpd512_maskz(__gcc_v8di, __gcc_v8df, __gcc_v8df, char); -__gcc_v16sf __builtin_ia32_vpermt2varps512_mask(__gcc_v16si, __gcc_v16sf, __gcc_v16sf, short); -__gcc_v16sf __builtin_ia32_vpermt2varps512_maskz(__gcc_v16si, __gcc_v16sf, __gcc_v16sf, short); -__gcc_v8di __builtin_ia32_vpermt2varq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, char); -__gcc_v8di __builtin_ia32_vpermt2varq512_maskz(__gcc_v8di, __gcc_v8di, __gcc_v8di, char); -__gcc_v8df __builtin_ia32_permvardf512_mask(__gcc_v8df, __gcc_v8di, __gcc_v8df, char); -__gcc_v8di __builtin_ia32_permvardi512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, char); -__gcc_v16sf __builtin_ia32_permvarsf512_mask(__gcc_v16sf, __gcc_v16si, __gcc_v16sf, short); -__gcc_v16si __builtin_ia32_permvarsi512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, short); -__gcc_v16si __builtin_ia32_pternlogd512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, int, short); -__gcc_v16si __builtin_ia32_pternlogd512_maskz(__gcc_v16si, __gcc_v16si, __gcc_v16si, int, short); -__gcc_v8di __builtin_ia32_pternlogq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, int, char); -__gcc_v8di __builtin_ia32_pternlogq512_maskz(__gcc_v8di, __gcc_v8di, __gcc_v8di, int, char); +unsigned char __builtin_ia32_ucmpq512_mask(__gcc_v8di, __gcc_v8di, int, unsigned char); +__gcc_v8df __builtin_ia32_unpckhpd512_mask(__gcc_v8df, __gcc_v8df, __gcc_v8df, unsigned char); +__gcc_v16sf __builtin_ia32_unpckhps512_mask(__gcc_v16sf, __gcc_v16sf, __gcc_v16sf, unsigned short); +__gcc_v8df __builtin_ia32_unpcklpd512_mask(__gcc_v8df, __gcc_v8df, __gcc_v8df, unsigned char); +__gcc_v16sf __builtin_ia32_unpcklps512_mask(__gcc_v16sf, __gcc_v16sf, __gcc_v16sf, unsigned short); +__gcc_v16si __builtin_ia32_vplzcntd_512_mask(__gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_vplzcntq_512_mask(__gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v16si __builtin_ia32_vpconflictsi_512_mask(__gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_vpconflictdi_512_mask(__gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v8df __builtin_ia32_permdf512_mask(__gcc_v8df, int, __gcc_v8df, unsigned char); +__gcc_v8di __builtin_ia32_permdi512_mask(__gcc_v8di, int, __gcc_v8di, unsigned char); +__gcc_v16si __builtin_ia32_vpermi2vard512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v8df __builtin_ia32_vpermi2varpd512_mask(__gcc_v8df, __gcc_v8di, __gcc_v8df, unsigned char); +__gcc_v16sf __builtin_ia32_vpermi2varps512_mask(__gcc_v16sf, __gcc_v16si, __gcc_v16sf, unsigned short); +__gcc_v8di __builtin_ia32_vpermi2varq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v8df __builtin_ia32_vpermilpd512_mask(__gcc_v8df, int, __gcc_v8df, unsigned char); +__gcc_v16sf __builtin_ia32_vpermilps512_mask(__gcc_v16sf, int, __gcc_v16sf, unsigned short); +__gcc_v8df __builtin_ia32_vpermilvarpd512_mask(__gcc_v8df, __gcc_v8di, __gcc_v8df, unsigned char); +__gcc_v16sf __builtin_ia32_vpermilvarps512_mask(__gcc_v16sf, __gcc_v16si, __gcc_v16sf, unsigned short); +__gcc_v16si __builtin_ia32_vpermt2vard512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v16si __builtin_ia32_vpermt2vard512_maskz(__gcc_v16si, __gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v8df __builtin_ia32_vpermt2varpd512_mask(__gcc_v8di, __gcc_v8df, __gcc_v8df, unsigned char); +__gcc_v8df __builtin_ia32_vpermt2varpd512_maskz(__gcc_v8di, __gcc_v8df, __gcc_v8df, unsigned char); +__gcc_v16sf __builtin_ia32_vpermt2varps512_mask(__gcc_v16si, __gcc_v16sf, __gcc_v16sf, unsigned short); +__gcc_v16sf __builtin_ia32_vpermt2varps512_maskz(__gcc_v16si, __gcc_v16sf, __gcc_v16sf, unsigned short); +__gcc_v8di __builtin_ia32_vpermt2varq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v8di __builtin_ia32_vpermt2varq512_maskz(__gcc_v8di, __gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v8df __builtin_ia32_permvardf512_mask(__gcc_v8df, __gcc_v8di, __gcc_v8df, unsigned char); +__gcc_v8di __builtin_ia32_permvardi512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v16sf __builtin_ia32_permvarsf512_mask(__gcc_v16sf, __gcc_v16si, __gcc_v16sf, unsigned short); +__gcc_v16si __builtin_ia32_permvarsi512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v16si __builtin_ia32_pternlogd512_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, int, unsigned short); +__gcc_v16si __builtin_ia32_pternlogd512_maskz(__gcc_v16si, __gcc_v16si, __gcc_v16si, int, unsigned short); +__gcc_v8di __builtin_ia32_pternlogq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, int, unsigned char); +__gcc_v8di __builtin_ia32_pternlogq512_maskz(__gcc_v8di, __gcc_v8di, __gcc_v8di, int, unsigned char); __gcc_v16sf __builtin_ia32_copysignps512(__gcc_v16sf, __gcc_v16sf); __gcc_v8df __builtin_ia32_copysignpd512(__gcc_v8df, __gcc_v8df); __gcc_v8df __builtin_ia32_sqrtpd512(__gcc_v8df); @@ -383,24 +383,24 @@ __gcc_v16sf __builtin_ia32_exp2ps(__gcc_v16sf); __gcc_v16si __builtin_ia32_roundpd_az_vec_pack_sfix512(__gcc_v8df, __gcc_v8df); __gcc_v16si __builtin_ia32_floorpd_vec_pack_sfix512(__gcc_v8df, __gcc_v8df, const int); __gcc_v16si __builtin_ia32_ceilpd_vec_pack_sfix512(__gcc_v8df, __gcc_v8df, const int); -short __builtin_ia32_kandhi(short, short); -short __builtin_ia32_kandnhi(short, short); -short __builtin_ia32_knothi(short); -short __builtin_ia32_korhi(short, short); -short __builtin_ia32_kortestchi(short, short); -short __builtin_ia32_kortestzhi(short, short); -short __builtin_ia32_kunpckhi(short, short); -short __builtin_ia32_kxnorhi(short, short); -short __builtin_ia32_kxorhi(short, short); +unsigned short __builtin_ia32_kandhi(unsigned short, unsigned short); +unsigned short __builtin_ia32_kandnhi(unsigned short, unsigned short); +unsigned short __builtin_ia32_knothi(unsigned short); +unsigned short __builtin_ia32_korhi(unsigned short, unsigned short); +unsigned short __builtin_ia32_kortestchi(unsigned short, unsigned short); +unsigned short __builtin_ia32_kortestzhi(unsigned short, unsigned short); +unsigned short __builtin_ia32_kunpckhi(unsigned short, unsigned short); +unsigned short __builtin_ia32_kxnorhi(unsigned short, unsigned short); +unsigned short __builtin_ia32_kxorhi(unsigned short, unsigned short); short __builtin_ia32_kmov16(short); -__gcc_v8df __builtin_ia32_addpd512_mask(__gcc_v8df, __gcc_v8df, __gcc_v8df, char, int); +__gcc_v8df __builtin_ia32_addpd512_mask(__gcc_v8df, __gcc_v8df, __gcc_v8df, unsigned char, int); __gcc_v16sf __builtin_ia32_addps512_mask(__gcc_v16sf, __gcc_v16sf, __gcc_v16sf, short, int); __gcc_v2df __builtin_ia32_addsd_round(__gcc_v2df, __gcc_v2df, int); __gcc_v4sf __builtin_ia32_addss_round(__gcc_v4sf, __gcc_v4sf, int); -char __builtin_ia32_cmppd512_mask(__gcc_v8df, __gcc_v8df, int, char, int); -short __builtin_ia32_cmpps512_mask(__gcc_v16sf, __gcc_v16sf, int, short, int); -char __builtin_ia32_cmpsd_mask(__gcc_v2df, __gcc_v2df, int, char, int); -char __builtin_ia32_cmpss_mask(__gcc_v4sf, __gcc_v4sf, int, char, int); +unsigned char __builtin_ia32_cmppd512_mask(__gcc_v8df, __gcc_v8df, int, unsigned char, int); +unsigned short __builtin_ia32_cmpps512_mask(__gcc_v16sf, __gcc_v16sf, int, unsigned short, int); +unsigned char __builtin_ia32_cmpsd_mask(__gcc_v2df, __gcc_v2df, int, unsigned char, int); +unsigned char __builtin_ia32_cmpss_mask(__gcc_v4sf, __gcc_v4sf, int, unsigned char, int); int __builtin_ia32_vcomisd(__gcc_v2df, __gcc_v2df, int, int); int __builtin_ia32_vcomiss(__gcc_v4sf, __gcc_v4sf, int, int); __gcc_v16sf __builtin_ia32_cvtdq2ps512_mask(__gcc_v16si, __gcc_v16sf, short, int); @@ -424,7 +424,7 @@ __gcc_v16sf __builtin_ia32_cvtudq2ps512_mask(__gcc_v16si, __gcc_v16sf, short, in __gcc_v2df __builtin_ia32_cvtusi2sd64(__gcc_v2df, unsigned long long, int); __gcc_v4sf __builtin_ia32_cvtusi2ss32(__gcc_v4sf, unsigned, int); __gcc_v4sf __builtin_ia32_cvtusi2ss64(__gcc_v4sf, unsigned long long, int); -__gcc_v8df __builtin_ia32_divpd512_mask(__gcc_v8df, __gcc_v8df, __gcc_v8df, char, int); +__gcc_v8df __builtin_ia32_divpd512_mask(__gcc_v8df, __gcc_v8df, __gcc_v8df, unsigned char, int); __gcc_v16sf __builtin_ia32_divps512_mask(__gcc_v16sf, __gcc_v16sf, __gcc_v16sf, short, int); __gcc_v2df __builtin_ia32_divsd_round(__gcc_v2df, __gcc_v2df, int); __gcc_v4sf __builtin_ia32_divss_round(__gcc_v4sf, __gcc_v4sf, int); @@ -444,15 +444,15 @@ __gcc_v8df __builtin_ia32_getmantpd512_mask(__gcc_v8df, int, __gcc_v8df, char, i __gcc_v16sf __builtin_ia32_getmantps512_mask(__gcc_v16sf, int, __gcc_v16sf, short, int); __gcc_v2df __builtin_ia32_getmantsd_round(__gcc_v2df, __gcc_v2df, int, int); __gcc_v4sf __builtin_ia32_getmantss_round(__gcc_v4sf, __gcc_v4sf, int, int); -__gcc_v8df __builtin_ia32_maxpd512_mask(__gcc_v8df, __gcc_v8df, __gcc_v8df, char, int); +__gcc_v8df __builtin_ia32_maxpd512_mask(__gcc_v8df, __gcc_v8df, __gcc_v8df, unsigned char, int); __gcc_v16sf __builtin_ia32_maxps512_mask(__gcc_v16sf, __gcc_v16sf, __gcc_v16sf, short, int); __gcc_v2df __builtin_ia32_maxsd_round(__gcc_v2df, __gcc_v2df, int); __gcc_v4sf __builtin_ia32_maxss_round(__gcc_v4sf, __gcc_v4sf, int); -__gcc_v8df __builtin_ia32_minpd512_mask(__gcc_v8df, __gcc_v8df, __gcc_v8df, char, int); +__gcc_v8df __builtin_ia32_minpd512_mask(__gcc_v8df, __gcc_v8df, __gcc_v8df, unsigned char, int); __gcc_v16sf __builtin_ia32_minps512_mask(__gcc_v16sf, __gcc_v16sf, __gcc_v16sf, short, int); __gcc_v2df __builtin_ia32_minsd_round(__gcc_v2df, __gcc_v2df, int); __gcc_v4sf __builtin_ia32_minss_round(__gcc_v4sf, __gcc_v4sf, int); -__gcc_v8df __builtin_ia32_mulpd512_mask(__gcc_v8df, __gcc_v8df, __gcc_v8df, char, int); +__gcc_v8df __builtin_ia32_mulpd512_mask(__gcc_v8df, __gcc_v8df, __gcc_v8df, unsigned char, int); __gcc_v16sf __builtin_ia32_mulps512_mask(__gcc_v16sf, __gcc_v16sf, __gcc_v16sf, short, int); __gcc_v2df __builtin_ia32_mulsd_round(__gcc_v2df, __gcc_v2df, int); __gcc_v4sf __builtin_ia32_mulss_round(__gcc_v4sf, __gcc_v4sf, int); @@ -460,7 +460,7 @@ __gcc_v8df __builtin_ia32_rndscalepd_mask(__gcc_v8df, int, __gcc_v8df, char, int __gcc_v16sf __builtin_ia32_rndscaleps_mask(__gcc_v16sf, int, __gcc_v16sf, short, int); __gcc_v2df __builtin_ia32_rndscalesd_round(__gcc_v2df, __gcc_v2df, int, int); __gcc_v4sf __builtin_ia32_rndscaless_round(__gcc_v4sf, __gcc_v4sf, int, int); -__gcc_v8df __builtin_ia32_scalefpd512_mask(__gcc_v8df, __gcc_v8df, __gcc_v8df, char, int); +__gcc_v8df __builtin_ia32_scalefpd512_mask(__gcc_v8df, __gcc_v8df, __gcc_v8df, unsigned char, int); __gcc_v16sf __builtin_ia32_scalefps512_mask(__gcc_v16sf, __gcc_v16sf, __gcc_v16sf, short, int); __gcc_v2df __builtin_ia32_scalefsd_round(__gcc_v2df, __gcc_v2df, int); __gcc_v4sf __builtin_ia32_scalefss_round(__gcc_v4sf, __gcc_v4sf, int); @@ -468,7 +468,7 @@ __gcc_v8df __builtin_ia32_sqrtpd512_mask(__gcc_v8df, __gcc_v8df, char, int); __gcc_v16sf __builtin_ia32_sqrtps512_mask(__gcc_v16sf, __gcc_v16sf, short, int); __gcc_v2df __builtin_ia32_sqrtsd_round(__gcc_v2df, __gcc_v2df, int); __gcc_v4sf __builtin_ia32_sqrtss_round(__gcc_v4sf, __gcc_v4sf, int); -__gcc_v8df __builtin_ia32_subpd512_mask(__gcc_v8df, __gcc_v8df, __gcc_v8df, char, int); +__gcc_v8df __builtin_ia32_subpd512_mask(__gcc_v8df, __gcc_v8df, __gcc_v8df, unsigned char, int); __gcc_v16sf __builtin_ia32_subps512_mask(__gcc_v16sf, __gcc_v16sf, __gcc_v16sf, short, int); __gcc_v2df __builtin_ia32_subsd_round(__gcc_v2df, __gcc_v2df, int); __gcc_v4sf __builtin_ia32_subss_round(__gcc_v4sf, __gcc_v4sf, int); @@ -494,9 +494,9 @@ __gcc_v4df __builtin_ia32_vfmaddpd256(__gcc_v4df, __gcc_v4df, __gcc_v4df); __gcc_v4sf __builtin_ia32_vfmaddps(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf); __gcc_v4sf __builtin_ia32_vfmaddss3(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf); __gcc_v8sf __builtin_ia32_vfmaddps256(__gcc_v8sf, __gcc_v8sf, __gcc_v8sf); -__gcc_v8df __builtin_ia32_vfmaddpd512_mask(__gcc_v8df, __gcc_v8df, __gcc_v8df, char, int); -__gcc_v8df __builtin_ia32_vfmaddpd512_mask3(__gcc_v8df, __gcc_v8df, __gcc_v8df, char, int); -__gcc_v8df __builtin_ia32_vfmaddpd512_maskz(__gcc_v8df, __gcc_v8df, __gcc_v8df, char, int); +__gcc_v8df __builtin_ia32_vfmaddpd512_mask(__gcc_v8df, __gcc_v8df, __gcc_v8df, unsigned char, int); +__gcc_v8df __builtin_ia32_vfmaddpd512_mask3(__gcc_v8df, __gcc_v8df, __gcc_v8df, unsigned char, int); +__gcc_v8df __builtin_ia32_vfmaddpd512_maskz(__gcc_v8df, __gcc_v8df, __gcc_v8df, unsigned char, int); __gcc_v16sf __builtin_ia32_vfmaddps512_mask(__gcc_v16sf, __gcc_v16sf, __gcc_v16sf, short, int); __gcc_v16sf __builtin_ia32_vfmaddps512_mask3(__gcc_v16sf, __gcc_v16sf, __gcc_v16sf, short, int); __gcc_v16sf __builtin_ia32_vfmaddps512_maskz(__gcc_v16sf, __gcc_v16sf, __gcc_v16sf, short, int); @@ -506,20 +506,20 @@ __gcc_v2df __builtin_ia32_vfmaddsubpd(__gcc_v2df,__gcc_v2df, __gcc_v2df); __gcc_v4df __builtin_ia32_vfmaddsubpd256(__gcc_v4df, __gcc_v4df, __gcc_v4df); __gcc_v4sf __builtin_ia32_vfmaddsubps(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf); __gcc_v8sf __builtin_ia32_vfmaddsubps256(__gcc_v8sf, __gcc_v8sf, __gcc_v8sf); -__gcc_v8df __builtin_ia32_vfmaddsubpd512_mask(__gcc_v8df, __gcc_v8df, __gcc_v8df, char, int); -__gcc_v8df __builtin_ia32_vfmaddsubpd512_mask3(__gcc_v8df, __gcc_v8df, __gcc_v8df, char, int); -__gcc_v8df __builtin_ia32_vfmaddsubpd512_maskz(__gcc_v8df, __gcc_v8df, __gcc_v8df, char, int); +__gcc_v8df __builtin_ia32_vfmaddsubpd512_mask(__gcc_v8df, __gcc_v8df, __gcc_v8df, unsigned char, int); +__gcc_v8df __builtin_ia32_vfmaddsubpd512_mask3(__gcc_v8df, __gcc_v8df, __gcc_v8df, unsigned char, int); +__gcc_v8df __builtin_ia32_vfmaddsubpd512_maskz(__gcc_v8df, __gcc_v8df, __gcc_v8df, unsigned char, int); __gcc_v16sf __builtin_ia32_vfmaddsubps512_mask(__gcc_v16sf, __gcc_v16sf, __gcc_v16sf, short, int); __gcc_v16sf __builtin_ia32_vfmaddsubps512_mask3(__gcc_v16sf, __gcc_v16sf, __gcc_v16sf, short, int); __gcc_v16sf __builtin_ia32_vfmaddsubps512_maskz(__gcc_v16sf, __gcc_v16sf, __gcc_v16sf, short, int); -__gcc_v8df __builtin_ia32_vfmsubaddpd512_mask3(__gcc_v8df, __gcc_v8df, __gcc_v8df, char, int); +__gcc_v8df __builtin_ia32_vfmsubaddpd512_mask3(__gcc_v8df, __gcc_v8df, __gcc_v8df, unsigned char, int); __gcc_v16sf __builtin_ia32_vfmsubaddps512_mask3(__gcc_v16sf, __gcc_v16sf, __gcc_v16sf, short, int); -__gcc_v8df __builtin_ia32_vfmsubpd512_mask3(__gcc_v8df, __gcc_v8df, __gcc_v8df, char, int); +__gcc_v8df __builtin_ia32_vfmsubpd512_mask3(__gcc_v8df, __gcc_v8df, __gcc_v8df, unsigned char, int); __gcc_v16sf __builtin_ia32_vfmsubps512_mask3(__gcc_v16sf, __gcc_v16sf, __gcc_v16sf, short, int); -__gcc_v8df __builtin_ia32_vfnmaddpd512_mask(__gcc_v8df, __gcc_v8df, __gcc_v8df, char, int); +__gcc_v8df __builtin_ia32_vfnmaddpd512_mask(__gcc_v8df, __gcc_v8df, __gcc_v8df, unsigned char, int); __gcc_v16sf __builtin_ia32_vfnmaddps512_mask(__gcc_v16sf, __gcc_v16sf, __gcc_v16sf, short, int); -__gcc_v8df __builtin_ia32_vfnmsubpd512_mask(__gcc_v8df, __gcc_v8df, __gcc_v8df, char, int); -__gcc_v8df __builtin_ia32_vfnmsubpd512_mask3(__gcc_v8df, __gcc_v8df, __gcc_v8df, char, int); +__gcc_v8df __builtin_ia32_vfnmsubpd512_mask(__gcc_v8df, __gcc_v8df, __gcc_v8df, unsigned char, int); +__gcc_v8df __builtin_ia32_vfnmsubpd512_mask3(__gcc_v8df, __gcc_v8df, __gcc_v8df, unsigned char, int); __gcc_v16sf __builtin_ia32_vfnmsubps512_mask(__gcc_v16sf, __gcc_v16sf, __gcc_v16sf, short, int); __gcc_v16sf __builtin_ia32_vfnmsubps512_mask3(__gcc_v16sf, __gcc_v16sf, __gcc_v16sf, short, int); __gcc_v8df __builtin_ia32_exp2pd_mask(__gcc_v8df, __gcc_v8df, char, int); diff --git a/src/ansi-c/gcc_builtin_headers_ia32-3.h b/src/ansi-c/gcc_builtin_headers_ia32-3.h new file mode 100644 index 00000000000..08aa6aee4c1 --- /dev/null +++ b/src/ansi-c/gcc_builtin_headers_ia32-3.h @@ -0,0 +1,666 @@ +__gcc_v32hi __builtin_ia32_loaddquhi512_mask(const short*, __gcc_v32hi, unsigned); +__gcc_v64qi __builtin_ia32_loaddquqi512_mask(const char*, __gcc_v64qi, unsigned long long); +void __builtin_ia32_storedquhi512_mask(short*, __gcc_v32hi, unsigned); +void __builtin_ia32_storedquqi512_mask(char*, __gcc_v64qi, unsigned long long); +__gcc_v16hi __builtin_ia32_loaddquhi256_mask(const short*, __gcc_v16hi, unsigned short); +__gcc_v8hi __builtin_ia32_loaddquhi128_mask(const short*, __gcc_v8hi, unsigned char); +__gcc_v32qi __builtin_ia32_loaddquqi256_mask(const char*, __gcc_v32qi, unsigned); +__gcc_v16qi __builtin_ia32_loaddquqi128_mask(const char*, __gcc_v16qi, unsigned short); +__gcc_v4di __builtin_ia32_movdqa64load256_mask(const __gcc_v4di*, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_movdqa64load128_mask(const __gcc_v2di*, __gcc_v2di, unsigned char); +__gcc_v8si __builtin_ia32_movdqa32load256_mask(const __gcc_v8si*, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_movdqa32load128_mask(const __gcc_v4si*, __gcc_v4si, unsigned char); +void __builtin_ia32_movdqa64store256_mask(__gcc_v4di*, __gcc_v4di, unsigned char); +void __builtin_ia32_movdqa64store128_mask(__gcc_v2di*, __gcc_v2di, unsigned char); +void __builtin_ia32_movdqa32store256_mask(__gcc_v8si*, __gcc_v8si, unsigned char); +void __builtin_ia32_movdqa32store128_mask(__gcc_v4si*, __gcc_v4si, unsigned char); +__gcc_v4df __builtin_ia32_loadapd256_mask(const __gcc_v4df*, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_loadapd128_mask(const __gcc_v2df*, __gcc_v2df, unsigned char); +__gcc_v8sf __builtin_ia32_loadaps256_mask(const __gcc_v8sf*, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_loadaps128_mask(const __gcc_v4sf*, __gcc_v4sf, unsigned char); +void __builtin_ia32_storeapd256_mask(__gcc_v4df*, __gcc_v4df, unsigned char); +void __builtin_ia32_storeapd128_mask(__gcc_v2df*, __gcc_v2df, unsigned char); +void __builtin_ia32_storeaps256_mask(__gcc_v8sf*, __gcc_v8sf, unsigned char); +void __builtin_ia32_storeaps128_mask(__gcc_v4sf*, __gcc_v4sf, unsigned char); +__gcc_v4df __builtin_ia32_loadupd256_mask(const double*, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_loadupd128_mask(const double*, __gcc_v2df, unsigned char); +__gcc_v8sf __builtin_ia32_loadups256_mask(const float*, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_loadups128_mask(const float*, __gcc_v4sf, unsigned char); +void __builtin_ia32_storeupd256_mask(double*, __gcc_v4df, unsigned char); +void __builtin_ia32_storeupd128_mask(double*, __gcc_v2df, unsigned char); +void __builtin_ia32_storeups256_mask(float*, __gcc_v8sf, unsigned char); +void __builtin_ia32_storeups128_mask(float*, __gcc_v4sf, unsigned char); +__gcc_v4di __builtin_ia32_loaddqudi256_mask(const long long*, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_loaddqudi128_mask(const long long*, __gcc_v2di, unsigned char); +__gcc_v8si __builtin_ia32_loaddqusi256_mask(const int*, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_loaddqusi128_mask(const int*, __gcc_v4si, unsigned char); +void __builtin_ia32_storedqudi256_mask(long long*, __gcc_v4di, unsigned char); +void __builtin_ia32_storedqudi128_mask(long long*, __gcc_v2di, unsigned char); +void __builtin_ia32_storedqusi256_mask(int*, __gcc_v8si, unsigned char); +void __builtin_ia32_storedqusi128_mask(int*, __gcc_v4si, unsigned char); +void __builtin_ia32_storedquhi256_mask(short*, __gcc_v16hi, unsigned short); +void __builtin_ia32_storedquhi128_mask(short*, __gcc_v8hi, unsigned char); +void __builtin_ia32_storedquqi256_mask(char*, __gcc_v32qi, unsigned); +void __builtin_ia32_storedquqi128_mask(char*, __gcc_v16qi, unsigned short); +void __builtin_ia32_compressstoredf256_mask(__gcc_v4df*, __gcc_v4df, unsigned char); +void __builtin_ia32_compressstoredf128_mask(__gcc_v2df*, __gcc_v2df, unsigned char); +void __builtin_ia32_compressstoresf256_mask(__gcc_v8sf*, __gcc_v8sf, unsigned char); +void __builtin_ia32_compressstoresf128_mask(__gcc_v4sf*, __gcc_v4sf, unsigned char); +void __builtin_ia32_compressstoredi256_mask(__gcc_v4di*, __gcc_v4di, unsigned char); +void __builtin_ia32_compressstoredi128_mask(__gcc_v2di*, __gcc_v2di, unsigned char); +void __builtin_ia32_compressstoresi256_mask(__gcc_v8si*, __gcc_v8si, unsigned char); +void __builtin_ia32_compressstoresi128_mask(__gcc_v4si*, __gcc_v4si, unsigned char); +__gcc_v4df __builtin_ia32_expandloaddf256_mask(const __gcc_v4df*, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_expandloaddf128_mask(const __gcc_v2df*, __gcc_v2df, unsigned char); +__gcc_v8sf __builtin_ia32_expandloadsf256_mask(const __gcc_v8sf*, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_expandloadsf128_mask(const __gcc_v4sf*, __gcc_v4sf, unsigned char); +__gcc_v4di __builtin_ia32_expandloaddi256_mask(const __gcc_v4di*, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_expandloaddi128_mask(const __gcc_v2di*, __gcc_v2di, unsigned char); +__gcc_v8si __builtin_ia32_expandloadsi256_mask(const __gcc_v8si*, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_expandloadsi128_mask(const __gcc_v4si*, __gcc_v4si, unsigned char); +__gcc_v4df __builtin_ia32_expandloaddf256_maskz(const __gcc_v4df*, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_expandloaddf128_maskz(const __gcc_v2df*, __gcc_v2df, unsigned char); +__gcc_v8sf __builtin_ia32_expandloadsf256_maskz(const __gcc_v8sf*, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_expandloadsf128_maskz(const __gcc_v4sf*, __gcc_v4sf, unsigned char); +__gcc_v4di __builtin_ia32_expandloaddi256_maskz(const __gcc_v4di*, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_expandloaddi128_maskz(const __gcc_v2di*, __gcc_v2di, unsigned char); +__gcc_v8si __builtin_ia32_expandloadsi256_maskz(const __gcc_v8si*, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_expandloadsi128_maskz(const __gcc_v4si*, __gcc_v4si, unsigned char); +void __builtin_ia32_pmovqd256mem_mask(__gcc_v4si*, __gcc_v4di, unsigned char); +void __builtin_ia32_pmovqd128mem_mask(__gcc_v4si*, __gcc_v2di, unsigned char); +void __builtin_ia32_pmovsqd256mem_mask(__gcc_v4si*, __gcc_v4di, unsigned char); +void __builtin_ia32_pmovsqd128mem_mask(__gcc_v4si*, __gcc_v2di, unsigned char); +void __builtin_ia32_pmovusqd256mem_mask(__gcc_v4si*, __gcc_v4di, unsigned char); +void __builtin_ia32_pmovusqd128mem_mask(__gcc_v4si*, __gcc_v2di, unsigned char); +void __builtin_ia32_pmovqw256mem_mask(__gcc_v8hi*, __gcc_v4di, unsigned char); +void __builtin_ia32_pmovqw128mem_mask(__gcc_v8hi*, __gcc_v2di, unsigned char); +void __builtin_ia32_pmovsqw256mem_mask(__gcc_v8hi*, __gcc_v4di, unsigned char); +void __builtin_ia32_pmovsqw128mem_mask(__gcc_v8hi*, __gcc_v2di, unsigned char); +void __builtin_ia32_pmovusqw256mem_mask(__gcc_v8hi*, __gcc_v4di, unsigned char); +void __builtin_ia32_pmovusqw128mem_mask(__gcc_v8hi*, __gcc_v2di, unsigned char); +void __builtin_ia32_pmovqb256mem_mask(__gcc_v16qi*, __gcc_v4di, unsigned char); +void __builtin_ia32_pmovqb128mem_mask(__gcc_v16qi*, __gcc_v2di, unsigned char); +void __builtin_ia32_pmovsqb256mem_mask(__gcc_v16qi*, __gcc_v4di, unsigned char); +void __builtin_ia32_pmovsqb128mem_mask(__gcc_v16qi*, __gcc_v2di, unsigned char); +void __builtin_ia32_pmovusqb256mem_mask(__gcc_v16qi*, __gcc_v4di, unsigned char); +void __builtin_ia32_pmovusqb128mem_mask(__gcc_v16qi*, __gcc_v2di, unsigned char); +void __builtin_ia32_pmovdb256mem_mask(__gcc_v16qi*, __gcc_v8si, unsigned char); +void __builtin_ia32_pmovdb128mem_mask(__gcc_v16qi*, __gcc_v4si, unsigned char); +void __builtin_ia32_pmovsdb256mem_mask(__gcc_v16qi*, __gcc_v8si, unsigned char); +void __builtin_ia32_pmovsdb128mem_mask(__gcc_v16qi*, __gcc_v4si, unsigned char); +void __builtin_ia32_pmovusdb256mem_mask(__gcc_v16qi*, __gcc_v8si, unsigned char); +void __builtin_ia32_pmovusdb128mem_mask(__gcc_v16qi*, __gcc_v4si, unsigned char); +void __builtin_ia32_pmovdw256mem_mask(__gcc_v8hi*, __gcc_v8si, unsigned char); +void __builtin_ia32_pmovdw128mem_mask(__gcc_v8hi*, __gcc_v4si, unsigned char); +void __builtin_ia32_pmovsdw256mem_mask(__gcc_v8hi*, __gcc_v8si, unsigned char); +void __builtin_ia32_pmovsdw128mem_mask(__gcc_v8hi*, __gcc_v4si, unsigned char); +void __builtin_ia32_pmovusdw256mem_mask(__gcc_v8hi*, __gcc_v8si, unsigned char); +void __builtin_ia32_pmovusdw128mem_mask(__gcc_v8hi*, __gcc_v4si, unsigned char); +unsigned __builtin_ia32_rdpkru(); +void __builtin_ia32_wrpkru(unsigned); +__gcc_v8si __builtin_ia32_vec_pack_sfix256 (__gcc_v4df, __gcc_v4df); +unsigned short __builtin_ia32_lzcnt_u16(unsigned short); +unsigned short __builtin_ia32_tzcnt_u16(unsigned short); +unsigned __builtin_ia32_tzcnt_u32(unsigned); +unsigned long long __builtin_ia32_tzcnt_u64(unsigned long long); +__gcc_v16si __builtin_ia32_si512_256si(__gcc_v8si); +__gcc_v16sf __builtin_ia32_ps512_256ps(__gcc_v8sf); +__gcc_v8df __builtin_ia32_pd512_256pd(__gcc_v4df); +__gcc_v16si __builtin_ia32_si512_si(__gcc_v4si); +__gcc_v16sf __builtin_ia32_ps512_ps(__gcc_v4sf); +__gcc_v8df __builtin_ia32_pd512_pd(__gcc_v2df); +__gcc_v16si __builtin_ia32_cvtps2dq512(__gcc_v16sf); +__gcc_v16si __builtin_ia32_vec_pack_sfix512(__gcc_v8df, __gcc_v8df); +__gcc_v16si __builtin_ia32_roundps_az_sfix512(__gcc_v16sf); +unsigned short __builtin_ia32_kshiftlihi(unsigned short, unsigned char); +unsigned __builtin_ia32_kshiftlisi(unsigned, unsigned char); +unsigned long long __builtin_ia32_kshiftlidi(unsigned long long, unsigned char); +unsigned short __builtin_ia32_kshiftrihi(unsigned short, unsigned char); +unsigned __builtin_ia32_kshiftrisi(unsigned, unsigned char); +unsigned long long __builtin_ia32_kshiftridi(unsigned long long, unsigned char); +unsigned char __builtin_ia32_kandqi(unsigned char, unsigned char); +unsigned __builtin_ia32_kandsi(unsigned, unsigned); +unsigned long long __builtin_ia32_kanddi(unsigned long long, unsigned long long); +unsigned char __builtin_ia32_kandnqi(unsigned char, unsigned char); +unsigned __builtin_ia32_kandnsi(unsigned, unsigned); +unsigned long long __builtin_ia32_kandndi(unsigned long long, unsigned long long); +unsigned char __builtin_ia32_knotqi(unsigned char); +unsigned __builtin_ia32_knotsi(unsigned); +unsigned long long __builtin_ia32_knotdi(unsigned long long); +unsigned char __builtin_ia32_korqi(unsigned char, unsigned char); +unsigned __builtin_ia32_korsi(unsigned, unsigned); +unsigned long long __builtin_ia32_kordi(unsigned long long, unsigned long long); +unsigned char __builtin_ia32_ktestcqi(unsigned char, unsigned char); +unsigned char __builtin_ia32_ktestzqi(unsigned char, unsigned char); +unsigned short __builtin_ia32_ktestchi(unsigned short, unsigned short); +unsigned short __builtin_ia32_ktestzhi(unsigned short, unsigned short); +unsigned __builtin_ia32_ktestcsi(unsigned, unsigned); +unsigned __builtin_ia32_ktestzsi(unsigned, unsigned); +unsigned long long __builtin_ia32_ktestcdi(unsigned long long, unsigned long long); +unsigned long long __builtin_ia32_ktestzdi(unsigned long long, unsigned long long); +unsigned char __builtin_ia32_kortestcqi(unsigned char, unsigned char); +unsigned char __builtin_ia32_kortestzqi(unsigned char, unsigned char); +unsigned __builtin_ia32_kortestcsi(unsigned, unsigned); +unsigned __builtin_ia32_kortestzsi(unsigned, unsigned); +unsigned long long __builtin_ia32_kortestcdi(unsigned long long, unsigned long long); +unsigned long long __builtin_ia32_kortestzdi(unsigned long long, unsigned long long); +unsigned char __builtin_ia32_kxnorqi(unsigned char, unsigned char); +unsigned __builtin_ia32_kxnorsi(unsigned, unsigned); +unsigned long long __builtin_ia32_kxnordi(unsigned long long, unsigned long long); +unsigned char __builtin_ia32_kxorqi(unsigned char, unsigned char); +unsigned __builtin_ia32_kxorsi(unsigned, unsigned); +unsigned long long __builtin_ia32_kxordi(unsigned long long, unsigned long long); +unsigned char __builtin_ia32_kmovb(unsigned char); +unsigned short __builtin_ia32_kmovw(unsigned short); +unsigned __builtin_ia32_kmovd(unsigned); +unsigned long long __builtin_ia32_kmovq(unsigned long long); +unsigned char __builtin_ia32_kaddqi(unsigned char, unsigned char); +unsigned short __builtin_ia32_kaddhi(unsigned short, unsigned short); +unsigned __builtin_ia32_kaddsi(unsigned, unsigned); +unsigned long long __builtin_ia32_kadddi(unsigned long long, unsigned long long); +__gcc_v4di __builtin_ia32_movdqa64_256_mask(__gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_movdqa64_128_mask(__gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v8si __builtin_ia32_movdqa32_256_mask(__gcc_v8si, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_movdqa32_128_mask(__gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v4df __builtin_ia32_movapd256_mask(__gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_movapd128_mask(__gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v8sf __builtin_ia32_movaps256_mask(__gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_movaps128_mask(__gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v16hi __builtin_ia32_movdquhi256_mask(__gcc_v16hi, __gcc_v16hi, unsigned short); +__gcc_v8hi __builtin_ia32_movdquhi128_mask(__gcc_v8hi, __gcc_v8hi, unsigned char); +__gcc_v32qi __builtin_ia32_movdquqi256_mask(__gcc_v32qi, __gcc_v32qi, unsigned); +__gcc_v16qi __builtin_ia32_movdquqi128_mask(__gcc_v16qi, __gcc_v16qi, unsigned short); +__gcc_v4sf __builtin_ia32_minps_mask(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v4sf __builtin_ia32_maxps_mask(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v2df __builtin_ia32_minpd_mask(__gcc_v2df, __gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v2df __builtin_ia32_maxpd_mask(__gcc_v2df, __gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v4df __builtin_ia32_maxpd256_mask(__gcc_v4df, __gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v8sf __builtin_ia32_maxps256_mask(__gcc_v8sf, __gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v4df __builtin_ia32_minpd256_mask(__gcc_v4df, __gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v8sf __builtin_ia32_minps256_mask(__gcc_v8sf, __gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_mulps_mask(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v4sf __builtin_ia32_divps_mask(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v2df __builtin_ia32_mulpd_mask(__gcc_v2df, __gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v2df __builtin_ia32_divpd_mask(__gcc_v2df, __gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v4df __builtin_ia32_divpd256_mask(__gcc_v4df, __gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v8sf __builtin_ia32_divps256_mask(__gcc_v8sf, __gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v4df __builtin_ia32_mulpd256_mask(__gcc_v4df, __gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v8sf __builtin_ia32_mulps256_mask(__gcc_v8sf, __gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v2df __builtin_ia32_addpd128_mask(__gcc_v2df, __gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v4df __builtin_ia32_addpd256_mask(__gcc_v4df, __gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v4sf __builtin_ia32_addps128_mask(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v8sf __builtin_ia32_addps256_mask(__gcc_v8sf, __gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v2df __builtin_ia32_subpd128_mask(__gcc_v2df, __gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v4df __builtin_ia32_subpd256_mask(__gcc_v4df, __gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v4sf __builtin_ia32_subps128_mask(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v8sf __builtin_ia32_subps256_mask(__gcc_v8sf, __gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v4df __builtin_ia32_xorpd256_mask(__gcc_v4df, __gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_xorpd128_mask(__gcc_v2df, __gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v8sf __builtin_ia32_xorps256_mask(__gcc_v8sf, __gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_xorps128_mask(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v4df __builtin_ia32_orpd256_mask(__gcc_v4df, __gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_orpd128_mask(__gcc_v2df, __gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v8sf __builtin_ia32_orps256_mask(__gcc_v8sf, __gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_orps128_mask(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v8sf __builtin_ia32_broadcastf32x2_256_mask(__gcc_v4sf, __gcc_v8sf, unsigned char); +__gcc_v8si __builtin_ia32_broadcasti32x2_256_mask(__gcc_v4si, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_broadcasti32x2_128_mask(__gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v4df __builtin_ia32_broadcastf64x2_256_mask(__gcc_v2df, __gcc_v4df, unsigned char); +__gcc_v4di __builtin_ia32_broadcasti64x2_256_mask(__gcc_v2di, __gcc_v4di, unsigned char); +__gcc_v8sf __builtin_ia32_broadcastf32x4_256_mask(__gcc_v4sf, __gcc_v8sf, unsigned char); +__gcc_v8si __builtin_ia32_broadcasti32x4_256_mask(__gcc_v4si, __gcc_v8si, unsigned char); +__gcc_v4sf __builtin_ia32_extractf32x4_256_mask(__gcc_v8sf, int, __gcc_v4sf, unsigned char); +__gcc_v4si __builtin_ia32_extracti32x4_256_mask(__gcc_v8si, int, __gcc_v4si, unsigned char); +__gcc_v16hi __builtin_ia32_dbpsadbw256_mask(__gcc_v32qi, __gcc_v32qi, int, __gcc_v16hi, unsigned short); +__gcc_v8hi __builtin_ia32_dbpsadbw128_mask(__gcc_v16qi, __gcc_v16qi, int, __gcc_v8hi, unsigned char); +__gcc_v4di __builtin_ia32_cvttpd2qq256_mask(__gcc_v4df, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_cvttpd2qq128_mask(__gcc_v2df, __gcc_v2di, unsigned char); +__gcc_v4di __builtin_ia32_cvttpd2uqq256_mask(__gcc_v4df, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_cvttpd2uqq128_mask(__gcc_v2df, __gcc_v2di, unsigned char); +__gcc_v4di __builtin_ia32_cvtpd2qq256_mask(__gcc_v4df, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_cvtpd2qq128_mask(__gcc_v2df, __gcc_v2di, unsigned char); +__gcc_v4di __builtin_ia32_cvtpd2uqq256_mask(__gcc_v4df, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_cvtpd2uqq128_mask(__gcc_v2df, __gcc_v2di, unsigned char); +__gcc_v4si __builtin_ia32_cvtpd2udq256_mask(__gcc_v4df, __gcc_v4si, unsigned char); +__gcc_v4si __builtin_ia32_cvtpd2udq128_mask(__gcc_v2df, __gcc_v4si, unsigned char); +__gcc_v4di __builtin_ia32_cvttps2qq256_mask(__gcc_v4sf, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_cvttps2qq128_mask(__gcc_v4sf, __gcc_v2di, unsigned char); +__gcc_v4di __builtin_ia32_cvttps2uqq256_mask(__gcc_v4sf, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_cvttps2uqq128_mask(__gcc_v4sf, __gcc_v2di, unsigned char); +__gcc_v8si __builtin_ia32_cvttps2dq256_mask(__gcc_v8sf, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_cvttps2dq128_mask(__gcc_v4sf, __gcc_v4si, unsigned char); +__gcc_v8si __builtin_ia32_cvttps2udq256_mask(__gcc_v8sf, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_cvttps2udq128_mask(__gcc_v4sf, __gcc_v4si, unsigned char); +__gcc_v4si __builtin_ia32_cvttpd2dq256_mask(__gcc_v4df, __gcc_v4si, unsigned char); +__gcc_v4si __builtin_ia32_cvttpd2dq128_mask(__gcc_v2df, __gcc_v4si, unsigned char); +__gcc_v4si __builtin_ia32_cvttpd2udq256_mask(__gcc_v4df, __gcc_v4si, unsigned char); +__gcc_v4si __builtin_ia32_cvttpd2udq128_mask(__gcc_v2df, __gcc_v4si, unsigned char); +__gcc_v4si __builtin_ia32_cvtpd2dq256_mask(__gcc_v4df, __gcc_v4si, unsigned char); +__gcc_v4si __builtin_ia32_cvtpd2dq128_mask(__gcc_v2df, __gcc_v4si, unsigned char); +__gcc_v4df __builtin_ia32_cvtdq2pd256_mask(__gcc_v4si, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_cvtdq2pd128_mask(__gcc_v4si, __gcc_v2df, unsigned char); +__gcc_v4df __builtin_ia32_cvtudq2pd256_mask(__gcc_v4si, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_cvtudq2pd128_mask(__gcc_v4si, __gcc_v2df, unsigned char); +__gcc_v8sf __builtin_ia32_cvtdq2ps256_mask(__gcc_v8si, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_cvtdq2ps128_mask(__gcc_v4si, __gcc_v4sf, unsigned char); +__gcc_v8sf __builtin_ia32_cvtudq2ps256_mask(__gcc_v8si, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_cvtudq2ps128_mask(__gcc_v4si, __gcc_v4sf, unsigned char); +__gcc_v4df __builtin_ia32_cvtps2pd256_mask(__gcc_v4sf, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_cvtps2pd128_mask(__gcc_v4sf, __gcc_v2df, unsigned char); +__gcc_v32qi __builtin_ia32_pbroadcastb256_mask(__gcc_v16qi, __gcc_v32qi, unsigned); +__gcc_v32qi __builtin_ia32_pbroadcastb256_gpr_mask(char, __gcc_v32qi, unsigned); +__gcc_v16qi __builtin_ia32_pbroadcastb128_mask(__gcc_v16qi, __gcc_v16qi, unsigned short); +__gcc_v16qi __builtin_ia32_pbroadcastb128_gpr_mask(char, __gcc_v16qi, unsigned short); +__gcc_v16hi __builtin_ia32_pbroadcastw256_mask(__gcc_v8hi, __gcc_v16hi, unsigned short); +__gcc_v16hi __builtin_ia32_pbroadcastw256_gpr_mask(short, __gcc_v16hi, unsigned short); +__gcc_v8hi __builtin_ia32_pbroadcastw128_mask(__gcc_v8hi, __gcc_v8hi, unsigned char); +__gcc_v8hi __builtin_ia32_pbroadcastw128_gpr_mask(short, __gcc_v8hi, unsigned char); +__gcc_v8si __builtin_ia32_pbroadcastd256_mask(__gcc_v4si, __gcc_v8si, unsigned char); +__gcc_v8si __builtin_ia32_pbroadcastd256_gpr_mask(int, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_pbroadcastd128_mask(__gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v4si __builtin_ia32_pbroadcastd128_gpr_mask(int, __gcc_v4si, unsigned char); +__gcc_v4di __builtin_ia32_pbroadcastq256_mask(__gcc_v2di, __gcc_v4di, unsigned char); +__gcc_v4di __builtin_ia32_pbroadcastq256_gpr_mask(long long, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_pbroadcastq128_mask(__gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v2di __builtin_ia32_pbroadcastq128_gpr_mask(long long, __gcc_v2di, unsigned char); +__gcc_v8sf __builtin_ia32_broadcastss256_mask(__gcc_v4sf, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_broadcastss128_mask(__gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v4df __builtin_ia32_broadcastsd256_mask(__gcc_v2df, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_extractf64x2_256_mask(__gcc_v4df, int, __gcc_v2df, unsigned char); +__gcc_v2di __builtin_ia32_extracti64x2_256_mask(__gcc_v4di, int, __gcc_v2di, unsigned char); +__gcc_v8sf __builtin_ia32_insertf32x4_256_mask(__gcc_v8sf, __gcc_v4sf, int, __gcc_v8sf, unsigned char); +__gcc_v8si __builtin_ia32_inserti32x4_256_mask(__gcc_v8si, __gcc_v4si, int, __gcc_v8si, unsigned char); +__gcc_v16hi __builtin_ia32_pmovsxbw256_mask(__gcc_v16qi, __gcc_v16hi, unsigned short); +__gcc_v8hi __builtin_ia32_pmovsxbw128_mask(__gcc_v16qi, __gcc_v8hi, unsigned char); +__gcc_v8si __builtin_ia32_pmovsxbd256_mask(__gcc_v16qi, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_pmovsxbd128_mask(__gcc_v16qi, __gcc_v4si, unsigned char); +__gcc_v4di __builtin_ia32_pmovsxbq256_mask(__gcc_v16qi, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_pmovsxbq128_mask(__gcc_v16qi, __gcc_v2di, unsigned char); +__gcc_v8si __builtin_ia32_pmovsxwd256_mask(__gcc_v8hi, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_pmovsxwd128_mask(__gcc_v8hi, __gcc_v4si, unsigned char); +__gcc_v4di __builtin_ia32_pmovsxwq256_mask(__gcc_v8hi, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_pmovsxwq128_mask(__gcc_v8hi, __gcc_v2di, unsigned char); +__gcc_v4di __builtin_ia32_pmovsxdq256_mask(__gcc_v4si, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_pmovsxdq128_mask(__gcc_v4si, __gcc_v2di, unsigned char); +__gcc_v16hi __builtin_ia32_pmovzxbw256_mask(__gcc_v16qi, __gcc_v16hi, unsigned short); +__gcc_v8hi __builtin_ia32_pmovzxbw128_mask(__gcc_v16qi, __gcc_v8hi, unsigned char); +__gcc_v8si __builtin_ia32_pmovzxbd256_mask(__gcc_v16qi, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_pmovzxbd128_mask(__gcc_v16qi, __gcc_v4si, unsigned char); +__gcc_v4di __builtin_ia32_pmovzxbq256_mask(__gcc_v16qi, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_pmovzxbq128_mask(__gcc_v16qi, __gcc_v2di, unsigned char); +__gcc_v8si __builtin_ia32_pmovzxwd256_mask(__gcc_v8hi, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_pmovzxwd128_mask(__gcc_v8hi, __gcc_v4si, unsigned char); +__gcc_v4di __builtin_ia32_pmovzxwq256_mask(__gcc_v8hi, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_pmovzxwq128_mask(__gcc_v8hi, __gcc_v2di, unsigned char); +__gcc_v4di __builtin_ia32_pmovzxdq256_mask(__gcc_v4si, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_pmovzxdq128_mask(__gcc_v4si, __gcc_v2di, unsigned char); +__gcc_v4df __builtin_ia32_reducepd256_mask(__gcc_v4df, int, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_reducepd128_mask(__gcc_v2df, int, __gcc_v2df, unsigned char); +__gcc_v8sf __builtin_ia32_reduceps256_mask(__gcc_v8sf, int, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_reduceps128_mask(__gcc_v4sf, int, __gcc_v4sf, unsigned char); +__gcc_v2df __builtin_ia32_reducesd(__gcc_v2df, __gcc_v2df, int); +__gcc_v4sf __builtin_ia32_reducess(__gcc_v4sf, __gcc_v4sf, int); +__gcc_v16hi __builtin_ia32_permvarhi256_mask(__gcc_v16hi, __gcc_v16hi, __gcc_v16hi, unsigned short); +__gcc_v8hi __builtin_ia32_permvarhi128_mask(__gcc_v8hi, __gcc_v8hi, __gcc_v8hi, unsigned char); +__gcc_v16hi __builtin_ia32_vpermt2varhi256_mask(__gcc_v16hi, __gcc_v16hi, __gcc_v16hi, unsigned short); +__gcc_v16hi __builtin_ia32_vpermt2varhi256_maskz(__gcc_v16hi, __gcc_v16hi, __gcc_v16hi, unsigned short); +__gcc_v8hi __builtin_ia32_vpermt2varhi128_mask(__gcc_v8hi, __gcc_v8hi, __gcc_v8hi, unsigned char); +__gcc_v8hi __builtin_ia32_vpermt2varhi128_maskz(__gcc_v8hi, __gcc_v8hi, __gcc_v8hi, unsigned char); +__gcc_v16hi __builtin_ia32_vpermi2varhi256_mask(__gcc_v16hi, __gcc_v16hi, __gcc_v16hi, unsigned short); +__gcc_v8hi __builtin_ia32_vpermi2varhi128_mask(__gcc_v8hi, __gcc_v8hi, __gcc_v8hi, unsigned char); +__gcc_v4df __builtin_ia32_rcp14pd256_mask(__gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_rcp14pd128_mask(__gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v8sf __builtin_ia32_rcp14ps256_mask(__gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_rcp14ps128_mask(__gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v4df __builtin_ia32_rsqrt14pd256_mask(__gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_rsqrt14pd128_mask(__gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v8sf __builtin_ia32_rsqrt14ps256_mask(__gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_rsqrt14ps128_mask(__gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v4df __builtin_ia32_sqrtpd256_mask(__gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_sqrtpd128_mask(__gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v8sf __builtin_ia32_sqrtps256_mask(__gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_sqrtps128_mask(__gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v16qi __builtin_ia32_paddb128_mask(__gcc_v16qi, __gcc_v16qi, __gcc_v16qi, unsigned short); +__gcc_v8hi __builtin_ia32_paddw128_mask(__gcc_v8hi, __gcc_v8hi, __gcc_v8hi, unsigned char); +__gcc_v4si __builtin_ia32_paddd128_mask(__gcc_v4si, __gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v2di __builtin_ia32_paddq128_mask(__gcc_v2di, __gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v16qi __builtin_ia32_psubb128_mask(__gcc_v16qi, __gcc_v16qi, __gcc_v16qi, unsigned short); +__gcc_v8hi __builtin_ia32_psubw128_mask(__gcc_v8hi, __gcc_v8hi, __gcc_v8hi, unsigned char); +__gcc_v4si __builtin_ia32_psubd128_mask(__gcc_v4si, __gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v2di __builtin_ia32_psubq128_mask(__gcc_v2di, __gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v16qi __builtin_ia32_paddsb128_mask(__gcc_v16qi, __gcc_v16qi, __gcc_v16qi, unsigned short); +__gcc_v8hi __builtin_ia32_paddsw128_mask(__gcc_v8hi, __gcc_v8hi, __gcc_v8hi, unsigned char); +__gcc_v16qi __builtin_ia32_psubsb128_mask(__gcc_v16qi, __gcc_v16qi, __gcc_v16qi, unsigned short); +__gcc_v8hi __builtin_ia32_psubsw128_mask(__gcc_v8hi, __gcc_v8hi, __gcc_v8hi, unsigned char); +__gcc_v16qi __builtin_ia32_paddusb128_mask(__gcc_v16qi, __gcc_v16qi, __gcc_v16qi, unsigned short); +__gcc_v8hi __builtin_ia32_paddusw128_mask(__gcc_v8hi, __gcc_v8hi, __gcc_v8hi, unsigned char); +__gcc_v16qi __builtin_ia32_psubusb128_mask(__gcc_v16qi, __gcc_v16qi, __gcc_v16qi, unsigned short); +__gcc_v8hi __builtin_ia32_psubusw128_mask(__gcc_v8hi, __gcc_v8hi, __gcc_v8hi, unsigned char); +__gcc_v32qi __builtin_ia32_paddb256_mask(__gcc_v32qi, __gcc_v32qi, __gcc_v32qi, unsigned); +__gcc_v16hi __builtin_ia32_paddw256_mask(__gcc_v16hi, __gcc_v16hi, __gcc_v16hi, unsigned short); +__gcc_v8si __builtin_ia32_paddd256_mask(__gcc_v8si, __gcc_v8si, __gcc_v8si, unsigned char); +__gcc_v4di __builtin_ia32_paddq256_mask(__gcc_v4di, __gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v32qi __builtin_ia32_paddsb256_mask(__gcc_v32qi, __gcc_v32qi, __gcc_v32qi, unsigned); +__gcc_v16hi __builtin_ia32_paddsw256_mask(__gcc_v16hi, __gcc_v16hi, __gcc_v16hi, unsigned short); +__gcc_v32qi __builtin_ia32_paddusb256_mask(__gcc_v32qi, __gcc_v32qi, __gcc_v32qi, unsigned); +__gcc_v16hi __builtin_ia32_paddusw256_mask(__gcc_v16hi, __gcc_v16hi, __gcc_v16hi, unsigned short); +__gcc_v32qi __builtin_ia32_psubb256_mask(__gcc_v32qi, __gcc_v32qi, __gcc_v32qi, unsigned); +__gcc_v16hi __builtin_ia32_psubw256_mask(__gcc_v16hi, __gcc_v16hi, __gcc_v16hi, unsigned short); +__gcc_v8si __builtin_ia32_psubd256_mask(__gcc_v8si, __gcc_v8si, __gcc_v8si, unsigned char); +__gcc_v4di __builtin_ia32_psubq256_mask(__gcc_v4di, __gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v32qi __builtin_ia32_psubsb256_mask(__gcc_v32qi, __gcc_v32qi, __gcc_v32qi, unsigned); +__gcc_v16hi __builtin_ia32_psubsw256_mask(__gcc_v16hi, __gcc_v16hi, __gcc_v16hi, unsigned short); +__gcc_v32qi __builtin_ia32_psubusb256_mask(__gcc_v32qi, __gcc_v32qi, __gcc_v32qi, unsigned); +__gcc_v16hi __builtin_ia32_psubusw256_mask(__gcc_v16hi, __gcc_v16hi, __gcc_v16hi, unsigned short); +__gcc_v4df __builtin_ia32_shuf_f64x2_256_mask(__gcc_v4df, __gcc_v4df, int, __gcc_v4df, unsigned char); +__gcc_v4di __builtin_ia32_shuf_i64x2_256_mask(__gcc_v4di, __gcc_v4di, int, __gcc_v4di, unsigned char); +__gcc_v8si __builtin_ia32_shuf_i32x4_256_mask(__gcc_v8si, __gcc_v8si, int, __gcc_v8si, unsigned char); +__gcc_v8sf __builtin_ia32_shuf_f32x4_256_mask(__gcc_v8sf, __gcc_v8sf, int, __gcc_v8sf, unsigned char); +__gcc_v16qi __builtin_ia32_pmovwb128_mask(__gcc_v8hi, __gcc_v16qi, unsigned char); +__gcc_v16qi __builtin_ia32_pmovwb256_mask(__gcc_v16hi, __gcc_v16qi, unsigned short); +__gcc_v16qi __builtin_ia32_pmovswb128_mask(__gcc_v8hi, __gcc_v16qi, unsigned char); +__gcc_v16qi __builtin_ia32_pmovswb256_mask(__gcc_v16hi, __gcc_v16qi, unsigned short); +__gcc_v16qi __builtin_ia32_pmovuswb128_mask(__gcc_v8hi, __gcc_v16qi, unsigned char); +__gcc_v16qi __builtin_ia32_pmovuswb256_mask(__gcc_v16hi, __gcc_v16qi, unsigned short); +__gcc_v16qi __builtin_ia32_pmovdb128_mask(__gcc_v4si, __gcc_v16qi, unsigned char); +__gcc_v16qi __builtin_ia32_pmovdb256_mask(__gcc_v8si, __gcc_v16qi, unsigned char); +__gcc_v16qi __builtin_ia32_pmovsdb128_mask(__gcc_v4si, __gcc_v16qi, unsigned char); +__gcc_v16qi __builtin_ia32_pmovsdb256_mask(__gcc_v8si, __gcc_v16qi, unsigned char); +__gcc_v16qi __builtin_ia32_pmovusdb128_mask(__gcc_v4si, __gcc_v16qi, unsigned char); +__gcc_v16qi __builtin_ia32_pmovusdb256_mask(__gcc_v8si, __gcc_v16qi, unsigned char); +__gcc_v8hi __builtin_ia32_pmovdw128_mask(__gcc_v4si, __gcc_v8hi, unsigned char); +__gcc_v8hi __builtin_ia32_pmovdw256_mask(__gcc_v8si, __gcc_v8hi, unsigned char); +__gcc_v8hi __builtin_ia32_pmovsdw128_mask(__gcc_v4si, __gcc_v8hi, unsigned char); +__gcc_v8hi __builtin_ia32_pmovsdw256_mask(__gcc_v8si, __gcc_v8hi, unsigned char); +__gcc_v8hi __builtin_ia32_pmovusdw128_mask(__gcc_v4si, __gcc_v8hi, unsigned char); +__gcc_v8hi __builtin_ia32_pmovusdw256_mask(__gcc_v8si, __gcc_v8hi, unsigned char); +__gcc_v16qi __builtin_ia32_pmovqb128_mask(__gcc_v2di, __gcc_v16qi, unsigned char); +__gcc_v16qi __builtin_ia32_pmovqb256_mask(__gcc_v4di, __gcc_v16qi, unsigned char); +__gcc_v16qi __builtin_ia32_pmovsqb128_mask(__gcc_v2di, __gcc_v16qi, unsigned char); +__gcc_v16qi __builtin_ia32_pmovsqb256_mask(__gcc_v4di, __gcc_v16qi, unsigned char); +__gcc_v16qi __builtin_ia32_pmovusqb128_mask(__gcc_v2di, __gcc_v16qi, unsigned char); +__gcc_v16qi __builtin_ia32_pmovusqb256_mask(__gcc_v4di, __gcc_v16qi, unsigned char); +__gcc_v8hi __builtin_ia32_pmovqw128_mask(__gcc_v2di, __gcc_v8hi, unsigned char); +__gcc_v8hi __builtin_ia32_pmovqw256_mask(__gcc_v4di, __gcc_v8hi, unsigned char); +__gcc_v8hi __builtin_ia32_pmovsqw128_mask(__gcc_v2di, __gcc_v8hi, unsigned char); +__gcc_v8hi __builtin_ia32_pmovsqw256_mask(__gcc_v4di, __gcc_v8hi, unsigned char); +__gcc_v8hi __builtin_ia32_pmovusqw128_mask(__gcc_v2di, __gcc_v8hi, unsigned char); +__gcc_v8hi __builtin_ia32_pmovusqw256_mask(__gcc_v4di, __gcc_v8hi, unsigned char); +__gcc_v4si __builtin_ia32_pmovqd128_mask(__gcc_v2di, __gcc_v4si, unsigned char); +__gcc_v4si __builtin_ia32_pmovqd256_mask(__gcc_v4di, __gcc_v4si, unsigned char); +__gcc_v4si __builtin_ia32_pmovsqd128_mask(__gcc_v2di, __gcc_v4si, unsigned char); +__gcc_v4si __builtin_ia32_pmovsqd256_mask(__gcc_v4di, __gcc_v4si, unsigned char); +__gcc_v4si __builtin_ia32_pmovusqd128_mask(__gcc_v2di, __gcc_v4si, unsigned char); +__gcc_v4si __builtin_ia32_pmovusqd256_mask(__gcc_v4di, __gcc_v4si, unsigned char); +__gcc_v4df __builtin_ia32_rangepd256_mask(__gcc_v4df, __gcc_v4df, int, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_rangepd128_mask(__gcc_v2df, __gcc_v2df, int, __gcc_v2df, unsigned char); +__gcc_v8sf __builtin_ia32_rangeps256_mask(__gcc_v8sf, __gcc_v8sf, int, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_rangeps128_mask(__gcc_v4sf, __gcc_v4sf, int, __gcc_v4sf, unsigned char); +__gcc_v8sf __builtin_ia32_getexpps256_mask(__gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v4df __builtin_ia32_getexppd256_mask(__gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v4sf __builtin_ia32_getexpps128_mask(__gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v2df __builtin_ia32_getexppd128_mask(__gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v4df __builtin_ia32_fixupimmpd256_mask(__gcc_v4df, __gcc_v4df, __gcc_v4di, int, unsigned char); +__gcc_v4df __builtin_ia32_fixupimmpd256_maskz(__gcc_v4df, __gcc_v4df, __gcc_v4di, int, unsigned char); +__gcc_v8sf __builtin_ia32_fixupimmps256_mask(__gcc_v8sf, __gcc_v8sf, __gcc_v8si, int, unsigned char); +__gcc_v8sf __builtin_ia32_fixupimmps256_maskz(__gcc_v8sf, __gcc_v8sf, __gcc_v8si, int, unsigned char); +__gcc_v2df __builtin_ia32_fixupimmpd128_mask(__gcc_v2df, __gcc_v2df, __gcc_v2di, int, unsigned char); +__gcc_v2df __builtin_ia32_fixupimmpd128_maskz(__gcc_v2df, __gcc_v2df, __gcc_v2di, int, unsigned char); +__gcc_v4sf __builtin_ia32_fixupimmps128_mask(__gcc_v4sf, __gcc_v4sf, __gcc_v4si, int, unsigned char); +__gcc_v4sf __builtin_ia32_fixupimmps128_maskz(__gcc_v4sf, __gcc_v4sf, __gcc_v4si, int, unsigned char); +__gcc_v4di __builtin_ia32_pabsq256_mask(__gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_pabsq128_mask(__gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v8si __builtin_ia32_pabsd256_mask(__gcc_v8si, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_pabsd128_mask(__gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v16hi __builtin_ia32_pmulhrsw256_mask(__gcc_v16hi, __gcc_v16hi, __gcc_v16hi, unsigned short); +__gcc_v8hi __builtin_ia32_pmulhrsw128_mask(__gcc_v8hi, __gcc_v8hi, __gcc_v8hi, unsigned char); +__gcc_v8hi __builtin_ia32_pmulhuw128_mask(__gcc_v8hi, __gcc_v8hi, __gcc_v8hi, unsigned char); +__gcc_v16hi __builtin_ia32_pmulhuw256_mask(__gcc_v16hi, __gcc_v16hi, __gcc_v16hi, unsigned short); +__gcc_v16hi __builtin_ia32_pmulhw256_mask(__gcc_v16hi, __gcc_v16hi, __gcc_v16hi, unsigned short); +__gcc_v8hi __builtin_ia32_pmulhw128_mask(__gcc_v8hi, __gcc_v8hi, __gcc_v8hi, unsigned char); +__gcc_v16hi __builtin_ia32_pmullw256_mask(__gcc_v16hi, __gcc_v16hi, __gcc_v16hi, unsigned short); +__gcc_v8hi __builtin_ia32_pmullw128_mask(__gcc_v8hi, __gcc_v8hi, __gcc_v8hi, unsigned char); +__gcc_v4di __builtin_ia32_pmullq256_mask(__gcc_v4di, __gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_pmullq128_mask(__gcc_v2di, __gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v4df __builtin_ia32_andpd256_mask(__gcc_v4df, __gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_andpd128_mask(__gcc_v2df, __gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v8sf __builtin_ia32_andps256_mask(__gcc_v8sf, __gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_andps128_mask(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v4df __builtin_ia32_andnpd256_mask(__gcc_v4df, __gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_andnpd128_mask(__gcc_v2df, __gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v8sf __builtin_ia32_andnps256_mask(__gcc_v8sf, __gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_andnps128_mask(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v8si __builtin_ia32_pandd256_mask(__gcc_v8si, __gcc_v8si, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_pandd128_mask(__gcc_v4si, __gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v4di __builtin_ia32_pandq256_mask(__gcc_v4di, __gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_pandq128_mask(__gcc_v2di, __gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v8si __builtin_ia32_pandnd256_mask(__gcc_v8si, __gcc_v8si, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_pandnd128_mask(__gcc_v4si, __gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v4di __builtin_ia32_pandnq256_mask(__gcc_v4di, __gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_pandnq128_mask(__gcc_v2di, __gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v8si __builtin_ia32_pord256_mask(__gcc_v8si, __gcc_v8si, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_pord128_mask(__gcc_v4si, __gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v4di __builtin_ia32_porq256_mask(__gcc_v4di, __gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_porq128_mask(__gcc_v2di, __gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v8si __builtin_ia32_pxord256_mask(__gcc_v8si, __gcc_v8si, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_pxord128_mask(__gcc_v4si, __gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v4di __builtin_ia32_pxorq256_mask(__gcc_v4di, __gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_pxorq128_mask(__gcc_v2di, __gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v32qi __builtin_ia32_packsswb256_mask(__gcc_v16hi, __gcc_v16hi, __gcc_v32qi, unsigned); +__gcc_v16qi __builtin_ia32_packsswb128_mask(__gcc_v8hi, __gcc_v8hi, __gcc_v16qi, unsigned short); +__gcc_v32qi __builtin_ia32_packuswb256_mask(__gcc_v16hi, __gcc_v16hi, __gcc_v32qi, unsigned); +__gcc_v16qi __builtin_ia32_packuswb128_mask(__gcc_v8hi, __gcc_v8hi, __gcc_v16qi, unsigned short); +__gcc_v8sf __builtin_ia32_rndscaleps_256_mask(__gcc_v8sf, int, __gcc_v8sf, unsigned char); +__gcc_v4df __builtin_ia32_rndscalepd_256_mask(__gcc_v4df, int, __gcc_v4df, unsigned char); +__gcc_v4sf __builtin_ia32_rndscaleps_128_mask(__gcc_v4sf, int, __gcc_v4sf, unsigned char); +__gcc_v2df __builtin_ia32_rndscalepd_128_mask(__gcc_v2df, int, __gcc_v2df, unsigned char); +__gcc_v4di __builtin_ia32_pternlogq256_mask(__gcc_v4di, __gcc_v4di, __gcc_v4di, int, unsigned char); +__gcc_v4di __builtin_ia32_pternlogq256_maskz(__gcc_v4di, __gcc_v4di, __gcc_v4di, int, unsigned char); +__gcc_v8si __builtin_ia32_pternlogd256_mask(__gcc_v8si, __gcc_v8si, __gcc_v8si, int, unsigned char); +__gcc_v8si __builtin_ia32_pternlogd256_maskz(__gcc_v8si, __gcc_v8si, __gcc_v8si, int, unsigned char); +__gcc_v2di __builtin_ia32_pternlogq128_mask(__gcc_v2di, __gcc_v2di, __gcc_v2di, int, unsigned char); +__gcc_v2di __builtin_ia32_pternlogq128_maskz(__gcc_v2di, __gcc_v2di, __gcc_v2di, int, unsigned char); +__gcc_v4si __builtin_ia32_pternlogd128_mask(__gcc_v4si, __gcc_v4si, __gcc_v4si, int, unsigned char); +__gcc_v4si __builtin_ia32_pternlogd128_maskz(__gcc_v4si, __gcc_v4si, __gcc_v4si, int, unsigned char); +__gcc_v4df __builtin_ia32_scalefpd256_mask(__gcc_v4df, __gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v8sf __builtin_ia32_scalefps256_mask(__gcc_v8sf, __gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v2df __builtin_ia32_scalefpd128_mask(__gcc_v2df, __gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v4sf __builtin_ia32_scalefps128_mask(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v4df __builtin_ia32_vfmaddpd256_mask(__gcc_v4df, __gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v4df __builtin_ia32_vfmaddpd256_mask3(__gcc_v4df, __gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v4df __builtin_ia32_vfmaddpd256_maskz(__gcc_v4df, __gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_vfmaddpd128_mask(__gcc_v2df, __gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v2df __builtin_ia32_vfmaddpd128_mask3(__gcc_v2df, __gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v2df __builtin_ia32_vfmaddpd128_maskz(__gcc_v2df, __gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v8sf __builtin_ia32_vfmaddps256_mask(__gcc_v8sf, __gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v8sf __builtin_ia32_vfmaddps256_mask3(__gcc_v8sf, __gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v8sf __builtin_ia32_vfmaddps256_maskz(__gcc_v8sf, __gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_vfmaddps128_mask(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v4sf __builtin_ia32_vfmaddps128_mask3(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v4sf __builtin_ia32_vfmaddps128_maskz(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v4df __builtin_ia32_vfmsubpd256_mask3(__gcc_v4df, __gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_vfmsubpd128_mask3(__gcc_v2df, __gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v8sf __builtin_ia32_vfmsubps256_mask3(__gcc_v8sf, __gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_vfmsubps128_mask3(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v4df __builtin_ia32_vfnmaddpd256_mask(__gcc_v4df, __gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_vfnmaddpd128_mask(__gcc_v2df, __gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v8sf __builtin_ia32_vfnmaddps256_mask(__gcc_v8sf, __gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_vfnmaddps128_mask(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v4df __builtin_ia32_vfnmsubpd256_mask(__gcc_v4df, __gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v4df __builtin_ia32_vfnmsubpd256_mask3(__gcc_v4df, __gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_vfnmsubpd128_mask(__gcc_v2df, __gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v2df __builtin_ia32_vfnmsubpd128_mask3(__gcc_v2df, __gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v8sf __builtin_ia32_vfnmsubps256_mask(__gcc_v8sf, __gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v8sf __builtin_ia32_vfnmsubps256_mask3(__gcc_v8sf, __gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_vfnmsubps128_mask(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v4sf __builtin_ia32_vfnmsubps128_mask3(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v4df __builtin_ia32_vfmaddsubpd256_mask(__gcc_v4df, __gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v4df __builtin_ia32_vfmaddsubpd256_mask3(__gcc_v4df, __gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v4df __builtin_ia32_vfmaddsubpd256_maskz(__gcc_v4df, __gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_vfmaddsubpd128_mask(__gcc_v2df, __gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v2df __builtin_ia32_vfmaddsubpd128_mask3(__gcc_v2df, __gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v2df __builtin_ia32_vfmaddsubpd128_maskz(__gcc_v2df, __gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v8sf __builtin_ia32_vfmaddsubps256_mask(__gcc_v8sf, __gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v8sf __builtin_ia32_vfmaddsubps256_mask3(__gcc_v8sf, __gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v8sf __builtin_ia32_vfmaddsubps256_maskz(__gcc_v8sf, __gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_vfmaddsubps128_mask(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v4sf __builtin_ia32_vfmaddsubps128_mask3(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v4sf __builtin_ia32_vfmaddsubps128_maskz(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v4df __builtin_ia32_vfmsubaddpd256_mask3(__gcc_v4df, __gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_vfmsubaddpd128_mask3(__gcc_v2df, __gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v8sf __builtin_ia32_vfmsubaddps256_mask3(__gcc_v8sf, __gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_vfmsubaddps128_mask3(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v4df __builtin_ia32_insertf64x2_256_mask(__gcc_v4df, __gcc_v2df, int, __gcc_v4df, unsigned char); +__gcc_v4di __builtin_ia32_inserti64x2_256_mask(__gcc_v4di, __gcc_v2di, int, __gcc_v4di, unsigned char); +__gcc_v16hi __builtin_ia32_psrav16hi_mask(__gcc_v16hi, __gcc_v16hi, __gcc_v16hi, unsigned short); +__gcc_v8hi __builtin_ia32_psrav8hi_mask(__gcc_v8hi, __gcc_v8hi, __gcc_v8hi, unsigned char); +__gcc_v16hi __builtin_ia32_pmaddubsw256_mask(__gcc_v32qi, __gcc_v32qi, __gcc_v16hi, unsigned short); +__gcc_v8hi __builtin_ia32_pmaddubsw128_mask(__gcc_v16qi, __gcc_v16qi, __gcc_v8hi, unsigned char); +__gcc_v8si __builtin_ia32_pmaddwd256_mask(__gcc_v16hi, __gcc_v16hi, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_pmaddwd128_mask(__gcc_v8hi, __gcc_v8hi, __gcc_v4si, unsigned char); +__gcc_v16hi __builtin_ia32_psrlv16hi_mask(__gcc_v16hi, __gcc_v16hi, __gcc_v16hi, unsigned short); +__gcc_v8hi __builtin_ia32_psrlv8hi_mask(__gcc_v8hi, __gcc_v8hi, __gcc_v8hi, unsigned char); +__gcc_v8si __builtin_ia32_cvtps2dq256_mask(__gcc_v8sf, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_cvtps2dq128_mask(__gcc_v4sf, __gcc_v4si, unsigned char); +__gcc_v8si __builtin_ia32_cvtps2udq256_mask(__gcc_v8sf, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_cvtps2udq128_mask(__gcc_v4sf, __gcc_v4si, unsigned char); +__gcc_v4di __builtin_ia32_cvtps2qq256_mask(__gcc_v4sf, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_cvtps2qq128_mask(__gcc_v4sf, __gcc_v2di, unsigned char); +__gcc_v4di __builtin_ia32_cvtps2uqq256_mask(__gcc_v4sf, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_cvtps2uqq128_mask(__gcc_v4sf, __gcc_v2di, unsigned char); +__gcc_v8sf __builtin_ia32_getmantps256_mask(__gcc_v8sf, int, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_getmantps128_mask(__gcc_v4sf, int, __gcc_v4sf, unsigned char); +__gcc_v4df __builtin_ia32_getmantpd256_mask(__gcc_v4df, int, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_getmantpd128_mask(__gcc_v2df, int, __gcc_v2df, unsigned char); +__gcc_v4df __builtin_ia32_movddup256_mask(__gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_movddup128_mask(__gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v8sf __builtin_ia32_movshdup256_mask(__gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_movshdup128_mask(__gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v8sf __builtin_ia32_movsldup256_mask(__gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_movsldup128_mask(__gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v4sf __builtin_ia32_cvtqq2ps256_mask(__gcc_v4di, __gcc_v4sf, unsigned char); +__gcc_v4sf __builtin_ia32_cvtqq2ps128_mask(__gcc_v2di, __gcc_v4sf, unsigned char); +__gcc_v4sf __builtin_ia32_cvtuqq2ps256_mask(__gcc_v4di, __gcc_v4sf, unsigned char); +__gcc_v4sf __builtin_ia32_cvtuqq2ps128_mask(__gcc_v2di, __gcc_v4sf, unsigned char); +__gcc_v4df __builtin_ia32_cvtqq2pd256_mask(__gcc_v4di, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_cvtqq2pd128_mask(__gcc_v2di, __gcc_v2df, unsigned char); +__gcc_v4df __builtin_ia32_cvtuqq2pd256_mask(__gcc_v4di, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_cvtuqq2pd128_mask(__gcc_v2di, __gcc_v2df, unsigned char); +__gcc_v4di __builtin_ia32_vpermt2varq256_mask(__gcc_v4di, __gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v4di __builtin_ia32_vpermt2varq256_maskz(__gcc_v4di, __gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v8si __builtin_ia32_vpermt2vard256_mask(__gcc_v8si, __gcc_v8si, __gcc_v8si, unsigned char); +__gcc_v8si __builtin_ia32_vpermt2vard256_maskz(__gcc_v8si, __gcc_v8si, __gcc_v8si, unsigned char); +__gcc_v4di __builtin_ia32_vpermi2varq256_mask(__gcc_v4di, __gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v8si __builtin_ia32_vpermi2vard256_mask(__gcc_v8si, __gcc_v8si, __gcc_v8si, unsigned char); +__gcc_v4df __builtin_ia32_vpermt2varpd256_mask(__gcc_v4di, __gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v4df __builtin_ia32_vpermt2varpd256_maskz(__gcc_v4di, __gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v8sf __builtin_ia32_vpermt2varps256_mask(__gcc_v8si, __gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v8sf __builtin_ia32_vpermt2varps256_maskz(__gcc_v8si, __gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v4df __builtin_ia32_vpermi2varpd256_mask(__gcc_v4df, __gcc_v4di, __gcc_v4df, unsigned char); +__gcc_v8sf __builtin_ia32_vpermi2varps256_mask(__gcc_v8sf, __gcc_v8si, __gcc_v8sf, unsigned char); +__gcc_v2di __builtin_ia32_vpermt2varq128_mask(__gcc_v2di, __gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v2di __builtin_ia32_vpermt2varq128_maskz(__gcc_v2di, __gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v4si __builtin_ia32_vpermt2vard128_mask(__gcc_v4si, __gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v4si __builtin_ia32_vpermt2vard128_maskz(__gcc_v4si, __gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v2di __builtin_ia32_vpermi2varq128_mask(__gcc_v2di, __gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v4si __builtin_ia32_vpermi2vard128_mask(__gcc_v4si, __gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v2df __builtin_ia32_vpermt2varpd128_mask(__gcc_v2di, __gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v2df __builtin_ia32_vpermt2varpd128_maskz(__gcc_v2di, __gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v4sf __builtin_ia32_vpermt2varps128_mask(__gcc_v4si, __gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v4sf __builtin_ia32_vpermt2varps128_maskz(__gcc_v4si, __gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v2df __builtin_ia32_vpermi2varpd128_mask(__gcc_v2df, __gcc_v2di, __gcc_v2df, unsigned char); +__gcc_v4sf __builtin_ia32_vpermi2varps128_mask(__gcc_v4sf, __gcc_v4si, __gcc_v4sf, unsigned char); +__gcc_v32qi __builtin_ia32_pshufb256_mask(__gcc_v32qi, __gcc_v32qi, __gcc_v32qi, unsigned); +__gcc_v16qi __builtin_ia32_pshufb128_mask(__gcc_v16qi, __gcc_v16qi, __gcc_v16qi, unsigned short); +__gcc_v16hi __builtin_ia32_pshufhw256_mask(__gcc_v16hi, int, __gcc_v16hi, unsigned short); +__gcc_v8hi __builtin_ia32_pshufhw128_mask(__gcc_v8hi, int, __gcc_v8hi, unsigned char); +__gcc_v16hi __builtin_ia32_pshuflw256_mask(__gcc_v16hi, int, __gcc_v16hi, unsigned short); +__gcc_v8hi __builtin_ia32_pshuflw128_mask(__gcc_v8hi, int, __gcc_v8hi, unsigned char); +__gcc_v8si __builtin_ia32_pshufd256_mask(__gcc_v8si, int, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_pshufd128_mask(__gcc_v4si, int, __gcc_v4si, unsigned char); +__gcc_v4df __builtin_ia32_shufpd256_mask(__gcc_v4df, __gcc_v4df, int, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_shufpd128_mask(__gcc_v2df, __gcc_v2df, int, __gcc_v2df, unsigned char); +__gcc_v8sf __builtin_ia32_shufps256_mask(__gcc_v8sf, __gcc_v8sf, int, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_shufps128_mask(__gcc_v4sf, __gcc_v4sf, int, __gcc_v4sf, unsigned char); +__gcc_v4di __builtin_ia32_prolvq256_mask(__gcc_v4di, __gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_prolvq128_mask(__gcc_v2di, __gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v4di __builtin_ia32_prolq256_mask(__gcc_v4di, int, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_prolq128_mask(__gcc_v2di, int, __gcc_v2di, unsigned char); +__gcc_v4di __builtin_ia32_prorvq256_mask(__gcc_v4di, __gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_prorvq128_mask(__gcc_v2di, __gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v4di __builtin_ia32_prorq256_mask(__gcc_v4di, int, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_prorq128_mask(__gcc_v2di, int, __gcc_v2di, unsigned char); +__gcc_v2di __builtin_ia32_psravq128_mask(__gcc_v2di, __gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v4di __builtin_ia32_psravq256_mask(__gcc_v4di, __gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v4di __builtin_ia32_psllv4di_mask(__gcc_v4di, __gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_psllv2di_mask(__gcc_v2di, __gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v8si __builtin_ia32_psllv8si_mask(__gcc_v8si, __gcc_v8si, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_psllv4si_mask(__gcc_v4si, __gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v8si __builtin_ia32_psrav8si_mask(__gcc_v8si, __gcc_v8si, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_psrav4si_mask(__gcc_v4si, __gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v4di __builtin_ia32_psrlv4di_mask(__gcc_v4di, __gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_psrlv2di_mask(__gcc_v2di, __gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v8si __builtin_ia32_psrlv8si_mask(__gcc_v8si, __gcc_v8si, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_psrlv4si_mask(__gcc_v4si, __gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v8si __builtin_ia32_prorvd256_mask(__gcc_v8si, __gcc_v8si, __gcc_v8si, unsigned char); +__gcc_v8si __builtin_ia32_prolvd256_mask(__gcc_v8si, __gcc_v8si, __gcc_v8si, unsigned char); +__gcc_v8si __builtin_ia32_prord256_mask(__gcc_v8si, int, __gcc_v8si, unsigned char); +__gcc_v8si __builtin_ia32_prold256_mask(__gcc_v8si, int, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_prorvd128_mask(__gcc_v4si, __gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v4si __builtin_ia32_prolvd128_mask(__gcc_v4si, __gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v4si __builtin_ia32_prord128_mask(__gcc_v4si, int, __gcc_v4si, unsigned char); +__gcc_v4si __builtin_ia32_prold128_mask(__gcc_v4si, int, __gcc_v4si, unsigned char); +char __builtin_ia32_fpclasspd256_mask(__gcc_v4df, int, unsigned char); +char __builtin_ia32_fpclasspd128_mask(__gcc_v2df, int, unsigned char); +char __builtin_ia32_fpclasssd(__gcc_v2df, int); +char __builtin_ia32_fpclassps256_mask(__gcc_v8sf, int, unsigned char); +char __builtin_ia32_fpclassps128_mask(__gcc_v4sf, int, unsigned char); +char __builtin_ia32_fpclassss(__gcc_v4sf, int); +unsigned short __builtin_ia32_cvtb2mask128(__gcc_v16qi); +unsigned __builtin_ia32_cvtb2mask256(__gcc_v32qi); +unsigned char __builtin_ia32_cvtw2mask128(__gcc_v8hi); +unsigned short __builtin_ia32_cvtw2mask256(__gcc_v16hi); +unsigned char __builtin_ia32_cvtd2mask128(__gcc_v4si); +unsigned char __builtin_ia32_cvtd2mask256(__gcc_v8si); +unsigned char __builtin_ia32_cvtq2mask128(__gcc_v2di); +unsigned char __builtin_ia32_cvtq2mask256(__gcc_v4di); +__gcc_v16qi __builtin_ia32_cvtmask2b128(unsigned short); +__gcc_v32qi __builtin_ia32_cvtmask2b256(unsigned); +__gcc_v8hi __builtin_ia32_cvtmask2w128(unsigned char); +__gcc_v16hi __builtin_ia32_cvtmask2w256(unsigned short); +__gcc_v4si __builtin_ia32_cvtmask2d128(unsigned char); +__gcc_v8si __builtin_ia32_cvtmask2d256(unsigned char); +__gcc_v2di __builtin_ia32_cvtmask2q128(unsigned char); +__gcc_v4di __builtin_ia32_cvtmask2q256(unsigned char); +unsigned short __builtin_ia32_pcmpeqb128_mask(__gcc_v16qi, __gcc_v16qi, unsigned short); +unsigned __builtin_ia32_pcmpeqb256_mask(__gcc_v32qi, __gcc_v32qi, unsigned); +unsigned char __builtin_ia32_pcmpeqw128_mask(__gcc_v8hi, __gcc_v8hi, unsigned char); +unsigned short __builtin_ia32_pcmpeqw256_mask(__gcc_v16hi, __gcc_v16hi, unsigned short); +unsigned char __builtin_ia32_pcmpeqd128_mask(__gcc_v4si, __gcc_v4si, unsigned char); +unsigned char __builtin_ia32_pcmpeqd256_mask(__gcc_v8si, __gcc_v8si, unsigned char); +unsigned char __builtin_ia32_pcmpeqq128_mask(__gcc_v2di, __gcc_v2di, unsigned char); +unsigned char __builtin_ia32_pcmpeqq256_mask(__gcc_v4di, __gcc_v4di, unsigned char); +unsigned short __builtin_ia32_pcmpgtb128_mask(__gcc_v16qi, __gcc_v16qi, unsigned short); +unsigned __builtin_ia32_pcmpgtb256_mask(__gcc_v32qi, __gcc_v32qi, unsigned); +unsigned char __builtin_ia32_pcmpgtw128_mask(__gcc_v8hi, __gcc_v8hi, unsigned char); +unsigned short __builtin_ia32_pcmpgtw256_mask(__gcc_v16hi, __gcc_v16hi, unsigned short); +unsigned char __builtin_ia32_pcmpgtd128_mask(__gcc_v4si, __gcc_v4si, unsigned char); +unsigned char __builtin_ia32_pcmpgtd256_mask(__gcc_v8si, __gcc_v8si, unsigned char); +unsigned char __builtin_ia32_pcmpgtq128_mask(__gcc_v2di, __gcc_v2di, unsigned char); +unsigned char __builtin_ia32_pcmpgtq256_mask(__gcc_v4di, __gcc_v4di, unsigned char); +unsigned short __builtin_ia32_ptestmb128(__gcc_v16qi, __gcc_v16qi, unsigned short); +unsigned __builtin_ia32_ptestmb256(__gcc_v32qi, __gcc_v32qi, unsigned); +unsigned char __builtin_ia32_ptestmw128(__gcc_v8hi, __gcc_v8hi, unsigned char); +unsigned short __builtin_ia32_ptestmw256(__gcc_v16hi, __gcc_v16hi, unsigned short); +unsigned char __builtin_ia32_ptestmd128(__gcc_v4si, __gcc_v4si, unsigned char); +unsigned char __builtin_ia32_ptestmd256(__gcc_v8si, __gcc_v8si, unsigned char); +unsigned char __builtin_ia32_ptestmq128(__gcc_v2di, __gcc_v2di, unsigned char); +unsigned char __builtin_ia32_ptestmq256(__gcc_v4di, __gcc_v4di, unsigned char); +unsigned short __builtin_ia32_ptestnmb128(__gcc_v16qi, __gcc_v16qi, unsigned short); +unsigned __builtin_ia32_ptestnmb256(__gcc_v32qi, __gcc_v32qi, unsigned); +unsigned char __builtin_ia32_ptestnmw128(__gcc_v8hi, __gcc_v8hi, unsigned char); +unsigned short __builtin_ia32_ptestnmw256(__gcc_v16hi, __gcc_v16hi, unsigned short); +unsigned char __builtin_ia32_ptestnmd128(__gcc_v4si, __gcc_v4si, unsigned char); +unsigned char __builtin_ia32_ptestnmd256(__gcc_v8si, __gcc_v8si, unsigned char); +unsigned char __builtin_ia32_ptestnmq128(__gcc_v2di, __gcc_v2di, unsigned char); +unsigned char __builtin_ia32_ptestnmq256(__gcc_v4di, __gcc_v4di, unsigned char); diff --git a/src/ansi-c/gcc_builtin_headers_ia32-4.h b/src/ansi-c/gcc_builtin_headers_ia32-4.h new file mode 100644 index 00000000000..5acd1ab952a --- /dev/null +++ b/src/ansi-c/gcc_builtin_headers_ia32-4.h @@ -0,0 +1,341 @@ +__gcc_v2di __builtin_ia32_broadcastmb128(unsigned char); +__gcc_v4di __builtin_ia32_broadcastmb256(unsigned char); +__gcc_v4si __builtin_ia32_broadcastmw128(unsigned short); +__gcc_v8si __builtin_ia32_broadcastmw256(unsigned short); +__gcc_v4df __builtin_ia32_compressdf256_mask(__gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_compressdf128_mask(__gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v8sf __builtin_ia32_compresssf256_mask(__gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_compresssf128_mask(__gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v4di __builtin_ia32_compressdi256_mask(__gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_compressdi128_mask(__gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v8si __builtin_ia32_compresssi256_mask(__gcc_v8si, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_compresssi128_mask(__gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v4df __builtin_ia32_expanddf256_mask(__gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_expanddf128_mask(__gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v8sf __builtin_ia32_expandsf256_mask(__gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_expandsf128_mask(__gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v4di __builtin_ia32_expanddi256_mask(__gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_expanddi128_mask(__gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v8si __builtin_ia32_expandsi256_mask(__gcc_v8si, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_expandsi128_mask(__gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v4df __builtin_ia32_expanddf256_maskz(__gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_expanddf128_maskz(__gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v8sf __builtin_ia32_expandsf256_maskz(__gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_expandsf128_maskz(__gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v4di __builtin_ia32_expanddi256_maskz(__gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_expanddi128_maskz(__gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v8si __builtin_ia32_expandsi256_maskz(__gcc_v8si, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_expandsi128_maskz(__gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v8si __builtin_ia32_pmaxsd256_mask(__gcc_v8si, __gcc_v8si, __gcc_v8si, unsigned char); +__gcc_v8si __builtin_ia32_pminsd256_mask(__gcc_v8si, __gcc_v8si, __gcc_v8si, unsigned char); +__gcc_v8si __builtin_ia32_pmaxud256_mask(__gcc_v8si, __gcc_v8si, __gcc_v8si, unsigned char); +__gcc_v8si __builtin_ia32_pminud256_mask(__gcc_v8si, __gcc_v8si, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_pmaxsd128_mask(__gcc_v4si, __gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v4si __builtin_ia32_pminsd128_mask(__gcc_v4si, __gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v4si __builtin_ia32_pmaxud128_mask(__gcc_v4si, __gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v4si __builtin_ia32_pminud128_mask(__gcc_v4si, __gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v4di __builtin_ia32_pmaxsq256_mask(__gcc_v4di, __gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v4di __builtin_ia32_pminsq256_mask(__gcc_v4di, __gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v4di __builtin_ia32_pmaxuq256_mask(__gcc_v4di, __gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v4di __builtin_ia32_pminuq256_mask(__gcc_v4di, __gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_pmaxsq128_mask(__gcc_v2di, __gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v2di __builtin_ia32_pminsq128_mask(__gcc_v2di, __gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v2di __builtin_ia32_pmaxuq128_mask(__gcc_v2di, __gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v2di __builtin_ia32_pminuq128_mask(__gcc_v2di, __gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v32qi __builtin_ia32_pminsb256_mask(__gcc_v32qi, __gcc_v32qi, __gcc_v32qi, unsigned); +__gcc_v32qi __builtin_ia32_pminub256_mask(__gcc_v32qi, __gcc_v32qi, __gcc_v32qi, unsigned); +__gcc_v32qi __builtin_ia32_pmaxsb256_mask(__gcc_v32qi, __gcc_v32qi, __gcc_v32qi, unsigned); +__gcc_v32qi __builtin_ia32_pmaxub256_mask(__gcc_v32qi, __gcc_v32qi, __gcc_v32qi, unsigned); +__gcc_v16qi __builtin_ia32_pminsb128_mask(__gcc_v16qi, __gcc_v16qi, __gcc_v16qi, unsigned short); +__gcc_v16qi __builtin_ia32_pminub128_mask(__gcc_v16qi, __gcc_v16qi, __gcc_v16qi, unsigned short); +__gcc_v16qi __builtin_ia32_pmaxsb128_mask(__gcc_v16qi, __gcc_v16qi, __gcc_v16qi, unsigned short); +__gcc_v16qi __builtin_ia32_pmaxub128_mask(__gcc_v16qi, __gcc_v16qi, __gcc_v16qi, unsigned short); +__gcc_v16hi __builtin_ia32_pminsw256_mask(__gcc_v16hi, __gcc_v16hi, __gcc_v16hi, unsigned short); +__gcc_v16hi __builtin_ia32_pminuw256_mask(__gcc_v16hi, __gcc_v16hi, __gcc_v16hi, unsigned short); +__gcc_v16hi __builtin_ia32_pmaxsw256_mask(__gcc_v16hi, __gcc_v16hi, __gcc_v16hi, unsigned short); +__gcc_v16hi __builtin_ia32_pmaxuw256_mask(__gcc_v16hi, __gcc_v16hi, __gcc_v16hi, unsigned short); +__gcc_v8hi __builtin_ia32_pminsw128_mask(__gcc_v8hi, __gcc_v8hi, __gcc_v8hi, unsigned char); +__gcc_v8hi __builtin_ia32_pminuw128_mask(__gcc_v8hi, __gcc_v8hi, __gcc_v8hi, unsigned char); +__gcc_v8hi __builtin_ia32_pmaxsw128_mask(__gcc_v8hi, __gcc_v8hi, __gcc_v8hi, unsigned char); +__gcc_v8hi __builtin_ia32_pmaxuw128_mask(__gcc_v8hi, __gcc_v8hi, __gcc_v8hi, unsigned char); +__gcc_v4di __builtin_ia32_vpconflictdi_256_mask(__gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v8si __builtin_ia32_vpconflictsi_256_mask(__gcc_v8si, __gcc_v8si, unsigned char); +__gcc_v4di __builtin_ia32_vplzcntq_256_mask(__gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v8si __builtin_ia32_vplzcntd_256_mask(__gcc_v8si, __gcc_v8si, unsigned char); +__gcc_v4df __builtin_ia32_unpckhpd256_mask(__gcc_v4df, __gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_unpckhpd128_mask(__gcc_v2df, __gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v8sf __builtin_ia32_unpckhps256_mask(__gcc_v8sf, __gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v4sf __builtin_ia32_unpckhps128_mask(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v4df __builtin_ia32_unpcklpd256_mask(__gcc_v4df, __gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v2df __builtin_ia32_unpcklpd128_mask(__gcc_v2df, __gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v8sf __builtin_ia32_unpcklps256_mask(__gcc_v8sf, __gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v2di __builtin_ia32_vpconflictdi_128_mask(__gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v4si __builtin_ia32_vpconflictsi_128_mask(__gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v2di __builtin_ia32_vplzcntq_128_mask(__gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v4si __builtin_ia32_vplzcntd_128_mask(__gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v4sf __builtin_ia32_unpcklps128_mask(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v8si __builtin_ia32_alignd256_mask(__gcc_v8si, __gcc_v8si, int, __gcc_v8si, unsigned char); +__gcc_v4di __builtin_ia32_alignq256_mask(__gcc_v4di, __gcc_v4di, int, __gcc_v4di, unsigned char); +__gcc_v4si __builtin_ia32_alignd128_mask(__gcc_v4si, __gcc_v4si, int, __gcc_v4si, unsigned char); +__gcc_v2di __builtin_ia32_alignq128_mask(__gcc_v2di, __gcc_v2di, int, __gcc_v2di, unsigned char); +__gcc_v8hi __builtin_ia32_vcvtps2ph256_mask(__gcc_v8sf, int, __gcc_v8hi, unsigned char); +__gcc_v8hi __builtin_ia32_vcvtps2ph_mask(__gcc_v4sf, int, __gcc_v8hi, unsigned char); +__gcc_v4sf __builtin_ia32_vcvtph2ps_mask(__gcc_v8hi, __gcc_v4sf, unsigned char); +__gcc_v8sf __builtin_ia32_vcvtph2ps256_mask(__gcc_v8hi, __gcc_v8sf, unsigned char); +__gcc_v4si __builtin_ia32_punpckhdq128_mask(__gcc_v4si, __gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v8si __builtin_ia32_punpckhdq256_mask(__gcc_v8si, __gcc_v8si, __gcc_v8si, unsigned char); +__gcc_v2di __builtin_ia32_punpckhqdq128_mask(__gcc_v2di, __gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v4di __builtin_ia32_punpckhqdq256_mask(__gcc_v4di, __gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v4si __builtin_ia32_punpckldq128_mask(__gcc_v4si, __gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v8si __builtin_ia32_punpckldq256_mask(__gcc_v8si, __gcc_v8si, __gcc_v8si, unsigned char); +__gcc_v2di __builtin_ia32_punpcklqdq128_mask(__gcc_v2di, __gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v4di __builtin_ia32_punpcklqdq256_mask(__gcc_v4di, __gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v16qi __builtin_ia32_punpckhbw128_mask(__gcc_v16qi, __gcc_v16qi, __gcc_v16qi, unsigned short); +__gcc_v32qi __builtin_ia32_punpckhbw256_mask(__gcc_v32qi, __gcc_v32qi, __gcc_v32qi, unsigned); +__gcc_v8hi __builtin_ia32_punpckhwd128_mask(__gcc_v8hi, __gcc_v8hi, __gcc_v8hi, unsigned char); +__gcc_v16hi __builtin_ia32_punpckhwd256_mask(__gcc_v16hi, __gcc_v16hi, __gcc_v16hi, unsigned short); +__gcc_v16qi __builtin_ia32_punpcklbw128_mask(__gcc_v16qi, __gcc_v16qi, __gcc_v16qi, unsigned short); +__gcc_v32qi __builtin_ia32_punpcklbw256_mask(__gcc_v32qi, __gcc_v32qi, __gcc_v32qi, unsigned); +__gcc_v8hi __builtin_ia32_punpcklwd128_mask(__gcc_v8hi, __gcc_v8hi, __gcc_v8hi, unsigned char); +__gcc_v16hi __builtin_ia32_punpcklwd256_mask(__gcc_v16hi, __gcc_v16hi, __gcc_v16hi, unsigned short); +__gcc_v16hi __builtin_ia32_psllv16hi_mask(__gcc_v16hi, __gcc_v16hi, __gcc_v16hi, unsigned short); +__gcc_v8hi __builtin_ia32_psllv8hi_mask(__gcc_v8hi, __gcc_v8hi, __gcc_v8hi, unsigned char); +__gcc_v16hi __builtin_ia32_packssdw256_mask(__gcc_v8si, __gcc_v8si, __gcc_v16hi, unsigned short); +__gcc_v8hi __builtin_ia32_packssdw128_mask(__gcc_v4si, __gcc_v4si, __gcc_v8hi, unsigned char); +__gcc_v16hi __builtin_ia32_packusdw256_mask(__gcc_v8si, __gcc_v8si, __gcc_v16hi, unsigned short); +__gcc_v8hi __builtin_ia32_packusdw128_mask(__gcc_v4si, __gcc_v4si, __gcc_v8hi, unsigned char); +__gcc_v32qi __builtin_ia32_pavgb256_mask(__gcc_v32qi, __gcc_v32qi, __gcc_v32qi, unsigned); +__gcc_v16hi __builtin_ia32_pavgw256_mask(__gcc_v16hi, __gcc_v16hi, __gcc_v16hi, unsigned short); +__gcc_v16qi __builtin_ia32_pavgb128_mask(__gcc_v16qi, __gcc_v16qi, __gcc_v16qi, unsigned short); +__gcc_v8hi __builtin_ia32_pavgw128_mask(__gcc_v8hi, __gcc_v8hi, __gcc_v8hi, unsigned char); +__gcc_v8sf __builtin_ia32_permvarsf256_mask(__gcc_v8sf, __gcc_v8si, __gcc_v8sf, unsigned char); +__gcc_v4df __builtin_ia32_permvardf256_mask(__gcc_v4df, __gcc_v4di, __gcc_v4df, unsigned char); +__gcc_v4df __builtin_ia32_permdf256_mask(__gcc_v4df, int, __gcc_v4df, unsigned char); +__gcc_v32qi __builtin_ia32_pabsb256_mask(__gcc_v32qi, __gcc_v32qi, unsigned); +__gcc_v16qi __builtin_ia32_pabsb128_mask(__gcc_v16qi, __gcc_v16qi, unsigned short); +__gcc_v16hi __builtin_ia32_pabsw256_mask(__gcc_v16hi, __gcc_v16hi, unsigned short); +__gcc_v8hi __builtin_ia32_pabsw128_mask(__gcc_v8hi, __gcc_v8hi, unsigned char); +__gcc_v2df __builtin_ia32_vpermilvarpd_mask(__gcc_v2df, __gcc_v2di, __gcc_v2df, unsigned char); +__gcc_v4sf __builtin_ia32_vpermilvarps_mask(__gcc_v4sf, __gcc_v4si, __gcc_v4sf, unsigned char); +__gcc_v4df __builtin_ia32_vpermilvarpd256_mask(__gcc_v4df, __gcc_v4di, __gcc_v4df, unsigned char); +__gcc_v8sf __builtin_ia32_vpermilvarps256_mask(__gcc_v8sf, __gcc_v8si, __gcc_v8sf, unsigned char); +__gcc_v2df __builtin_ia32_vpermilpd_mask(__gcc_v2df, int, __gcc_v2df, unsigned char); +__gcc_v4sf __builtin_ia32_vpermilps_mask(__gcc_v4sf, int, __gcc_v4sf, unsigned char); +__gcc_v4df __builtin_ia32_vpermilpd256_mask(__gcc_v4df, int, __gcc_v4df, unsigned char); +__gcc_v8sf __builtin_ia32_vpermilps256_mask(__gcc_v8sf, int, __gcc_v8sf, unsigned char); +__gcc_v4di __builtin_ia32_blendmq_256_mask(__gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v8si __builtin_ia32_blendmd_256_mask(__gcc_v8si, __gcc_v8si, unsigned char); +__gcc_v4df __builtin_ia32_blendmpd_256_mask(__gcc_v4df, __gcc_v4df, unsigned char); +__gcc_v8sf __builtin_ia32_blendmps_256_mask(__gcc_v8sf, __gcc_v8sf, unsigned char); +__gcc_v2di __builtin_ia32_blendmq_128_mask(__gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v4si __builtin_ia32_blendmd_128_mask(__gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v2df __builtin_ia32_blendmpd_128_mask(__gcc_v2df, __gcc_v2df, unsigned char); +__gcc_v4sf __builtin_ia32_blendmps_128_mask(__gcc_v4sf, __gcc_v4sf, unsigned char); +__gcc_v16hi __builtin_ia32_blendmw_256_mask(__gcc_v16hi, __gcc_v16hi, unsigned short); +__gcc_v32qi __builtin_ia32_blendmb_256_mask(__gcc_v32qi, __gcc_v32qi, unsigned); +__gcc_v8hi __builtin_ia32_blendmw_128_mask(__gcc_v8hi, __gcc_v8hi, unsigned char); +__gcc_v16qi __builtin_ia32_blendmb_128_mask(__gcc_v16qi, __gcc_v16qi, unsigned short); +__gcc_v8si __builtin_ia32_pmulld256_mask(__gcc_v8si, __gcc_v8si, __gcc_v8si, unsigned char); +__gcc_v4si __builtin_ia32_pmulld128_mask(__gcc_v4si, __gcc_v4si, __gcc_v4si, unsigned char); +__gcc_v4di __builtin_ia32_pmuludq256_mask(__gcc_v8si, __gcc_v8si, __gcc_v4di, unsigned char); +__gcc_v4di __builtin_ia32_pmuldq256_mask(__gcc_v8si, __gcc_v8si, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_pmuldq128_mask(__gcc_v4si, __gcc_v4si, __gcc_v2di, unsigned char); +__gcc_v2di __builtin_ia32_pmuludq128_mask(__gcc_v4si, __gcc_v4si, __gcc_v2di, unsigned char); +__gcc_v4sf __builtin_ia32_cvtpd2ps256_mask(__gcc_v4df, __gcc_v4sf, unsigned char); +__gcc_v4sf __builtin_ia32_cvtpd2ps_mask(__gcc_v2df, __gcc_v4sf, unsigned char); +__gcc_v8si __builtin_ia32_permvarsi256_mask(__gcc_v8si, __gcc_v8si, __gcc_v8si, unsigned char); +__gcc_v4di __builtin_ia32_permvardi256_mask(__gcc_v4di, __gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v4di __builtin_ia32_permdi256_mask(__gcc_v4di, int, __gcc_v4di, unsigned char); +unsigned char __builtin_ia32_cmpq256_mask(__gcc_v4di, __gcc_v4di, int, unsigned char); +unsigned char __builtin_ia32_cmpd256_mask(__gcc_v8si, __gcc_v8si, int, unsigned char); +unsigned char __builtin_ia32_ucmpq256_mask(__gcc_v4di, __gcc_v4di, int, unsigned char); +unsigned char __builtin_ia32_ucmpd256_mask(__gcc_v8si, __gcc_v8si, int, unsigned char); +unsigned __builtin_ia32_cmpb256_mask(__gcc_v32qi, __gcc_v32qi, int, unsigned); +unsigned short __builtin_ia32_cmpw256_mask(__gcc_v16hi, __gcc_v16hi, int, unsigned short); +unsigned __builtin_ia32_ucmpb256_mask(__gcc_v32qi, __gcc_v32qi, int, unsigned); +unsigned short __builtin_ia32_ucmpw256_mask(__gcc_v16hi, __gcc_v16hi, int, unsigned short); +char __builtin_ia32_cmppd256_mask(__gcc_v4df, __gcc_v4df, int, unsigned char); +char __builtin_ia32_cmpps256_mask(__gcc_v8sf, __gcc_v8sf, int, unsigned char); +unsigned char __builtin_ia32_cmpq128_mask(__gcc_v2di, __gcc_v2di, int, unsigned char); +unsigned char __builtin_ia32_cmpd128_mask(__gcc_v4si, __gcc_v4si, int, unsigned char); +unsigned char __builtin_ia32_ucmpq128_mask(__gcc_v2di, __gcc_v2di, int, unsigned char); +unsigned char __builtin_ia32_ucmpd128_mask(__gcc_v4si, __gcc_v4si, int, unsigned char); +unsigned short __builtin_ia32_cmpb128_mask(__gcc_v16qi, __gcc_v16qi, int, unsigned short); +unsigned char __builtin_ia32_cmpw128_mask(__gcc_v8hi, __gcc_v8hi, int, unsigned char); +unsigned short __builtin_ia32_ucmpb128_mask(__gcc_v16qi, __gcc_v16qi, int, unsigned short); +unsigned char __builtin_ia32_ucmpw128_mask(__gcc_v8hi, __gcc_v8hi, int, unsigned char); +unsigned char __builtin_ia32_cmppd128_mask(__gcc_v2df, __gcc_v2df, int, unsigned char); +unsigned char __builtin_ia32_cmpps128_mask(__gcc_v4sf, __gcc_v4sf, int, unsigned char); +__gcc_v16sf __builtin_ia32_broadcastf32x2_512_mask(__gcc_v4sf, __gcc_v16sf, unsigned short); +__gcc_v16si __builtin_ia32_broadcasti32x2_512_mask(__gcc_v4si, __gcc_v16si, unsigned short); +__gcc_v8df __builtin_ia32_broadcastf64x2_512_mask(__gcc_v2df, __gcc_v8df, unsigned char); +__gcc_v8di __builtin_ia32_broadcasti64x2_512_mask(__gcc_v2di, __gcc_v8di, unsigned char); +__gcc_v16sf __builtin_ia32_broadcastf32x8_512_mask(__gcc_v8sf, __gcc_v16sf, unsigned short); +__gcc_v16si __builtin_ia32_broadcasti32x8_512_mask(__gcc_v8si, __gcc_v16si, unsigned short); +__gcc_v2df __builtin_ia32_extractf64x2_512_mask(__gcc_v8df, int, __gcc_v2df, unsigned char); +__gcc_v8sf __builtin_ia32_extractf32x8_mask(__gcc_v16sf, int, __gcc_v8sf, unsigned char); +__gcc_v2di __builtin_ia32_extracti64x2_512_mask(__gcc_v8di, int, __gcc_v2di, unsigned char); +__gcc_v8si __builtin_ia32_extracti32x8_mask(__gcc_v16si, int, __gcc_v8si, unsigned char); +__gcc_v8df __builtin_ia32_reducepd512_mask(__gcc_v8df, int, __gcc_v8df, unsigned char); +__gcc_v16sf __builtin_ia32_reduceps512_mask(__gcc_v16sf, int, __gcc_v16sf, unsigned short); +__gcc_v8di __builtin_ia32_pmullq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v8df __builtin_ia32_xorpd512_mask(__gcc_v8df, __gcc_v8df, __gcc_v8df, unsigned char); +__gcc_v16sf __builtin_ia32_xorps512_mask(__gcc_v16sf, __gcc_v16sf, __gcc_v16sf, unsigned short); +__gcc_v8df __builtin_ia32_orpd512_mask(__gcc_v8df, __gcc_v8df, __gcc_v8df, unsigned char); +__gcc_v16sf __builtin_ia32_orps512_mask(__gcc_v16sf, __gcc_v16sf, __gcc_v16sf, unsigned short); +__gcc_v8df __builtin_ia32_andpd512_mask(__gcc_v8df, __gcc_v8df, __gcc_v8df, unsigned char); +__gcc_v16sf __builtin_ia32_andps512_mask(__gcc_v16sf, __gcc_v16sf, __gcc_v16sf, unsigned short); +__gcc_v8df __builtin_ia32_andnpd512_mask(__gcc_v8df, __gcc_v8df, __gcc_v8df, unsigned char); +__gcc_v16sf __builtin_ia32_andnps512_mask(__gcc_v16sf, __gcc_v16sf, __gcc_v16sf, unsigned short); +__gcc_v16sf __builtin_ia32_insertf32x8_mask(__gcc_v16sf, __gcc_v8sf, int, __gcc_v16sf, unsigned short); +__gcc_v16si __builtin_ia32_inserti32x8_mask(__gcc_v16si, __gcc_v8si, int, __gcc_v16si, unsigned short); +__gcc_v8df __builtin_ia32_insertf64x2_512_mask(__gcc_v8df, __gcc_v2df, int, __gcc_v8df, unsigned char); +__gcc_v8di __builtin_ia32_inserti64x2_512_mask(__gcc_v8di, __gcc_v2di, int, __gcc_v8di, unsigned char); +char __builtin_ia32_fpclasspd512_mask(__gcc_v8df, int, unsigned char); +short __builtin_ia32_fpclassps512_mask(__gcc_v16sf, int, unsigned short); +unsigned short __builtin_ia32_cvtd2mask512(__gcc_v16si); +unsigned char __builtin_ia32_cvtq2mask512(__gcc_v8di); +__gcc_v16si __builtin_ia32_cvtmask2d512(unsigned short); +__gcc_v8di __builtin_ia32_cvtmask2q512(unsigned char); +unsigned __builtin_ia32_kunpcksi(unsigned, unsigned); +unsigned long long __builtin_ia32_kunpckdi(unsigned long long, unsigned long long); +__gcc_v32hi __builtin_ia32_packusdw512_mask(__gcc_v16si, __gcc_v16si, __gcc_v32hi, unsigned); +__gcc_v32hi __builtin_ia32_packssdw512_mask(__gcc_v16si, __gcc_v16si, __gcc_v32hi, unsigned); +__gcc_v32hi __builtin_ia32_movdquhi512_mask(__gcc_v32hi, __gcc_v32hi, unsigned); +__gcc_v64qi __builtin_ia32_movdquqi512_mask(__gcc_v64qi, __gcc_v64qi, unsigned long long); +__gcc_v8di __builtin_ia32_psadbw512(__gcc_v64qi, __gcc_v64qi); +__gcc_v32hi __builtin_ia32_dbpsadbw512_mask(__gcc_v64qi, __gcc_v64qi, int, __gcc_v32hi, unsigned); +__gcc_v64qi __builtin_ia32_pbroadcastb512_mask(__gcc_v16qi, __gcc_v64qi, unsigned long long); +__gcc_v64qi __builtin_ia32_pbroadcastb512_gpr_mask(char, __gcc_v64qi, unsigned long long); +__gcc_v32hi __builtin_ia32_pbroadcastw512_mask(__gcc_v8hi, __gcc_v32hi, unsigned); +__gcc_v32hi __builtin_ia32_pbroadcastw512_gpr_mask(short, __gcc_v32hi, unsigned); +__gcc_v32hi __builtin_ia32_pmovsxbw512_mask(__gcc_v32qi, __gcc_v32hi, unsigned); +__gcc_v32hi __builtin_ia32_pmovzxbw512_mask(__gcc_v32qi, __gcc_v32hi, unsigned); +__gcc_v32hi __builtin_ia32_permvarhi512_mask(__gcc_v32hi, __gcc_v32hi, __gcc_v32hi, unsigned); +__gcc_v32hi __builtin_ia32_vpermt2varhi512_mask(__gcc_v32hi, __gcc_v32hi, __gcc_v32hi, unsigned); +__gcc_v32hi __builtin_ia32_vpermt2varhi512_maskz(__gcc_v32hi, __gcc_v32hi, __gcc_v32hi, unsigned); +__gcc_v32hi __builtin_ia32_vpermi2varhi512_mask(__gcc_v32hi, __gcc_v32hi, __gcc_v32hi, unsigned); +__gcc_v64qi __builtin_ia32_pavgb512_mask(__gcc_v64qi, __gcc_v64qi, __gcc_v64qi, unsigned long long); +__gcc_v32hi __builtin_ia32_pavgw512_mask(__gcc_v32hi, __gcc_v32hi, __gcc_v32hi, unsigned); +__gcc_v64qi __builtin_ia32_paddb512_mask(__gcc_v64qi, __gcc_v64qi, __gcc_v64qi, unsigned long long); +__gcc_v64qi __builtin_ia32_psubb512_mask(__gcc_v64qi, __gcc_v64qi, __gcc_v64qi, unsigned long long); +__gcc_v64qi __builtin_ia32_psubsb512_mask(__gcc_v64qi, __gcc_v64qi, __gcc_v64qi, unsigned long long); +__gcc_v64qi __builtin_ia32_paddsb512_mask(__gcc_v64qi, __gcc_v64qi, __gcc_v64qi, unsigned long long); +__gcc_v64qi __builtin_ia32_psubusb512_mask(__gcc_v64qi, __gcc_v64qi, __gcc_v64qi, unsigned long long); +__gcc_v64qi __builtin_ia32_paddusb512_mask(__gcc_v64qi, __gcc_v64qi, __gcc_v64qi, unsigned long long); +__gcc_v32hi __builtin_ia32_psubw512_mask(__gcc_v32hi, __gcc_v32hi, __gcc_v32hi, unsigned); +__gcc_v32hi __builtin_ia32_paddw512_mask(__gcc_v32hi, __gcc_v32hi, __gcc_v32hi, unsigned); +__gcc_v32hi __builtin_ia32_psubsw512_mask(__gcc_v32hi, __gcc_v32hi, __gcc_v32hi, unsigned); +__gcc_v32hi __builtin_ia32_paddsw512_mask(__gcc_v32hi, __gcc_v32hi, __gcc_v32hi, unsigned); +__gcc_v32hi __builtin_ia32_psubusw512_mask(__gcc_v32hi, __gcc_v32hi, __gcc_v32hi, unsigned); +__gcc_v32hi __builtin_ia32_paddusw512_mask(__gcc_v32hi, __gcc_v32hi, __gcc_v32hi, unsigned); +__gcc_v32hi __builtin_ia32_pmaxuw512_mask(__gcc_v32hi, __gcc_v32hi, __gcc_v32hi, unsigned); +__gcc_v32hi __builtin_ia32_pmaxsw512_mask(__gcc_v32hi, __gcc_v32hi, __gcc_v32hi, unsigned); +__gcc_v32hi __builtin_ia32_pminuw512_mask(__gcc_v32hi, __gcc_v32hi, __gcc_v32hi, unsigned); +__gcc_v32hi __builtin_ia32_pminsw512_mask(__gcc_v32hi, __gcc_v32hi, __gcc_v32hi, unsigned); +__gcc_v64qi __builtin_ia32_pmaxub512_mask(__gcc_v64qi, __gcc_v64qi, __gcc_v64qi, unsigned long long); +__gcc_v64qi __builtin_ia32_pmaxsb512_mask(__gcc_v64qi, __gcc_v64qi, __gcc_v64qi, unsigned long long); +__gcc_v64qi __builtin_ia32_pminub512_mask(__gcc_v64qi, __gcc_v64qi, __gcc_v64qi, unsigned long long); +__gcc_v64qi __builtin_ia32_pminsb512_mask(__gcc_v64qi, __gcc_v64qi, __gcc_v64qi, unsigned long long); +__gcc_v32qi __builtin_ia32_pmovwb512_mask(__gcc_v32hi, __gcc_v32qi, unsigned); +__gcc_v32qi __builtin_ia32_pmovswb512_mask(__gcc_v32hi, __gcc_v32qi, unsigned); +__gcc_v32qi __builtin_ia32_pmovuswb512_mask(__gcc_v32hi, __gcc_v32qi, unsigned); +__gcc_v32hi __builtin_ia32_pmulhrsw512_mask(__gcc_v32hi, __gcc_v32hi, __gcc_v32hi, unsigned); +__gcc_v32hi __builtin_ia32_pmulhuw512_mask(__gcc_v32hi, __gcc_v32hi, __gcc_v32hi, unsigned); +__gcc_v32hi __builtin_ia32_pmulhw512_mask(__gcc_v32hi, __gcc_v32hi, __gcc_v32hi, unsigned); +__gcc_v32hi __builtin_ia32_pmullw512_mask(__gcc_v32hi, __gcc_v32hi, __gcc_v32hi, unsigned); +__gcc_v64qi __builtin_ia32_packsswb512_mask(__gcc_v32hi, __gcc_v32hi, __gcc_v64qi, unsigned long long); +__gcc_v64qi __builtin_ia32_packuswb512_mask(__gcc_v32hi, __gcc_v32hi, __gcc_v64qi, unsigned long long); +__gcc_v32hi __builtin_ia32_psrav32hi_mask(__gcc_v32hi, __gcc_v32hi, __gcc_v32hi, unsigned); +__gcc_v32hi __builtin_ia32_pmaddubsw512_mask(__gcc_v64qi, __gcc_v64qi, __gcc_v32hi, unsigned); +__gcc_v16si __builtin_ia32_pmaddwd512_mask(__gcc_v32hi, __gcc_v32hi, __gcc_v16si, unsigned short); +__gcc_v32hi __builtin_ia32_psrlv32hi_mask(__gcc_v32hi, __gcc_v32hi, __gcc_v32hi, unsigned); +__gcc_v64qi __builtin_ia32_punpckhbw512_mask(__gcc_v64qi, __gcc_v64qi, __gcc_v64qi, unsigned long long); +__gcc_v32hi __builtin_ia32_punpckhwd512_mask(__gcc_v32hi, __gcc_v32hi, __gcc_v32hi, unsigned); +__gcc_v64qi __builtin_ia32_punpcklbw512_mask(__gcc_v64qi, __gcc_v64qi, __gcc_v64qi, unsigned long long); +__gcc_v32hi __builtin_ia32_punpcklwd512_mask(__gcc_v32hi, __gcc_v32hi, __gcc_v32hi, unsigned); +__gcc_v64qi __builtin_ia32_pshufb512_mask(__gcc_v64qi, __gcc_v64qi, __gcc_v64qi, unsigned long long); +__gcc_v32hi __builtin_ia32_pshufhw512_mask(__gcc_v32hi, int, __gcc_v32hi, unsigned); +__gcc_v32hi __builtin_ia32_pshuflw512_mask(__gcc_v32hi, int, __gcc_v32hi, unsigned); +unsigned long long __builtin_ia32_cvtb2mask512(__gcc_v64qi); +unsigned __builtin_ia32_cvtw2mask512(__gcc_v32hi); +__gcc_v64qi __builtin_ia32_cvtmask2b512(unsigned long long); +__gcc_v32hi __builtin_ia32_cvtmask2w512(unsigned); +unsigned long long __builtin_ia32_pcmpeqb512_mask(__gcc_v64qi, __gcc_v64qi, unsigned long long); +unsigned __builtin_ia32_pcmpeqw512_mask(__gcc_v32hi, __gcc_v32hi, unsigned); +unsigned long long __builtin_ia32_pcmpgtb512_mask(__gcc_v64qi, __gcc_v64qi, unsigned long long); +unsigned __builtin_ia32_pcmpgtw512_mask(__gcc_v32hi, __gcc_v32hi, unsigned); +unsigned long long __builtin_ia32_ptestmb512(__gcc_v64qi, __gcc_v64qi, unsigned long long); +unsigned __builtin_ia32_ptestmw512(__gcc_v32hi, __gcc_v32hi, unsigned); +unsigned long long __builtin_ia32_ptestnmb512(__gcc_v64qi, __gcc_v64qi, unsigned long long); +unsigned __builtin_ia32_ptestnmw512(__gcc_v32hi, __gcc_v32hi, unsigned); +__gcc_v32hi __builtin_ia32_psllv32hi_mask(__gcc_v32hi, __gcc_v32hi, __gcc_v32hi, unsigned); +__gcc_v64qi __builtin_ia32_pabsb512_mask(__gcc_v64qi, __gcc_v64qi, unsigned long long); +__gcc_v32hi __builtin_ia32_pabsw512_mask(__gcc_v32hi, __gcc_v32hi, unsigned); +__gcc_v32hi __builtin_ia32_blendmw_512_mask(__gcc_v32hi, __gcc_v32hi, unsigned); +__gcc_v64qi __builtin_ia32_blendmb_512_mask(__gcc_v64qi, __gcc_v64qi, unsigned long long); +unsigned long long __builtin_ia32_cmpb512_mask(__gcc_v64qi, __gcc_v64qi, int, unsigned long long); +unsigned __builtin_ia32_cmpw512_mask(__gcc_v32hi, __gcc_v32hi, int, unsigned); +unsigned long long __builtin_ia32_ucmpb512_mask(__gcc_v64qi, __gcc_v64qi, int, unsigned long long); +unsigned __builtin_ia32_ucmpw512_mask(__gcc_v32hi, __gcc_v32hi, int, unsigned); +__gcc_v8di __builtin_ia32_vpmadd52luq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v8di __builtin_ia32_vpmadd52luq512_maskz(__gcc_v8di, __gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v8di __builtin_ia32_vpmadd52huq512_mask(__gcc_v8di, __gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v8di __builtin_ia32_vpmadd52huq512_maskz(__gcc_v8di, __gcc_v8di, __gcc_v8di, unsigned char); +__gcc_v4di __builtin_ia32_vpmadd52luq256_mask(__gcc_v4di, __gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v4di __builtin_ia32_vpmadd52luq256_maskz(__gcc_v4di, __gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v4di __builtin_ia32_vpmadd52huq256_mask(__gcc_v4di, __gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v4di __builtin_ia32_vpmadd52huq256_maskz(__gcc_v4di, __gcc_v4di, __gcc_v4di, unsigned char); +__gcc_v2di __builtin_ia32_vpmadd52luq128_mask(__gcc_v2di, __gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v2di __builtin_ia32_vpmadd52luq128_maskz(__gcc_v2di, __gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v2di __builtin_ia32_vpmadd52huq128_mask(__gcc_v2di, __gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v2di __builtin_ia32_vpmadd52huq128_maskz(__gcc_v2di, __gcc_v2di, __gcc_v2di, unsigned char); +__gcc_v64qi __builtin_ia32_vpmultishiftqb512_mask(__gcc_v64qi, __gcc_v64qi, __gcc_v64qi, unsigned long long); +__gcc_v32qi __builtin_ia32_vpmultishiftqb256_mask(__gcc_v32qi, __gcc_v32qi, __gcc_v32qi, unsigned); +__gcc_v16qi __builtin_ia32_vpmultishiftqb128_mask(__gcc_v16qi, __gcc_v16qi, __gcc_v16qi, unsigned short); +__gcc_v64qi __builtin_ia32_permvarqi512_mask(__gcc_v64qi, __gcc_v64qi, __gcc_v64qi, unsigned long long); +__gcc_v64qi __builtin_ia32_vpermt2varqi512_mask(__gcc_v64qi, __gcc_v64qi, __gcc_v64qi, unsigned long long); +__gcc_v64qi __builtin_ia32_vpermt2varqi512_maskz(__gcc_v64qi, __gcc_v64qi, __gcc_v64qi, unsigned long long); +__gcc_v64qi __builtin_ia32_vpermi2varqi512_mask(__gcc_v64qi, __gcc_v64qi, __gcc_v64qi, unsigned long long); +__gcc_v32qi __builtin_ia32_permvarqi256_mask(__gcc_v32qi, __gcc_v32qi, __gcc_v32qi, unsigned); +__gcc_v16qi __builtin_ia32_permvarqi128_mask(__gcc_v16qi, __gcc_v16qi, __gcc_v16qi, unsigned short); +__gcc_v32qi __builtin_ia32_vpermt2varqi256_mask(__gcc_v32qi, __gcc_v32qi, __gcc_v32qi, unsigned); +__gcc_v32qi __builtin_ia32_vpermt2varqi256_maskz(__gcc_v32qi, __gcc_v32qi, __gcc_v32qi, unsigned); +__gcc_v16qi __builtin_ia32_vpermt2varqi128_mask(__gcc_v16qi, __gcc_v16qi, __gcc_v16qi, unsigned short); +__gcc_v16qi __builtin_ia32_vpermt2varqi128_maskz(__gcc_v16qi, __gcc_v16qi, __gcc_v16qi, unsigned short); +__gcc_v32qi __builtin_ia32_vpermi2varqi256_mask(__gcc_v32qi, __gcc_v32qi, __gcc_v32qi, unsigned); +__gcc_v16qi __builtin_ia32_vpermi2varqi128_mask(__gcc_v16qi, __gcc_v16qi, __gcc_v16qi, unsigned short); +__gcc_v2df __builtin_ia32_rangesd128_round(__gcc_v2df, __gcc_v2df, int, int); +__gcc_v4sf __builtin_ia32_rangess128_round(__gcc_v4sf, __gcc_v4sf, int, int); +__gcc_v8di __builtin_ia32_cvtpd2qq512_mask(__gcc_v8df, __gcc_v8di, char, int); +__gcc_v8di __builtin_ia32_cvtps2qq512_mask(__gcc_v8sf, __gcc_v8di, char, int); +__gcc_v8di __builtin_ia32_cvtpd2uqq512_mask(__gcc_v8df, __gcc_v8di, char, int); +__gcc_v8di __builtin_ia32_cvtps2uqq512_mask(__gcc_v8sf, __gcc_v8di, char, int); +__gcc_v8sf __builtin_ia32_cvtqq2ps512_mask(__gcc_v8di, __gcc_v8sf, char, int); +__gcc_v8sf __builtin_ia32_cvtuqq2ps512_mask(__gcc_v8di, __gcc_v8sf, char, int); +__gcc_v8df __builtin_ia32_cvtqq2pd512_mask(__gcc_v8di, __gcc_v8df, char, int); +__gcc_v8df __builtin_ia32_cvtuqq2pd512_mask(__gcc_v8di, __gcc_v8df, char, int); +__gcc_v8di __builtin_ia32_cvttps2qq512_mask(__gcc_v8sf, __gcc_v8di, char, int); +__gcc_v8di __builtin_ia32_cvttps2uqq512_mask(__gcc_v8sf, __gcc_v8di, char, int); +__gcc_v8di __builtin_ia32_cvttpd2qq512_mask(__gcc_v8df, __gcc_v8di, char, int); +__gcc_v8di __builtin_ia32_cvttpd2uqq512_mask(__gcc_v8df, __gcc_v8di, char, int); +__gcc_v16sf __builtin_ia32_rangeps512_mask(__gcc_v16sf, __gcc_v16sf, int, __gcc_v16sf, short, int); +__gcc_v8df __builtin_ia32_rangepd512_mask(__gcc_v8df, __gcc_v8df, int, __gcc_v8df, char, int); +__gcc_v16sf __builtin_ia32_4fmaddps_mask(__gcc_v16sf, __gcc_v16sf, __gcc_v16sf, __gcc_v16sf, __gcc_v16sf, const __gcc_v4sf*, __gcc_v16sf, unsigned short); +__gcc_v16sf __builtin_ia32_4fmaddps(__gcc_v16sf, __gcc_v16sf, __gcc_v16sf, __gcc_v16sf, __gcc_v16sf, const __gcc_v4sf*); +__gcc_v4sf __builtin_ia32_4fmaddss(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf, __gcc_v4sf, __gcc_v4sf, const __gcc_v4sf*); +__gcc_v4sf __builtin_ia32_4fmaddss_mask(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf, __gcc_v4sf, __gcc_v4sf, const __gcc_v4sf*, __gcc_v4sf, unsigned char); +__gcc_v16sf __builtin_ia32_4fnmaddps_mask(__gcc_v16sf, __gcc_v16sf, __gcc_v16sf, __gcc_v16sf, __gcc_v16sf, const __gcc_v4sf*, __gcc_v16sf, unsigned short); +__gcc_v16sf __builtin_ia32_4fnmaddps(__gcc_v16sf, __gcc_v16sf, __gcc_v16sf, __gcc_v16sf, __gcc_v16sf, const __gcc_v4sf*); +__gcc_v4sf __builtin_ia32_4fnmaddss(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf, __gcc_v4sf, __gcc_v4sf, const __gcc_v4sf*); +__gcc_v4sf __builtin_ia32_4fnmaddss_mask(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf, __gcc_v4sf, __gcc_v4sf, const __gcc_v4sf*, __gcc_v4sf, unsigned char); +__gcc_v16si __builtin_ia32_vp4dpwssd(__gcc_v16si, __gcc_v16si, __gcc_v16si, __gcc_v16si, __gcc_v16si, const __gcc_v4si*); +__gcc_v16si __builtin_ia32_vp4dpwssd_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, __gcc_v16si, __gcc_v16si, const __gcc_v4si*, __gcc_v16si, unsigned short); +__gcc_v16si __builtin_ia32_vp4dpwssds(__gcc_v16si, __gcc_v16si, __gcc_v16si, __gcc_v16si, __gcc_v16si, const __gcc_v4si*); +__gcc_v16si __builtin_ia32_vp4dpwssds_mask(__gcc_v16si, __gcc_v16si, __gcc_v16si, __gcc_v16si, __gcc_v16si, const __gcc_v4si*, __gcc_v16si, unsigned short); +__gcc_v16si __builtin_ia32_vpopcountd_v16si(__gcc_v16si); +__gcc_v16si __builtin_ia32_vpopcountd_v16si_mask(__gcc_v16si, __gcc_v16si, unsigned short); +__gcc_v8di __builtin_ia32_vpopcountq_v8di(__gcc_v8di); +__gcc_v8di __builtin_ia32_vpopcountq_v8di_mask(__gcc_v8di, __gcc_v8di, unsigned char); +unsigned __builtin_ia32_rdpid(); +unsigned long __builtin_ia32_sizeof(void); diff --git a/src/ansi-c/gcc_builtin_headers_ia32.h b/src/ansi-c/gcc_builtin_headers_ia32.h index 90ffac22ba1..9be09f54701 100644 --- a/src/ansi-c/gcc_builtin_headers_ia32.h +++ b/src/ansi-c/gcc_builtin_headers_ia32.h @@ -3,7 +3,7 @@ __float128 __builtin_fabsq(__float128); __float128 __builtin_copysignq(__float128, __float128); -void __builtin_ia32_pause(void); +void __builtin_ia32_pause(); __float128 __builtin_infq(void); __float128 __builtin_huge_valq(void); __gcc_v8qi __builtin_ia32_paddb(__gcc_v8qi, __gcc_v8qi); @@ -74,18 +74,18 @@ __gcc_v4hi __builtin_ia32_pminsw(__gcc_v4hi, __gcc_v4hi); int __builtin_ia32_pextrw(__gcc_v4hi, int); __gcc_v4hi __builtin_ia32_pinsrw(__gcc_v4hi, int, int); int __builtin_ia32_pmovmskb(__gcc_v8qi); -void __builtin_ia32_maskmovq(__gcc_v8qi, __gcc_v8qi, char *); +void __builtin_ia32_maskmovq(__gcc_v8qi, __gcc_v8qi, char*); // clang uses the following: -// void __builtin_ia32_movntq(__gcc_v1di *, __gcc_v1di); -// -// GCC uses this: -// void __builtin_ia32_movntq(__gcc_di *, __gcc_di); -// -// So, we use: -void __builtin_ia32_movntq(void *, ...); +// void __builtin_ia32_movntq(__gcc_v1di*, __gcc_v1di); + // + // GCC uses this: +// void __builtin_ia32_movntq(__gcc_di*, __gcc_di); + // + // So, we use: +void __builtin_ia32_movntq(void*, ...); -void __builtin_ia32_sfence(void); +void __builtin_ia32_sfence(); int __builtin_ia32_comieq(__gcc_v4sf, __gcc_v4sf); int __builtin_ia32_comineq(__gcc_v4sf, __gcc_v4sf); int __builtin_ia32_comilt(__gcc_v4sf, __gcc_v4sf); @@ -152,35 +152,35 @@ __gcc_v4sf __builtin_ia32_rcpss(__gcc_v4sf); __gcc_v4sf __builtin_ia32_rsqrtss(__gcc_v4sf); __gcc_v4sf __builtin_ia32_sqrtss(__gcc_v4sf); __gcc_v4sf __builtin_ia32_shufps(__gcc_v4sf, __gcc_v4sf, int); -void __builtin_ia32_movntps(float *, __gcc_v4sf); +void __builtin_ia32_movntps(float*, __gcc_v4sf); int __builtin_ia32_movmskps(__gcc_v4sf); -__gcc_v4sf __builtin_ia32_loadaps(float *); -void __builtin_ia32_storeaps(float *, __gcc_v4sf); -__gcc_v4sf __builtin_ia32_loadups(float *); -void __builtin_ia32_storeups(float *, __gcc_v4sf); -__gcc_v4sf __builtin_ia32_loadsss(float *); -void __builtin_ia32_storess(float *, __gcc_v4sf); +__gcc_v4sf __builtin_ia32_loadaps(float*); +void __builtin_ia32_storeaps(float*, __gcc_v4sf); +__gcc_v4sf __builtin_ia32_loadups(const float*); +void __builtin_ia32_storeups(float*, __gcc_v4sf); +__gcc_v4sf __builtin_ia32_loadsss(float*); +void __builtin_ia32_storess(float*, __gcc_v4sf); // clang uses these: -// __gcc_v4sf __builtin_ia32_loadhps(__gcc_v4sf, const __gcc_v2si *); -// __gcc_v4sf __builtin_ia32_loadlps(__gcc_v4sf, const __gcc_v2si *); -// void __builtin_ia32_storehps(__gcc_v2si *, __gcc_v4sf); -// void __builtin_ia32_storelps(__gcc_v2si *, __gcc_v4sf); +// __gcc_v4sf __builtin_ia32_loadhps(__gcc_v4sf, const __gcc_v2si*); +// __gcc_v4sf __builtin_ia32_loadlps(__gcc_v4sf, const __gcc_v2si*); +// void __builtin_ia32_storehps(__gcc_v2si*, __gcc_v4sf); +// void __builtin_ia32_storelps(__gcc_v2si*, __gcc_v4sf); // // but GCC uses: -// __gcc_v4sf __builtin_ia32_loadhps(__gcc_v4sf, const __gcc_v2sf *); -// __gcc_v4sf __builtin_ia32_loadlps(__gcc_v4sf, const __gcc_v2sf *); -// void __builtin_ia32_storehps(__gcc_v2sf *, __gcc_v4sf); -// void __builtin_ia32_storelps(__gcc_v2sf *, __gcc_v4sf); +// __gcc_v4sf __builtin_ia32_loadhps(__gcc_v4sf, const __gcc_v2sf*); +// __gcc_v4sf __builtin_ia32_loadlps(__gcc_v4sf, const __gcc_v2sf*); +// void __builtin_ia32_storehps(__gcc_v2sf*, __gcc_v4sf); +// void __builtin_ia32_storelps(__gcc_v2sf*, __gcc_v4sf); // // So we use: -__gcc_v4sf __builtin_ia32_loadhps(__gcc_v4sf, const void *); -__gcc_v4sf __builtin_ia32_loadlps(__gcc_v4sf, const void *); -void __builtin_ia32_storehps(void *, __gcc_v4sf); -void __builtin_ia32_storelps(void *, __gcc_v4sf); +__gcc_v4sf __builtin_ia32_loadhps(__gcc_v4sf, const void*); +__gcc_v4sf __builtin_ia32_loadlps(__gcc_v4sf, const void*); +void __builtin_ia32_storehps(void*, __gcc_v4sf); +void __builtin_ia32_storelps(void*, __gcc_v4sf); -__gcc_v4si __builtin_ia32_loadlv4si(const __gcc_v2si *); -void __builtin_ia32_storelv4si(__gcc_v2si *, __gcc_v4si); +__gcc_v4si __builtin_ia32_loadlv4si(const __gcc_v2si*); +void __builtin_ia32_storelv4si(__gcc_v2si*, __gcc_v4si); __gcc_v4si __builtin_ia32_movqv4si(__gcc_v4si); int __builtin_ia32_comisdeq(__gcc_v2df, __gcc_v2df); @@ -274,17 +274,17 @@ __gcc_v16qi __builtin_ia32_packsswb128(__gcc_v8hi, __gcc_v8hi); __gcc_v8hi __builtin_ia32_packssdw128(__gcc_v4si, __gcc_v4si); __gcc_v16qi __builtin_ia32_packuswb128(__gcc_v8hi, __gcc_v8hi); __gcc_v8hi __builtin_ia32_pmulhuw128(__gcc_v8hi, __gcc_v8hi); -void __builtin_ia32_maskmovdqu(__gcc_v16qi, __gcc_v16qi, char *); -__gcc_v2df __builtin_ia32_loadupd(double *); -void __builtin_ia32_storeupd(double *, __gcc_v2df); -__gcc_v2df __builtin_ia32_loadhpd(__gcc_v2df, double const *); -__gcc_v2df __builtin_ia32_loadlpd(__gcc_v2df, double const *); +void __builtin_ia32_maskmovdqu(__gcc_v16qi, __gcc_v16qi, char*); +__gcc_v2df __builtin_ia32_loadupd(const double*); +void __builtin_ia32_storeupd(double*, __gcc_v2df); +__gcc_v2df __builtin_ia32_loadhpd(__gcc_v2df, const double*); +__gcc_v2df __builtin_ia32_loadlpd(__gcc_v2df, const double*); int __builtin_ia32_movmskpd(__gcc_v2df); int __builtin_ia32_pmovmskb128(__gcc_v16qi); -void __builtin_ia32_movnti(int *, int); -void __builtin_ia32_movnti64(__gcc_di *, __gcc_di); -void __builtin_ia32_movntpd(double *, __gcc_v2df); -void __builtin_ia32_movntdq(__gcc_v2di *, __gcc_v2di); +void __builtin_ia32_movnti(int*, int); +void __builtin_ia32_movnti64(long long*, long long); +void __builtin_ia32_movntpd(double*, __gcc_v2df); +void __builtin_ia32_movntdq(__gcc_v2di*, __gcc_v2di); __gcc_v4si __builtin_ia32_pshufd(__gcc_v4si, int); __gcc_v8hi __builtin_ia32_pshuflw(__gcc_v8hi, int); __gcc_v8hi __builtin_ia32_pshufhw(__gcc_v8hi, int); @@ -302,20 +302,20 @@ __gcc_v2si __builtin_ia32_cvttpd2pi(__gcc_v2df); __gcc_v2df __builtin_ia32_cvtpi2pd(__gcc_v2si); int __builtin_ia32_cvtsd2si(__gcc_v2df); int __builtin_ia32_cvttsd2si(__gcc_v2df); -__gcc_di __builtin_ia32_cvtsd2si64(__gcc_v2df); -__gcc_di __builtin_ia32_cvttsd2si64(__gcc_v2df); +long long __builtin_ia32_cvtsd2si64(__gcc_v2df); +long long __builtin_ia32_cvttsd2si64(__gcc_v2df); __gcc_v4si __builtin_ia32_cvtps2dq(__gcc_v4sf); __gcc_v2df __builtin_ia32_cvtps2pd(__gcc_v4sf); __gcc_v4si __builtin_ia32_cvttps2dq(__gcc_v4sf); __gcc_v2df __builtin_ia32_cvtsi2sd(__gcc_v2df, int); -__gcc_v2df __builtin_ia32_cvtsi642sd(__gcc_v2df, __gcc_di); +__gcc_v2df __builtin_ia32_cvtsi642sd(__gcc_v2df, long long); __gcc_v4sf __builtin_ia32_cvtsd2ss(__gcc_v4sf, __gcc_v2df); __gcc_v2df __builtin_ia32_cvtss2sd(__gcc_v2df, __gcc_v4sf); -void __builtin_ia32_clflush(const void *); -void __builtin_ia32_lfence(void); +void __builtin_ia32_clflush(const void*); +void __builtin_ia32_lfence(); void __builtin_ia32_mfence(void); -__gcc_v16qi __builtin_ia32_loaddqu(const char *); -void __builtin_ia32_storedqu(char *, __gcc_v16qi); +__gcc_v16qi __builtin_ia32_loaddqu(const char*); +void __builtin_ia32_storedqu(char*, __gcc_v16qi); __gcc_v1di __builtin_ia32_pmuludq(__gcc_v2si, __gcc_v2si); __gcc_v2di __builtin_ia32_pmuludq128(__gcc_v4si, __gcc_v4si); __gcc_v8hi __builtin_ia32_psllw128(__gcc_v8hi, __gcc_v8hi); @@ -344,13 +344,13 @@ __gcc_v2df __builtin_ia32_haddpd(__gcc_v2df, __gcc_v2df); __gcc_v4sf __builtin_ia32_haddps(__gcc_v4sf, __gcc_v4sf); __gcc_v2df __builtin_ia32_hsubpd(__gcc_v2df, __gcc_v2df); __gcc_v4sf __builtin_ia32_hsubps(__gcc_v4sf, __gcc_v4sf); -__gcc_v16qi __builtin_ia32_lddqu(char const *); -void __builtin_ia32_monitor(void *, unsigned int, unsigned int); +__gcc_v16qi __builtin_ia32_lddqu(const char*); +void __builtin_ia32_monitor(void*, unsigned int, unsigned int); __gcc_v2df __builtin_ia32_movddup(__gcc_v2df); __gcc_v4sf __builtin_ia32_movshdup(__gcc_v4sf); __gcc_v4sf __builtin_ia32_movsldup(__gcc_v4sf); void __builtin_ia32_mwait(unsigned int, unsigned int); -__gcc_v2df __builtin_ia32_loadddup(double const *); +__gcc_v2df __builtin_ia32_loadddup(double const*); __gcc_v2si __builtin_ia32_phaddd(__gcc_v2si, __gcc_v2si); __gcc_v4hi __builtin_ia32_phaddw(__gcc_v4hi, __gcc_v4hi); __gcc_v4hi __builtin_ia32_phaddsw(__gcc_v4hi, __gcc_v4hi); @@ -383,18 +383,18 @@ __gcc_v2di __builtin_ia32_palignr128(__gcc_v2di, __gcc_v2di, int); __gcc_v16qi __builtin_ia32_pabsb128(__gcc_v16qi); __gcc_v4si __builtin_ia32_pabsd128(__gcc_v4si); __gcc_v8hi __builtin_ia32_pabsw128(__gcc_v8hi); -__gcc_v2df __builtin_ia32_blendpd(__gcc_v2df, __gcc_v2df, const int); -__gcc_v4sf __builtin_ia32_blendps(__gcc_v4sf, __gcc_v4sf, const int); +__gcc_v2df __builtin_ia32_blendpd(__gcc_v2df, __gcc_v2df, int); +__gcc_v4sf __builtin_ia32_blendps(__gcc_v4sf, __gcc_v4sf, int); __gcc_v2df __builtin_ia32_blendvpd(__gcc_v2df, __gcc_v2df, __gcc_v2df); __gcc_v4sf __builtin_ia32_blendvps(__gcc_v4sf, __gcc_v4sf, __gcc_v4sf); -__gcc_v2df __builtin_ia32_dppd(__gcc_v2df, __gcc_v2df, const int); -__gcc_v4sf __builtin_ia32_dpps(__gcc_v4sf, __gcc_v4sf, const int); -__gcc_v4sf __builtin_ia32_insertps128(__gcc_v4sf, __gcc_v4sf, const int); -__gcc_v2di __builtin_ia32_movntdqa(__gcc_v2di *); -__gcc_v16qi __builtin_ia32_mpsadbw128(__gcc_v16qi, __gcc_v16qi, const int); +__gcc_v2df __builtin_ia32_dppd(__gcc_v2df, __gcc_v2df, int); +__gcc_v4sf __builtin_ia32_dpps(__gcc_v4sf, __gcc_v4sf, int); +__gcc_v4sf __builtin_ia32_insertps128(__gcc_v4sf, __gcc_v4sf, int); +__gcc_v2di __builtin_ia32_movntdqa(__gcc_v2di*); +__gcc_v16qi __builtin_ia32_mpsadbw128(__gcc_v16qi, __gcc_v16qi, int); __gcc_v8hi __builtin_ia32_packusdw128(__gcc_v4si, __gcc_v4si); __gcc_v16qi __builtin_ia32_pblendvb128(__gcc_v16qi, __gcc_v16qi, __gcc_v16qi); -__gcc_v8hi __builtin_ia32_pblendw128(__gcc_v8hi, __gcc_v8hi, const int); +__gcc_v8hi __builtin_ia32_pblendw128(__gcc_v8hi, __gcc_v8hi, int); __gcc_v2di __builtin_ia32_pcmpeqq(__gcc_v2di, __gcc_v2di); __gcc_v8hi __builtin_ia32_phminposuw128(__gcc_v8hi); __gcc_v16qi __builtin_ia32_pmaxsb128(__gcc_v16qi, __gcc_v16qi); @@ -422,10 +422,10 @@ __gcc_v4si __builtin_ia32_pmulld128(__gcc_v4si, __gcc_v4si); int __builtin_ia32_ptestc128(__gcc_v2di, __gcc_v2di); int __builtin_ia32_ptestnzc128(__gcc_v2di, __gcc_v2di); int __builtin_ia32_ptestz128(__gcc_v2di, __gcc_v2di); -__gcc_v2df __builtin_ia32_roundpd(__gcc_v2df, const int); -__gcc_v4sf __builtin_ia32_roundps(__gcc_v4sf, const int); -__gcc_v2df __builtin_ia32_roundsd(__gcc_v2df, __gcc_v2df, const int); -__gcc_v4sf __builtin_ia32_roundss(__gcc_v4sf, __gcc_v4sf, const int); +__gcc_v2df __builtin_ia32_roundpd(__gcc_v2df, int); +__gcc_v4sf __builtin_ia32_roundps(__gcc_v4sf, int); +__gcc_v2df __builtin_ia32_roundsd(__gcc_v2df, __gcc_v2df, int); +__gcc_v4sf __builtin_ia32_roundss(__gcc_v4sf, __gcc_v4sf, int); int __builtin_ia32_vec_ext___gcc_v16qi(__gcc_v16qi, const int); float __builtin_ia32_vec_ext___gcc_v4sf(__gcc_v4sf, const int); int __builtin_ia32_vec_ext___gcc_v4si(__gcc_v4si, const int); @@ -445,31 +445,31 @@ int __builtin_ia32_pcmpistrio128(__gcc_v16qi, __gcc_v16qi, const int); int __builtin_ia32_pcmpistris128(__gcc_v16qi, __gcc_v16qi, const int); int __builtin_ia32_pcmpistriz128(__gcc_v16qi, __gcc_v16qi, const int); __gcc_v2di __builtin_ia32_pcmpgtq(__gcc_v2di, __gcc_v2di); -unsigned int __builtin_ia32_crc32qi(unsigned int, unsigned char); -unsigned int __builtin_ia32_crc32hi(unsigned int, unsigned short); -unsigned int __builtin_ia32_crc32si(unsigned int, unsigned int); +unsigned __builtin_ia32_crc32qi(unsigned, unsigned char); +unsigned __builtin_ia32_crc32hi(unsigned, unsigned short); +unsigned __builtin_ia32_crc32si(unsigned, unsigned); unsigned long long __builtin_ia32_crc32di(unsigned long long, unsigned long long); int __builtin_popcount(unsigned int); int __builtin_popcountl(unsigned long); int __builtin_popcountll(unsigned long long); -__gcc_v4df __builtin_ia32_addpd256(__gcc_v4df,__gcc_v4df); -__gcc_v8sf __builtin_ia32_addps256(__gcc_v8sf,__gcc_v8sf); -__gcc_v4df __builtin_ia32_addsubpd256(__gcc_v4df,__gcc_v4df); -__gcc_v8sf __builtin_ia32_addsubps256(__gcc_v8sf,__gcc_v8sf); -__gcc_v4df __builtin_ia32_andnpd256(__gcc_v4df,__gcc_v4df); -__gcc_v8sf __builtin_ia32_andnps256(__gcc_v8sf,__gcc_v8sf); -__gcc_v4df __builtin_ia32_andpd256(__gcc_v4df,__gcc_v4df); -__gcc_v8sf __builtin_ia32_andps256(__gcc_v8sf,__gcc_v8sf); -__gcc_v4df __builtin_ia32_blendpd256(__gcc_v4df,__gcc_v4df,int); -__gcc_v8sf __builtin_ia32_blendps256(__gcc_v8sf,__gcc_v8sf,int); -__gcc_v4df __builtin_ia32_blendvpd256(__gcc_v4df,__gcc_v4df,__gcc_v4df); -__gcc_v8sf __builtin_ia32_blendvps256(__gcc_v8sf,__gcc_v8sf,__gcc_v8sf); -__gcc_v2df __builtin_ia32_cmppd(__gcc_v2df,__gcc_v2df,int); -__gcc_v4df __builtin_ia32_cmppd256(__gcc_v4df,__gcc_v4df,int); -__gcc_v4sf __builtin_ia32_cmpps(__gcc_v4sf,__gcc_v4sf,int); -__gcc_v8sf __builtin_ia32_cmpps256(__gcc_v8sf,__gcc_v8sf,int); -__gcc_v2df __builtin_ia32_cmpsd(__gcc_v2df,__gcc_v2df,int); -__gcc_v4sf __builtin_ia32_cmpss(__gcc_v4sf,__gcc_v4sf,int); +__gcc_v4df __builtin_ia32_addpd256(__gcc_v4df, __gcc_v4df); +__gcc_v8sf __builtin_ia32_addps256(__gcc_v8sf, __gcc_v8sf); +__gcc_v4df __builtin_ia32_addsubpd256(__gcc_v4df, __gcc_v4df); +__gcc_v8sf __builtin_ia32_addsubps256(__gcc_v8sf, __gcc_v8sf); +__gcc_v4df __builtin_ia32_andnpd256(__gcc_v4df, __gcc_v4df); +__gcc_v8sf __builtin_ia32_andnps256(__gcc_v8sf, __gcc_v8sf); +__gcc_v4df __builtin_ia32_andpd256(__gcc_v4df, __gcc_v4df); +__gcc_v8sf __builtin_ia32_andps256(__gcc_v8sf, __gcc_v8sf); +__gcc_v4df __builtin_ia32_blendpd256(__gcc_v4df, __gcc_v4df, int); +__gcc_v8sf __builtin_ia32_blendps256(__gcc_v8sf, __gcc_v8sf, int); +__gcc_v4df __builtin_ia32_blendvpd256(__gcc_v4df, __gcc_v4df, __gcc_v4df); +__gcc_v8sf __builtin_ia32_blendvps256(__gcc_v8sf, __gcc_v8sf, __gcc_v8sf); +__gcc_v2df __builtin_ia32_cmppd(__gcc_v2df, __gcc_v2df, int); +__gcc_v4df __builtin_ia32_cmppd256(__gcc_v4df, __gcc_v4df, int); +__gcc_v4sf __builtin_ia32_cmpps(__gcc_v4sf, __gcc_v4sf, int); +__gcc_v8sf __builtin_ia32_cmpps256(__gcc_v8sf, __gcc_v8sf, int); +__gcc_v2df __builtin_ia32_cmpsd(__gcc_v2df, __gcc_v2df, int); +__gcc_v4sf __builtin_ia32_cmpss(__gcc_v4sf, __gcc_v4sf, int); __gcc_v4df __builtin_ia32_cvtdq2pd256(__gcc_v4si); __gcc_v8sf __builtin_ia32_cvtdq2ps256(__gcc_v8si); __gcc_v4si __builtin_ia32_cvtpd2dq256(__gcc_v4df); @@ -478,38 +478,38 @@ __gcc_v8si __builtin_ia32_cvtps2dq256(__gcc_v8sf); __gcc_v4df __builtin_ia32_cvtps2pd256(__gcc_v4sf); __gcc_v4si __builtin_ia32_cvttpd2dq256(__gcc_v4df); __gcc_v8si __builtin_ia32_cvttps2dq256(__gcc_v8sf); -__gcc_v4df __builtin_ia32_divpd256(__gcc_v4df,__gcc_v4df); -__gcc_v8sf __builtin_ia32_divps256(__gcc_v8sf,__gcc_v8sf); -__gcc_v8sf __builtin_ia32_dpps256(__gcc_v8sf,__gcc_v8sf,int); -__gcc_v4df __builtin_ia32_haddpd256(__gcc_v4df,__gcc_v4df); -__gcc_v8sf __builtin_ia32_haddps256(__gcc_v8sf,__gcc_v8sf); -__gcc_v4df __builtin_ia32_hsubpd256(__gcc_v4df,__gcc_v4df); -__gcc_v8sf __builtin_ia32_hsubps256(__gcc_v8sf,__gcc_v8sf); -__gcc_v32qi __builtin_ia32_lddqu256(const char *); -__gcc_v32qi __builtin_ia32_loaddqu256(const char *); -__gcc_v4df __builtin_ia32_loadupd256(const double *); -__gcc_v8sf __builtin_ia32_loadups256(const float *); -__gcc_v2df __builtin_ia32_maskloadpd(const __gcc_v2df *,__gcc_v2df); -__gcc_v4df __builtin_ia32_maskloadpd256(const __gcc_v4df *,__gcc_v4df); -__gcc_v4sf __builtin_ia32_maskloadps(const __gcc_v4sf *,__gcc_v4sf); -__gcc_v8sf __builtin_ia32_maskloadps256(const __gcc_v8sf *,__gcc_v8sf); -void __builtin_ia32_maskstorepd(__gcc_v2df *,__gcc_v2df,__gcc_v2df); -void __builtin_ia32_maskstorepd256(__gcc_v4df *,__gcc_v4df,__gcc_v4df); -void __builtin_ia32_maskstoreps(__gcc_v4sf *,__gcc_v4sf,__gcc_v4sf); -void __builtin_ia32_maskstoreps256(__gcc_v8sf *,__gcc_v8sf,__gcc_v8sf); -__gcc_v4df __builtin_ia32_maxpd256(__gcc_v4df,__gcc_v4df); -__gcc_v8sf __builtin_ia32_maxps256(__gcc_v8sf,__gcc_v8sf); -__gcc_v4df __builtin_ia32_minpd256(__gcc_v4df,__gcc_v4df); -__gcc_v8sf __builtin_ia32_minps256(__gcc_v8sf,__gcc_v8sf); +__gcc_v4df __builtin_ia32_divpd256(__gcc_v4df, __gcc_v4df); +__gcc_v8sf __builtin_ia32_divps256(__gcc_v8sf, __gcc_v8sf); +__gcc_v8sf __builtin_ia32_dpps256(__gcc_v8sf, __gcc_v8sf, int); +__gcc_v4df __builtin_ia32_haddpd256(__gcc_v4df, __gcc_v4df); +__gcc_v8sf __builtin_ia32_haddps256(__gcc_v8sf, __gcc_v8sf); +__gcc_v4df __builtin_ia32_hsubpd256(__gcc_v4df, __gcc_v4df); +__gcc_v8sf __builtin_ia32_hsubps256(__gcc_v8sf, __gcc_v8sf); +__gcc_v32qi __builtin_ia32_lddqu256(const char*); +__gcc_v32qi __builtin_ia32_loaddqu256(const char*); +__gcc_v4df __builtin_ia32_loadupd256(const double*); +__gcc_v8sf __builtin_ia32_loadups256(const float*); +__gcc_v2df __builtin_ia32_maskloadpd(const __gcc_v2df*, __gcc_v2di); +__gcc_v4df __builtin_ia32_maskloadpd256(const __gcc_v4df*, __gcc_v4di); +__gcc_v4sf __builtin_ia32_maskloadps(const __gcc_v4sf*, __gcc_v4si); +__gcc_v8sf __builtin_ia32_maskloadps256(const __gcc_v8sf*, __gcc_v8si); +void __builtin_ia32_maskstorepd(__gcc_v2df*, __gcc_v2di, __gcc_v2df); +void __builtin_ia32_maskstorepd256(__gcc_v4df*, __gcc_v4di, __gcc_v4df); +void __builtin_ia32_maskstoreps(__gcc_v4sf*, __gcc_v4si, __gcc_v4sf); +void __builtin_ia32_maskstoreps256(__gcc_v8sf*, __gcc_v8si, __gcc_v8sf); +__gcc_v4df __builtin_ia32_maxpd256(__gcc_v4df, __gcc_v4df); +__gcc_v8sf __builtin_ia32_maxps256(__gcc_v8sf, __gcc_v8sf); +__gcc_v4df __builtin_ia32_minpd256(__gcc_v4df, __gcc_v4df); +__gcc_v8sf __builtin_ia32_minps256(__gcc_v8sf, __gcc_v8sf); __gcc_v4df __builtin_ia32_movddup256(__gcc_v4df); int __builtin_ia32_movmskpd256(__gcc_v4df); int __builtin_ia32_movmskps256(__gcc_v8sf); __gcc_v8sf __builtin_ia32_movshdup256(__gcc_v8sf); __gcc_v8sf __builtin_ia32_movsldup256(__gcc_v8sf); -__gcc_v4df __builtin_ia32_mulpd256(__gcc_v4df,__gcc_v4df); -__gcc_v8sf __builtin_ia32_mulps256(__gcc_v8sf,__gcc_v8sf); -__gcc_v4df __builtin_ia32_orpd256(__gcc_v4df,__gcc_v4df); -__gcc_v8sf __builtin_ia32_orps256(__gcc_v8sf,__gcc_v8sf); +__gcc_v4df __builtin_ia32_mulpd256(__gcc_v4df, __gcc_v4df); +__gcc_v8sf __builtin_ia32_mulps256(__gcc_v8sf, __gcc_v8sf); +__gcc_v4df __builtin_ia32_orpd256(__gcc_v4df, __gcc_v4df); +__gcc_v8sf __builtin_ia32_orps256(__gcc_v8sf, __gcc_v8sf); __gcc_v2df __builtin_ia32_pd_pd256(__gcc_v4df); __gcc_v4df __builtin_ia32_pd256_pd(__gcc_v2df); __gcc_v4sf __builtin_ia32_ps_ps256(__gcc_v8sf); @@ -518,52 +518,52 @@ int __builtin_ia32_ptestc256(__gcc_v4di,__gcc_v4di,...); int __builtin_ia32_ptestnzc256(__gcc_v4di,__gcc_v4di,...); int __builtin_ia32_ptestz256(__gcc_v4di,__gcc_v4di,...); __gcc_v8sf __builtin_ia32_rcpps256(__gcc_v8sf); -__gcc_v4df __builtin_ia32_roundpd256(__gcc_v4df,int); -__gcc_v8sf __builtin_ia32_roundps256(__gcc_v8sf,int); +__gcc_v4df __builtin_ia32_roundpd256(__gcc_v4df, int); +__gcc_v8sf __builtin_ia32_roundps256(__gcc_v8sf, int); __gcc_v8sf __builtin_ia32_rsqrtps_nr256(__gcc_v8sf); __gcc_v8sf __builtin_ia32_rsqrtps256(__gcc_v8sf); -__gcc_v4df __builtin_ia32_shufpd256(__gcc_v4df,__gcc_v4df,int); -__gcc_v8sf __builtin_ia32_shufps256(__gcc_v8sf,__gcc_v8sf,int); +__gcc_v4df __builtin_ia32_shufpd256(__gcc_v4df, __gcc_v4df, int); +__gcc_v8sf __builtin_ia32_shufps256(__gcc_v8sf, __gcc_v8sf, int); __gcc_v4si __builtin_ia32_si_si256(__gcc_v8si); __gcc_v8si __builtin_ia32_si256_si(__gcc_v4si); __gcc_v4df __builtin_ia32_sqrtpd256(__gcc_v4df); __gcc_v8sf __builtin_ia32_sqrtps_nr256(__gcc_v8sf); __gcc_v8sf __builtin_ia32_sqrtps256(__gcc_v8sf); -void __builtin_ia32_storedqu256(char *,__gcc_v32qi); -void __builtin_ia32_storeupd256(double *,__gcc_v4df); -void __builtin_ia32_storeups256(float *,__gcc_v8sf); -__gcc_v4df __builtin_ia32_subpd256(__gcc_v4df,__gcc_v4df); -__gcc_v8sf __builtin_ia32_subps256(__gcc_v8sf,__gcc_v8sf); -__gcc_v4df __builtin_ia32_unpckhpd256(__gcc_v4df,__gcc_v4df); -__gcc_v8sf __builtin_ia32_unpckhps256(__gcc_v8sf,__gcc_v8sf); -__gcc_v4df __builtin_ia32_unpcklpd256(__gcc_v4df,__gcc_v4df); -__gcc_v8sf __builtin_ia32_unpcklps256(__gcc_v8sf,__gcc_v8sf); -__gcc_v4df __builtin_ia32_vbroadcastf128_pd256(const __gcc_v2df *); -__gcc_v8sf __builtin_ia32_vbroadcastf128_ps256(const __gcc_v4sf *); -__gcc_v4df __builtin_ia32_vbroadcastsd256(const double *); -__gcc_v4sf __builtin_ia32_vbroadcastss(const float *); -__gcc_v8sf __builtin_ia32_vbroadcastss256(const float *); -__gcc_v2df __builtin_ia32_vextractf128_pd256(__gcc_v4df,int); -__gcc_v4sf __builtin_ia32_vextractf128_ps256(__gcc_v8sf,int); -__gcc_v4si __builtin_ia32_vextractf128_si256(__gcc_v8si,int); -__gcc_v4df __builtin_ia32_vinsertf128_pd256(__gcc_v4df,__gcc_v2df,int); -__gcc_v8sf __builtin_ia32_vinsertf128_ps256(__gcc_v8sf,__gcc_v4sf,int); -__gcc_v8si __builtin_ia32_vinsertf128_si256(__gcc_v8si,__gcc_v4si,int); -__gcc_v4df __builtin_ia32_vperm2f128_pd256(__gcc_v4df,__gcc_v4df,int); -__gcc_v8sf __builtin_ia32_vperm2f128_ps256(__gcc_v8sf,__gcc_v8sf,int); -__gcc_v8si __builtin_ia32_vperm2f128_si256(__gcc_v8si,__gcc_v8si,int); +void __builtin_ia32_storedqu256(char*, __gcc_v32qi); +void __builtin_ia32_storeupd256(double*, __gcc_v4df); +void __builtin_ia32_storeups256(float*, __gcc_v8sf); +__gcc_v4df __builtin_ia32_subpd256(__gcc_v4df, __gcc_v4df); +__gcc_v8sf __builtin_ia32_subps256(__gcc_v8sf, __gcc_v8sf); +__gcc_v4df __builtin_ia32_unpckhpd256(__gcc_v4df, __gcc_v4df); +__gcc_v8sf __builtin_ia32_unpckhps256(__gcc_v8sf, __gcc_v8sf); +__gcc_v4df __builtin_ia32_unpcklpd256(__gcc_v4df, __gcc_v4df); +__gcc_v8sf __builtin_ia32_unpcklps256(__gcc_v8sf, __gcc_v8sf); +__gcc_v4df __builtin_ia32_vbroadcastf128_pd256(const __gcc_v2df*); +__gcc_v8sf __builtin_ia32_vbroadcastf128_ps256(const __gcc_v4sf*); +__gcc_v4df __builtin_ia32_vbroadcastsd256(const double*); +__gcc_v4sf __builtin_ia32_vbroadcastss(const float*); +__gcc_v8sf __builtin_ia32_vbroadcastss256(const float*); +__gcc_v2df __builtin_ia32_vextractf128_pd256(__gcc_v4df, int); +__gcc_v4sf __builtin_ia32_vextractf128_ps256(__gcc_v8sf, int); +__gcc_v4si __builtin_ia32_vextractf128_si256(__gcc_v8si, int); +__gcc_v4df __builtin_ia32_vinsertf128_pd256(__gcc_v4df, __gcc_v2df, int); +__gcc_v8sf __builtin_ia32_vinsertf128_ps256(__gcc_v8sf, __gcc_v4sf, int); +__gcc_v8si __builtin_ia32_vinsertf128_si256(__gcc_v8si, __gcc_v4si, int); +__gcc_v4df __builtin_ia32_vperm2f128_pd256(__gcc_v4df, __gcc_v4df, int); +__gcc_v8sf __builtin_ia32_vperm2f128_ps256(__gcc_v8sf, __gcc_v8sf, int); +__gcc_v8si __builtin_ia32_vperm2f128_si256(__gcc_v8si, __gcc_v8si, int); __gcc_v2df __builtin_ia32_vpermil2pd(__gcc_v2df,__gcc_v2df,__gcc_v2di,int); __gcc_v4df __builtin_ia32_vpermil2pd256(__gcc_v4df,__gcc_v4df,__gcc_v4di,int); __gcc_v4sf __builtin_ia32_vpermil2ps(__gcc_v4sf,__gcc_v4sf,__gcc_v4si,int); __gcc_v8sf __builtin_ia32_vpermil2ps256(__gcc_v8sf,__gcc_v8sf,__gcc_v8si,int); -__gcc_v2df __builtin_ia32_vpermilpd(__gcc_v2df,int); -__gcc_v4df __builtin_ia32_vpermilpd256(__gcc_v4df,int); -__gcc_v4sf __builtin_ia32_vpermilps(__gcc_v4sf,int); -__gcc_v8sf __builtin_ia32_vpermilps256(__gcc_v8sf,int); -__gcc_v2df __builtin_ia32_vpermilvarpd(__gcc_v2df,__gcc_v2di); -__gcc_v4df __builtin_ia32_vpermilvarpd256(__gcc_v4df,__gcc_v4di); -__gcc_v4sf __builtin_ia32_vpermilvarps(__gcc_v4sf,__gcc_v4si); -__gcc_v8sf __builtin_ia32_vpermilvarps256(__gcc_v8sf,__gcc_v8si); +__gcc_v2df __builtin_ia32_vpermilpd(__gcc_v2df, int); +__gcc_v4df __builtin_ia32_vpermilpd256(__gcc_v4df, int); +__gcc_v4sf __builtin_ia32_vpermilps(__gcc_v4sf, int); +__gcc_v8sf __builtin_ia32_vpermilps256(__gcc_v8sf, int); +__gcc_v2df __builtin_ia32_vpermilvarpd(__gcc_v2df, __gcc_v2di); +__gcc_v4df __builtin_ia32_vpermilvarpd256(__gcc_v4df, __gcc_v4di); +__gcc_v4sf __builtin_ia32_vpermilvarps(__gcc_v4sf, __gcc_v4si); +__gcc_v8sf __builtin_ia32_vpermilvarps256(__gcc_v8sf, __gcc_v8si); int __builtin_ia32_vtestcpd(__gcc_v2df,__gcc_v2df,...); int __builtin_ia32_vtestcpd256(__gcc_v4df,__gcc_v4df,...); int __builtin_ia32_vtestcps(__gcc_v4sf,__gcc_v4sf,...); @@ -576,61 +576,61 @@ int __builtin_ia32_vtestzpd(__gcc_v2df,__gcc_v2df,...); int __builtin_ia32_vtestzpd256(__gcc_v4df,__gcc_v4df,...); int __builtin_ia32_vtestzps(__gcc_v4sf,__gcc_v4sf,...); int __builtin_ia32_vtestzps256(__gcc_v8sf,__gcc_v8sf,...); -void __builtin_ia32_vzeroall(void); -void __builtin_ia32_vzeroupper(void); -__gcc_v4df __builtin_ia32_xorpd256(__gcc_v4df,__gcc_v4df); -__gcc_v8sf __builtin_ia32_xorps256(__gcc_v8sf,__gcc_v8sf); -__gcc_v32qi __builtin_ia32_mpsadbw256(__gcc_v32qi,__gcc_v32qi,int); +void __builtin_ia32_vzeroall(); +void __builtin_ia32_vzeroupper(); +__gcc_v4df __builtin_ia32_xorpd256(__gcc_v4df, __gcc_v4df); +__gcc_v8sf __builtin_ia32_xorps256(__gcc_v8sf, __gcc_v8sf); +__gcc_v32qi __builtin_ia32_mpsadbw256(__gcc_v32qi, __gcc_v32qi, int); __gcc_v32qi __builtin_ia32_pabsb256(__gcc_v32qi); __gcc_v16hi __builtin_ia32_pabsw256(__gcc_v16hi); __gcc_v8si __builtin_ia32_pabsd256(__gcc_v8si); -__gcc_v16hi __builtin_ia32_packssdw256(__gcc_v8si,__gcc_v8si); -__gcc_v32qi __builtin_ia32_packsswb256(__gcc_v16hi,__gcc_v16hi); -__gcc_v16hi __builtin_ia32_packusdw256(__gcc_v8si,__gcc_v8si); -__gcc_v32qi __builtin_ia32_packuswb256(__gcc_v16hi,__gcc_v16hi); -__gcc_v32qi __builtin_ia32_paddb256(__gcc_v32qi,__gcc_v32qi); -__gcc_v16hi __builtin_ia32_paddw256(__gcc_v16hi,__gcc_v16hi); -__gcc_v8si __builtin_ia32_paddd256(__gcc_v8si,__gcc_v8si); -__gcc_v4di __builtin_ia32_paddq256(__gcc_v4di,__gcc_v4di); -__gcc_v32qi __builtin_ia32_paddsb256(__gcc_v32qi,__gcc_v32qi); -__gcc_v16hi __builtin_ia32_paddsw256(__gcc_v16hi,__gcc_v16hi); -__gcc_v32qi __builtin_ia32_paddusb256(__gcc_v32qi,__gcc_v32qi); -__gcc_v16hi __builtin_ia32_paddusw256(__gcc_v16hi,__gcc_v16hi); +__gcc_v16hi __builtin_ia32_packssdw256(__gcc_v8si, __gcc_v8si); +__gcc_v32qi __builtin_ia32_packsswb256(__gcc_v16hi, __gcc_v16hi); +__gcc_v16hi __builtin_ia32_packusdw256(__gcc_v8si, __gcc_v8si); +__gcc_v32qi __builtin_ia32_packuswb256(__gcc_v16hi, __gcc_v16hi); +__gcc_v32qi __builtin_ia32_paddb256(__gcc_v32qi, __gcc_v32qi); +__gcc_v16hi __builtin_ia32_paddw256(__gcc_v16hi, __gcc_v16hi); +__gcc_v8si __builtin_ia32_paddd256(__gcc_v8si, __gcc_v8si); +__gcc_v4di __builtin_ia32_paddq256(__gcc_v4di, __gcc_v4di); +__gcc_v32qi __builtin_ia32_paddsb256(__gcc_v32qi, __gcc_v32qi); +__gcc_v16hi __builtin_ia32_paddsw256(__gcc_v16hi, __gcc_v16hi); +__gcc_v32qi __builtin_ia32_paddusb256(__gcc_v32qi, __gcc_v32qi); +__gcc_v16hi __builtin_ia32_paddusw256(__gcc_v16hi, __gcc_v16hi); __gcc_v4di __builtin_ia32_palignr256(__gcc_v4di,__gcc_v4di,int); -__gcc_v4di __builtin_ia32_andsi256(__gcc_v4di,__gcc_v4di); -__gcc_v4di __builtin_ia32_andnotsi256(__gcc_v4di,__gcc_v4di); -__gcc_v32qi __builtin_ia32_pavgb256(__gcc_v32qi,__gcc_v32qi); -__gcc_v16hi __builtin_ia32_pavgw256(__gcc_v16hi,__gcc_v16hi); -__gcc_v32qi __builtin_ia32_pblendvb256(__gcc_v32qi,__gcc_v32qi,__gcc_v32qi); -__gcc_v16hi __builtin_ia32_pblendw256(__gcc_v16hi,__gcc_v16hi,int); -__gcc_v32qi __builtin_ia32_pcmpeqb256(__gcc_v32qi,__gcc_v32qi); -__gcc_v16hi __builtin_ia32_pcmpeqw256(__gcc_v16hi,__gcc_v16hi); -__gcc_v8si __builtin_ia32_pcmpeqd256(__gcc_v8si,__gcc_v8si); -__gcc_v4di __builtin_ia32_pcmpeqq256(__gcc_v4di,__gcc_v4di); -__gcc_v32qi __builtin_ia32_pcmpgtb256(__gcc_v32qi,__gcc_v32qi); -__gcc_v16hi __builtin_ia32_pcmpgtw256(__gcc_v16hi,__gcc_v16hi); -__gcc_v8si __builtin_ia32_pcmpgtd256(__gcc_v8si,__gcc_v8si); -__gcc_v4di __builtin_ia32_pcmpgtq256(__gcc_v4di,__gcc_v4di); -__gcc_v16hi __builtin_ia32_phaddw256(__gcc_v16hi,__gcc_v16hi); -__gcc_v8si __builtin_ia32_phaddd256(__gcc_v8si,__gcc_v8si); -__gcc_v16hi __builtin_ia32_phaddsw256(__gcc_v16hi,__gcc_v16hi); -__gcc_v16hi __builtin_ia32_phsubw256(__gcc_v16hi,__gcc_v16hi); -__gcc_v8si __builtin_ia32_phsubd256(__gcc_v8si,__gcc_v8si); -__gcc_v16hi __builtin_ia32_phsubsw256(__gcc_v16hi,__gcc_v16hi); -__gcc_v32qi __builtin_ia32_pmaddubsw256(__gcc_v32qi,__gcc_v32qi); -__gcc_v16hi __builtin_ia32_pmaddwd256(__gcc_v16hi,__gcc_v16hi); -__gcc_v32qi __builtin_ia32_pmaxsb256(__gcc_v32qi,__gcc_v32qi); -__gcc_v16hi __builtin_ia32_pmaxsw256(__gcc_v16hi,__gcc_v16hi); -__gcc_v8si __builtin_ia32_pmaxsd256(__gcc_v8si,__gcc_v8si); -__gcc_v32qi __builtin_ia32_pmaxub256(__gcc_v32qi,__gcc_v32qi); -__gcc_v16hi __builtin_ia32_pmaxuw256(__gcc_v16hi,__gcc_v16hi); -__gcc_v8si __builtin_ia32_pmaxud256(__gcc_v8si,__gcc_v8si); -__gcc_v32qi __builtin_ia32_pminsb256(__gcc_v32qi,__gcc_v32qi); -__gcc_v16hi __builtin_ia32_pminsw256(__gcc_v16hi,__gcc_v16hi); -__gcc_v8si __builtin_ia32_pminsd256(__gcc_v8si,__gcc_v8si); -__gcc_v32qi __builtin_ia32_pminub256(__gcc_v32qi,__gcc_v32qi); -__gcc_v16hi __builtin_ia32_pminuw256(__gcc_v16hi,__gcc_v16hi); -__gcc_v8si __builtin_ia32_pminud256(__gcc_v8si,__gcc_v8si); +__gcc_v4di __builtin_ia32_andsi256(__gcc_v4di, __gcc_v4di); +__gcc_v4di __builtin_ia32_andnotsi256(__gcc_v4di, __gcc_v4di); +__gcc_v32qi __builtin_ia32_pavgb256(__gcc_v32qi, __gcc_v32qi); +__gcc_v16hi __builtin_ia32_pavgw256(__gcc_v16hi, __gcc_v16hi); +__gcc_v32qi __builtin_ia32_pblendvb256(__gcc_v32qi, __gcc_v32qi, __gcc_v32qi); +__gcc_v16hi __builtin_ia32_pblendw256(__gcc_v16hi, __gcc_v16hi, int); +__gcc_v32qi __builtin_ia32_pcmpeqb256(__gcc_v32qi, __gcc_v32qi); +__gcc_v16hi __builtin_ia32_pcmpeqw256(__gcc_v16hi, __gcc_v16hi); +__gcc_v8si __builtin_ia32_pcmpeqd256(__gcc_v8si, __gcc_v8si); +__gcc_v4di __builtin_ia32_pcmpeqq256(__gcc_v4di, __gcc_v4di); +__gcc_v32qi __builtin_ia32_pcmpgtb256(__gcc_v32qi, __gcc_v32qi); +__gcc_v16hi __builtin_ia32_pcmpgtw256(__gcc_v16hi, __gcc_v16hi); +__gcc_v8si __builtin_ia32_pcmpgtd256(__gcc_v8si, __gcc_v8si); +__gcc_v4di __builtin_ia32_pcmpgtq256(__gcc_v4di, __gcc_v4di); +__gcc_v16hi __builtin_ia32_phaddw256(__gcc_v16hi, __gcc_v16hi); +__gcc_v8si __builtin_ia32_phaddd256(__gcc_v8si, __gcc_v8si); +__gcc_v16hi __builtin_ia32_phaddsw256(__gcc_v16hi, __gcc_v16hi); +__gcc_v16hi __builtin_ia32_phsubw256(__gcc_v16hi, __gcc_v16hi); +__gcc_v8si __builtin_ia32_phsubd256(__gcc_v8si, __gcc_v8si); +__gcc_v16hi __builtin_ia32_phsubsw256(__gcc_v16hi, __gcc_v16hi); +__gcc_v16hi __builtin_ia32_pmaddubsw256(__gcc_v32qi, __gcc_v32qi); +__gcc_v8si __builtin_ia32_pmaddwd256(__gcc_v16hi, __gcc_v16hi); +__gcc_v32qi __builtin_ia32_pmaxsb256(__gcc_v32qi, __gcc_v32qi); +__gcc_v16hi __builtin_ia32_pmaxsw256(__gcc_v16hi, __gcc_v16hi); +__gcc_v8si __builtin_ia32_pmaxsd256(__gcc_v8si, __gcc_v8si); +__gcc_v32qi __builtin_ia32_pmaxub256(__gcc_v32qi, __gcc_v32qi); +__gcc_v16hi __builtin_ia32_pmaxuw256(__gcc_v16hi, __gcc_v16hi); +__gcc_v8si __builtin_ia32_pmaxud256(__gcc_v8si, __gcc_v8si); +__gcc_v32qi __builtin_ia32_pminsb256(__gcc_v32qi, __gcc_v32qi); +__gcc_v16hi __builtin_ia32_pminsw256(__gcc_v16hi, __gcc_v16hi); +__gcc_v8si __builtin_ia32_pminsd256(__gcc_v8si, __gcc_v8si); +__gcc_v32qi __builtin_ia32_pminub256(__gcc_v32qi, __gcc_v32qi); +__gcc_v16hi __builtin_ia32_pminuw256(__gcc_v16hi, __gcc_v16hi); +__gcc_v8si __builtin_ia32_pminud256(__gcc_v8si, __gcc_v8si); int __builtin_ia32_pmovmskb256(__gcc_v32qi); __gcc_v16hi __builtin_ia32_pmovsxbw256(__gcc_v16qi); __gcc_v8si __builtin_ia32_pmovsxbd256(__gcc_v16qi); @@ -644,22 +644,22 @@ __gcc_v4di __builtin_ia32_pmovzxbq256(__gcc_v16qi); __gcc_v8si __builtin_ia32_pmovzxwd256(__gcc_v8hi); __gcc_v4di __builtin_ia32_pmovzxwq256(__gcc_v8hi); __gcc_v4di __builtin_ia32_pmovzxdq256(__gcc_v4si); -__gcc_v4di __builtin_ia32_pmuldq256(__gcc_v8si,__gcc_v8si); +__gcc_v4di __builtin_ia32_pmuldq256(__gcc_v8si, __gcc_v8si); __gcc_v16hi __builtin_ia32_pmulhrsw256(__gcc_v16hi, __gcc_v16hi); -__gcc_v16hi __builtin_ia32_pmulhuw256(__gcc_v16hi,__gcc_v16hi); -__gcc_v16hi __builtin_ia32_pmulhw256(__gcc_v16hi,__gcc_v16hi); -__gcc_v16hi __builtin_ia32_pmullw256(__gcc_v16hi,__gcc_v16hi); -__gcc_v8si __builtin_ia32_pmulld256(__gcc_v8si,__gcc_v8si); -__gcc_v4di __builtin_ia32_pmuludq256(__gcc_v8si,__gcc_v8si); -__gcc_v4di __builtin_ia32_por256(__gcc_v4di,__gcc_v4di); -__gcc_v16hi __builtin_ia32_psadbw256(__gcc_v32qi,__gcc_v32qi); -__gcc_v32qi __builtin_ia32_pshufb256(__gcc_v32qi,__gcc_v32qi); -__gcc_v8si __builtin_ia32_pshufd256(__gcc_v8si,int); -__gcc_v16hi __builtin_ia32_pshufhw256(__gcc_v16hi,int); -__gcc_v16hi __builtin_ia32_pshuflw256(__gcc_v16hi,int); -__gcc_v32qi __builtin_ia32_psignb256(__gcc_v32qi,__gcc_v32qi); -__gcc_v16hi __builtin_ia32_psignw256(__gcc_v16hi,__gcc_v16hi); -__gcc_v8si __builtin_ia32_psignd256(__gcc_v8si,__gcc_v8si); +__gcc_v16hi __builtin_ia32_pmulhuw256(__gcc_v16hi, __gcc_v16hi); +__gcc_v16hi __builtin_ia32_pmulhw256(__gcc_v16hi, __gcc_v16hi); +__gcc_v16hi __builtin_ia32_pmullw256(__gcc_v16hi, __gcc_v16hi); +__gcc_v8si __builtin_ia32_pmulld256(__gcc_v8si, __gcc_v8si); +__gcc_v4di __builtin_ia32_pmuludq256(__gcc_v8si, __gcc_v8si); +__gcc_v4di __builtin_ia32_por256(__gcc_v4di, __gcc_v4di); +__gcc_v16hi __builtin_ia32_psadbw256(__gcc_v32qi, __gcc_v32qi); +__gcc_v32qi __builtin_ia32_pshufb256(__gcc_v32qi, __gcc_v32qi); +__gcc_v8si __builtin_ia32_pshufd256(__gcc_v8si, int); +__gcc_v16hi __builtin_ia32_pshufhw256(__gcc_v16hi, int); +__gcc_v16hi __builtin_ia32_pshuflw256(__gcc_v16hi, int); +__gcc_v32qi __builtin_ia32_psignb256(__gcc_v32qi, __gcc_v32qi); +__gcc_v16hi __builtin_ia32_psignw256(__gcc_v16hi, __gcc_v16hi); +__gcc_v8si __builtin_ia32_psignd256(__gcc_v8si, __gcc_v8si); __gcc_v4di __builtin_ia32_pslldqi256(__gcc_v4di,int); __gcc_v16hi __builtin_ia32_psllwi256(__gcc_v16hi,int); __gcc_v16hi __builtin_ia32_psllw256(__gcc_v16hi,__gcc_v8hi); @@ -678,30 +678,30 @@ __gcc_v8si __builtin_ia32_psrldi256(__gcc_v8si,int); __gcc_v8si __builtin_ia32_psrld256(__gcc_v8si,__gcc_v4si); __gcc_v4di __builtin_ia32_psrlqi256(__gcc_v4di,int); __gcc_v4di __builtin_ia32_psrlq256(__gcc_v4di,__gcc_v2di); -__gcc_v32qi __builtin_ia32_psubb256(__gcc_v32qi,__gcc_v32qi); -__gcc_v32hi __builtin_ia32_psubw256(__gcc_v16hi,__gcc_v16hi); -__gcc_v8si __builtin_ia32_psubd256(__gcc_v8si,__gcc_v8si); -__gcc_v4di __builtin_ia32_psubq256(__gcc_v4di,__gcc_v4di); -__gcc_v32qi __builtin_ia32_psubsb256(__gcc_v32qi,__gcc_v32qi); -__gcc_v16hi __builtin_ia32_psubsw256(__gcc_v16hi,__gcc_v16hi); -__gcc_v32qi __builtin_ia32_psubusb256(__gcc_v32qi,__gcc_v32qi); -__gcc_v16hi __builtin_ia32_psubusw256(__gcc_v16hi,__gcc_v16hi); -__gcc_v32qi __builtin_ia32_punpckhbw256(__gcc_v32qi,__gcc_v32qi); -__gcc_v16hi __builtin_ia32_punpckhwd256(__gcc_v16hi,__gcc_v16hi); -__gcc_v8si __builtin_ia32_punpckhdq256(__gcc_v8si,__gcc_v8si); -__gcc_v4di __builtin_ia32_punpckhqdq256(__gcc_v4di,__gcc_v4di); -__gcc_v32qi __builtin_ia32_punpcklbw256(__gcc_v32qi,__gcc_v32qi); -__gcc_v16hi __builtin_ia32_punpcklwd256(__gcc_v16hi,__gcc_v16hi); -__gcc_v8si __builtin_ia32_punpckldq256(__gcc_v8si,__gcc_v8si); -__gcc_v4di __builtin_ia32_punpcklqdq256(__gcc_v4di,__gcc_v4di); -__gcc_v4di __builtin_ia32_pxor256(__gcc_v4di,__gcc_v4di); -__gcc_v4di __builtin_ia32_movntdqa256(__gcc_v4di *); +__gcc_v32qi __builtin_ia32_psubb256(__gcc_v32qi, __gcc_v32qi); +__gcc_v16hi __builtin_ia32_psubw256(__gcc_v16hi, __gcc_v16hi); +__gcc_v8si __builtin_ia32_psubd256(__gcc_v8si, __gcc_v8si); +__gcc_v4di __builtin_ia32_psubq256(__gcc_v4di, __gcc_v4di); +__gcc_v32qi __builtin_ia32_psubsb256(__gcc_v32qi, __gcc_v32qi); +__gcc_v16hi __builtin_ia32_psubsw256(__gcc_v16hi, __gcc_v16hi); +__gcc_v32qi __builtin_ia32_psubusb256(__gcc_v32qi, __gcc_v32qi); +__gcc_v16hi __builtin_ia32_psubusw256(__gcc_v16hi, __gcc_v16hi); +__gcc_v32qi __builtin_ia32_punpckhbw256(__gcc_v32qi, __gcc_v32qi); +__gcc_v16hi __builtin_ia32_punpckhwd256(__gcc_v16hi, __gcc_v16hi); +__gcc_v8si __builtin_ia32_punpckhdq256(__gcc_v8si, __gcc_v8si); +__gcc_v4di __builtin_ia32_punpckhqdq256(__gcc_v4di, __gcc_v4di); +__gcc_v32qi __builtin_ia32_punpcklbw256(__gcc_v32qi, __gcc_v32qi); +__gcc_v16hi __builtin_ia32_punpcklwd256(__gcc_v16hi, __gcc_v16hi); +__gcc_v8si __builtin_ia32_punpckldq256(__gcc_v8si, __gcc_v8si); +__gcc_v4di __builtin_ia32_punpcklqdq256(__gcc_v4di, __gcc_v4di); +__gcc_v4di __builtin_ia32_pxor256(__gcc_v4di, __gcc_v4di); +__gcc_v4di __builtin_ia32_movntdqa256(__gcc_v4di*); __gcc_v4sf __builtin_ia32_vbroadcastss_ps(__gcc_v4sf); __gcc_v8sf __builtin_ia32_vbroadcastss_ps256(__gcc_v4sf); __gcc_v4df __builtin_ia32_vbroadcastsd_pd256(__gcc_v2df); __gcc_v4di __builtin_ia32_vbroadcastsi256(__gcc_v2di); -__gcc_v4si __builtin_ia32_pblendd128(__gcc_v4si,__gcc_v4si,int); -__gcc_v8si __builtin_ia32_pblendd256(__gcc_v8si,__gcc_v8si,int); +__gcc_v4si __builtin_ia32_pblendd128(__gcc_v4si, __gcc_v4si, int); +__gcc_v8si __builtin_ia32_pblendd256(__gcc_v8si, __gcc_v8si, int); __gcc_v32qi __builtin_ia32_pbroadcastb256(__gcc_v16qi); __gcc_v16hi __builtin_ia32_pbroadcastw256(__gcc_v8hi); __gcc_v8si __builtin_ia32_pbroadcastd256(__gcc_v4si); @@ -710,21 +710,21 @@ __gcc_v16qi __builtin_ia32_pbroadcastb128(__gcc_v16qi); __gcc_v8hi __builtin_ia32_pbroadcastw128(__gcc_v8hi); __gcc_v4si __builtin_ia32_pbroadcastd128(__gcc_v4si); __gcc_v2di __builtin_ia32_pbroadcastq128(__gcc_v2di); -__gcc_v8si __builtin_ia32_permvarsi256(__gcc_v8si,__gcc_v8si); -__gcc_v4df __builtin_ia32_permdf256(__gcc_v4df,int); -__gcc_v8sf __builtin_ia32_permvarsf256(__gcc_v8sf,__gcc_v8sf); -__gcc_v4di __builtin_ia32_permdi256(__gcc_v4di,int); -__gcc_v4di __builtin_ia32_permti256(__gcc_v4di,__gcc_v4di,int); -__gcc_v4di __builtin_ia32_extract128i256(__gcc_v4di,int); -__gcc_v4di __builtin_ia32_insert128i256(__gcc_v4di,__gcc_v2di,int); -__gcc_v8si __builtin_ia32_maskloadd256(const __gcc_v8si *,__gcc_v8si); -__gcc_v4di __builtin_ia32_maskloadq256(const __gcc_v4di *,__gcc_v4di); -__gcc_v4si __builtin_ia32_maskloadd(const __gcc_v4si *,__gcc_v4si); -__gcc_v2di __builtin_ia32_maskloadq(const __gcc_v2di *,__gcc_v2di); -void __builtin_ia32_maskstored256(__gcc_v8si *,__gcc_v8si,__gcc_v8si); -void __builtin_ia32_maskstoreq256(__gcc_v4di *,__gcc_v4di,__gcc_v4di); -void __builtin_ia32_maskstored(__gcc_v4si *,__gcc_v4si,__gcc_v4si); -void __builtin_ia32_maskstoreq(__gcc_v2di *,__gcc_v2di,__gcc_v2di); +__gcc_v8si __builtin_ia32_permvarsi256(__gcc_v8si, __gcc_v8si); +__gcc_v4df __builtin_ia32_permdf256(__gcc_v4df, int); +__gcc_v8sf __builtin_ia32_permvarsf256(__gcc_v8sf, __gcc_v8si); +__gcc_v4di __builtin_ia32_permdi256(__gcc_v4di, int); +__gcc_v4di __builtin_ia32_permti256(__gcc_v4di, __gcc_v4di, int); +__gcc_v2di __builtin_ia32_extract128i256(__gcc_v4di, int); +__gcc_v4di __builtin_ia32_insert128i256(__gcc_v4di, __gcc_v2di, int); +__gcc_v8si __builtin_ia32_maskloadd256(const __gcc_v8si*, __gcc_v8si); +__gcc_v4di __builtin_ia32_maskloadq256(const __gcc_v4di*, __gcc_v4di); +__gcc_v4si __builtin_ia32_maskloadd(const __gcc_v4si*, __gcc_v4si); +__gcc_v2di __builtin_ia32_maskloadq(const __gcc_v2di*, __gcc_v2di); +void __builtin_ia32_maskstored256(__gcc_v8si*, __gcc_v8si, __gcc_v8si); +void __builtin_ia32_maskstoreq256(__gcc_v4di*, __gcc_v4di, __gcc_v4di); +void __builtin_ia32_maskstored(__gcc_v4si*, __gcc_v4si, __gcc_v4si); +void __builtin_ia32_maskstoreq(__gcc_v2di*, __gcc_v2di, __gcc_v2di); __gcc_v8si __builtin_ia32_psll__gcc_v8si(__gcc_v8si,__gcc_v8si); __gcc_v4si __builtin_ia32_psll__gcc_v4si(__gcc_v4si,__gcc_v4si); __gcc_v4di __builtin_ia32_psll__gcc_v4di(__gcc_v4di,__gcc_v4di); @@ -735,22 +735,22 @@ __gcc_v8si __builtin_ia32_psrl__gcc_v8si(__gcc_v8si,__gcc_v8si); __gcc_v4si __builtin_ia32_psrl__gcc_v4si(__gcc_v4si,__gcc_v4si); __gcc_v4di __builtin_ia32_psrl__gcc_v4di(__gcc_v4di,__gcc_v4di); __gcc_v2di __builtin_ia32_psrl__gcc_v2di(__gcc_v2di,__gcc_v2di); -__gcc_v2df __builtin_ia32_gathersi__gcc_v2df(__gcc_v2df, const double *,__gcc_v4si,__gcc_v2df,int); -__gcc_v4df __builtin_ia32_gathersi__gcc_v4df(__gcc_v4df, const double *,__gcc_v4si,__gcc_v4df,int); -__gcc_v2df __builtin_ia32_gatherdi__gcc_v2df(__gcc_v2df, const double *,__gcc_v2di,__gcc_v2df,int); -__gcc_v4df __builtin_ia32_gatherdi__gcc_v4df(__gcc_v4df, const double *,__gcc_v4di,__gcc_v4df,int); -__gcc_v4sf __builtin_ia32_gathersi__gcc_v4sf(__gcc_v4sf, const float *,__gcc_v4si,__gcc_v4sf,int); -__gcc_v8sf __builtin_ia32_gathersi__gcc_v8sf(__gcc_v8sf, const float *,__gcc_v8si,__gcc_v8sf,int); -__gcc_v4sf __builtin_ia32_gatherdi__gcc_v4sf(__gcc_v4sf, const float *,__gcc_v2di,__gcc_v4sf,int); -__gcc_v4sf __builtin_ia32_gatherdi__gcc_v4sf256(__gcc_v4sf, const float *,__gcc_v4di,__gcc_v4sf,int); -__gcc_v2di __builtin_ia32_gathersi__gcc_v2di(__gcc_v2di, const long long int *,__gcc_v4si,__gcc_v2di,int); -__gcc_v4di __builtin_ia32_gathersi__gcc_v4di(__gcc_v4di, const long long int *,__gcc_v4si,__gcc_v4di,int); -__gcc_v2di __builtin_ia32_gatherdi__gcc_v2di(__gcc_v2di, const long long int *,__gcc_v2di,__gcc_v2di,int); -__gcc_v4di __builtin_ia32_gatherdi__gcc_v4di(__gcc_v4di, const long long int *,__gcc_v4di,__gcc_v4di,int); -__gcc_v4si __builtin_ia32_gathersi__gcc_v4si(__gcc_v4si, const int *,__gcc_v4si,__gcc_v4si,int); -__gcc_v8si __builtin_ia32_gathersi__gcc_v8si(__gcc_v8si, const int *,__gcc_v8si,__gcc_v8si,int); -__gcc_v4si __builtin_ia32_gatherdi__gcc_v4si(__gcc_v4si, const int *,__gcc_v2di,__gcc_v4si,int); -__gcc_v4si __builtin_ia32_gatherdi__gcc_v4si256(__gcc_v4si, const int *,__gcc_v4di,__gcc_v4si,int); +__gcc_v2df __builtin_ia32_gathersi__gcc_v2df(__gcc_v2df, const double*,__gcc_v4si,__gcc_v2df,int); +__gcc_v4df __builtin_ia32_gathersi__gcc_v4df(__gcc_v4df, const double*,__gcc_v4si,__gcc_v4df,int); +__gcc_v2df __builtin_ia32_gatherdi__gcc_v2df(__gcc_v2df, const double*,__gcc_v2di,__gcc_v2df,int); +__gcc_v4df __builtin_ia32_gatherdi__gcc_v4df(__gcc_v4df, const double*,__gcc_v4di,__gcc_v4df,int); +__gcc_v4sf __builtin_ia32_gathersi__gcc_v4sf(__gcc_v4sf, const float*,__gcc_v4si,__gcc_v4sf,int); +__gcc_v8sf __builtin_ia32_gathersi__gcc_v8sf(__gcc_v8sf, const float*,__gcc_v8si,__gcc_v8sf,int); +__gcc_v4sf __builtin_ia32_gatherdi__gcc_v4sf(__gcc_v4sf, const float*,__gcc_v2di,__gcc_v4sf,int); +__gcc_v4sf __builtin_ia32_gatherdi__gcc_v4sf256(__gcc_v4sf, const float*,__gcc_v4di,__gcc_v4sf,int); +__gcc_v2di __builtin_ia32_gathersi__gcc_v2di(__gcc_v2di, const long long int*,__gcc_v4si,__gcc_v2di,int); +__gcc_v4di __builtin_ia32_gathersi__gcc_v4di(__gcc_v4di, const long long int*,__gcc_v4si,__gcc_v4di,int); +__gcc_v2di __builtin_ia32_gatherdi__gcc_v2di(__gcc_v2di, const long long int*,__gcc_v2di,__gcc_v2di,int); +__gcc_v4di __builtin_ia32_gatherdi__gcc_v4di(__gcc_v4di, const long long int*,__gcc_v4di,__gcc_v4di,int); +__gcc_v4si __builtin_ia32_gathersi__gcc_v4si(__gcc_v4si, const int*,__gcc_v4si,__gcc_v4si,int); +__gcc_v8si __builtin_ia32_gathersi__gcc_v8si(__gcc_v8si, const int*,__gcc_v8si,__gcc_v8si,int); +__gcc_v4si __builtin_ia32_gatherdi__gcc_v4si(__gcc_v4si, const int*,__gcc_v2di,__gcc_v4si,int); +__gcc_v4si __builtin_ia32_gatherdi__gcc_v4si256(__gcc_v4si, const int*,__gcc_v4di,__gcc_v4si,int); __gcc_v2di __builtin_ia32_aesenc128(__gcc_v2di, __gcc_v2di); __gcc_v2di __builtin_ia32_aesenclast128(__gcc_v2di, __gcc_v2di); __gcc_v2di __builtin_ia32_aesdec128(__gcc_v2di, __gcc_v2di); @@ -758,23 +758,23 @@ __gcc_v2di __builtin_ia32_aesdeclast128(__gcc_v2di, __gcc_v2di); __gcc_v2di __builtin_ia32_aeskeygenassist128(__gcc_v2di, const int); __gcc_v2di __builtin_ia32_aesimc128(__gcc_v2di); __gcc_v2di __builtin_ia32_pclmulqdq128(__gcc_v2di, __gcc_v2di, const int); -unsigned int __builtin_ia32_rdfsbase32(void); -unsigned long long __builtin_ia32_rdfsbase64(void); -unsigned int __builtin_ia32_rdgsbase32(void); -unsigned long long __builtin_ia32_rdgsbase64(void); +unsigned __builtin_ia32_rdfsbase32(); +unsigned long long __builtin_ia32_rdfsbase64(); +unsigned __builtin_ia32_rdgsbase32(); +unsigned long long __builtin_ia32_rdgsbase64(); void _writefsbase_u32(unsigned int); void _writefsbase_u64(unsigned long long); void _writegsbase_u32(unsigned int); void _writegsbase_u64(unsigned long long); -unsigned int __builtin_ia32_rdrand16_step(unsigned short *); -unsigned int __builtin_ia32_rdrand32_step(unsigned int *); -unsigned int __builtin_ia32_rdrand64_step(unsigned long long *); -void __builtin_ia32_movntsd(double *, __gcc_v2df); -void __builtin_ia32_movntss(float *, __gcc_v4sf); +unsigned int __builtin_ia32_rdrand16_step(unsigned short*); +unsigned int __builtin_ia32_rdrand32_step(unsigned int*); +unsigned int __builtin_ia32_rdrand64_step(unsigned long long*); +void __builtin_ia32_movntsd(double*, __gcc_v2df); +void __builtin_ia32_movntss(float*, __gcc_v4sf); __gcc_v2di __builtin_ia32_extrq (__gcc_v2di, __gcc_v16qi); -__gcc_v2di __builtin_ia32_extrqi(__gcc_v2di, const unsigned int, const unsigned int); +__gcc_v2di __builtin_ia32_extrqi(__gcc_v2di, unsigned, unsigned); __gcc_v2di __builtin_ia32_insertq(__gcc_v2di, __gcc_v2di); -__gcc_v2di __builtin_ia32_insertqi(__gcc_v2di, __gcc_v2di, const unsigned int, const unsigned int); +__gcc_v2di __builtin_ia32_insertqi(__gcc_v2di, __gcc_v2di, unsigned, unsigned); __gcc_v2df __builtin_ia32_vfrczpd(__gcc_v2df); __gcc_v4sf __builtin_ia32_vfrczps(__gcc_v4sf); __gcc_v2df __builtin_ia32_vfrczsd(__gcc_v2df); @@ -931,19 +931,19 @@ __gcc_v4df __builtin_ia32_fmaddsubpd256(__gcc_v4df, __gcc_v4df, __gcc_v4df); __gcc_v8sf __builtin_ia32_fmaddsubps256(__gcc_v8sf, __gcc_v8sf, __gcc_v8sf); __gcc_v4df __builtin_ia32_fmsubaddpd256(__gcc_v4df, __gcc_v4df, __gcc_v4df); __gcc_v8sf __builtin_ia32_fmsubaddps256(__gcc_v8sf, __gcc_v8sf, __gcc_v8sf); -void __builtin_ia32_llwpcb16(void *); -void __builtin_ia32_llwpcb32(void *); -void __builtin_ia32_llwpcb64(void *); -//void * __builtin_ia32_llwpcb16(void); -//void * __builtin_ia32_llwpcb32(void); -//void * __builtin_ia32_llwpcb64(void); +void __builtin_ia32_llwpcb16(void*); +void __builtin_ia32_llwpcb32(void*); +void __builtin_ia32_llwpcb64(void*); +//void* __builtin_ia32_llwpcb16(void); +//void* __builtin_ia32_llwpcb32(void); +//void* __builtin_ia32_llwpcb64(void); void __builtin_ia32_lwpval16(unsigned short, unsigned int, unsigned short); -void __builtin_ia32_lwpval32(unsigned int, unsigned int, unsigned int); -void __builtin_ia32_lwpval64(unsigned __int64, unsigned int, unsigned int); +void __builtin_ia32_lwpval32(unsigned, unsigned, unsigned); +void __builtin_ia32_lwpval64(unsigned long long, unsigned, unsigned); unsigned char __builtin_ia32_lwpins16(unsigned short, unsigned int, unsigned short); -unsigned char __builtin_ia32_lwpins32(unsigned int, unsigned int, unsigned int); -unsigned char __builtin_ia32_lwpins64(unsigned __int64, unsigned int, unsigned int); -unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int); +unsigned char __builtin_ia32_lwpins32(unsigned, unsigned, unsigned); +unsigned char __builtin_ia32_lwpins64(unsigned long long, unsigned, unsigned); +unsigned __builtin_ia32_bextr_u32(unsigned, unsigned); unsigned long long __builtin_ia32_bextr_u64(unsigned long long, unsigned long long); unsigned int _bzhi_u32(unsigned int, unsigned int); unsigned int _pdep_u32(unsigned int, unsigned int); @@ -952,11 +952,11 @@ unsigned long long _bzhi_u64(unsigned long long, unsigned long long); unsigned long long _pdep_u64(unsigned long long, unsigned long long); unsigned long long _pext_u64(unsigned long long, unsigned long long); unsigned short __builtin_ia32_lzcnt_16(unsigned short); -unsigned int __builtin_ia32_lzcnt_u32(unsigned int); +unsigned __builtin_ia32_lzcnt_u32(unsigned); unsigned long long __builtin_ia32_lzcnt_u64(unsigned long long); -unsigned int __builtin_ia32_bextri_u32(unsigned int, const unsigned int); -unsigned long long __builtin_ia32_bextri_u64(unsigned long long, const unsigned long long); -void __builtin_ia32_femms(void); +unsigned __builtin_ia32_bextri_u32(unsigned, unsigned); +unsigned long long __builtin_ia32_bextri_u64(unsigned long long, unsigned long long); +void __builtin_ia32_femms(); __gcc_v8qi __builtin_ia32_pavgusb(__gcc_v8qi, __gcc_v8qi); __gcc_v2si __builtin_ia32_pf2id(__gcc_v2sf); __gcc_v2sf __builtin_ia32_pfacc(__gcc_v2sf, __gcc_v2sf); diff --git a/src/ansi-c/gcc_builtin_headers_math.h b/src/ansi-c/gcc_builtin_headers_math.h new file mode 100644 index 00000000000..9ab9d4992ff --- /dev/null +++ b/src/ansi-c/gcc_builtin_headers_math.h @@ -0,0 +1,379 @@ +int __builtin_abs(int); +double __builtin_acos(double); +float __builtin_acosf(float); +double __builtin_acosh(double); +float __builtin_acoshf(float); +long double __builtin_acoshl(long double); +long double __builtin_acosl(long double); +_Bool __builtin_add_overflow(); +_Bool __builtin_add_overflow_p(); +double __builtin_asin(double); +float __builtin_asinf(float); +double __builtin_asinh(double); +float __builtin_asinhf(float); +long double __builtin_asinhl(long double); +long double __builtin_asinl(long double); +double __builtin_atan(double); +double __builtin_atan2(double, double); +float __builtin_atan2f(float, float); +long double __builtin_atan2l(long double, long double); +float __builtin_atanf(float); +double __builtin_atanh(double); +float __builtin_atanhf(float); +long double __builtin_atanhl(long double); +long double __builtin_atanl(long double); +double __builtin_cabs(double _Complex); +float __builtin_cabsf(float _Complex); +long double __builtin_cabsl(long double _Complex); +double _Complex __builtin_cacos(double _Complex); +float _Complex __builtin_cacosf(float _Complex); +double _Complex __builtin_cacosh(double _Complex); +float _Complex __builtin_cacoshf(float _Complex); +long double _Complex __builtin_cacoshl(long double _Complex); +long double _Complex __builtin_cacosl(long double _Complex); +double __builtin_carg(double _Complex); +float __builtin_cargf(float _Complex); +long double __builtin_cargl(long double _Complex); +double _Complex __builtin_casin(double _Complex); +float _Complex __builtin_casinf(float _Complex); +double _Complex __builtin_casinh(double _Complex); +float _Complex __builtin_casinhf(float _Complex); +long double _Complex __builtin_casinhl(long double _Complex); +long double _Complex __builtin_casinl(long double _Complex); +double _Complex __builtin_catan(double _Complex); +float _Complex __builtin_catanf(float _Complex); +double _Complex __builtin_catanh(double _Complex); +float _Complex __builtin_catanhf(float _Complex); +long double _Complex __builtin_catanhl(long double _Complex); +long double _Complex __builtin_catanl(long double _Complex); +double __builtin_cbrt(double); +float __builtin_cbrtf(float); +long double __builtin_cbrtl(long double); +double _Complex __builtin_ccos(double _Complex); +float _Complex __builtin_ccosf(float _Complex); +double _Complex __builtin_ccosh(double _Complex); +float _Complex __builtin_ccoshf(float _Complex); +long double _Complex __builtin_ccoshl(long double _Complex); +long double _Complex __builtin_ccosl(long double _Complex); +double __builtin_ceil(double); +float __builtin_ceilf(float); +long double __builtin_ceill(long double); +double _Complex __builtin_cexp(double _Complex); +float _Complex __builtin_cexpf(float _Complex); +double _Complex __builtin_cexpi(double); +float _Complex __builtin_cexpif(float); +long double _Complex __builtin_cexpil(long double); +long double _Complex __builtin_cexpl(long double _Complex); +double __builtin_cimag(double _Complex); +float __builtin_cimagf(float _Complex); +long double __builtin_cimagl(long double _Complex); +double _Complex __builtin_clog(double _Complex); +double _Complex __builtin_clog10(double _Complex); +float _Complex __builtin_clog10f(float _Complex); +long double _Complex __builtin_clog10l(long double _Complex); +float _Complex __builtin_clogf(float _Complex); +long double _Complex __builtin_clogl(long double _Complex); +double _Complex __builtin_conj(double _Complex); +float _Complex __builtin_conjf(float _Complex); +long double _Complex __builtin_conjl(long double _Complex); +double __builtin_copysign(double, double); +float __builtin_copysignf(float, float); +long double __builtin_copysignl(long double, long double); +double __builtin_cos(double); +float __builtin_cosf(float); +double __builtin_cosh(double); +float __builtin_coshf(float); +long double __builtin_coshl(long double); +long double __builtin_cosl(long double); +double _Complex __builtin_cpow(double _Complex, double _Complex); +float _Complex __builtin_cpowf(float _Complex, float _Complex); +long double _Complex __builtin_cpowl(long double _Complex, long double _Complex); +double _Complex __builtin_cproj(double _Complex); +float _Complex __builtin_cprojf(float _Complex); +long double _Complex __builtin_cprojl(long double _Complex); +double __builtin_creal(double _Complex); +float __builtin_crealf(float _Complex); +long double __builtin_creall(long double _Complex); +double _Complex __builtin_csin(double _Complex); +float _Complex __builtin_csinf(float _Complex); +double _Complex __builtin_csinh(double _Complex); +float _Complex __builtin_csinhf(float _Complex); +long double _Complex __builtin_csinhl(long double _Complex); +long double _Complex __builtin_csinl(long double _Complex); +double _Complex __builtin_csqrt(double _Complex); +float _Complex __builtin_csqrtf(float _Complex); +long double _Complex __builtin_csqrtl(long double _Complex); +double _Complex __builtin_ctan(double _Complex); +float _Complex __builtin_ctanf(float _Complex); +double _Complex __builtin_ctanh(double _Complex); +float _Complex __builtin_ctanhf(float _Complex); +long double _Complex __builtin_ctanhl(long double _Complex); +long double _Complex __builtin_ctanl(long double _Complex); +int __builtin_ctz(unsigned); +int __builtin_ctzl(unsigned long); +int __builtin_ctzll(unsigned long long); +double __builtin_drem(double, double); +float __builtin_dremf(float, float); +long double __builtin_dreml(long double, long double); +double __builtin_erf(double); +double __builtin_erfc(double); +float __builtin_erfcf(float); +long double __builtin_erfcl(long double); +float __builtin_erff(float); +long double __builtin_erfl(long double); +double __builtin_exp(double); +double __builtin_exp10(double); +float __builtin_exp10f(float); +long double __builtin_exp10l(long double); +double __builtin_exp2(double); +float __builtin_exp2f(float); +long double __builtin_exp2l(long double); +float __builtin_expf(float); +long double __builtin_expl(long double); +double __builtin_expm1(double); +float __builtin_expm1f(float); +long double __builtin_expm1l(long double); +double __builtin_fabs(double); +float __builtin_fabsf(float); +long double __builtin_fabsl(long double); +double __builtin_fdim(double, double); +float __builtin_fdimf(float, float); +long double __builtin_fdiml(long double, long double); +int __builtin_finite(double); +int __builtin_finitef(float); +int __builtin_finitel(long double); +double __builtin_floor(double); +float __builtin_floorf(float); +long double __builtin_floorl(long double); +double __builtin_fma(double, double, double); +float __builtin_fmaf(float, float, float); +long double __builtin_fmal(long double, long double, long double); +double __builtin_fmax(double, double); +float __builtin_fmaxf(float, float); +long double __builtin_fmaxl(long double, long double); +double __builtin_fmin(double, double); +float __builtin_fminf(float, float); +long double __builtin_fminl(long double, long double); +double __builtin_fmod(double, double); +float __builtin_fmodf(float, float); +long double __builtin_fmodl(long double, long double); +int __builtin_fpclassify(int, int, int, int, int, ...); +double __builtin_frexp(double, int*); +float __builtin_frexpf(float, int*); +long double __builtin_frexpl(long double, int*); +double __builtin_gamma(double); +double __builtin_gamma_r(double, int*); +float __builtin_gammaf(float); +float __builtin_gammaf_r(float, int*); +long double __builtin_gammal(long double); +long double __builtin_gammal_r(long double, int*); +double __builtin_huge_val(); +float __builtin_huge_valf(); +long double __builtin_huge_vall(); +double __builtin_hypot(double, double); +float __builtin_hypotf(float, float); +long double __builtin_hypotl(long double, long double); +int __builtin_iceil(double); +int __builtin_iceilf(float); +int __builtin_iceill(long double); +int __builtin_ifloor(double); +int __builtin_ifloorf(float); +int __builtin_ifloorl(long double); +int __builtin_ilogb(double); +int __builtin_ilogbf(float); +int __builtin_ilogbl(long double); +double __builtin_inf(); +float __builtin_inff(); +long double __builtin_infl(); +int __builtin_irint(double); +int __builtin_irintf(float); +int __builtin_irintl(long double); +int __builtin_iround(double); +int __builtin_iroundf(float); +int __builtin_iroundl(long double); +int __builtin_isfinite(); +int __builtin_isgreater(); +int __builtin_isgreaterequal(); +int __builtin_isinf(double); +int __builtin_isinf_sign(); +int __builtin_isinff(float); +int __builtin_isinfl(long double); +int __builtin_isless(); +int __builtin_islessequal(); +int __builtin_islessgreater(); +int __builtin_isnan(double); +int __builtin_isnanf(float); +int __builtin_isnanl(long double); +int __builtin_isnormal(); +int __builtin_isunordered(); +double __builtin_j0(double); +float __builtin_j0f(float); +long double __builtin_j0l(long double); +double __builtin_j1(double); +float __builtin_j1f(float); +long double __builtin_j1l(long double); +double __builtin_jn(int, double); +float __builtin_jnf(int, float); +long double __builtin_jnl(int, long double); +long __builtin_labs(long); +long __builtin_lceil(double); +long __builtin_lceilf(float); +long __builtin_lceill(long double); +double __builtin_ldexp(double, int); +float __builtin_ldexpf(float, int); +long double __builtin_ldexpl(long double, int); +long __builtin_lfloor(double); +long __builtin_lfloorf(float); +long __builtin_lfloorl(long double); +double __builtin_lgamma(double); +double __builtin_lgamma_r(double, int*); +float __builtin_lgammaf(float); +float __builtin_lgammaf_r(float, int*); +long double __builtin_lgammal(long double); +long double __builtin_lgammal_r(long double, int*); +long long __builtin_llabs(long long); +long long __builtin_llceil(double); +long long __builtin_llceilf(float); +long long __builtin_llceill(long double); +long long __builtin_llfloor(double); +long long __builtin_llfloorf(float); +long long __builtin_llfloorl(long double); +long long __builtin_llrint(double); +long long __builtin_llrintf(float); +long long __builtin_llrintl(long double); +long long __builtin_llround(double); +long long __builtin_llroundf(float); +long long __builtin_llroundl(long double); +double __builtin_log(double); +double __builtin_log10(double); +float __builtin_log10f(float); +long double __builtin_log10l(long double); +double __builtin_log1p(double); +float __builtin_log1pf(float); +long double __builtin_log1pl(long double); +double __builtin_log2(double); +float __builtin_log2f(float); +long double __builtin_log2l(long double); +double __builtin_logb(double); +float __builtin_logbf(float); +long double __builtin_logbl(long double); +float __builtin_logf(float); +long double __builtin_logl(long double); +long __builtin_lrint(double); +long __builtin_lrintf(float); +long __builtin_lrintl(long double); +long __builtin_lround(double); +long __builtin_lroundf(float); +long __builtin_lroundl(long double); +double __builtin_modf(double, double*); +float __builtin_modff(float, float*); +long double __builtin_modfl(long double, long double*); +_Bool __builtin_mul_overflow(); +_Bool __builtin_mul_overflow_p(); +double __builtin_nan(const char*); +float __builtin_nanf(const char*); +long double __builtin_nanl(const char*); +double __builtin_nans(const char*); +float __builtin_nansf(const char*); +long double __builtin_nansl(const char*); +double __builtin_nearbyint(double); +float __builtin_nearbyintf(float); +long double __builtin_nearbyintl(long double); +double __builtin_nextafter(double, double); +float __builtin_nextafterf(float, float); +long double __builtin_nextafterl(long double, long double); +double __builtin_nexttoward(double, long double); +float __builtin_nexttowardf(float, long double); +long double __builtin_nexttowardl(long double, long double); +int __builtin_parity(unsigned); +int __builtin_parityl(unsigned long); +int __builtin_parityll(unsigned long long); +double __builtin_pow(double, double); +double __builtin_pow10(double); +float __builtin_pow10f(float); +long double __builtin_pow10l(long double); +float __builtin_powf(float, float); +double __builtin_powi(double, int); +float __builtin_powif(float, int); +long double __builtin_powil(long double, int); +long double __builtin_powl(long double, long double); +double __builtin_remainder(double, double); +float __builtin_remainderf(float, float); +long double __builtin_remainderl(long double, long double); +double __builtin_remquo(double, double, int*); +float __builtin_remquof(float, float, int*); +long double __builtin_remquol(long double, long double, int*); +double __builtin_rint(double); +float __builtin_rintf(float); +long double __builtin_rintl(long double); +double __builtin_round(double); +float __builtin_roundf(float); +long double __builtin_roundl(long double); +_Bool __builtin_sadd_overflow(int, int, int*); +_Bool __builtin_saddl_overflow(long, long, long*); +_Bool __builtin_saddll_overflow(long long, long long, long long*); +double __builtin_scalb(double, double); +float __builtin_scalbf(float, float); +long double __builtin_scalbl(long double, long double); +double __builtin_scalbln(double, long); +float __builtin_scalblnf(float, long); +long double __builtin_scalblnl(long double, long); +double __builtin_scalbn(double, int); +float __builtin_scalbnf(float, int); +long double __builtin_scalbnl(long double, int); +int __builtin_signbit(double); +int __builtin_signbitf(float); +int __builtin_signbitl(long double); +double __builtin_significand(double); +float __builtin_significandf(float); +long double __builtin_significandl(long double); +double __builtin_sin(double); +void __builtin_sincos(double, double*, double*); +void __builtin_sincosf(float, float*, float*); +void __builtin_sincosl(long double, long double*, long double*); +float __builtin_sinf(float); +double __builtin_sinh(double); +float __builtin_sinhf(float); +long double __builtin_sinhl(long double); +long double __builtin_sinl(long double); +_Bool __builtin_smul_overflow(int, int, int*); +_Bool __builtin_smull_overflow(long, long, long*); +_Bool __builtin_smulll_overflow(long long, long long, long long*); +double __builtin_sqrt(double); +float __builtin_sqrtf(float); +long double __builtin_sqrtl(long double); +_Bool __builtin_ssub_overflow(int, int, int*); +_Bool __builtin_ssubl_overflow(long, long, long*); +_Bool __builtin_ssubll_overflow(long long, long long, long long*); +_Bool __builtin_sub_overflow(); +_Bool __builtin_sub_overflow_p(); +double __builtin_tan(double); +float __builtin_tanf(float); +double __builtin_tanh(double); +float __builtin_tanhf(float); +long double __builtin_tanhl(long double); +long double __builtin_tanl(long double); +double __builtin_tgamma(double); +float __builtin_tgammaf(float); +long double __builtin_tgammal(long double); +double __builtin_trunc(double); +float __builtin_truncf(float); +long double __builtin_truncl(long double); +_Bool __builtin_uadd_overflow(unsigned, unsigned, unsigned*); +_Bool __builtin_uaddl_overflow(unsigned long, unsigned long, unsigned long*); +_Bool __builtin_uaddll_overflow(unsigned long long, unsigned long long, unsigned long long*); +_Bool __builtin_umul_overflow(unsigned, unsigned, unsigned*); +_Bool __builtin_umull_overflow(unsigned long, unsigned long, unsigned long*); +_Bool __builtin_umulll_overflow(unsigned long long, unsigned long long, unsigned long long*); +_Bool __builtin_usub_overflow(unsigned, unsigned, unsigned*); +_Bool __builtin_usubl_overflow(unsigned long, unsigned long, unsigned long*); +_Bool __builtin_usubll_overflow(unsigned long long, unsigned long long, unsigned long long*); +double __builtin_y0(double); +float __builtin_y0f(float); +long double __builtin_y0l(long double); +double __builtin_y1(double); +float __builtin_y1f(float); +long double __builtin_y1l(long double); +double __builtin_yn(int, double); +float __builtin_ynf(int, float); +long double __builtin_ynl(int, long double); diff --git a/src/ansi-c/gcc_builtin_headers_mem_string.h b/src/ansi-c/gcc_builtin_headers_mem_string.h new file mode 100644 index 00000000000..dca5af04300 --- /dev/null +++ b/src/ansi-c/gcc_builtin_headers_mem_string.h @@ -0,0 +1,118 @@ +void __builtin___bnd_chk_ptr_bounds(const void*, __CPROVER_size_t); +void __builtin___bnd_chk_ptr_lbounds(const void*); +void __builtin___bnd_chk_ptr_ubounds(const void*); +void* __builtin___bnd_copy_ptr_bounds(const void*, const void*); +const void* __builtin___bnd_get_ptr_lbound(const void*); +const void* __builtin___bnd_get_ptr_ubound(const void*); +void* __builtin___bnd_init_ptr_bounds(const void*); +void* __builtin___bnd_narrow_ptr_bounds(const void*, const void*, __CPROVER_size_t); +void* __builtin___bnd_null_ptr_bounds(const void*); +void* __builtin___bnd_set_ptr_bounds(const void*, __CPROVER_size_t); +void __builtin___bnd_store_ptr_bounds(void**, const void*); +const void* __builtin___chkp_bndldx(const void*, const void*); +void __builtin___clear_cache(void*, void*); +void* __builtin___memcpy_chk(void*, const void*, __CPROVER_size_t, __CPROVER_size_t); +void* __builtin___memmove_chk(void*, const void*, __CPROVER_size_t, __CPROVER_size_t); +void* __builtin___mempcpy_chk(void*, const void*, __CPROVER_size_t, __CPROVER_size_t); +void* __builtin___memset_chk(void*, int, __CPROVER_size_t, __CPROVER_size_t); +char* __builtin___stpcpy(char *s1, const char *s2); +char* __builtin___stpcpy_chk(char*, const char*, __CPROVER_size_t); +char* __builtin___stpncpy_chk(char*, const char*, __CPROVER_size_t, __CPROVER_size_t); +char* __builtin___strcat_chk(char*, const char*, __CPROVER_size_t); +char* __builtin___strcpy_chk(char*, const char*, __CPROVER_size_t); +char* __builtin___strncat_chk(char*, const char*, __CPROVER_size_t, __CPROVER_size_t); +char* __builtin___strncpy_chk(char*, const char*, __CPROVER_size_t, __CPROVER_size_t); +void* __builtin_aggregate_incoming_address(); +void* __builtin_aligned_alloc(__CPROVER_size_t, __CPROVER_size_t); +void* __builtin_alloca(__CPROVER_size_t); +void* __builtin_assume_aligned(const void*, __CPROVER_size_t, ...); +int __builtin_bcmp(const void*, const void*, __CPROVER_size_t); +void __builtin_bcopy(const void*, void*, __CPROVER_size_t); +short unsigned int __builtin_bswap16(short unsigned int); +unsigned int __builtin_bswap32(unsigned int); +long long unsigned int __builtin_bswap64(long long unsigned int); +void __builtin_bzero(void*, __CPROVER_size_t); +void* __builtin_calloc(__CPROVER_size_t, __CPROVER_size_t); +void* __builtin_chkp_memcpy_nobnd(void*, const void*, __CPROVER_size_t); +void* __builtin_chkp_memcpy_nobnd_nochk(void*, const void*, __CPROVER_size_t); +void* __builtin_chkp_memcpy_nochk(void*, const void*, __CPROVER_size_t); +void* __builtin_chkp_memmove_nobnd(void*, const void*, __CPROVER_size_t); +void* __builtin_chkp_memmove_nobnd_nochk(void*, const void*, __CPROVER_size_t); +void* __builtin_chkp_memmove_nochk(void*, const void*, __CPROVER_size_t); +void* __builtin_chkp_mempcpy_nobnd(void*, const void*, __CPROVER_size_t); +void* __builtin_chkp_mempcpy_nobnd_nochk(void*, const void*, __CPROVER_size_t); +void* __builtin_chkp_mempcpy_nochk(void*, const void*, __CPROVER_size_t); +void* __builtin_chkp_memset_nobnd(void*, int, __CPROVER_size_t); +void* __builtin_chkp_memset_nobnd_nochk(void*, int, __CPROVER_size_t); +void* __builtin_chkp_memset_nochk(void*, int, __CPROVER_size_t); +int __builtin_clrsb(int); +int __builtin_clrsbl(long); +int __builtin_clrsbll(long long); +int __builtin_clz(unsigned); +int __builtin_clzl(unsigned long); +int __builtin_clzll(unsigned long long); +int __builtin_ctz(unsigned); +int __builtin_ctzl(unsigned long); +int __builtin_ctzll(unsigned long long); +char* __builtin_dcgettext(const char*, const char*, int); +char* __builtin_dgettext(const char*, const char*); +void* __builtin_extract_return_addr(void*); +int __builtin_ffs(int); +int __builtin_ffsl(long); +int __builtin_ffsll(long long); +void* __builtin_frame_address(unsigned); +void __builtin_free(void*); +void* __builtin_frob_return_addr(void*); +char* __builtin_gettext(const char*); +char* __builtin_index(const char*, int); +int __builtin_isalnum(int); +int __builtin_isalpha(int); +int __builtin_isascii(int); +int __builtin_isblank(int); +int __builtin_iscntrl(int); +int __builtin_isdigit(int); +int __builtin_isgraph(int); +int __builtin_islower(int); +int __builtin_isprint(int); +int __builtin_ispunct(int); +int __builtin_isspace(int); +int __builtin_isupper(int); +int __builtin_isxdigit(int); +void* __builtin_malloc(__CPROVER_size_t); +void* __builtin_memchr(const void*, int, __CPROVER_size_t); +int __builtin_memcmp(const void*, const void*, __CPROVER_size_t); +void* __builtin_memcpy(void*, const void*, __CPROVER_size_t); +void* __builtin_memmove(void*, const void*, __CPROVER_size_t); +void* __builtin_mempcpy(void*, const void*, __CPROVER_size_t); +void* __builtin_memset(void*, int, __CPROVER_size_t); +__CPROVER_size_t __builtin_object_size(const void*, int); +int __builtin_popcount(unsigned); +int __builtin_popcountll(unsigned long long int x); +int __builtin_posix_memalign(void**, __CPROVER_size_t, __CPROVER_size_t); +void __builtin_prefetch(const void*, ...); +void* __builtin_realloc(void*, __CPROVER_size_t); +void* __builtin_return_address(unsigned); +char* __builtin_rindex(const char*, int); +char* __builtin_stpcpy(char*, const char*); +char* __builtin_stpncpy(char*, const char*, __CPROVER_size_t); +int __builtin_strcasecmp(const char*, const char*); +char* __builtin_strcat(char*, const char*); +char* __builtin_strchr(const char*, int); +int __builtin_strcmp(const char*, const char*); +char* __builtin_strcpy(char*, const char*); +__CPROVER_size_t __builtin_strcspn(const char*, const char*); +char* __builtin_strdup(const char*); +__CPROVER_size_t __builtin_strftime(char*, __CPROVER_size_t, const char*, const struct tm*); +__CPROVER_size_t __builtin_strlen(const char*); +int __builtin_strncasecmp(const char*, const char*, __CPROVER_size_t); +char* __builtin_strncat(char*, const char*, __CPROVER_size_t); +int __builtin_strncmp(const char*, const char*, __CPROVER_size_t); +char* __builtin_strncpy(char*, const char*, __CPROVER_size_t); +char* __builtin_strndup(const char*, __CPROVER_size_t); +char* __builtin_strpbrk(const char*, const char*); +char* __builtin_strrchr(const char*, int); +__CPROVER_size_t __builtin_strspn(const char*, const char*); +char* __builtin_strstr(const char*, const char*); +int __builtin_toascii(int); +int __builtin_tolower(int); +int __builtin_toupper(int); diff --git a/src/ansi-c/gcc_builtin_headers_omp.h b/src/ansi-c/gcc_builtin_headers_omp.h new file mode 100644 index 00000000000..6b7b28957b0 --- /dev/null +++ b/src/ansi-c/gcc_builtin_headers_omp.h @@ -0,0 +1,90 @@ +int __builtin_omp_get_thread_num(); +int __builtin_omp_get_num_threads(); +int __builtin_omp_get_team_num(); +int __builtin_omp_get_num_teams(); +void __builtin_GOMP_atomic_start(); +void __builtin_GOMP_atomic_end(); +void __builtin_GOMP_barrier(); +_Bool __builtin_GOMP_barrier_cancel(); +void __builtin_GOMP_taskwait(); +void __builtin_GOMP_taskyield(); +void __builtin_GOMP_taskgroup_start(); +void __builtin_GOMP_taskgroup_end(); +_Bool __builtin_GOMP_cancel(int, _Bool); +_Bool __builtin_GOMP_cancellation_point(int); +void __builtin_GOMP_critical_start(); +void __builtin_GOMP_critical_end(); +void __builtin_GOMP_critical_name_start(void**); +void __builtin_GOMP_critical_name_end(void**); +_Bool __builtin_GOMP_loop_static_start(long, long, long, long, long*, long*); +_Bool __builtin_GOMP_loop_dynamic_start(long, long, long, long, long*, long*); +_Bool __builtin_GOMP_loop_guided_start(long, long, long, long, long*, long*); +_Bool __builtin_GOMP_loop_runtime_start(long, long, long, long*, long*); +_Bool __builtin_GOMP_loop_nonmonotonic_dynamic_start(long, long, long, long, long*, long*); +_Bool __builtin_GOMP_loop_nonmonotonic_guided_start(long, long, long, long, long*, long*); +_Bool __builtin_GOMP_loop_ordered_static_start(long, long, long, long, long*, long*); +_Bool __builtin_GOMP_loop_ordered_dynamic_start(long, long, long, long, long*, long*); +_Bool __builtin_GOMP_loop_ordered_guided_start(long, long, long, long, long*, long*); +_Bool __builtin_GOMP_loop_ordered_runtime_start(long, long, long, long*, long*); +_Bool __builtin_GOMP_loop_doacross_static_start(unsigned, long*, long, long*, long*); +_Bool __builtin_GOMP_loop_doacross_dynamic_start(unsigned, long*, long, long*, long*); +_Bool __builtin_GOMP_loop_doacross_guided_start(unsigned, long*, long, long*, long*); +_Bool __builtin_GOMP_loop_doacross_runtime_start(unsigned, long*, long*, long*); +_Bool __builtin_GOMP_loop_static_next(long*, long*); +_Bool __builtin_GOMP_loop_dynamic_next(long*, long*); +_Bool __builtin_GOMP_loop_guided_next(long*, long*); +_Bool __builtin_GOMP_loop_runtime_next(long*, long*); +_Bool __builtin_GOMP_loop_nonmonotonic_dynamic_next(long*, long*); +_Bool __builtin_GOMP_loop_nonmonotonic_guided_next(long*, long*); +_Bool __builtin_GOMP_loop_ordered_static_next(long*, long*); +_Bool __builtin_GOMP_loop_ordered_dynamic_next(long*, long*); +_Bool __builtin_GOMP_loop_ordered_guided_next(long*, long*); +_Bool __builtin_GOMP_loop_ordered_runtime_next(long*, long*); +_Bool __builtin_GOMP_loop_ull_static_start(_Bool, unsigned long long, unsigned long long, unsigned long long, unsigned long long, unsigned long long*, unsigned long long*); +_Bool __builtin_GOMP_loop_ull_dynamic_start(_Bool, unsigned long long, unsigned long long, unsigned long long, unsigned long long, unsigned long long*, unsigned long long*); +_Bool __builtin_GOMP_loop_ull_guided_start(_Bool, unsigned long long, unsigned long long, unsigned long long, unsigned long long, unsigned long long*, unsigned long long*); +_Bool __builtin_GOMP_loop_ull_runtime_start(_Bool, unsigned long long, unsigned long long, unsigned long long, unsigned long long*, unsigned long long*); +_Bool __builtin_GOMP_loop_ull_nonmonotonic_dynamic_start(_Bool, unsigned long long, unsigned long long, unsigned long long, unsigned long long, unsigned long long*, unsigned long long*); +_Bool __builtin_GOMP_loop_ull_nonmonotonic_guided_start(_Bool, unsigned long long, unsigned long long, unsigned long long, unsigned long long, unsigned long long*, unsigned long long*); +_Bool __builtin_GOMP_loop_ull_ordered_static_start(_Bool, unsigned long long, unsigned long long, unsigned long long, unsigned long long, unsigned long long*, unsigned long long*); +_Bool __builtin_GOMP_loop_ull_ordered_dynamic_start(_Bool, unsigned long long, unsigned long long, unsigned long long, unsigned long long, unsigned long long*, unsigned long long*); +_Bool __builtin_GOMP_loop_ull_ordered_guided_start(_Bool, unsigned long long, unsigned long long, unsigned long long, unsigned long long, unsigned long long*, unsigned long long*); +_Bool __builtin_GOMP_loop_ull_ordered_runtime_start(_Bool, unsigned long long, unsigned long long, unsigned long long, unsigned long long*, unsigned long long*); +_Bool __builtin_GOMP_loop_ull_doacross_static_start(unsigned, unsigned long long*, unsigned long long, unsigned long long*, unsigned long long*); +_Bool __builtin_GOMP_loop_ull_doacross_dynamic_start(unsigned, unsigned long long*, unsigned long long, unsigned long long*, unsigned long long*); +_Bool __builtin_GOMP_loop_ull_doacross_guided_start(unsigned, unsigned long long*, unsigned long long, unsigned long long*, unsigned long long*); +_Bool __builtin_GOMP_loop_ull_doacross_runtime_start(unsigned, unsigned long long*, unsigned long long*, unsigned long long*); +_Bool __builtin_GOMP_loop_ull_static_next(unsigned long long*, unsigned long long*); +_Bool __builtin_GOMP_loop_ull_dynamic_next(unsigned long long*, unsigned long long*); +_Bool __builtin_GOMP_loop_ull_guided_next(unsigned long long*, unsigned long long*); +_Bool __builtin_GOMP_loop_ull_runtime_next(unsigned long long*, unsigned long long*); +_Bool __builtin_GOMP_loop_ull_nonmonotonic_dynamic_next(unsigned long long*, unsigned long long*); +_Bool __builtin_GOMP_loop_ull_nonmonotonic_guided_next(unsigned long long*, unsigned long long*); +_Bool __builtin_GOMP_loop_ull_ordered_static_next(unsigned long long*, unsigned long long*); +_Bool __builtin_GOMP_loop_ull_ordered_dynamic_next(unsigned long long*, unsigned long long*); +_Bool __builtin_GOMP_loop_ull_ordered_guided_next(unsigned long long*, unsigned long long*); +_Bool __builtin_GOMP_loop_ull_ordered_runtime_next(unsigned long long*, unsigned long long*); +void __builtin_GOMP_loop_end(); +_Bool __builtin_GOMP_loop_end_cancel(); +void __builtin_GOMP_loop_end_nowait(); +void __builtin_GOMP_ordered_start(); +void __builtin_GOMP_ordered_end(); +void __builtin_GOMP_doacross_post(void*); +void __builtin_GOMP_doacross_wait(long, ...); +void __builtin_GOMP_doacross_ull_post(void*); +void __builtin_GOMP_doacross_ull_wait(unsigned long long, ...); +unsigned __builtin_GOMP_sections_start(unsigned); +unsigned __builtin_GOMP_sections_next(); +void __builtin_GOMP_sections_end(); +_Bool __builtin_GOMP_sections_end_cancel(); +void __builtin_GOMP_sections_end_nowait(); +_Bool __builtin_GOMP_single_start(); +void* __builtin_GOMP_single_copy_start(); +void __builtin_GOMP_single_copy_end(void*); +void __builtin_GOMP_offload_register_ver(int, void*, int, void*); +void __builtin_GOMP_offload_unregister_ver(int, void*, int, void*); +void __builtin_GOMP_target_data_ext(int, __CPROVER_size_t, void*, void*, void*); +void __builtin_GOMP_target_end_data(); +void __builtin_GOMP_target_update_ext(int, __CPROVER_size_t, void*, void*, void*, unsigned, void*); +void __builtin_GOMP_target_enter_exit_data(int, __CPROVER_size_t, void*, void*, void*, unsigned, void*); +void __builtin_GOMP_teams(unsigned, unsigned); diff --git a/src/ansi-c/gcc_builtin_headers_tm.h b/src/ansi-c/gcc_builtin_headers_tm.h new file mode 100644 index 00000000000..bee9771f29a --- /dev/null +++ b/src/ansi-c/gcc_builtin_headers_tm.h @@ -0,0 +1,44 @@ +unsigned __builtin__ITM_beginTransaction(unsigned, ...); +void __builtin__ITM_commitTransaction(); +void __builtin__ITM_commitTransactionEH(void*); +void __builtin__ITM_abortTransaction(int); +void __builtin__ITM_changeTransactionMode(int); +void __builtin__ITM_memcpyRtWt(void*, const void*, __CPROVER_size_t); +void __builtin__ITM_memcpyRnWt(void*, const void*, __CPROVER_size_t); +void __builtin__ITM_memcpyRtWn(void*, const void*, __CPROVER_size_t); +void __builtin__ITM_memmoveRtWt(void*, const void*, __CPROVER_size_t); +void __builtin__ITM_memsetW(void*, int, __CPROVER_size_t); +void* __builtin__ITM_malloc(__CPROVER_size_t); +void* __builtin__ITM_calloc(__CPROVER_size_t, __CPROVER_size_t); +void __builtin__ITM_LB(volatile void*, __CPROVER_size_t); +void* __builtin__ITM_getTMCloneOrIrrevocable(void*); +void* __builtin__ITM_getTMCloneSafe(void*); +void __builtin__ITM_free(void*); +void __builtin__ITM_LU1(volatile void*); +void __builtin__ITM_LU2(volatile void*); +void __builtin__ITM_LU4(volatile void*); +void __builtin__ITM_LU8(volatile void*); +void __builtin__ITM_LF(volatile void*); +void __builtin__ITM_LD(volatile void*); +void __builtin__ITM_LE(volatile void*); +void __builtin__ITM_WF(volatile void*, float); +void __builtin__ITM_WaRF(volatile void*, float); +void __builtin__ITM_WaWF(volatile void*, float); +void __builtin__ITM_WD(volatile void*, double); +void __builtin__ITM_WaRD(volatile void*, double); +void __builtin__ITM_WaWD(volatile void*, double); +void __builtin__ITM_WE(volatile void*, long double); +void __builtin__ITM_WaRE(volatile void*, long double); +void __builtin__ITM_WaWE(volatile void*, long double); +float __builtin__ITM_RF(volatile void*); +float __builtin__ITM_RaRF(volatile void*); +float __builtin__ITM_RaWF(volatile void*); +float __builtin__ITM_RfWF(volatile void*); +double __builtin__ITM_RD(double*); +double __builtin__ITM_RaRD(double*); +double __builtin__ITM_RaWD(double*); +double __builtin__ITM_RfWD(double*); +long double __builtin__ITM_RE(volatile void*); +long double __builtin__ITM_RaRE(volatile void*); +long double __builtin__ITM_RaWE(volatile void*); +long double __builtin__ITM_RfWE(volatile void*); diff --git a/src/ansi-c/gcc_builtin_headers_ubsan.h b/src/ansi-c/gcc_builtin_headers_ubsan.h new file mode 100644 index 00000000000..4536f2b1d08 --- /dev/null +++ b/src/ansi-c/gcc_builtin_headers_ubsan.h @@ -0,0 +1,92 @@ +void __builtin___asan_init(); +void __builtin___asan_version_mismatch_check_v8(); +void __builtin___asan_report_load1(void*); +void __builtin___asan_report_load2(void*); +void __builtin___asan_report_load4(void*); +void __builtin___asan_report_load8(void*); +void __builtin___asan_report_load16(void*); +void __builtin___asan_report_store1(void*); +void __builtin___asan_report_store2(void*); +void __builtin___asan_report_store4(void*); +void __builtin___asan_report_store8(void*); +void __builtin___asan_report_store16(void*); +void __builtin___asan_report_load1_noabort(void*); +void __builtin___asan_report_load2_noabort(void*); +void __builtin___asan_report_load4_noabort(void*); +void __builtin___asan_report_load8_noabort(void*); +void __builtin___asan_report_load16_noabort(void*); +void __builtin___asan_report_store1_noabort(void*); +void __builtin___asan_report_store2_noabort(void*); +void __builtin___asan_report_store4_noabort(void*); +void __builtin___asan_report_store8_noabort(void*); +void __builtin___asan_report_store16_noabort(void*); +void __builtin___asan_load1(void*); +void __builtin___asan_load2(void*); +void __builtin___asan_load4(void*); +void __builtin___asan_load8(void*); +void __builtin___asan_load16(void*); +void __builtin___asan_store1(void*); +void __builtin___asan_store2(void*); +void __builtin___asan_store4(void*); +void __builtin___asan_store8(void*); +void __builtin___asan_store16(void*); +void __builtin___asan_load1_noabort(void*); +void __builtin___asan_load2_noabort(void*); +void __builtin___asan_load4_noabort(void*); +void __builtin___asan_load8_noabort(void*); +void __builtin___asan_load16_noabort(void*); +void __builtin___asan_store1_noabort(void*); +void __builtin___asan_store2_noabort(void*); +void __builtin___asan_store4_noabort(void*); +void __builtin___asan_store8_noabort(void*); +void __builtin___asan_store16_noabort(void*); +void __builtin___asan_handle_no_return(); +void __builtin___asan_before_dynamic_init(const void*); +void __builtin___asan_after_dynamic_init(); +void __builtin___tsan_init(); +void __builtin___tsan_func_entry(void*); +void __builtin___tsan_func_exit(void*); +void __builtin___tsan_vptr_update(void*, void*); +void __builtin___tsan_read1(void*); +void __builtin___tsan_read2(void*); +void __builtin___tsan_read4(void*); +void __builtin___tsan_read8(void*); +void __builtin___tsan_read16(void*); +void __builtin___tsan_write1(void*); +void __builtin___tsan_write2(void*); +void __builtin___tsan_write4(void*); +void __builtin___tsan_write8(void*); +void __builtin___tsan_write16(void*); +void __builtin___tsan_atomic_thread_fence(int); +void __builtin___tsan_atomic_signal_fence(int); +void __builtin___ubsan_handle_divrem_overflow(void*, void*, void*); +void __builtin___ubsan_handle_shift_out_of_bounds(void*, void*, void*); +void __builtin___ubsan_handle_builtin_unreachable(void*); +void __builtin___ubsan_handle_missing_return(void*); +void __builtin___ubsan_handle_vla_bound_not_positive(void*, void*); +void __builtin___ubsan_handle_type_mismatch(void*, void*); +void __builtin___ubsan_handle_add_overflow(void*, void*, void*); +void __builtin___ubsan_handle_sub_overflow(void*, void*, void*); +void __builtin___ubsan_handle_mul_overflow(void*, void*, void*); +void __builtin___ubsan_handle_negate_overflow(void*, void*); +void __builtin___ubsan_handle_load_invalid_value(void*, void*); +void __builtin___ubsan_handle_divrem_overflow_abort(void*, void*, void*); +void __builtin___ubsan_handle_shift_out_of_bounds_abort(void*, void*, void*); +void __builtin___ubsan_handle_vla_bound_not_positive_abort(void*, void*); +void __builtin___ubsan_handle_type_mismatch_abort(void*, void*); +void __builtin___ubsan_handle_add_overflow_abort(void*, void*, void*); +void __builtin___ubsan_handle_sub_overflow_abort(void*, void*, void*); +void __builtin___ubsan_handle_mul_overflow_abort(void*, void*, void*); +void __builtin___ubsan_handle_negate_overflow_abort(void*, void*); +void __builtin___ubsan_handle_load_invalid_value_abort(void*, void*); +void __builtin___ubsan_handle_float_cast_overflow(void*, void*); +void __builtin___ubsan_handle_float_cast_overflow_abort(void*, void*); +void __builtin___ubsan_handle_out_of_bounds(void*, void*); +void __builtin___ubsan_handle_out_of_bounds_abort(void*, void*); +void __builtin___ubsan_handle_nonnull_arg(void*); +void __builtin___ubsan_handle_nonnull_arg_abort(void*); +void __builtin___ubsan_handle_nonnull_return(void*); +void __builtin___ubsan_handle_nonnull_return_abort(void*); +void __builtin___ubsan_handle_dynamic_type_cache_miss(void*, void*, void*); +void __builtin___ubsan_handle_dynamic_type_cache_miss_abort(void*, void*, void*); +void __builtin___sanitizer_cov_trace_pc(); diff --git a/src/ansi-c/get-gcc-builtins.sh b/src/ansi-c/get-gcc-builtins.sh index dd02b98c99d..fd06b79945d 100755 --- a/src/ansi-c/get-gcc-builtins.sh +++ b/src/ansi-c/get-gcc-builtins.sh @@ -10,10 +10,11 @@ fi builtin_defs=" \ builtin-types.def builtins.def sync-builtins.def \ omp-builtins.def gtm-builtins.def cilk-builtins.def cilkplus.def \ - sanitizer.def chkp-builtins.def hsa-builtins.def" + sanitizer.def chkp-builtins.def hsa-builtins.def brig-builtins.def \ + config/i386/i386-builtin.def config/i386/i386-builtin-types.def" for f in $builtin_defs ; do - [ ! -s $f ] || continue + [ ! -s `basename $f` ] || continue echo Downloading http://gcc.gnu.org/svn/gcc/trunk/gcc/$f svn export http://gcc.gnu.org/svn/gcc/trunk/gcc/$f > /dev/null done @@ -25,6 +26,31 @@ cat > gcc-builtins.h < #include +typedef char __gcc_v8qi __attribute__ ((__vector_size__ (8))); +typedef char __gcc_v16qi __attribute__ ((__vector_size__ (16))); +typedef char __gcc_v32qi __attribute__ ((__vector_size__ (32))); +typedef char __gcc_v64qi __attribute__ ((__vector_size__ (64))); +typedef int __gcc_v2si __attribute__ ((__vector_size__ (8))); +typedef int __gcc_v4si __attribute__ ((__vector_size__ (16))); +typedef int __gcc_v8si __attribute__ ((__vector_size__ (32))); +typedef int __gcc_v16si __attribute__ ((__vector_size__ (64))); +typedef short __gcc_v4hi __attribute__ ((__vector_size__ (8))); +typedef short __gcc_v8hi __attribute__ ((__vector_size__ (16))); +typedef short __gcc_v16hi __attribute__ ((__vector_size__ (32))); +typedef short __gcc_v32hi __attribute__ ((__vector_size__ (64))); +typedef float __gcc_v2sf __attribute__ ((__vector_size__ (8))); +typedef float __gcc_v4sf __attribute__ ((__vector_size__ (16))); +typedef float __gcc_v8sf __attribute__ ((__vector_size__ (32))); +typedef float __gcc_v16sf __attribute__ ((__vector_size__ (64))); +typedef double __gcc_v2df __attribute__ ((__vector_size__ (16))); +typedef double __gcc_v4df __attribute__ ((__vector_size__ (32))); +typedef double __gcc_v8df __attribute__ ((__vector_size__ (64))); +typedef long long __gcc_v1di __attribute__ ((__vector_size__ (8))); +typedef long long __gcc_v2di __attribute__ ((__vector_size__ (16))); +typedef long long __gcc_v4di __attribute__ ((__vector_size__ (32))); +typedef long long __gcc_v8di __attribute__ ((__vector_size__ (64))); +typedef unsigned long long __gcc_di; + EOF cat > builtins.h < builtins.h < i386-builtin-types-expanded.def + +grep -v '^DEF_FUNCTION_TYPE[[:space:]]' i386-builtin-types.def | \ + grep '^DEF_P' | \ + sed '/^DEF_POINTER_TYPE[^,]*, [^,]*, [^,]*$/ s/_TYPE/_TYPE_CONST/' \ + >> i386-builtin-types-expanded.def + +cat i386-builtin-types.def | \ + sed '/^DEF_FUNCTION_TYPE[[:space:]]/! s/.*//' | \ + sed 's/^DEF_FUNCTION_TYPE[[:space:]]*(\([^,]*\))/\1_FTYPE_VOID/' | \ + sed 's/^DEF_FUNCTION_TYPE[[:space:]]*(\([^,]*\), \(.*\))/\1_FTYPE_\2/' | \ + sed 's/, /_/g' > i386-type-names.def +cat i386-builtin-types.def | tr -c -d ',\n' | awk '{ print length }' | \ + paste - i386-type-names.def i386-builtin-types.def | grep -v '#' | \ + sed 's/^\([0-9]\)[[:space:]]*\([^[:space:]]*\)[[:space:]]*DEF_FUNCTION_TYPE[[:space:]]*(/DEF_FUNCTION_TYPE_\1(\2, /' | \ + grep ^DEF_FUNCTION_TYPE >> i386-builtin-types-expanded.def + +gcc -E builtins.h | sed 's/^NEXTDEF/#define/' | \ + cat - builtins.def i386-builtin.def | \ gcc -E -P - | \ sed 's/MANGLE("__builtin_" "\(.*\)")/__builtin_\1/' | \ + sed 's/MANGLEi386("__builtin_\(.*\)")/__builtin_\1/' | \ + sed 's/^(int) //' | \ sed '/^;$/d' >> gcc-builtins.h -rm $builtin_defs builtins.h +for f in $builtin_defs builtins.h i386-builtin-types-expanded.def i386-type-names.def ; do + rm `basename $f` +done + +sed_is_gnu_sed=0 +if sed --version >/dev/null 2>&1 ; then + # GNU sed + sed_is_gnu_sed=1 +fi # for some we don't know how to handle them - removing symbols should be safe remove_line() { local pattern="$1" - if sed --version >/dev/null 2>&1 ; then - # GNU sed + if [ $sed_is_gnu_sed -eq 1 ] ; then sed -i "/$pattern/d" gcc-builtins.h else sed -i '' "/$pattern/d" gcc-builtins.h @@ -152,9 +226,50 @@ remove_line BT_FN remove_line lang_hooks.types.type_for_mode remove_line __float remove_line pointer_bounds_type_node +remove_line BT_LAST +remove_line BDESC_END +remove_line error_mark_node +remove_line '^0(' +remove_line 'CC.mode(' +remove_line FTYPE +remove_line MULTI_ARG + +ifs=$IFS +IFS=' +' + +while read line ; do + if [ $sed_is_gnu_sed -eq 1 ] ; then + line=`echo "$line" | sed 's/\\([^\.]\)/_Complex\1/g'` + else + line=`echo "$line" | sed 's/[[:<:]]size_t/__CPROVER_size_t/g'` + line=`echo "$line" | sed 's/[[:<:]]complex[[:>:]]\([^\.]\)/_Complex\1/g'` + fi + + if grep -q -F "$line" gcc_builtin_headers_*.h ; then + continue + fi + + bi=`echo "$line" | cut -f1 -d'(' | sed 's/.* //'` + + if [[ $bi =~ __builtin_ia32 ]] ; then + if grep -wq $bi gcc_builtin_headers_ia32*.h ; then + if [ $sed_is_gnu_sed -eq 1 ] ; then + sed -i "/^[^/].*$bi(/ s/.*/$line/" gcc_builtin_headers_ia32*.h + else + sed -i '' "/^[^/].*$bi(/ s/.*/$line/" gcc_builtin_headers_ia32*.h + fi + continue + fi + fi + + echo "$line" >> _gcc-builtins.h +done < gcc-builtins.h +mv _gcc-builtins.h gcc-builtins.h cat gcc-builtins.h | sed 's/__builtin/XX__builtin/' | \ - gcc -c -fno-builtin -x c - -o gcc-builtins.o + gcc -D__CPROVER_size_t=size_t -c -fno-builtin -x c - -o gcc-builtins.o rm gcc-builtins.o echo "Successfully built gcc-builtins.h" diff --git a/src/ansi-c/library/converter.cpp b/src/ansi-c/library/converter.cpp index e114c5c2409..391511cdcd7 100644 --- a/src/ansi-c/library/converter.cpp +++ b/src/ansi-c/library/converter.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -57,7 +58,7 @@ int main() std::cout << ch; } - std::cout << "\\n\"" << std::endl; + std::cout << "\\n\"\n"; } } diff --git a/src/ansi-c/library/cprover.h b/src/ansi-c/library/cprover.h index 42c92b7ed7a..ac9c529145a 100644 --- a/src/ansi-c/library/cprover.h +++ b/src/ansi-c/library/cprover.h @@ -1,3 +1,14 @@ +/*******************************************************************\ + +Module: + +Author: Daniel Kroening, kroening@kroening.com + +\*******************************************************************/ + +#ifndef CPROVER_ANSI_C_LIBRARY_CPROVER_H +#define CPROVER_ANSI_C_LIBRARY_CPROVER_H + typedef __typeof__(sizeof(int)) __CPROVER_size_t; void *__CPROVER_malloc(__CPROVER_size_t size); extern const void *__CPROVER_deallocated; @@ -41,11 +52,13 @@ void CBMC_trace(int lvl, const char *event, ...); #endif // pointers -//unsigned __CPROVER_POINTER_OBJECT(const void *p); +unsigned __CPROVER_POINTER_OBJECT(const void *p); signed __CPROVER_POINTER_OFFSET(const void *p); __CPROVER_bool __CPROVER_DYNAMIC_OBJECT(const void *p); #if 0 extern unsigned char __CPROVER_memory[__CPROVER_constant_infinity_uint]; +void __CPROVER_allocated_memory( + __CPROVER_size_t address, __CPROVER_size_t extent); // this is ANSI-C extern __CPROVER_thread_local const char __func__[__CPROVER_constant_infinity_uint]; @@ -91,7 +104,8 @@ float __CPROVER_fabsf(float); // arrays //__CPROVER_bool __CPROVER_array_equal(const void *array1, const void *array2); void __CPROVER_array_copy(const void *dest, const void *src); -//void __CPROVER_array_set(const void *dest, ...); +void __CPROVER_array_set(const void *dest, ...); +void __CPROVER_array_replace(const void *dest, const void *src); #if 0 // k-induction @@ -130,3 +144,5 @@ __CPROVER_bool __CPROVER_get_may(const void *, const char *); #define __CPROVER_danger_max_solution_size 1 #define __CPROVER_danger_number_of_vars 1 #define __CPROVER_danger_number_of_consts 1 + +#endif // CPROVER_ANSI_C_LIBRARY_CPROVER_H diff --git a/src/ansi-c/library/jsa.h b/src/ansi-c/library/jsa.h index 20f68ad371d..4859e34a927 100644 --- a/src/ansi-c/library/jsa.h +++ b/src/ansi-c/library/jsa.h @@ -7,6 +7,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Counterexample-Guided Inductive Synthesis + /* FUNCTION: __CPROVER_jsa_synthesise */ #ifndef CPROVER_ANSI_C_LIBRARY_JSA_H diff --git a/src/ansi-c/library/stdlib.c b/src/ansi-c/library/stdlib.c index b6f13e9e9a2..3b85223320e 100644 --- a/src/ansi-c/library/stdlib.c +++ b/src/ansi-c/library/stdlib.c @@ -67,17 +67,18 @@ inline void *malloc(__CPROVER_size_t malloc_size); inline void *calloc(__CPROVER_size_t nmemb, __CPROVER_size_t size) { __CPROVER_HIDE:; - __CPROVER_size_t total_size=nmemb*size; void *res; - res=malloc(total_size); + res=malloc(nmemb*size); #ifdef __CPROVER_STRING_ABSTRACTION __CPROVER_is_zero_string(res)=1; __CPROVER_zero_string_length(res)=0; //for(int i=0; i1) + __CPROVER_array_set(res, 0); + else if(nmemb==1) + for(__CPROVER_size_t i=0; i=(const char *)src+n) + char src_n[n]; + __CPROVER_array_copy(src_n, (char*)src); + __CPROVER_array_replace((char*)dest, src_n); + #endif + return dest; +} + +/* FUNCTION: __builtin___memmove_chk */ + +#ifndef __CPROVER_STRING_H_INCLUDED +#include +#define __CPROVER_STRING_H_INCLUDED +#endif + +#undef memmove + +void *__builtin___memmove_chk(void *dest, const void *src, size_t n, __CPROVER_size_t size) +{ + __CPROVER_HIDE:; + #ifdef __CPROVER_STRING_ABSTRACTION + __CPROVER_assert(__CPROVER_buffer_size(src)>=n, "memmove buffer overflow"); + __CPROVER_assert(__CPROVER_buffer_size(dest)==size, "builtin object size"); + // dst = src (with overlap allowed) + if(__CPROVER_is_zero_string(src) && + n > __CPROVER_zero_string_length(src)) { - for(__CPROVER_size_t i=0; i0; i--) ((char *)dest)[i-1]=((const char *)src)[i-1]; - } + __CPROVER_is_zero_string(dest)=0; + #else + (void)size; + char src_n[n]; + __CPROVER_array_copy(src_n, (char*)src); + __CPROVER_array_replace((char*)dest, src_n); #endif return dest; } diff --git a/src/ansi-c/library/unistd.c b/src/ansi-c/library/unistd.c index b9c632fcb77..00af7246882 100644 --- a/src/ansi-c/library/unistd.c +++ b/src/ansi-c/library/unistd.c @@ -198,14 +198,19 @@ ssize_t read(int fildes, void *buf, size_t nbyte) if((fildes>=0 && fildes<=2) || fildes < __CPROVER_pipe_offset) { ssize_t nread; - size_t i; __CPROVER_assume(0<=nread && (size_t)nread<=nbyte); +#if 0 + size_t i; for(i=0; i #include +#include #include -#include "../c_types.h" - #include "unescape_string.h" #include "convert_character_literal.h" -/*******************************************************************\ - -Function: convert_character_literal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt convert_character_literal( const std::string &src, bool force_integer_type) diff --git a/src/ansi-c/literals/convert_character_literal.h b/src/ansi-c/literals/convert_character_literal.h index 4c497db73cd..797457a3970 100644 --- a/src/ansi-c/literals/convert_character_literal.h +++ b/src/ansi-c/literals/convert_character_literal.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// C++ Language Conversion + #ifndef CPROVER_ANSI_C_LITERALS_CONVERT_CHARACTER_LITERAL_H #define CPROVER_ANSI_C_LITERALS_CONVERT_CHARACTER_LITERAL_H diff --git a/src/ansi-c/literals/convert_float_literal.cpp b/src/ansi-c/literals/convert_float_literal.cpp index 7e72f6e6f53..e89148c9749 100644 --- a/src/ansi-c/literals/convert_float_literal.cpp +++ b/src/ansi-c/literals/convert_float_literal.cpp @@ -6,31 +6,22 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// C++ Language Conversion + #include #include +#include #include #include #include #include #include -#include "../c_types.h" #include "parse_float.h" #include "convert_float_literal.h" -/*******************************************************************\ - -Function: convert_float_literal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt convert_float_literal(const std::string &src) { mp_integer significand; diff --git a/src/ansi-c/literals/convert_float_literal.h b/src/ansi-c/literals/convert_float_literal.h index 4c76abbd312..5aa627ace8c 100644 --- a/src/ansi-c/literals/convert_float_literal.h +++ b/src/ansi-c/literals/convert_float_literal.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// C Language Conversion + #ifndef CPROVER_ANSI_C_LITERALS_CONVERT_FLOAT_LITERAL_H #define CPROVER_ANSI_C_LITERALS_CONVERT_FLOAT_LITERAL_H diff --git a/src/ansi-c/literals/convert_integer_literal.cpp b/src/ansi-c/literals/convert_integer_literal.cpp index d7c832dee31..d14c5c92b24 100644 --- a/src/ansi-c/literals/convert_integer_literal.cpp +++ b/src/ansi-c/literals/convert_integer_literal.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// C++ Language Conversion + #include #include @@ -17,18 +20,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "convert_integer_literal.h" -/*******************************************************************\ - -Function: convert_integer_literal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt convert_integer_literal(const std::string &src) { bool is_unsigned=false, is_imaginary=false; diff --git a/src/ansi-c/literals/convert_integer_literal.h b/src/ansi-c/literals/convert_integer_literal.h index 5ce3847fdb6..27c231d3790 100644 --- a/src/ansi-c/literals/convert_integer_literal.h +++ b/src/ansi-c/literals/convert_integer_literal.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// C++ Language Conversion + #ifndef CPROVER_ANSI_C_LITERALS_CONVERT_INTEGER_LITERAL_H #define CPROVER_ANSI_C_LITERALS_CONVERT_INTEGER_LITERAL_H diff --git a/src/ansi-c/literals/convert_string_literal.cpp b/src/ansi-c/literals/convert_string_literal.cpp index 4176581afe2..a32a4fb0c93 100644 --- a/src/ansi-c/literals/convert_string_literal.cpp +++ b/src/ansi-c/literals/convert_string_literal.cpp @@ -6,29 +6,20 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// C/C++ Language Conversion + #include #include +#include #include #include "../string_constant.h" -#include "../c_types.h" #include "unescape_string.h" #include "convert_string_literal.h" -/*******************************************************************\ - -Function: convert_one_string_literal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::basic_string convert_one_string_literal( const std::string &src) { @@ -47,7 +38,7 @@ std::basic_string convert_one_string_literal( // pad into wide string value.resize(utf8_value.size()); - for(unsigned i=0; i convert_one_string_literal( assert(src[0]=='"'); assert(src[src.size()-1]=='"'); - std::basic_string value= - unescape_wide_string(std::string(src, 1, src.size()-2)); - - // turn into utf-8 - std::string utf8_value=utf32_to_utf8(value); + std::string char_value= + unescape_string(std::string(src, 1, src.size()-2)); // pad into wide string - value.resize(utf8_value.size()); - for(unsigned i=0; i value; + value.resize(char_value.size()); + for(std::size_t i=0; i tmp_value= - convert_one_string_literal(tmp_src); - value.append(tmp_value); - i=j; - } + for(++j; j tmp_value= + convert_one_string_literal(tmp_src); + value.append(tmp_value); + i=j; } if(wide!=0) @@ -161,7 +135,7 @@ exprt convert_string_literal(const std::string &src) result.type().set(ID_size, from_integer(value.size(), index_type())); result.operands().resize(value.size()); - for(unsigned i=0; i255. // gcc issues a warning in this case. diff --git a/src/ansi-c/literals/convert_string_literal.h b/src/ansi-c/literals/convert_string_literal.h index f634a1dfb1f..16b7e5e5929 100644 --- a/src/ansi-c/literals/convert_string_literal.h +++ b/src/ansi-c/literals/convert_string_literal.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// C/C++ Language Conversion + #ifndef CPROVER_ANSI_C_LITERALS_CONVERT_STRING_LITERAL_H #define CPROVER_ANSI_C_LITERALS_CONVERT_STRING_LITERAL_H diff --git a/src/ansi-c/literals/parse_float.cpp b/src/ansi-c/literals/parse_float.cpp index 674e986e35a..e5c67ea4d70 100644 --- a/src/ansi-c/literals/parse_float.cpp +++ b/src/ansi-c/literals/parse_float.cpp @@ -6,22 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Conversion of Expressions + #include #include "parse_float.h" -/*******************************************************************\ - -Function: convert_ct::parse_float - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void parse_float( const std::string &src, mp_integer &significand, diff --git a/src/ansi-c/literals/parse_float.h b/src/ansi-c/literals/parse_float.h index 7edb55a08b7..b750c0cd77b 100644 --- a/src/ansi-c/literals/parse_float.h +++ b/src/ansi-c/literals/parse_float.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// ANSI-C Conversion / Type Checking + #ifndef CPROVER_ANSI_C_LITERALS_PARSE_FLOAT_H #define CPROVER_ANSI_C_LITERALS_PARSE_FLOAT_H diff --git a/src/ansi-c/literals/unescape_string.cpp b/src/ansi-c/literals/unescape_string.cpp index 6ecfadc703d..1ca8edc7cad 100644 --- a/src/ansi-c/literals/unescape_string.cpp +++ b/src/ansi-c/literals/unescape_string.cpp @@ -6,159 +6,49 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// ANSI-C Language Conversion + #include #include -#include - -#include "unescape_string.h" - -/*******************************************************************\ -Function: unescape_string +#include - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ +#include "unescape_string.h" -std::string unescape_string(const std::string &src) +static void append_universal_char( + unsigned int value, + std::string &dest) { - std::string dest; - dest.reserve(src.size()); - - for(unsigned i=0; i value_str(1, value); - // go back - i--; + // turn into utf-8 + std::string utf8_value=utf32_to_utf8(value_str); - ch=octal_to_unsigned(octal.c_str(), octal.size()); - dest+=ch; - } - else - { - // Unknown escape sequence. - // Both GCC and CL turn \% into %. - dest.push_back(ch); - } - } - } - else - dest+=ch; - } - - return dest; + dest.append(utf8_value); } -/*******************************************************************\ - -Function: unescape_wide_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ +static void append_universal_char( + unsigned int value, + std::basic_string &dest) +{ + dest.push_back(value); +} -std::basic_string unescape_wide_string( - const std::string &src) +template +std::basic_string unescape_string_templ(const std::string &src) { - std::basic_string dest; + std::basic_string dest; dest.reserve(src.size()); // about that long, but may be shorter for(unsigned i=0; i unescape_wide_string( { std::string hex; - unsigned count=(ch=='u')?4:8; - hex.reserve(count); + const unsigned digits=(ch=='u')?4:8; + hex.reserve(digits); - for(; count!=0 && i unescape_wide_string( { std::string hex; + while(i unescape_wide_string( // go back i--; - unsigned int result; - sscanf(hex.c_str(), "%x", &result); - ch=result; + ch=hex_to_unsigned(hex.c_str(), hex.size()); } + // if T isn't sufficiently wide to hold unsigned values + // the following might truncate; but then + // universal characters in non-wide strings don't + // really work; gcc just issues a warning. dest.push_back(ch); break; @@ -236,9 +130,7 @@ std::basic_string unescape_wide_string( // go back i--; - unsigned int result; - sscanf(octal.c_str(), "%o", &result); - ch=result; + ch=octal_to_unsigned(octal.c_str(), octal.size()); dest.push_back(ch); } else @@ -256,17 +148,16 @@ std::basic_string unescape_wide_string( return dest; } -/*******************************************************************\ - -Function: hex_to_unsigned - - Inputs: - - Outputs: - - Purpose: +std::string unescape_string(const std::string &src) +{ + return unescape_string_templ(src); +} -\*******************************************************************/ +std::basic_string unescape_wide_string( + const std::string &src) +{ + return unescape_string_templ(src); +} unsigned hex_to_unsigned(const char *hex, std::size_t digits) { @@ -290,18 +181,6 @@ unsigned hex_to_unsigned(const char *hex, std::size_t digits) return value; } -/*******************************************************************\ - -Function: octal_to_unsigned - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - unsigned octal_to_unsigned(const char *octal, std::size_t digits) { unsigned value=0; diff --git a/src/ansi-c/literals/unescape_string.h b/src/ansi-c/literals/unescape_string.h index 9d672cde19c..be6f1a18093 100644 --- a/src/ansi-c/literals/unescape_string.h +++ b/src/ansi-c/literals/unescape_string.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// ANSI-C Language Conversion + #ifndef CPROVER_ANSI_C_LITERALS_UNESCAPE_STRING_H #define CPROVER_ANSI_C_LITERALS_UNESCAPE_STRING_H diff --git a/src/ansi-c/padding.cpp b/src/ansi-c/padding.cpp index 16391ee33a7..4973354e503 100644 --- a/src/ansi-c/padding.cpp +++ b/src/ansi-c/padding.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include #include @@ -15,18 +18,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "padding.h" -/*******************************************************************\ - -Function: alignment - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - mp_integer alignment(const typet &type, const namespacet &ns) { // we need to consider a number of different cases: @@ -114,18 +105,6 @@ mp_integer alignment(const typet &type, const namespacet &ns) return result; } -/*******************************************************************\ - -Function: add_padding - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void add_padding(struct_typet &type, const namespacet &ns) { struct_typet::componentst &components=type.components(); @@ -322,23 +301,14 @@ void add_padding(struct_typet &type, const namespacet &ns) } } -/*******************************************************************\ - -Function: add_padding - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void add_padding(union_typet &type, const namespacet &ns) { mp_integer max_alignment=alignment(type, ns)*8; mp_integer size_bits=pointer_offset_bits(type, ns); + if(size_bits<0) + throw "type of unknown size:\n"+type.pretty(); + union_typet::componentst &components=type.components(); // Is the union packed? diff --git a/src/ansi-c/padding.h b/src/ansi-c/padding.h index 18634a61559..27fb6fda099 100644 --- a/src/ansi-c/padding.h +++ b/src/ansi-c/padding.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// ANSI-C Language Type Checking + #ifndef CPROVER_ANSI_C_PADDING_H #define CPROVER_ANSI_C_PADDING_H diff --git a/src/ansi-c/parser.y b/src/ansi-c/parser.y index 3529ef5cff0..0819265fe70 100644 --- a/src/ansi-c/parser.y +++ b/src/ansi-c/parser.y @@ -22,6 +22,8 @@ extern char *yyansi_ctext; #include "parser_static.inc" +#include "literals/convert_integer_literal.h" + #include "ansi_c_y.tab.h" // statements have right recursion, deep nesting of statements thus @@ -425,6 +427,17 @@ offsetof_member_designator: mto($2, $3); mto($$, $2); } + | offsetof_member_designator TOK_ARROW member_name + { + $$=$1; + set($2, ID_index); + exprt tmp=convert_integer_literal("0"); + stack($2).move_to_operands(tmp); + mto($$, $2); + set($2, ID_member); + stack($2).set(ID_component_name, stack($3).get(ID_C_base_name)); + mto($$, $2); + } ; quantifier_expression: diff --git a/src/ansi-c/parser_static.inc b/src/ansi-c/parser_static.inc index 5e24eff5a05..e0c8385998d 100644 --- a/src/ansi-c/parser_static.inc +++ b/src/ansi-c/parser_static.inc @@ -1,10 +1,9 @@ +#include #include #include #include #include -#include "c_types.h" - #define YYSTYPE unsigned #define YYSTYPE_IS_TRIVIAL 1 @@ -100,8 +99,8 @@ Function: merge_types static void merge_types(irept &dest, irept &src) { #if 0 - std::cout << "D: " << dest.pretty() << std::endl; - std::cout << "S: " << src.pretty() << std::endl; + std::cout << "D: " << dest.pretty() << '\n'; + std::cout << "S: " << src.pretty() << '\n'; #endif if(src.is_nil()) @@ -183,8 +182,8 @@ static void make_subtype(typet &dest, typet &src) // find spot in 'dest' where to insert 'src' #if 0 - std::cout << "D: " << dest.pretty() << std::endl; - std::cout << "S: " << src.pretty() << std::endl; + std::cout << "D: " << dest.pretty() << '\n'; + std::cout << "S: " << src.pretty() << '\n'; #endif assert(src.id()==ID_array || diff --git a/src/ansi-c/preprocessor_line.cpp b/src/ansi-c/preprocessor_line.cpp index a9b651fc3f7..b3b2ea1e2c5 100644 --- a/src/ansi-c/preprocessor_line.cpp +++ b/src/ansi-c/preprocessor_line.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// ANSI-C Language Conversion + #include #include @@ -14,18 +17,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "literals/unescape_string.h" #include "preprocessor_line.h" -/*******************************************************************\ - -Function: preprocessor_line - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void preprocessor_line( const char *text, parsert &parser) diff --git a/src/ansi-c/preprocessor_line.h b/src/ansi-c/preprocessor_line.h index 5222fdd83d9..bd18aa636fe 100644 --- a/src/ansi-c/preprocessor_line.h +++ b/src/ansi-c/preprocessor_line.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// ANSI-C Language Conversion + #ifndef CPROVER_ANSI_C_PREPROCESSOR_LINE_H #define CPROVER_ANSI_C_PREPROCESSOR_LINE_H diff --git a/src/ansi-c/printf_formatter.cpp b/src/ansi-c/printf_formatter.cpp index 31ddfa735f2..52f9c7e6384 100644 --- a/src/ansi-c/printf_formatter.cpp +++ b/src/ansi-c/printf_formatter.cpp @@ -6,27 +6,18 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// printf Formatting + #include #include +#include #include #include -#include "c_types.h" #include "printf_formatter.h" -/*******************************************************************\ - -Function: printf_formattert::make_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const exprt printf_formattert::make_type( const exprt &src, const typet &dest) { @@ -38,18 +29,6 @@ const exprt printf_formattert::make_type( return tmp; } -/*******************************************************************\ - -Function: printf_formattert::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void printf_formattert::operator()( const std::string &_format, const std::list &_operands) @@ -58,18 +37,6 @@ void printf_formattert::operator()( operands=_operands; } -/*******************************************************************\ - -Function: printf_formattert::print() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void printf_formattert::print(std::ostream &out) { format_pos=0; @@ -85,18 +52,6 @@ void printf_formattert::print(std::ostream &out) } } -/*******************************************************************\ - -Function: printf_formattert::as_string() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string printf_formattert::as_string() { std::ostringstream stream; @@ -104,18 +59,6 @@ std::string printf_formattert::as_string() return stream.str(); } -/*******************************************************************\ - -Function: printf_formattert::process_format - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void printf_formattert::process_format(std::ostream &out) { exprt tmp; @@ -236,18 +179,6 @@ void printf_formattert::process_format(std::ostream &out) } } -/*******************************************************************\ - -Function: printf_formattert::process_char - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void printf_formattert::process_char(std::ostream &out) { char ch=next(); diff --git a/src/ansi-c/printf_formatter.h b/src/ansi-c/printf_formatter.h index 4048af9a6a4..2cc36b87d1e 100644 --- a/src/ansi-c/printf_formatter.h +++ b/src/ansi-c/printf_formatter.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// printf Formatting + #ifndef CPROVER_ANSI_C_PRINTF_FORMATTER_H #define CPROVER_ANSI_C_PRINTF_FORMATTER_H diff --git a/src/ansi-c/scanner.l b/src/ansi-c/scanner.l index 2b58bd40c9f..7a97b0a7b89 100644 --- a/src/ansi-c/scanner.l +++ b/src/ansi-c/scanner.l @@ -21,7 +21,6 @@ static int isatty(int) { return 0; } #include -#include "c_types.h" #include "preprocessor_line.h" #include "string_constant.h" diff --git a/src/ansi-c/string_constant.cpp b/src/ansi-c/string_constant.cpp index 6576a99ea5b..05f99c85e5a 100644 --- a/src/ansi-c/string_constant.cpp +++ b/src/ansi-c/string_constant.cpp @@ -6,23 +6,12 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include +#include #include #include "string_constant.h" -#include "c_types.h" - -/*******************************************************************\ - -Function: string_constantt::string_constantt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ string_constantt::string_constantt(): exprt(ID_string_constant) @@ -30,36 +19,12 @@ string_constantt::string_constantt(): set_value(irep_idt()); } -/*******************************************************************\ - -Function: string_constantt::string_constantt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - string_constantt::string_constantt(const irep_idt &_value): exprt(ID_string_constant) { set_value(_value); } -/*******************************************************************\ - -Function: string_constantt::set_value - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_constantt::set_value(const irep_idt &value) { exprt size_expr=from_integer(value.size()+1, index_type()); @@ -67,18 +32,7 @@ void string_constantt::set_value(const irep_idt &value) set(ID_value, value); } -/*******************************************************************\ - -Function: string_constantt:to_array_expr - - Inputs: - - Outputs: - - Purpose: convert string into array constant - -\*******************************************************************/ - +/// convert string into array constant array_exprt string_constantt::to_array_expr() const { const std::string &str=get_string(ID_value); @@ -119,18 +73,8 @@ array_exprt string_constantt::to_array_expr() const return dest; } -/*******************************************************************\ - -Function: string_constantt:from_array_expr - - Inputs: - - Outputs: true on error - - Purpose: convert array constant into string - -\*******************************************************************/ - +/// convert array constant into string +/// \return true on error bool string_constantt::from_array_expr(const array_exprt &src) { id(ID_string_constant); diff --git a/src/ansi-c/string_constant.h b/src/ansi-c/string_constant.h index 40ef0a94366..d991d6409c1 100644 --- a/src/ansi-c/string_constant.h +++ b/src/ansi-c/string_constant.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_ANSI_C_STRING_CONSTANT_H #define CPROVER_ANSI_C_STRING_CONSTANT_H diff --git a/src/ansi-c/type2name.cpp b/src/ansi-c/type2name.cpp index fdcf6b0a276..e9a564d35b2 100644 --- a/src/ansi-c/type2name.cpp +++ b/src/ansi-c/type2name.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// Type Naming for C + #include #include #include @@ -22,18 +25,6 @@ static std::string type2name( const namespacet &ns, symbol_numbert &symbol_number); -/*******************************************************************\ - -Function: type2name_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static std::string type2name_symbol( const typet &type, const namespacet &ns, @@ -90,18 +81,6 @@ static std::string type2name_symbol( return result; } -/*******************************************************************\ - -Function: type2name - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static bool parent_is_sym_check=false; static std::string type2name( const typet &type, @@ -131,7 +110,7 @@ static std::string type2name( if(!type.source_location().get_function().empty()) result+='l'; - if(type.id()==irep_idt()) + if(type.id().empty()) throw "empty type encountered"; else if(type.id()==ID_empty) result+='V'; @@ -278,18 +257,6 @@ static std::string type2name( return result; } -/*******************************************************************\ - -Function: type2name - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string type2name(const typet &type, const namespacet &ns) { parent_is_sym_check=true; @@ -297,18 +264,6 @@ std::string type2name(const typet &type, const namespacet &ns) return type2name(type, ns, symbol_number); } -/*******************************************************************\ - -Function: type2name - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string type2name(const typet &type) { symbol_tablet symbol_table; diff --git a/src/ansi-c/type2name.h b/src/ansi-c/type2name.h index b7299617e7f..b8d2d5c0e05 100644 --- a/src/ansi-c/type2name.h +++ b/src/ansi-c/type2name.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// Type Naming for C + #ifndef CPROVER_ANSI_C_TYPE2NAME_H #define CPROVER_ANSI_C_TYPE2NAME_H diff --git a/src/assembler/assembler_parser.cpp b/src/assembler/assembler_parser.cpp index 59367857340..c4be4aa2bfe 100644 --- a/src/assembler/assembler_parser.cpp +++ b/src/assembler/assembler_parser.cpp @@ -6,24 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "assembler_parser.h" assembler_parsert assembler_parser; -/*******************************************************************\ - -Function: yyassemblererror - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - extern char *yyassemblertext; int yyassemblererror(const std::string &error) diff --git a/src/assembler/assembler_parser.h b/src/assembler/assembler_parser.h index 7745ec21ed6..4d3a160da25 100644 --- a/src/assembler/assembler_parser.h +++ b/src/assembler/assembler_parser.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_ASSEMBLER_ASSEMBLER_PARSER_H #define CPROVER_ASSEMBLER_ASSEMBLER_PARSER_H diff --git a/src/cbmc/Makefile b/src/cbmc/Makefile index 37f8b65eb00..4d890b0b5fa 100644 --- a/src/cbmc/Makefile +++ b/src/cbmc/Makefile @@ -17,6 +17,7 @@ SRC = all_properties.cpp \ OBJ += ../ansi-c/ansi-c$(LIBEXT) \ ../cpp/cpp$(LIBEXT) \ + ../java_bytecode/java_bytecode$(LIBEXT) \ ../linking/linking$(LIBEXT) \ ../big-int/big-int$(LIBEXT) \ ../goto-programs/goto-programs$(LIBEXT) \ @@ -58,26 +59,11 @@ ifneq ($(wildcard ../bv_refinement/Makefile),) CP_CXXFLAGS += -DHAVE_BV_REFINEMENT endif -ifneq ($(wildcard ../java_bytecode/Makefile),) - OBJ += ../java_bytecode/java_bytecode$(LIBEXT) - CP_CXXFLAGS += -DHAVE_JAVA_BYTECODE -endif - ifneq ($(wildcard ../jsil/Makefile),) OBJ += ../jsil/jsil$(LIBEXT) CP_CXXFLAGS += -DHAVE_JSIL endif -ifneq ($(wildcard ../specc/Makefile),) - OBJ += ../specc/specc$(LIBEXT) - CP_CXXFLAGS += -DHAVE_SPECC -endif - -ifneq ($(wildcard ../php/Makefile),) - OBJ += ../php/php$(LIBEXT) - CP_CXXFLAGS += -DHAVE_PHP -endif - ############################################################################### cbmc$(EXEEXT): $(OBJ) diff --git a/src/cbmc/all_properties.cpp b/src/cbmc/all_properties.cpp index 2534ba7827a..bd9c5242dd4 100644 --- a/src/cbmc/all_properties.cpp +++ b/src/cbmc/all_properties.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbolic Execution of ANSI-C + #include #include @@ -23,18 +26,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "all_properties_class.h" -/*******************************************************************\ - -Function: bmc_all_propertiest::goal_covered - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bmc_all_propertiest::goal_covered(const cover_goalst::goalt &) { for(auto &g : goal_map) @@ -61,18 +52,6 @@ void bmc_all_propertiest::goal_covered(const cover_goalst::goalt &) } } -/*******************************************************************\ - -Function: bmc_all_propertiest::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - safety_checkert::resultt bmc_all_propertiest::operator()() { status() << "Passing problem to " << solver.decision_procedure_text() << eom; @@ -178,18 +157,6 @@ safety_checkert::resultt bmc_all_propertiest::operator()() return safe?safety_checkert::resultt::SAFE:safety_checkert::resultt::UNSAFE; } -/*******************************************************************\ - -Function: bmc_all_propertiest::report() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bmc_all_propertiest::report(const cover_goalst &cover_goals) { switch(bmc.ui) @@ -263,18 +230,6 @@ void bmc_all_propertiest::report(const cover_goalst &cover_goals) } } -/*******************************************************************\ - -Function: bmct::all_properties - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - safety_checkert::resultt bmct::all_properties( const goto_functionst &goto_functions, prop_convt &solver) diff --git a/src/cbmc/all_properties_class.h b/src/cbmc/all_properties_class.h index 1f3fc27960a..89c4614cc12 100644 --- a/src/cbmc/all_properties_class.h +++ b/src/cbmc/all_properties_class.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbolic Execution of ANSI-C + #ifndef CPROVER_CBMC_ALL_PROPERTIES_CLASS_H #define CPROVER_CBMC_ALL_PROPERTIES_CLASS_H @@ -13,18 +16,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "bmc.h" -/*******************************************************************\ - - Class: bmc_all_propertiest - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - class bmc_all_propertiest: public cover_goalst::observert, public messaget diff --git a/src/cbmc/bmc.cpp b/src/cbmc/bmc.cpp index 0a8fd5053c8..f92483d2441 100644 --- a/src/cbmc/bmc.cpp +++ b/src/cbmc/bmc.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbolic Execution of ANSI-C + #include #include #include @@ -39,35 +42,11 @@ Author: Daniel Kroening, kroening@kroening.com #include "fault_localization.h" #include "bmc.h" -/*******************************************************************\ - -Function: bmct::do_unwind_module - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bmct::do_unwind_module() { // this is a hook for hw-cbmc } -/*******************************************************************\ - -Function: bmct::error_trace - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bmct::error_trace() { status() << "Building error trace" << eom; @@ -109,18 +88,7 @@ void bmct::error_trace() } } -/*******************************************************************\ - -Function: bmct::output_graphml - - Inputs: - - Outputs: - - Purpose: outputs witnesses in graphml format - -\*******************************************************************/ - +/// outputs witnesses in graphml format void bmct::output_graphml( resultt result, const goto_functionst &goto_functions) @@ -146,18 +114,6 @@ void bmct::output_graphml( } } -/*******************************************************************\ - -Function: bmct::do_conversion - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bmct::do_conversion() { // convert HDL (hook for hw-cbmc) @@ -178,18 +134,6 @@ void bmct::do_conversion() } } -/*******************************************************************\ - -Function: bmct::run_decision_procedure - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - decision_proceduret::resultt bmct::run_decision_procedure(prop_convt &prop_conv) { @@ -217,18 +161,6 @@ bmct::run_decision_procedure(prop_convt &prop_conv) return dec_result; } -/*******************************************************************\ - -Function: bmct::report_success - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bmct::report_success() { result() << "VERIFICATION SUCCESSFUL" << eom; @@ -257,18 +189,6 @@ void bmct::report_success() } } -/*******************************************************************\ - -Function: bmct::report_failure - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bmct::report_failure() { result() << "VERIFICATION FAILED" << eom; @@ -297,18 +217,6 @@ void bmct::report_failure() } } -/*******************************************************************\ - -Function: bmct::show_program - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bmct::show_program() { unsigned count=1; @@ -398,18 +306,6 @@ void bmct::show_program() } } -/*******************************************************************\ - -Function: bmct::run - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - safety_checkert::resultt bmct::run( const goto_functionst &goto_functions) { @@ -595,18 +491,6 @@ safety_checkert::resultt bmct::run( } } -/*******************************************************************\ - -Function: bmct::decide - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - safety_checkert::resultt bmct::decide( const goto_functionst &goto_functions, prop_convt &prop_conv) @@ -619,18 +503,6 @@ safety_checkert::resultt bmct::decide( return all_properties(goto_functions, prop_conv); } -/*******************************************************************\ - -Function: bmct::stop_on_fail - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - safety_checkert::resultt bmct::stop_on_fail( const goto_functionst &goto_functions, prop_convt &prop_conv) @@ -667,18 +539,6 @@ safety_checkert::resultt bmct::stop_on_fail( } } -/*******************************************************************\ - -Function: bmct::setup_unwind - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bmct::setup_unwind() { const std::string &set=options.get_option("unwindset"); diff --git a/src/cbmc/bmc.h b/src/cbmc/bmc.h index 33d73005c1a..4c69fab527c 100644 --- a/src/cbmc/bmc.h +++ b/src/cbmc/bmc.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Bounded Model Checking for ANSI-C + HDL + #ifndef CPROVER_CBMC_BMC_H #define CPROVER_CBMC_BMC_H diff --git a/src/cbmc/bmc_cover.cpp b/src/cbmc/bmc_cover.cpp index fd900dda14d..4c101cc2159 100644 --- a/src/cbmc/bmc_cover.cpp +++ b/src/cbmc/bmc_cover.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Test-Suite Generation with BMC + #include #include @@ -24,18 +27,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "bmc.h" #include "bv_cbmc.h" -/*******************************************************************\ - - Class: bmc_covert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - class bmc_covert: public cover_goalst::observert, public messaget @@ -149,18 +140,6 @@ class bmc_covert: bmct &bmc; }; -/*******************************************************************\ - -Function: bmc_covert::satisfying_assignment - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bmc_covert::satisfying_assignment() { tests.push_back(testt()); @@ -210,18 +189,6 @@ void bmc_covert::satisfying_assignment() #endif } -/*******************************************************************\ - -Function: bmc_covert::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool bmc_covert::operator()() { status() << "Passing problem to " << solver.decision_procedure_text() << eom; @@ -463,18 +430,7 @@ bool bmc_covert::operator()() return false; } -/*******************************************************************\ - -Function: bmct::cover - - Inputs: - - Outputs: - - Purpose: Try to cover all goals - -\*******************************************************************/ - +/// Try to cover all goals bool bmct::cover( const goto_functionst &goto_functions, const optionst::value_listt &criteria) diff --git a/src/cbmc/bv_cbmc.cpp b/src/cbmc/bv_cbmc.cpp index 830507c0099..1d0ddb384f9 100644 --- a/src/cbmc/bv_cbmc.cpp +++ b/src/cbmc/bv_cbmc.cpp @@ -6,23 +6,12 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include "bv_cbmc.h" -/*******************************************************************\ - -Function: bv_cbmct::convert_waitfor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_cbmct::convert_waitfor(const exprt &expr) { if(expr.operands().size()!=4) @@ -144,18 +133,6 @@ bvt bv_cbmct::convert_waitfor(const exprt &expr) return convert_bitvector(new_cycle); } -/*******************************************************************\ - -Function: bv_cbmct::convert_waitfor_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_cbmct::convert_waitfor_symbol(const exprt &expr) { if(expr.operands().size()!=1) @@ -179,18 +156,6 @@ bvt bv_cbmct::convert_waitfor_symbol(const exprt &expr) return convert_bitvector(result); } -/*******************************************************************\ - -Function: bv_cbmct::convert_bitvector - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_cbmct::convert_bitvector(const exprt &expr) { if(expr.id()=="waitfor") diff --git a/src/cbmc/bv_cbmc.h b/src/cbmc/bv_cbmc.h index 9f7cc8630f4..a55805ffbe7 100644 --- a/src/cbmc/bv_cbmc.h +++ b/src/cbmc/bv_cbmc.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_CBMC_BV_CBMC_H #define CPROVER_CBMC_BV_CBMC_H diff --git a/src/cbmc/cbmc_dimacs.cpp b/src/cbmc/cbmc_dimacs.cpp index 4df2dfbbed9..8584c8fac4b 100644 --- a/src/cbmc/cbmc_dimacs.cpp +++ b/src/cbmc/cbmc_dimacs.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Writing DIMACS Files + #include #include @@ -13,18 +16,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "cbmc_dimacs.h" -/*******************************************************************\ - -Function: cbmc_dimacst::write_dimacs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool cbmc_dimacst::write_dimacs(const std::string &filename) { if(filename.empty() || filename=="-") @@ -41,18 +32,6 @@ bool cbmc_dimacst::write_dimacs(const std::string &filename) return write_dimacs(out); } -/*******************************************************************\ - -Function: cbmc_dimacst::write_dimacs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool cbmc_dimacst::write_dimacs(std::ostream &out) { dynamic_cast(prop).write_dimacs_cnf(out); diff --git a/src/cbmc/cbmc_dimacs.h b/src/cbmc/cbmc_dimacs.h index e8ccda5155a..444a99e73f4 100644 --- a/src/cbmc/cbmc_dimacs.h +++ b/src/cbmc/cbmc_dimacs.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Writing DIMACS Files + #ifndef CPROVER_CBMC_CBMC_DIMACS_H #define CPROVER_CBMC_CBMC_DIMACS_H diff --git a/src/cbmc/cbmc_languages.cpp b/src/cbmc/cbmc_languages.cpp index a18d0344833..2f44ea7c979 100644 --- a/src/cbmc/cbmc_languages.cpp +++ b/src/cbmc/cbmc_languages.cpp @@ -6,18 +6,14 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Language Registration + #include #include #include - -#ifdef HAVE_SPECC -#include -#endif - -#ifdef HAVE_JAVA_BYTECODE #include -#endif #ifdef HAVE_JSIL #include @@ -25,30 +21,11 @@ Author: Daniel Kroening, kroening@kroening.com #include "cbmc_parse_options.h" -/*******************************************************************\ - -Function: cbmc_parse_optionst::register_languages - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cbmc_parse_optionst::register_languages() { register_language(new_ansi_c_language); register_language(new_cpp_language); - - #ifdef HAVE_SPECC - register_language(new_specc_language); - #endif - - #ifdef HAVE_JAVA_BYTECODE register_language(new_java_bytecode_language); - #endif #ifdef HAVE_JSIL register_language(new_jsil_language); diff --git a/src/cbmc/cbmc_main.cpp b/src/cbmc/cbmc_main.cpp index d09ecc4772e..e5e679a8d0e 100644 --- a/src/cbmc/cbmc_main.cpp +++ b/src/cbmc/cbmc_main.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// CBMC Main Module + /* CBMC @@ -22,18 +25,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "cbmc_parse_options.h" -/*******************************************************************\ - -Function: main / wmain - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - #ifdef IREP_HASH_STATS extern unsigned long long irep_hash_cnt; extern unsigned long long irep_cmp_cnt; @@ -53,9 +44,9 @@ int main(int argc, const char **argv) int res=parse_options.main(); #ifdef IREP_HASH_STATS - std::cout << "IREP_HASH_CNT=" << irep_hash_cnt << std::endl; - std::cout << "IREP_CMP_CNT=" << irep_cmp_cnt << std::endl; - std::cout << "IREP_CMP_NE_CNT=" << irep_cmp_ne_cnt << std::endl; + std::cout << "IREP_HASH_CNT=" << irep_hash_cnt << '\n'; + std::cout << "IREP_CMP_CNT=" << irep_cmp_cnt << '\n'; + std::cout << "IREP_CMP_NE_CNT=" << irep_cmp_ne_cnt << '\n'; #endif return res; diff --git a/src/cbmc/cbmc_parse_options.cpp b/src/cbmc/cbmc_parse_options.cpp index b9230c6b4e6..772b62d9b74 100644 --- a/src/cbmc/cbmc_parse_options.cpp +++ b/src/cbmc/cbmc_parse_options.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// CBMC Command Line Option Processing + #include #include // exit() #include @@ -16,6 +19,7 @@ Author: Daniel Kroening, kroening@kroening.com #include #include #include +#include #include @@ -30,6 +34,7 @@ Author: Daniel Kroening, kroening@kroening.com #include #include #include +#include #include #include #include @@ -62,18 +67,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "version.h" #include "xml_interface.h" -/*******************************************************************\ - -Function: cbmc_parse_optionst::cbmc_parse_optionst - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - cbmc_parse_optionst::cbmc_parse_optionst(int argc, const char **argv): parse_options_baset(CBMC_OPTIONS, argc, argv), xml_interfacet(cmdline), @@ -82,18 +75,6 @@ cbmc_parse_optionst::cbmc_parse_optionst(int argc, const char **argv): { } -/*******************************************************************\ - -Function: cbmc_parse_optionst::cbmc_parse_optionst - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - ::cbmc_parse_optionst::cbmc_parse_optionst( int argc, const char **argv, @@ -105,18 +86,6 @@ ::cbmc_parse_optionst::cbmc_parse_optionst( { } -/*******************************************************************\ - -Function: cbmc_parse_optionst::eval_verbosity - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cbmc_parse_optionst::eval_verbosity() { // this is our default verbosity @@ -132,18 +101,6 @@ void cbmc_parse_optionst::eval_verbosity() ui_message_handler.set_verbosity(v); } -/*******************************************************************\ - -Function: cbmc_parse_optionst::get_command_line_options - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cbmc_parse_optionst::get_command_line_options(optionst &options) { if(config.set(cmdline)) @@ -152,6 +109,27 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options) exit(1); // should contemplate EX_USAGE from sysexits.h } + // Test only; do not use for input validation + if(cmdline.isset("test-invariant-failure")) + { + // Have to catch this as the default handling of uncaught exceptions + // on windows appears to be silent termination. + try + { + INVARIANT(0, "Test invariant failure"); + } + catch (const invariant_failedt &e) + { + std::cerr << e.what(); + exit(0); // should contemplate EX_OK from sysexits.h + } + catch (...) + { + error() << "Unexpected exception type\n"; + } + exit(1); + } + if(cmdline.isset("program-only")) options.set_option("program-only", true); @@ -456,23 +434,12 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options) cmdline.get_value("symex-coverage-report")); } -/*******************************************************************\ - -Function: cbmc_parse_optionst::doit - - Inputs: - - Outputs: - - Purpose: invoke main modules - -\*******************************************************************/ - +/// invoke main modules int cbmc_parse_optionst::doit() { if(cmdline.isset("version")) { - std::cout << CBMC_VERSION << std::endl; + std::cout << CBMC_VERSION << '\n'; return 0; // should contemplate EX_OK from sysexits.h } @@ -517,35 +484,14 @@ int cbmc_parse_optionst::doit() goto_functionst goto_functions; - // get solver - cbmc_solverst cbmc_solvers(options, symbol_table, ui_message_handler); - cbmc_solvers.set_ui(get_ui()); - - std::unique_ptr cbmc_solver; - - try - { - cbmc_solver=cbmc_solvers.get_solver(); - } - - catch(const char *error_msg) - { - error() << error_msg << eom; - return 1; // should contemplate EX_SOFTWARE from sysexits.h - } - - prop_convt &prop_conv=cbmc_solver->prop_conv(); - - bmct bmc(options, symbol_table, ui_message_handler, prop_conv); + expr_listt bmc_constraints; int get_goto_program_ret= - get_goto_program(options, bmc, goto_functions); + get_goto_program(options, bmc_constraints, goto_functions); if(get_goto_program_ret!=-1) return get_goto_program_ret; - label_properties(goto_functions); - if(cmdline.isset("show-claims") || // will go away cmdline.isset("show-properties")) // use this one { @@ -562,21 +508,30 @@ int cbmc_parse_optionst::doit() if(options.get_bool_option("java-unwind-enum-static")) remove_static_init_loops(symbol_table, goto_functions, options); - // do actual BMC - return do_bmc(bmc, goto_functions); -} + // get solver + cbmc_solverst cbmc_solvers(options, symbol_table, ui_message_handler); + cbmc_solvers.set_ui(get_ui()); -/*******************************************************************\ + std::unique_ptr cbmc_solver; -Function: cbmc_parse_optionst::set_properties + try + { + cbmc_solver=cbmc_solvers.get_solver(); + } - Inputs: + catch(const char *error_msg) + { + error() << error_msg << eom; + return 1; // should contemplate EX_SOFTWARE from sysexits.h + } - Outputs: + prop_convt &prop_conv=cbmc_solver->prop_conv(); - Purpose: + bmct bmc(options, symbol_table, ui_message_handler, prop_conv); -\*******************************************************************/ + // do actual BMC + return do_bmc(bmc, goto_functions); +} bool cbmc_parse_optionst::set_properties(goto_functionst &goto_functions) { @@ -609,21 +564,9 @@ bool cbmc_parse_optionst::set_properties(goto_functionst &goto_functions) return false; } -/*******************************************************************\ - -Function: cbmc_parse_optionst::get_goto_program - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - int cbmc_parse_optionst::get_goto_program( const optionst &options, - bmct &bmc, // for get_modules + expr_listt &bmc_constraints, // for get_modules goto_functionst &goto_functions) { if(cmdline.args.empty()) @@ -669,7 +612,7 @@ int cbmc_parse_optionst::get_goto_program( language->set_message_handler(get_message_handler()); - status("Parsing", filename); + status() << "Parsing " << filename << eom; if(language->parse(infile, filename)) { @@ -705,7 +648,7 @@ int cbmc_parse_optionst::get_goto_program( return 6; if(typecheck()) return 6; - int get_modules_ret=get_modules(bmc); + int get_modules_ret=get_modules(bmc_constraints); if(get_modules_ret!=-1) return get_modules_ret; if(binaries.empty() && final()) @@ -787,18 +730,6 @@ int cbmc_parse_optionst::get_goto_program( return -1; // no error, continue } -/*******************************************************************\ - -Function: cbmc_parse_optionst::preprocessing - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cbmc_parse_optionst::preprocessing() { try @@ -855,18 +786,6 @@ void cbmc_parse_optionst::preprocessing() } } -/*******************************************************************\ - -Function: cbmc_parse_optionst::process_goto_program - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool cbmc_parse_optionst::process_goto_program( const optionst &options, goto_functionst &goto_functions) @@ -900,6 +819,8 @@ bool cbmc_parse_optionst::process_goto_program( // Similar removal of RTTI inspection: remove_instanceof(symbol_table, goto_functions); + mm_io(symbol_table, goto_functions); + // do partial inlining status() << "Partial Inlining" << eom; goto_partial_inline(goto_functions, ns, ui_message_handler); @@ -928,13 +849,6 @@ bool cbmc_parse_optionst::process_goto_program( status() << "Generic Property Instrumentation" << eom; goto_check(ns, options, goto_functions); - // full slice? - if(cmdline.isset("full-slice")) - { - status() << "Performing a full slice" << eom; - full_slicer(goto_functions, ns); - } - // checks don't know about adjusted float expressions adjust_float_expressions(goto_functions, ns); @@ -984,6 +898,23 @@ bool cbmc_parse_optionst::process_goto_program( return true; } + // label the assertions + // This must be done after adding assertions and + // before using the argument of the "property" option. + // Do not re-label after using the property slicer because + // this would cause the property identifiers to change. + label_properties(goto_functions); + + // full slice? + if(cmdline.isset("full-slice")) + { + status() << "Performing a full slice" << eom; + if(cmdline.isset("property")) + property_slicer(goto_functions, ns, cmdline.get_values("property")); + else + full_slicer(goto_functions, ns); + } + // remove skips remove_skip(goto_functions); goto_functions.update(); @@ -1015,18 +946,7 @@ bool cbmc_parse_optionst::process_goto_program( return false; } -/*******************************************************************\ - -Function: cbmc_parse_optionst::do_bmc - - Inputs: - - Outputs: - - Purpose: invoke main modules - -\*******************************************************************/ - +/// invoke main modules int cbmc_parse_optionst::do_bmc( bmct &bmc, const goto_functionst &goto_functions) @@ -1057,23 +977,12 @@ int cbmc_parse_optionst::do_bmc( return result; } -/*******************************************************************\ - -Function: cbmc_parse_optionst::help - - Inputs: - - Outputs: - - Purpose: display command line help - -\*******************************************************************/ - +/// display command line help void cbmc_parse_optionst::help() { std::cout << "\n" - "* * CBMC " CBMC_VERSION " - Copyright (C) 2001-2016 "; + "* * CBMC " CBMC_VERSION " - Copyright (C) 2001-2017 "; std::cout << "(" << (sizeof(void *)*8) << "-bit version)"; diff --git a/src/cbmc/cbmc_parse_options.h b/src/cbmc/cbmc_parse_options.h index 2c54dfc7353..4f43637234a 100644 --- a/src/cbmc/cbmc_parse_options.h +++ b/src/cbmc/cbmc_parse_options.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// CBMC Command Line Option Processing + #ifndef CPROVER_CBMC_CBMC_PARSE_OPTIONS_H #define CPROVER_CBMC_CBMC_PARSE_OPTIONS_H @@ -64,6 +67,7 @@ class optionst; "(java-cp-include-files):" \ "(localize-faults)(localize-faults-method):" \ "(lazy-methods)" \ + "(test-invariant-failure)" \ "(fixedbv)(floatbv)(all-claims)(all-properties)" // legacy, and will eventually disappear // NOLINT(whitespace/line_length) class cbmc_parse_optionst: @@ -86,11 +90,14 @@ class cbmc_parse_optionst: virtual void register_languages(); virtual void get_command_line_options(optionst &options); - virtual int do_bmc(bmct &bmc, const goto_functionst &goto_functions); + + virtual int do_bmc( + bmct &bmc, + const goto_functionst &goto_functions); virtual int get_goto_program( const optionst &options, - bmct &bmc, + expr_listt &bmc_constraints, goto_functionst &goto_functions); virtual bool process_goto_program( @@ -101,8 +108,8 @@ class cbmc_parse_optionst: void eval_verbosity(); - // get any additional stuff before finalizing - virtual int get_modules(bmct &bmc) + // get any additional stuff before finalizing the goto program + virtual int get_modules(expr_listt &bmc_constraints) { return -1; // continue } diff --git a/src/cbmc/cbmc_solvers.cpp b/src/cbmc/cbmc_solvers.cpp index a9395f476bb..1825a1cd3ab 100644 --- a/src/cbmc/cbmc_solvers.cpp +++ b/src/cbmc/cbmc_solvers.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Solvers for VCs Generated by Symbolic Execution of ANSI-C + #include #include #include @@ -27,18 +30,8 @@ Author: Daniel Kroening, kroening@kroening.com #include "counterexample_beautification.h" #include "version.h" -/*******************************************************************\ - -Function: cbmc_solverst::get_smt1_solver_type - - Inputs: None - - Outputs: An smt1_dect::solvert giving the solver to use. - - Purpose: Uses the options to pick an SMT 1.2 solver - -\*******************************************************************/ - +/// Uses the options to pick an SMT 1.2 solver +/// \return An smt1_dect::solvert giving the solver to use. smt1_dect::solvert cbmc_solverst::get_smt1_solver_type() const { assert(options.get_bool_option("smt1")); @@ -65,18 +58,8 @@ smt1_dect::solvert cbmc_solverst::get_smt1_solver_type() const return s; } -/*******************************************************************\ - -Function: cbmc_solverst::get_smt2_solver_type - - Inputs: None - - Outputs: An smt2_dect::solvert giving the solver to use. - - Purpose: Uses the options to pick an SMT 2.0 solver - -\*******************************************************************/ - +/// Uses the options to pick an SMT 2.0 solver +/// \return An smt2_dect::solvert giving the solver to use. smt2_dect::solvert cbmc_solverst::get_smt2_solver_type() const { assert(options.get_bool_option("smt2")); @@ -103,18 +86,7 @@ smt2_dect::solvert cbmc_solverst::get_smt2_solver_type() const return s; } -/*******************************************************************\ - -Function: cbmc_solverst::get_default - - Inputs: - - Outputs: - - Purpose: Get the default decision procedure - -\*******************************************************************/ - +/// Get the default decision procedure cbmc_solverst::solvert* cbmc_solverst::get_default() { solvert *solver=new solvert; @@ -144,18 +116,6 @@ cbmc_solverst::solvert* cbmc_solverst::get_default() return solver; } -/*******************************************************************\ - -Function: cbmc_solverst::get_dimacs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - cbmc_solverst::solvert* cbmc_solverst::get_dimacs() { no_beautification(); @@ -169,18 +129,6 @@ cbmc_solverst::solvert* cbmc_solverst::get_dimacs() return new solvert(new cbmc_dimacst(ns, *prop, filename), prop); } -/*******************************************************************\ - -Function: cbmc_solverst::get_bv_refinement - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - cbmc_solverst::solvert* cbmc_solverst::get_bv_refinement() { propt *prop; @@ -212,17 +160,9 @@ cbmc_solverst::solvert* cbmc_solverst::get_bv_refinement() return new solvert(bv_refinement, prop); } -/*******************************************************************\ - -Function: cbmc_solverst::get_string_refinement - - Outputs: a solver for cbmc - - Purpose: the string refinement adds to the bit vector refinement - specifications for functions from the Java string library - -\*******************************************************************/ - +/// the string refinement adds to the bit vector refinement specifications for +/// functions from the Java string library +/// \return a solver for cbmc cbmc_solverst::solvert* cbmc_solverst::get_string_refinement() { propt *prop; @@ -254,18 +194,6 @@ cbmc_solverst::solvert* cbmc_solverst::get_string_refinement() return new solvert(string_refinement, prop); } -/*******************************************************************\ - -Function: cbmc_solverst::get_smt1 - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - cbmc_solverst::solvert* cbmc_solverst::get_smt1(smt1_dect::solvert solver) { no_beautification(); @@ -335,18 +263,6 @@ cbmc_solverst::solvert* cbmc_solverst::get_smt1(smt1_dect::solvert solver) } } -/*******************************************************************\ - -Function: cbmc_solverst::get_smt2 - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - cbmc_solverst::solvert* cbmc_solverst::get_smt2(smt2_dect::solvert solver) { no_beautification(); @@ -424,18 +340,6 @@ cbmc_solverst::solvert* cbmc_solverst::get_smt2(smt2_dect::solvert solver) } } -/*******************************************************************\ - -Function: cbmc_solverst::no_beautification - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cbmc_solverst::no_beautification() { if(options.get_bool_option("beautify")) @@ -445,18 +349,6 @@ void cbmc_solverst::no_beautification() } } -/*******************************************************************\ - -Function: cbmc_solverst::no_incremental_check - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cbmc_solverst::no_incremental_check() { if(options.get_bool_option("all-properties") || diff --git a/src/cbmc/cbmc_solvers.h b/src/cbmc/cbmc_solvers.h index c837bd55806..f17f9b663bf 100644 --- a/src/cbmc/cbmc_solvers.h +++ b/src/cbmc/cbmc_solvers.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Bounded Model Checking for ANSI-C + HDL + #ifndef CPROVER_CBMC_CBMC_SOLVERS_H #define CPROVER_CBMC_CBMC_SOLVERS_H @@ -27,12 +30,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "bv_cbmc.h" -/*******************************************************************\ - -Solver factory - -\*******************************************************************/ - class cbmc_solverst:public messaget { public: diff --git a/src/cbmc/counterexample_beautification.cpp b/src/cbmc/counterexample_beautification.cpp index a65069618df..334366ca8f2 100644 --- a/src/cbmc/counterexample_beautification.cpp +++ b/src/cbmc/counterexample_beautification.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Counterexample Beautification using Incremental SAT + #include #include #include @@ -16,18 +19,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "counterexample_beautification.h" -/*******************************************************************\ - -Function: counterexample_beautificationt::get_minimization_list - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void counterexample_beautificationt::get_minimization_list( prop_convt &prop_conv, const symex_target_equationt &equation, @@ -68,18 +59,6 @@ void counterexample_beautificationt::get_minimization_list( } } -/*******************************************************************\ - -Function: counterexample_beautificationt::get_failed_property - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - symex_target_equationt::SSA_stepst::const_iterator counterexample_beautificationt::get_failed_property( const prop_convt &prop_conv, @@ -99,18 +78,6 @@ counterexample_beautificationt::get_failed_property( return equation.SSA_steps.end(); } -/*******************************************************************\ - -Function: counterexample_beautificationt::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void counterexample_beautificationt::operator()( bv_cbmct &bv_cbmc, const symex_target_equationt &equation, diff --git a/src/cbmc/counterexample_beautification.h b/src/cbmc/counterexample_beautification.h index d4f9c35bc88..10bb96f4597 100644 --- a/src/cbmc/counterexample_beautification.h +++ b/src/cbmc/counterexample_beautification.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Counterexample Beautification + #ifndef CPROVER_CBMC_COUNTEREXAMPLE_BEAUTIFICATION_H #define CPROVER_CBMC_COUNTEREXAMPLE_BEAUTIFICATION_H diff --git a/src/cbmc/fault_localization.cpp b/src/cbmc/fault_localization.cpp index f248428c5be..2beae26ff79 100644 --- a/src/cbmc/fault_localization.cpp +++ b/src/cbmc/fault_localization.cpp @@ -6,6 +6,9 @@ Author: Peter Schrammel \*******************************************************************/ +/// \file +/// Fault Localization + #include #include #include @@ -21,18 +24,6 @@ Author: Peter Schrammel #include "fault_localization.h" #include "counterexample_beautification.h" -/*******************************************************************\ - -Function: fault_localizationt::freeze_guards - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void fault_localizationt::freeze_guards() { for(const auto &step : bmc.equation.SSA_steps) @@ -45,18 +36,6 @@ void fault_localizationt::freeze_guards() } } -/*******************************************************************\ - -Function: fault_localizationt::collect_guards - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void fault_localizationt::collect_guards(lpointst &lpoints) { for(symex_target_equationt::SSA_stepst::const_iterator @@ -80,18 +59,6 @@ void fault_localizationt::collect_guards(lpointst &lpoints) } } -/*******************************************************************\ - -Function: fault_localizationt::get_failed_property - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - symex_target_equationt::SSA_stepst::const_iterator fault_localizationt::get_failed_property() { @@ -107,18 +74,6 @@ fault_localizationt::get_failed_property() return bmc.equation.SSA_steps.end(); } -/*******************************************************************\ - -Function: fault_localizationt::check - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool fault_localizationt::check(const lpointst &lpoints, const lpoints_valuet &value) { @@ -145,18 +100,6 @@ bool fault_localizationt::check(const lpointst &lpoints, return true; } -/*******************************************************************\ - -Function: fault_localizationt::update_scores - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void fault_localizationt::update_scores(lpointst &lpoints, const lpoints_valuet &value) { @@ -174,18 +117,6 @@ void fault_localizationt::update_scores(lpointst &lpoints, } } -/*******************************************************************\ - -Function: fault_localizationt::localize_linear - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void fault_localizationt::localize_linear(lpointst &lpoints) { lpoints_valuet v; @@ -204,18 +135,6 @@ void fault_localizationt::localize_linear(lpointst &lpoints) } } -/*******************************************************************\ - -Function: fault_localizationt::run - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void fault_localizationt::run(irep_idt goal_id) { // find failed property @@ -243,18 +162,6 @@ void fault_localizationt::run(irep_idt goal_id) bmc.prop_conv.set_assumptions(assumptions); } -/*******************************************************************\ - -Function: fault_localizationt::report() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void fault_localizationt::report(irep_idt goal_id) { if(goal_id==ID_nil) @@ -284,18 +191,6 @@ void fault_localizationt::report(irep_idt goal_id) << eom; } -/*******************************************************************\ - -Function: fault_localizationt::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - safety_checkert::resultt fault_localizationt::operator()() { if(options.get_bool_option("stop-on-fail")) @@ -304,18 +199,6 @@ safety_checkert::resultt fault_localizationt::operator()() return bmc_all_propertiest::operator()(); } -/*******************************************************************\ - -Function: fault_localizationt::run_decision_procedure - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - decision_proceduret::resultt fault_localizationt::run_decision_procedure(prop_convt &prop_conv) { @@ -346,18 +229,6 @@ fault_localizationt::run_decision_procedure(prop_convt &prop_conv) return dec_result; } -/*******************************************************************\ - -Function: fault_localizationt::stop_on_fail - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - safety_checkert::resultt fault_localizationt::stop_on_fail() { switch(run_decision_procedure(bmc.prop_conv)) @@ -391,18 +262,6 @@ safety_checkert::resultt fault_localizationt::stop_on_fail() } } -/*******************************************************************\ - -Function: fault_localizationt::goal_covered - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void fault_localizationt::goal_covered( const cover_goalst::goalt &) { @@ -434,18 +293,6 @@ void fault_localizationt::goal_covered( } } -/*******************************************************************\ - -Function: fault_localizationt::report - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void fault_localizationt::report( const cover_goalst &cover_goals) { diff --git a/src/cbmc/fault_localization.h b/src/cbmc/fault_localization.h index 552095b7cd3..0c3ec090153 100644 --- a/src/cbmc/fault_localization.h +++ b/src/cbmc/fault_localization.h @@ -6,6 +6,9 @@ Author: Peter Schrammel \*******************************************************************/ +/// \file +/// Fault Localization + #ifndef CPROVER_CBMC_FAULT_LOCALIZATION_H #define CPROVER_CBMC_FAULT_LOCALIZATION_H diff --git a/src/cbmc/show_vcc.cpp b/src/cbmc/show_vcc.cpp index 1ae0de6900a..f7a777173ce 100644 --- a/src/cbmc/show_vcc.cpp +++ b/src/cbmc/show_vcc.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbolic Execution of ANSI-C + #include #include @@ -20,18 +23,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "bmc.h" -/*******************************************************************\ - -Function: bmct::show_vcc_plain - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bmct::show_vcc_plain(std::ostream &out) { out << "\n" << "VERIFICATION CONDITIONS:" << "\n" << "\n"; @@ -90,18 +81,6 @@ void bmct::show_vcc_plain(std::ostream &out) } } -/*******************************************************************\ - -Function: bmct::show_vcc_json - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bmct::show_vcc_json(std::ostream &out) { json_objectt json_result; @@ -160,18 +139,6 @@ void bmct::show_vcc_json(std::ostream &out) out << ",\n" << json_result; } -/*******************************************************************\ - -Function: bmct::show_vcc - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bmct::show_vcc() { const std::string &filename=options.get_option("outfile"); diff --git a/src/cbmc/symex_bmc.cpp b/src/cbmc/symex_bmc.cpp index 5ae65275ef6..ce6afc9dfa2 100644 --- a/src/cbmc/symex_bmc.cpp +++ b/src/cbmc/symex_bmc.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Bounded Model Checking for ANSI-C + #include #include @@ -13,18 +16,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "symex_bmc.h" -/*******************************************************************\ - -Function: symex_bmct::symex_bmct - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - symex_bmct::symex_bmct( const namespacet &_ns, symbol_tablet &_new_symbol_table, @@ -36,18 +27,7 @@ symex_bmct::symex_bmct( { } -/*******************************************************************\ - -Function: symex_bmct::symex_step - - Inputs: - - Outputs: - - Purpose: show progress - -\*******************************************************************/ - +/// show progress void symex_bmct::symex_step( const goto_functionst &goto_functions, statet &state) @@ -65,6 +45,7 @@ void symex_bmct::symex_step( } const goto_programt::const_targett cur_pc=state.source.pc; + const guardt cur_guard=state.guard; if(!state.guard.is_false() && state.source.pc->is_assume() && @@ -84,30 +65,25 @@ void symex_bmct::symex_step( 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!=goto_functions.entry_point()) && - // 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); + cur_pc->function!=goto_functions.entry_point())) + { + // forward goto will effectively be covered via phi function, + // which does not invoke symex_step; as symex_step is called + // before merge_gotos, also state.guard will be false (we have + // taken an impossible transition); thus we synthesize a + // transition from the goto instruction to its target to make + // sure the goto is considered covered + if(cur_pc->is_goto() && + cur_pc->get_target()!=state.source.pc && + cur_pc->guard.is_true()) + symex_coverage.covered(cur_pc, cur_pc->get_target()); + else if(!state.guard.is_false()) + 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) @@ -127,18 +103,6 @@ void symex_bmct::merge_goto( symex_coverage.covered(prev_pc, state.source.pc); } -/*******************************************************************\ - -Function: symex_bmct::get_unwind - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool symex_bmct::get_unwind( const symex_targett::sourcet &source, unsigned unwind) @@ -180,18 +144,6 @@ bool symex_bmct::get_unwind( return abort; } -/*******************************************************************\ - -Function: symex_bmct::get_unwind_recursion - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool symex_bmct::get_unwind_recursion( const irep_idt &id, const unsigned thread_nr, @@ -237,18 +189,6 @@ bool symex_bmct::get_unwind_recursion( return abort; } -/*******************************************************************\ - -Function: symex_bmct::no_body - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_bmct::no_body(const irep_idt &identifier) { if(body_warnings.insert(identifier).second) diff --git a/src/cbmc/symex_bmc.h b/src/cbmc/symex_bmc.h index 8b2df348f3b..b8d23a52719 100644 --- a/src/cbmc/symex_bmc.h +++ b/src/cbmc/symex_bmc.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Bounded Model Checking for ANSI-C + #ifndef CPROVER_CBMC_SYMEX_BMC_H #define CPROVER_CBMC_SYMEX_BMC_H diff --git a/src/cbmc/symex_coverage.cpp b/src/cbmc/symex_coverage.cpp index 812df4de062..8f41ece7667 100644 --- a/src/cbmc/symex_coverage.cpp +++ b/src/cbmc/symex_coverage.cpp @@ -8,6 +8,9 @@ Date: March 2016 \*******************************************************************/ +/// \file +/// Record and print code coverage of symbolic execution + #include #include #include @@ -91,18 +94,6 @@ class goto_program_coverage_recordt:public coverage_recordt coverage_lines_mapt &dest); }; -/*******************************************************************\ - -Function: rate - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static std::string rate( std::size_t covered, std::size_t total, @@ -129,17 +120,16 @@ static std::string rate( return oss.str(); } -/*******************************************************************\ - -Function: goto_program_coverage_recordt::goto_program_coverage_recordt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ +static std::string rate_detailed( + std::size_t covered, + std::size_t total, + bool per_cent=false) +{ + std::ostringstream oss; + oss << rate(covered, total, per_cent) + << " (" << covered << '/' << total << ')'; + return oss.str(); +} goto_program_coverage_recordt::goto_program_coverage_recordt( const namespacet &ns, @@ -187,7 +177,7 @@ goto_program_coverage_recordt::goto_program_coverage_recordt( from_type(ns, gf_it->first, sig_type)); xml.set_attribute("line-rate", - rate(lines_covered, lines_total)); + rate_detailed(lines_covered, lines_total)); xml.set_attribute("branch-rate", rate(branches_covered, branches_total)); @@ -219,26 +209,13 @@ goto_program_coverage_recordt::goto_program_coverage_recordt( 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()); + line.set_attribute( + "condition-coverage", + rate_detailed(total_taken, number*2, true)); } } } -/*******************************************************************\ - -Function: goto_program_coverage_recordt::compute_coverage_lines - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_program_coverage_recordt::compute_coverage_lines( const goto_programt &goto_program, const irep_idt &file_name, @@ -279,9 +256,9 @@ void goto_program_coverage_recordt::compute_coverage_lines( { if(!(c_entry->second.size()==1 || is_branch)) { - std::cerr << it->location_number << std::endl; + std::cerr << it->location_number << '\n'; for(const auto &cov : c_entry->second) - std::cerr << cov.second.succ->location_number << std::endl; + std::cerr << cov.second.succ->location_number << '\n'; } assert(c_entry->second.size()==1 || is_branch); @@ -292,7 +269,8 @@ void goto_program_coverage_recordt::compute_coverage_lines( if(entry.first->second.hits==0) ++lines_covered; - entry.first->second.hits+=cov.second.num_executions; + if(cov.second.num_executions>entry.first->second.hits) + entry.first->second.hits=cov.second.num_executions; if(is_branch) { @@ -321,18 +299,6 @@ void goto_program_coverage_recordt::compute_coverage_lines( } } -/*******************************************************************\ - -Function: symex_coveraget::compute_overall_coverage - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_coveraget::compute_overall_coverage( const goto_functionst &goto_functions, coverage_recordt &dest) const @@ -409,18 +375,6 @@ void symex_coveraget::compute_overall_coverage( } } -/*******************************************************************\ - -Function: symex_coveraget::build_cobertura - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_coveraget::build_cobertura( const goto_functionst &goto_functions, xmlt &xml_coverage) const @@ -462,18 +416,6 @@ void symex_coveraget::build_cobertura( package.set_attribute("complexity", "0.0"); } -/*******************************************************************\ - -Function: symex_coveraget::output_report - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool symex_coveraget::output_report( const goto_functionst &goto_functions, std::ostream &os) const @@ -489,18 +431,6 @@ bool symex_coveraget::output_report( return !os.good(); } -/*******************************************************************\ - -Function: symex_coveraget::output_report - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool symex_coveraget::generate_report( const goto_functionst &goto_functions, const std::string &path) const diff --git a/src/cbmc/symex_coverage.h b/src/cbmc/symex_coverage.h index c173bc65ad7..b7556b1087b 100644 --- a/src/cbmc/symex_coverage.h +++ b/src/cbmc/symex_coverage.h @@ -8,6 +8,9 @@ Date: March 2016 \*******************************************************************/ +/// \file +/// Record and print code coverage of symbolic execution + #ifndef CPROVER_CBMC_SYMEX_COVERAGE_H #define CPROVER_CBMC_SYMEX_COVERAGE_H diff --git a/src/cbmc/xml_interface.cpp b/src/cbmc/xml_interface.cpp index d94fa7bf034..da58cfe12c5 100644 --- a/src/cbmc/xml_interface.cpp +++ b/src/cbmc/xml_interface.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// XML Interface + #include #include @@ -14,18 +17,7 @@ Author: Daniel Kroening, kroening@kroening.com #include "xml_interface.h" -/*******************************************************************\ - -Function: xml_interfacet::get_xml_options - - Inputs: - - Outputs: - - Purpose: XML User Interface - -\*******************************************************************/ - +/// XML User Interface void xml_interfacet::get_xml_options(cmdlinet &cmdline) { if(cmdline.isset("xml-interface")) @@ -41,18 +33,7 @@ void xml_interfacet::get_xml_options(cmdlinet &cmdline) } } -/*******************************************************************\ - -Function: xml_interfacet::get_xml_options - - Inputs: - - Outputs: - - Purpose: XML User Interface - -\*******************************************************************/ - +/// XML User Interface void xml_interfacet::get_xml_options( const xmlt &xml, cmdlinet &cmdline) diff --git a/src/cbmc/xml_interface.h b/src/cbmc/xml_interface.h index 0cf038083db..945be7624bb 100644 --- a/src/cbmc/xml_interface.h +++ b/src/cbmc/xml_interface.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// XML Interface + #ifndef CPROVER_CBMC_XML_INTERFACE_H #define CPROVER_CBMC_XML_INTERFACE_H diff --git a/src/clobber/clobber_main.cpp b/src/clobber/clobber_main.cpp index 8255f068c92..16e2a286900 100644 --- a/src/clobber/clobber_main.cpp +++ b/src/clobber/clobber_main.cpp @@ -6,22 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symex Main Module + #include #include "clobber_parse_options.h" -/*******************************************************************\ - -Function: main - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - #ifdef _MSC_VER int wmain(int argc, const wchar_t **argv_wide) { diff --git a/src/clobber/clobber_parse_options.cpp b/src/clobber/clobber_parse_options.cpp index a8fd471ecb6..42aadee4326 100644 --- a/src/clobber/clobber_parse_options.cpp +++ b/src/clobber/clobber_parse_options.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symex Command Line Options Processing + #include #include #include @@ -37,18 +40,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "clobber_parse_options.h" // #include "clobber_instrumenter.h" -/*******************************************************************\ - -Function: clobber_parse_optionst::clobber_parse_optionst - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - clobber_parse_optionst::clobber_parse_optionst(int argc, const char **argv): parse_options_baset(CLOBBER_OPTIONS, argc, argv), language_uit(cmdline, ui_message_handler), @@ -56,18 +47,6 @@ clobber_parse_optionst::clobber_parse_optionst(int argc, const char **argv): { } -/*******************************************************************\ - -Function: clobber_parse_optionst::eval_verbosity - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void clobber_parse_optionst::eval_verbosity() { // this is our default verbosity @@ -85,18 +64,6 @@ void clobber_parse_optionst::eval_verbosity() ui_message_handler.set_verbosity(v); } -/*******************************************************************\ - -Function: clobber_parse_optionst::get_command_line_options - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void clobber_parse_optionst::get_command_line_options(optionst &options) { if(config.set(cmdline)) @@ -131,23 +98,12 @@ void clobber_parse_optionst::get_command_line_options(optionst &options) options.set_option("error-label", cmdline.get_value("error-label")); } -/*******************************************************************\ - -Function: clobber_parse_optionst::doit - - Inputs: - - Outputs: - - Purpose: invoke main modules - -\*******************************************************************/ - +/// invoke main modules int clobber_parse_optionst::doit() { if(cmdline.isset("version")) { - std::cout << CBMC_VERSION << std::endl; + std::cout << CBMC_VERSION << '\n'; return 0; } @@ -224,18 +180,6 @@ int clobber_parse_optionst::doit() #endif } -/*******************************************************************\ - -Function: clobber_parse_optionst::set_properties - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool clobber_parse_optionst::set_properties(goto_functionst &goto_functions) { if(cmdline.isset("property")) @@ -244,18 +188,6 @@ bool clobber_parse_optionst::set_properties(goto_functionst &goto_functions) return false; } -/*******************************************************************\ - -Function: clobber_parse_optionst::get_goto_program - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool clobber_parse_optionst::get_goto_program( const optionst &options, goto_functionst &goto_functions) @@ -326,7 +258,7 @@ bool clobber_parse_optionst::get_goto_program( language->set_message_handler(get_message_handler()); - status("Parsing", filename); + status() << "Parsing " << filename << eom; if(language->parse(infile, filename)) { @@ -378,18 +310,6 @@ bool clobber_parse_optionst::get_goto_program( return false; } -/*******************************************************************\ - -Function: clobber_parse_optionst::process_goto_program - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool clobber_parse_optionst::process_goto_program( const optionst &options, goto_functionst &goto_functions) @@ -435,18 +355,6 @@ bool clobber_parse_optionst::process_goto_program( return false; } -/*******************************************************************\ - -Function: clobber_parse_optionst::report_properties - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - #if 0 void clobber_parse_optionst::report_properties( const path_searcht::property_mapt &property_map) @@ -506,18 +414,6 @@ void clobber_parse_optionst::report_properties( } #endif -/*******************************************************************\ - -Function: clobber_parse_optionst::report_success - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void clobber_parse_optionst::report_success() { result() << "VERIFICATION SUCCESSFUL" << eom; @@ -532,7 +428,7 @@ void clobber_parse_optionst::report_success() xmlt xml("cprover-status"); xml.data="SUCCESS"; std::cout << xml; - std::cout << std::endl; + std::cout << '\n'; } break; @@ -541,18 +437,6 @@ void clobber_parse_optionst::report_success() } } -/*******************************************************************\ - -Function: clobber_parse_optionst::show_counterexample - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void clobber_parse_optionst::show_counterexample( const goto_tracet &error_trace) { @@ -561,7 +445,7 @@ void clobber_parse_optionst::show_counterexample( switch(get_ui()) { case ui_message_handlert::uit::PLAIN: - std::cout << std::endl << "Counterexample:" << std::endl; + std::cout << "\nCounterexample:\n"; show_goto_trace(std::cout, ns, error_trace); break; @@ -569,7 +453,7 @@ void clobber_parse_optionst::show_counterexample( { xmlt xml; convert(ns, error_trace, xml); - std::cout << xml << std::endl; + std::cout << xml << '\n'; } break; @@ -578,18 +462,6 @@ void clobber_parse_optionst::show_counterexample( } } -/*******************************************************************\ - -Function: clobber_parse_optionst::report_failure - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void clobber_parse_optionst::report_failure() { result() << "VERIFICATION FAILED" << eom; @@ -604,7 +476,7 @@ void clobber_parse_optionst::report_failure() xmlt xml("cprover-status"); xml.data="FAILURE"; std::cout << xml; - std::cout << std::endl; + std::cout << '\n'; } break; @@ -613,18 +485,7 @@ void clobber_parse_optionst::report_failure() } } -/*******************************************************************\ - -Function: clobber_parse_optionst::help - - Inputs: - - Outputs: - - Purpose: display command line help - -\*******************************************************************/ - +/// display command line help void clobber_parse_optionst::help() { std::cout << diff --git a/src/clobber/clobber_parse_options.h b/src/clobber/clobber_parse_options.h index ffd897c9155..89faff353f0 100644 --- a/src/clobber/clobber_parse_options.h +++ b/src/clobber/clobber_parse_options.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Command Line Parsing + #ifndef CPROVER_CLOBBER_CLOBBER_PARSE_OPTIONS_H #define CPROVER_CLOBBER_CLOBBER_PARSE_OPTIONS_H diff --git a/src/common b/src/common index 20c4fadbb44..2cab9f49cbb 100644 --- a/src/common +++ b/src/common @@ -30,14 +30,17 @@ else EXEEXT = endif CFLAGS ?= -Wall -O2 - CXXFLAGS ?= -Wall -O2 CP_CFLAGS = -MMD -MP + CXXFLAGS ?= -Wall -O2 ifeq ($(filter-out OSX OSX_Universal,$(BUILD_ENV_)),) CP_CXXFLAGS = -MMD -MP -mmacosx-version-min=10.9 -std=c++11 -stdlib=libc++ LINKFLAGS += -mmacosx-version-min=10.9 -stdlib=libc++ LINKNATIVE += -mmacosx-version-min=10.9 -stdlib=libc++ else CP_CXXFLAGS = -MMD -MP -std=c++11 +endif +ifeq ($(filter -O%,$(CXXFLAGS)),) + CP_CXXFLAGS += -O2 endif #LINKFLAGS = -static ifeq ($(filter-out OSX OSX_Universal,$(BUILD_ENV_)),) diff --git a/src/cpp/cpp_constructor.cpp b/src/cpp/cpp_constructor.cpp index 3c5b34762dd..07eed381807 100644 --- a/src/cpp/cpp_constructor.cpp +++ b/src/cpp/cpp_constructor.cpp @@ -6,26 +6,19 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include #include -#include +#include #include "cpp_typecheck.h" #include "cpp_util.h" -/*******************************************************************\ - -Function: cpp_typecheckt::cpp_constructor - - Inputs: non-typchecked object, non-typechecked operands - - Outputs: typechecked code - - Purpose: - -\*******************************************************************/ - +/// \param non:typchecked object, non-typechecked operands +/// \return typechecked code codet cpp_typecheckt::cpp_constructor( const source_locationt &source_location, const exprt &object, @@ -315,18 +308,6 @@ codet cpp_typecheckt::cpp_constructor( return nil; } -/*******************************************************************\ - -Function: cpp_typecheckt::new_temporary - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::new_temporary( const source_locationt &source_location, const typet &type, @@ -359,18 +340,6 @@ void cpp_typecheckt::new_temporary( temporary.swap(tmp_object_expr); } -/*******************************************************************\ - -Function: cpp_typecheckt::new_temporary - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::new_temporary( const source_locationt &source_location, const typet &type, diff --git a/src/cpp/cpp_convert_type.cpp b/src/cpp/cpp_convert_type.cpp index 0f106b19575..e1ea09606a4 100644 --- a/src/cpp/cpp_convert_type.cpp +++ b/src/cpp/cpp_convert_type.cpp @@ -6,13 +6,16 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Conversion + #include #include #include #include -#include +#include #include "cpp_convert_type.h" #include "cpp_declaration.h" @@ -42,18 +45,6 @@ class cpp_convert_typet void read_template(const typet &type); }; -/*******************************************************************\ - -Function: cpp_convert_typet::read - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_convert_typet::read(const typet &type) { unsigned_cnt=signed_cnt=char_cnt=int_cnt=short_cnt= @@ -66,29 +57,17 @@ void cpp_convert_typet::read(const typet &type) other.clear(); #if 0 - std::cout << "cpp_convert_typet::read: " << type.pretty() << std::endl; + std::cout << "cpp_convert_typet::read: " << type.pretty() << '\n'; #endif read_rec(type); } -/*******************************************************************\ - -Function: cpp_convert_typet::read_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_convert_typet::read_rec(const typet &type) { #if 0 std::cout << "cpp_convert_typet::read_rec: " - << type.pretty() << std::endl; + << type.pretty() << '\n'; #endif if(type.id()==ID_merged_type) @@ -185,18 +164,6 @@ void cpp_convert_typet::read_rec(const typet &type) } } -/*******************************************************************\ - -Function: cpp_covnert_typet::read_template - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_convert_typet::read_template(const typet &type) { other.push_back(type); @@ -225,18 +192,6 @@ void cpp_convert_typet::read_template(const typet &type) } } -/*******************************************************************\ - -Function: cpp_convert_typet::read_function_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_convert_typet::read_function_type(const typet &type) { other.push_back(type); @@ -338,18 +293,6 @@ void cpp_convert_typet::read_function_type(const typet &type) parameters.get_sub().clear(); } -/*******************************************************************\ - -Function: cpp_convert_typet::write - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_convert_typet::write(typet &type) { type.clear(); @@ -600,18 +543,6 @@ void cpp_convert_typet::write(typet &type) type.set(ID_C_volatile, true); } -/*******************************************************************\ - -Function: cpp_convert_plain_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_convert_plain_type(typet &type) { if(type.id()==ID_cpp_name || diff --git a/src/cpp/cpp_convert_type.h b/src/cpp/cpp_convert_type.h index 9c690287fae..590ce6e98a6 100644 --- a/src/cpp/cpp_convert_type.h +++ b/src/cpp/cpp_convert_type.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Conversion + #ifndef CPROVER_CPP_CPP_CONVERT_TYPE_H #define CPROVER_CPP_CPP_CONVERT_TYPE_H diff --git a/src/cpp/cpp_declaration.cpp b/src/cpp/cpp_declaration.cpp index 1a06fbaa36d..432390c79bc 100644 --- a/src/cpp/cpp_declaration.cpp +++ b/src/cpp/cpp_declaration.cpp @@ -6,22 +6,13 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include #include "cpp_declaration.h" -/*******************************************************************\ - -Function: cpp_declarationt::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_declarationt::output(std::ostream &out) const { out << "is_template: " << is_template() << "\n"; @@ -38,18 +29,6 @@ void cpp_declarationt::output(std::ostream &out) const } } -/*******************************************************************\ - -Function: cpp_declarationt::name_anon_struct_union - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_declarationt::name_anon_struct_union(typet &dest) { // We name any anon struct/unions according to the first diff --git a/src/cpp/cpp_declaration.h b/src/cpp/cpp_declaration.h index 271f7c5ee44..17cf872d226 100644 --- a/src/cpp/cpp_declaration.h +++ b/src/cpp/cpp_declaration.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #ifndef CPROVER_CPP_CPP_DECLARATION_H #define CPROVER_CPP_CPP_DECLARATION_H diff --git a/src/cpp/cpp_declarator.cpp b/src/cpp/cpp_declarator.cpp index 063003b696c..cbf97d6a06e 100644 --- a/src/cpp/cpp_declarator.cpp +++ b/src/cpp/cpp_declarator.cpp @@ -6,23 +6,14 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include #include #include "cpp_declarator.h" -/*******************************************************************\ - -Function: cpp_declaratort::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_declaratort::output(std::ostream &out) const { out << " name: " << name().pretty() << "\n"; @@ -32,18 +23,6 @@ void cpp_declaratort::output(std::ostream &out) const out << " method_qualifier: " << method_qualifier().pretty() << "\n"; } -/*******************************************************************\ - -Function: cpp_declaratort::merge_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet cpp_declaratort::merge_type(const typet &declaration_type) const { typet dest_type=type(); @@ -70,7 +49,7 @@ typet cpp_declaratort::merge_type(const typet &declaration_type) const } else { - assert(t.id()!=irep_idt()); + assert(!t.id().empty()); p=&t.subtype(); } } diff --git a/src/cpp/cpp_declarator.h b/src/cpp/cpp_declarator.h index 3a08f17180a..7f316506f56 100644 --- a/src/cpp/cpp_declarator.h +++ b/src/cpp/cpp_declarator.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #ifndef CPROVER_CPP_CPP_DECLARATOR_H #define CPROVER_CPP_CPP_DECLARATOR_H diff --git a/src/cpp/cpp_declarator_converter.cpp b/src/cpp/cpp_declarator_converter.cpp index 24a295a03f7..986da53bb11 100644 --- a/src/cpp/cpp_declarator_converter.cpp +++ b/src/cpp/cpp_declarator_converter.cpp @@ -6,27 +6,18 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include #include -#include +#include #include "cpp_type2name.h" #include "cpp_declarator_converter.h" #include "cpp_typecheck.h" -/*******************************************************************\ - -Function: cpp_declarator_convertert::cpp_declarator_convertert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - cpp_declarator_convertert::cpp_declarator_convertert( class cpp_typecheckt &_cpp_typecheck): is_typedef(false), @@ -38,18 +29,6 @@ cpp_declarator_convertert::cpp_declarator_convertert( { } -/*******************************************************************\ - -Function: cpp_declarator_convertert::convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - symbolt &cpp_declarator_convertert::convert( const typet &declaration_type, const cpp_storage_spect &storage_spec, @@ -252,18 +231,6 @@ symbolt &cpp_declarator_convertert::convert( } } -/*******************************************************************\ - -Function: cpp_declarator_convertert::combine_types - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_declarator_convertert::combine_types( const source_locationt &source_location, const typet &decl_type, @@ -346,18 +313,6 @@ void cpp_declarator_convertert::combine_types( throw 0; } -/*******************************************************************\ - -Function: cpp_declarator_convertert::enforce_rules - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_declarator_convertert::enforce_rules(const symbolt &symbol) { // enforce rules for operator overloading @@ -367,18 +322,6 @@ void cpp_declarator_convertert::enforce_rules(const symbolt &symbol) main_function_rules(symbol); } -/*******************************************************************\ - -Function: cpp_declarator_convertert::handle_initializer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_declarator_convertert::handle_initializer( symbolt &symbol, cpp_declaratort &declarator) @@ -431,18 +374,6 @@ void cpp_declarator_convertert::handle_initializer( } } -/*******************************************************************\ - -Function: cpp_declarator_convertert::get_final_identifier - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_declarator_convertert::get_final_identifier() { std::string identifier=id2string(base_name); @@ -489,18 +420,6 @@ void cpp_declarator_convertert::get_final_identifier() identifier; } -/*******************************************************************\ - -Function: cpp_declarator_convertert::convert_new_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - symbolt &cpp_declarator_convertert::convert_new_symbol( const cpp_storage_spect &storage_spec, const cpp_member_spect &member_spec, @@ -641,18 +560,6 @@ symbolt &cpp_declarator_convertert::convert_new_symbol( return *new_symbol; } -/*******************************************************************\ - -Function: cpp_declarator_convertert::get_pretty_name - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - irep_idt cpp_declarator_convertert::get_pretty_name() { if(is_code) @@ -680,35 +587,11 @@ irep_idt cpp_declarator_convertert::get_pretty_name() return scope->prefix+id2string(base_name); } -/*******************************************************************\ - -Function: cpp_declarator_convertert::operator_overloading_rules - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_declarator_convertert::operator_overloading_rules( const symbolt &symbol) { } -/*******************************************************************\ - -Function: cpp_declarator_convertert::main_function_rules - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_declarator_convertert::main_function_rules( const symbolt &symbol) { diff --git a/src/cpp/cpp_declarator_converter.h b/src/cpp/cpp_declarator_converter.h index 850549a69d5..54399c6b62e 100644 --- a/src/cpp/cpp_declarator_converter.h +++ b/src/cpp/cpp_declarator_converter.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #ifndef CPROVER_CPP_CPP_DECLARATOR_CONVERTER_H #define CPROVER_CPP_CPP_DECLARATOR_CONVERTER_H diff --git a/src/cpp/cpp_destructor.cpp b/src/cpp/cpp_destructor.cpp index 75479a0ee85..00137a3138a 100644 --- a/src/cpp/cpp_destructor.cpp +++ b/src/cpp/cpp_destructor.cpp @@ -6,24 +6,16 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include -#include +#include #include "cpp_typecheck.h" -/*******************************************************************\ - -Function: cpp_typecheckt::cpp_destructor - - Inputs: - - Outputs: typechecked code - - Purpose: - -\*******************************************************************/ - +/// \return typechecked code codet cpp_typecheckt::cpp_destructor( const source_locationt &source_location, const typet &type, diff --git a/src/cpp/cpp_enum_type.cpp b/src/cpp/cpp_enum_type.cpp index ba4bc6ecbae..7d2c1de8e64 100644 --- a/src/cpp/cpp_enum_type.cpp +++ b/src/cpp/cpp_enum_type.cpp @@ -6,38 +6,17 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -#include +/// \file +/// C++ Language Type Checking -#include "cpp_enum_type.h" - -/*******************************************************************\ - -Function: cpp_enum_typet::cpp_enum_typet - - Inputs: +#include - Outputs: - - Purpose: - -\*******************************************************************/ +#include "cpp_enum_type.h" cpp_enum_typet::cpp_enum_typet():typet(ID_c_enum) { } -/*******************************************************************\ - -Function: cpp_enum_typet::generate_anon_tag - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - irep_idt cpp_enum_typet::generate_anon_tag() const { // This will only clash with anon enums that would have diff --git a/src/cpp/cpp_enum_type.h b/src/cpp/cpp_enum_type.h index 23edd61900e..97dc50df769 100644 --- a/src/cpp/cpp_enum_type.h +++ b/src/cpp/cpp_enum_type.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #ifndef CPROVER_CPP_CPP_ENUM_TYPE_H #define CPROVER_CPP_CPP_ENUM_TYPE_H diff --git a/src/cpp/cpp_exception_id.cpp b/src/cpp/cpp_exception_id.cpp index e64fa67e0df..18649696f53 100644 --- a/src/cpp/cpp_exception_id.cpp +++ b/src/cpp/cpp_exception_id.cpp @@ -6,20 +6,12 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -#include "cpp_exception_id.h" - -/*******************************************************************\ - -Function: cpp_exception_list_rec - - Inputs: - - Outputs: - - Purpose: turns a type into a list of relevant exception IDs +/// \file +/// C++ Language Type Checking -\*******************************************************************/ +#include "cpp_exception_id.h" +/// turns a type into a list of relevant exception IDs void cpp_exception_list_rec( const typet &src, const namespacet &ns, @@ -67,7 +59,7 @@ void cpp_exception_list_rec( // grab C/C++ type irep_idt c_type=src.get(ID_C_c_type); - if(c_type!=irep_idt()) + if(!c_type.empty()) { dest.push_back(id2string(c_type)+suffix); return; @@ -75,18 +67,7 @@ void cpp_exception_list_rec( } } -/*******************************************************************\ - -Function: cpp_exception_list - - Inputs: - - Outputs: - - Purpose: turns a type into a list of relevant exception IDs - -\*******************************************************************/ - +/// turns a type into a list of relevant exception IDs irept cpp_exception_list( const typet &src, const namespacet &ns) @@ -103,18 +84,7 @@ irept cpp_exception_list( return result; } -/*******************************************************************\ - -Function: cpp_exception_id - - Inputs: - - Outputs: - - Purpose: turns a type into an exception ID - -\*******************************************************************/ - +/// turns a type into an exception ID irep_idt cpp_exception_id( const typet &src, const namespacet &ns) diff --git a/src/cpp/cpp_exception_id.h b/src/cpp/cpp_exception_id.h index 38b675c76fb..c652169aa50 100644 --- a/src/cpp/cpp_exception_id.h +++ b/src/cpp/cpp_exception_id.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #ifndef CPROVER_CPP_CPP_EXCEPTION_ID_H #define CPROVER_CPP_CPP_EXCEPTION_ID_H diff --git a/src/cpp/cpp_id.cpp b/src/cpp/cpp_id.cpp index 4ccb1a095d1..7a18c134ba0 100644 --- a/src/cpp/cpp_id.cpp +++ b/src/cpp/cpp_id.cpp @@ -6,23 +6,14 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include #include "cpp_id.h" #include "cpp_scope.h" -/*******************************************************************\ - -Function: cpp_idt::cpp_idt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - cpp_idt::cpp_idt(): is_member(false), is_method(false), @@ -36,18 +27,6 @@ cpp_idt::cpp_idt(): { } -/*******************************************************************\ - -Function: cpp_idt::print - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_idt::print(std::ostream &out, unsigned indent) const { print_fields(out, indent); @@ -59,41 +38,29 @@ void cpp_idt::print(std::ostream &out, unsigned indent) const it++) it->second.print(out, indent+2); - out << std::endl; + out << '\n'; } } -/*******************************************************************\ - -Function: cpp_idt::print_fields - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_idt::print_fields(std::ostream &out, unsigned indent) const { for(unsigned i=0; i at " << s_it->source_location << std::endl; + out << "> at " << s_it->source_location << '\n'; } } -/*******************************************************************\ - -Function: cpp_typecheckt::class_template_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const symbolt &cpp_typecheckt::class_template_symbol( const source_locationt &source_location, const symbolt &template_symbol, @@ -212,18 +179,7 @@ const symbolt &cpp_typecheckt::class_template_symbol( return *s_ptr; } -/*******************************************************************\ - -Function: cpp_typecheckt::elaborate_class_template - - Inputs: - - Outputs: - - Purpose: elaborate class template instances - -\*******************************************************************/ - +/// elaborate class template instances void cpp_typecheckt::elaborate_class_template( const typet &type) { @@ -248,21 +204,10 @@ void cpp_typecheckt::elaborate_class_template( } } -/*******************************************************************\ - -Function: cpp_typecheckt::instantiate_template - - Inputs: location of the instantiation, - the identifier of the template symbol, - typechecked template arguments, - an (optional) specialization - - Outputs: - - Purpose: - -\*******************************************************************/ - +/// \par parameters: location of the instantiation, +/// the identifier of the template symbol, +/// typechecked template arguments, +/// an (optional) specialization #define MAX_DEPTH 50 const symbolt &cpp_typecheckt::instantiate_template( @@ -286,8 +231,8 @@ const symbolt &cpp_typecheckt::instantiate_template( instantiation_stack.back().full_template_args=full_template_args; #if 0 - std::cout << "L: " << source_location << std::endl; - std::cout << "I: " << template_symbol.name << std::endl; + std::cout << "L: " << source_location << '\n'; + std::cout << "I: " << template_symbol.name << '\n'; #endif cpp_save_scopet cpp_saved_scope(cpp_scopes); @@ -310,7 +255,7 @@ const symbolt &cpp_typecheckt::instantiate_template( else std::cout << to_string(*it); } - std::cout << ">" << std::endl; + std::cout << ">\n"; #endif // do we have arguments? @@ -429,7 +374,7 @@ const symbolt &cpp_typecheckt::instantiate_template( } #if 0 - std::cout << "MAP:" << std::endl; + std::cout << "MAP:\n"; template_map.print(std::cout); #endif @@ -540,7 +485,7 @@ const symbolt &cpp_typecheckt::instantiate_template( bool is_static=new_decl.storage_spec().is_static(); irep_idt access = new_decl.get(ID_C_access); - assert(access != irep_idt()); + assert(!access.empty()); assert(symb.type.id()==ID_struct); typecheck_compound_declarator( diff --git a/src/cpp/cpp_internal_additions.cpp b/src/cpp/cpp_internal_additions.cpp index dfeabc2739e..cd80ac8f298 100644 --- a/src/cpp/cpp_internal_additions.cpp +++ b/src/cpp/cpp_internal_additions.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -14,18 +15,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "cpp_internal_additions.h" -/*******************************************************************\ - -Function: c2cpp - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string c2cpp(const std::string &s) { std::string result; @@ -49,18 +38,6 @@ std::string c2cpp(const std::string &s) return result; } -/*******************************************************************\ - -Function: cpp_interal_additions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_internal_additions(std::ostream &out) { out << "# 1 \"\"" << '\n'; @@ -136,11 +113,20 @@ void cpp_internal_additions(std::ostream &out) { out << "extern \"C\" {" << '\n'; out << c2cpp(gcc_builtin_headers_generic); + out << c2cpp(gcc_builtin_headers_math); + out << c2cpp(gcc_builtin_headers_mem_string); + out << c2cpp(gcc_builtin_headers_omp); + out << c2cpp(gcc_builtin_headers_tm); + out << c2cpp(gcc_builtin_headers_ubsan); + out << c2cpp(clang_builtin_headers); if(config.ansi_c.mode==configt::ansi_ct::flavourt::APPLE) out << "typedef double __float128;\n"; // clang doesn't do __float128 out << c2cpp(gcc_builtin_headers_ia32); + out << c2cpp(gcc_builtin_headers_ia32_2); + out << c2cpp(gcc_builtin_headers_ia32_3); + out << c2cpp(gcc_builtin_headers_ia32_4); out << "}" << '\n'; } diff --git a/src/cpp/cpp_internal_additions.h b/src/cpp/cpp_internal_additions.h index 54a2189e877..c2b0fd46024 100644 --- a/src/cpp/cpp_internal_additions.h +++ b/src/cpp/cpp_internal_additions.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_CPP_CPP_INTERNAL_ADDITIONS_H #define CPROVER_CPP_CPP_INTERNAL_ADDITIONS_H diff --git a/src/cpp/cpp_is_pod.cpp b/src/cpp/cpp_is_pod.cpp index 2b5c895611e..5cd698fd718 100644 --- a/src/cpp/cpp_is_pod.cpp +++ b/src/cpp/cpp_is_pod.cpp @@ -6,40 +6,10 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -#include "cpp_typecheck.h" - -/*******************************************************************\ - -Function: cpp_typecheckt::cpp_is_pod - - Inputs: - - Outputs: +/// \file +/// C++ Language Type Checking - Standard: - "Arithmetic types (3.9.1), enumeration types, pointer types, and - pointer to member types (3.9.2), and cvqualified versions of - these types (3.9.3) are collectively called scalar types. Scalar - types, POD-struct types, POD-union types (clause 9), arrays of - such types and cv-qualified versions of these types (3.9.3) are - collectively called POD types." - - "A POD-struct is an aggregate class that has no non-static data - members of type non-POD-struct, non-POD-union (or array of such - types) or reference, and has no user-defined copy assignment - operator and no user-defined destructor. Similarly, a POD-union - is an aggregate union that has no non-static data members of type - non-POD-struct, non-POD-union (or array of such types) or reference, - and has no userdefined copy assignment operator and no user-defined - destructor. A POD class is a class that is either a POD-struct or - a POD-union." - - "An aggregate is an array or a class (clause 9) with no - user-declared constructors (12.1), no private or protected - non-static data members (clause 11), no base classes (clause 10), - and no virtual functions (10.3)." - -\*******************************************************************/ +#include "cpp_typecheck.h" bool cpp_typecheckt::cpp_is_pod(const typet &type) const { diff --git a/src/cpp/cpp_item.h b/src/cpp/cpp_item.h index f3f32674278..75b7c3e120c 100644 --- a/src/cpp/cpp_item.h +++ b/src/cpp/cpp_item.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #ifndef CPROVER_CPP_CPP_ITEM_H #define CPROVER_CPP_CPP_ITEM_H diff --git a/src/cpp/cpp_language.cpp b/src/cpp/cpp_language.cpp index f1b4b97018d..3843038950a 100644 --- a/src/cpp/cpp_language.cpp +++ b/src/cpp/cpp_language.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Module + #include #include #include @@ -26,18 +29,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "cpp_typecheck.h" #include "cpp_type2name.h" -/*******************************************************************\ - -Function: cpp_languaget::extensions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::set cpp_languaget::extensions() const { std::set s; @@ -56,35 +47,12 @@ std::set cpp_languaget::extensions() const return s; } -/*******************************************************************\ - -Function: cpp_languaget::modules_provided - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_languaget::modules_provided(std::set &modules) { modules.insert(get_base_name(parse_path, true)); } -/*******************************************************************\ - -Function: cpp_languaget::preprocess - - Inputs: - - Outputs: - - Purpose: ANSI-C preprocessing - -\*******************************************************************/ - +/// ANSI-C preprocessing bool cpp_languaget::preprocess( std::istream &instream, const std::string &path, @@ -111,18 +79,6 @@ bool cpp_languaget::preprocess( return c_preprocess(path, outstream, get_message_handler()); } -/*******************************************************************\ - -Function: cpp_languaget::parse - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool cpp_languaget::parse( std::istream &instream, const std::string &path) @@ -161,18 +117,6 @@ bool cpp_languaget::parse( return result; } -/*******************************************************************\ - -Function: cpp_languaget::typecheck - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool cpp_languaget::typecheck( symbol_tablet &symbol_table, const std::string &module) @@ -189,18 +133,6 @@ bool cpp_languaget::typecheck( return linking(symbol_table, new_symbol_table, get_message_handler()); } -/*******************************************************************\ - -Function: cpp_languaget::final - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool cpp_languaget::final(symbol_tablet &symbol_table) { if(ansi_c_entry_point(symbol_table, "main", get_message_handler())) @@ -209,18 +141,6 @@ bool cpp_languaget::final(symbol_tablet &symbol_table) return false; } -/*******************************************************************\ - -Function: cpp_languaget::show_parse - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_languaget::show_parse(std::ostream &out) { for(cpp_parse_treet::itemst::const_iterator it= @@ -230,18 +150,6 @@ void cpp_languaget::show_parse(std::ostream &out) show_parse(out, *it); } -/*******************************************************************\ - -Function: cpp_languaget::show_parse - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_languaget::show_parse( std::ostream &out, const cpp_itemt &item) @@ -252,7 +160,7 @@ void cpp_languaget::show_parse( item.get_linkage_spec(); out << "LINKAGE " << linkage_spec.linkage().get("value") - << ":" << std::endl; + << ":\n"; for(cpp_linkage_spect::itemst::const_iterator it=linkage_spec.items().begin(); @@ -260,7 +168,7 @@ void cpp_languaget::show_parse( it++) show_parse(out, *it); - out << std::endl; + out << '\n'; } else if(item.is_namespace_spec()) { @@ -268,7 +176,7 @@ void cpp_languaget::show_parse( item.get_namespace_spec(); out << "NAMESPACE " << namespace_spec.get_namespace() - << ":" << std::endl; + << ":\n"; for(cpp_namespace_spect::itemst::const_iterator it=namespace_spec.items().begin(); @@ -276,7 +184,7 @@ void cpp_languaget::show_parse( it++) show_parse(out, *it); - out << std::endl; + out << '\n'; } else if(item.is_using()) { @@ -285,46 +193,22 @@ void cpp_languaget::show_parse( out << "USING "; if(cpp_using.get_namespace()) out << "NAMESPACE "; - out << cpp_using.name().pretty() << std::endl; - out << std::endl; + out << cpp_using.name().pretty() << '\n'; + out << '\n'; } else if(item.is_declaration()) { item.get_declaration().output(out); } else - out << "UNKNOWN: " << item.pretty() << std::endl; + out << "UNKNOWN: " << item.pretty() << '\n'; } -/*******************************************************************\ - -Function: new_cpp_language - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - languaget *new_cpp_language() { return new cpp_languaget; } -/*******************************************************************\ - -Function: cpp_languaget::from_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool cpp_languaget::from_expr( const exprt &expr, std::string &code, @@ -334,18 +218,6 @@ bool cpp_languaget::from_expr( return false; } -/*******************************************************************\ - -Function: cpp_languaget::from_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool cpp_languaget::from_type( const typet &type, std::string &code, @@ -355,18 +227,6 @@ bool cpp_languaget::from_type( return false; } -/*******************************************************************\ - -Function: cpp_languaget::type_to_name - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool cpp_languaget::type_to_name( const typet &type, std::string &name, @@ -376,18 +236,6 @@ bool cpp_languaget::type_to_name( return false; } -/*******************************************************************\ - -Function: cpp_languaget::to_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool cpp_languaget::to_expr( const std::string &code, const std::string &module, @@ -426,18 +274,6 @@ bool cpp_languaget::to_expr( return result; } -/*******************************************************************\ - -Function: cpp_languaget::~cpp_languaget - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - cpp_languaget::~cpp_languaget() { } diff --git a/src/cpp/cpp_language.h b/src/cpp/cpp_language.h index 329adbaa1a5..982e2e180c1 100644 --- a/src/cpp/cpp_language.h +++ b/src/cpp/cpp_language.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Module + #ifndef CPROVER_CPP_CPP_LANGUAGE_H #define CPROVER_CPP_CPP_LANGUAGE_H diff --git a/src/cpp/cpp_linkage_spec.h b/src/cpp/cpp_linkage_spec.h index 67cf2c93b63..d7b6002ea60 100644 --- a/src/cpp/cpp_linkage_spec.h +++ b/src/cpp/cpp_linkage_spec.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #ifndef CPROVER_CPP_CPP_LINKAGE_SPEC_H #define CPROVER_CPP_CPP_LINKAGE_SPEC_H diff --git a/src/cpp/cpp_member_spec.h b/src/cpp/cpp_member_spec.h index 714b84b684b..76097e1b14c 100644 --- a/src/cpp/cpp_member_spec.h +++ b/src/cpp/cpp_member_spec.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ + #ifndef CPROVER_CPP_CPP_MEMBER_SPEC_H #define CPROVER_CPP_CPP_MEMBER_SPEC_H diff --git a/src/cpp/cpp_name.cpp b/src/cpp/cpp_name.cpp index ae73ba3cbca..cdc3806c489 100644 --- a/src/cpp/cpp_name.cpp +++ b/src/cpp/cpp_name.cpp @@ -6,23 +6,14 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include #include #include "cpp_name.h" -/*******************************************************************\ - -Function: cpp_namet::get_base_name - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - irep_idt cpp_namet::get_base_name() const { const subt &sub=get_sub(); @@ -49,18 +40,6 @@ irep_idt cpp_namet::get_base_name() const return irep_idt(); } -/*******************************************************************\ - -Function: cpp_namet::convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - #if 0 void cpp_namet::convert( std::string &identifier, @@ -77,7 +56,7 @@ void cpp_namet::convert( else if(id==ID_template_args) { std::stringstream ss; - ss << location() << std::endl; + ss << location() << '\n'; ss << "no template arguments allowed here"; throw ss.str(); } @@ -94,18 +73,6 @@ void cpp_namet::convert( } #endif -/*******************************************************************\ - -Function: cpp_namet::convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string cpp_namet::to_string() const { std::string str; diff --git a/src/cpp/cpp_name.h b/src/cpp/cpp_name.h index 9f1f635e26a..a27374c5524 100644 --- a/src/cpp/cpp_name.h +++ b/src/cpp/cpp_name.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ + #ifndef CPROVER_CPP_CPP_NAME_H #define CPROVER_CPP_CPP_NAME_H diff --git a/src/cpp/cpp_namespace_spec.cpp b/src/cpp/cpp_namespace_spec.cpp index d7e8adb5eda..c4b60e3eb24 100644 --- a/src/cpp/cpp_namespace_spec.cpp +++ b/src/cpp/cpp_namespace_spec.cpp @@ -6,23 +6,14 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include #include "cpp_namespace_spec.h" #include "cpp_item.h" -/*******************************************************************\ - -Function: cpp_namespace_spect::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_namespace_spect::output(std::ostream &out) const { out << " namespace: " << get_namespace() << "\n"; diff --git a/src/cpp/cpp_namespace_spec.h b/src/cpp/cpp_namespace_spec.h index 84aa6314086..ed96d1dd338 100644 --- a/src/cpp/cpp_namespace_spec.h +++ b/src/cpp/cpp_namespace_spec.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #ifndef CPROVER_CPP_CPP_NAMESPACE_SPEC_H #define CPROVER_CPP_CPP_NAMESPACE_SPEC_H diff --git a/src/cpp/cpp_parse_tree.cpp b/src/cpp/cpp_parse_tree.cpp index 33614a83f53..9027c9ed3b0 100644 --- a/src/cpp/cpp_parse_tree.cpp +++ b/src/cpp/cpp_parse_tree.cpp @@ -6,37 +6,16 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -#include "cpp_parse_tree.h" - -/*******************************************************************\ - -Function: cpp_parse_treet::swap - - Inputs: +/// \file +/// C++ Parser - Outputs: - - Purpose: - -\*******************************************************************/ +#include "cpp_parse_tree.h" void cpp_parse_treet::swap(cpp_parse_treet &cpp_parse_tree) { cpp_parse_tree.items.swap(items); } -/*******************************************************************\ - -Function: cpp_parse_treet::clear - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_parse_treet::clear() { items.clear(); diff --git a/src/cpp/cpp_parse_tree.h b/src/cpp/cpp_parse_tree.h index 9d620864247..afcd706fcef 100644 --- a/src/cpp/cpp_parse_tree.h +++ b/src/cpp/cpp_parse_tree.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Parser + #ifndef CPROVER_CPP_CPP_PARSE_TREE_H #define CPROVER_CPP_CPP_PARSE_TREE_H diff --git a/src/cpp/cpp_parser.cpp b/src/cpp/cpp_parser.cpp index b72c6be6d5e..fd0135bb259 100644 --- a/src/cpp/cpp_parser.cpp +++ b/src/cpp/cpp_parser.cpp @@ -6,24 +6,15 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Parser + #include #include "cpp_parser.h" cpp_parsert cpp_parser; -/*******************************************************************\ - -Function: cpp_parsert::parse - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool cpp_parse(); bool cpp_parsert::parse() diff --git a/src/cpp/cpp_parser.h b/src/cpp/cpp_parser.h index f2db8e6c2f7..1a167f71f24 100644 --- a/src/cpp/cpp_parser.h +++ b/src/cpp/cpp_parser.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Parser + #ifndef CPROVER_CPP_CPP_PARSER_H #define CPROVER_CPP_CPP_PARSER_H diff --git a/src/cpp/cpp_scope.cpp b/src/cpp/cpp_scope.cpp index 6254cc70af3..0594660ffe6 100644 --- a/src/cpp/cpp_scope.cpp +++ b/src/cpp/cpp_scope.cpp @@ -6,21 +6,12 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include "cpp_typecheck.h" #include "cpp_scope.h" -/*******************************************************************\ - -Function: cpp_scopet::operator << - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::ostream &operator << (std::ostream &out, cpp_scopet::lookup_kindt kind) { switch(kind) @@ -34,18 +25,6 @@ std::ostream &operator << (std::ostream &out, cpp_scopet::lookup_kindt kind) return out; } -/*******************************************************************\ - -Function: cpp_scopet::lookup - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_scopet::lookup( const irep_idt &base_name, lookup_kindt kind, @@ -109,18 +88,6 @@ void cpp_scopet::lookup( get_parent().lookup(base_name, kind, id_set); } -/*******************************************************************\ - -Function: cpp_scopet::lookup - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_scopet::lookup( const irep_idt &base_name, lookup_kindt kind, @@ -131,11 +98,11 @@ void cpp_scopet::lookup( // are looking for templates! #if 0 - std::cout << "B: " << base_name << std::endl; - std::cout << "K: " << kind << std::endl; - std::cout << "I: " << id_class << std::endl; + std::cout << "B: " << base_name << '\n'; + std::cout << "K: " << kind << '\n'; + std::cout << "I: " << id_class << '\n'; std::cout << "THIS: " << this->base_name << " " << this->id_class - << " " << this->identifier << std::endl; + << " " << this->identifier << '\n'; #endif cpp_id_mapt::iterator @@ -201,18 +168,6 @@ void cpp_scopet::lookup( get_parent().lookup(base_name, kind, id_class, id_set); } -/*******************************************************************\ - -Function: cpp_scopet::lookup_identifier - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_scopet::lookup_identifier( const irep_idt &identifier, cpp_idt::id_classt id_class, @@ -241,18 +196,6 @@ void cpp_scopet::lookup_identifier( #endif } -/*******************************************************************\ - -Function: cpp_scopet::new_scope - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - cpp_scopet &cpp_scopet::new_scope(const irep_idt &new_scope_name) { cpp_idt &id=insert(new_scope_name); @@ -265,18 +208,6 @@ cpp_scopet &cpp_scopet::new_scope(const irep_idt &new_scope_name) } -/*******************************************************************\ - -Function: cpp_scopet::contains - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool cpp_scopet::contains(const irep_idt &base_name) { id_sett id_set; diff --git a/src/cpp/cpp_scope.h b/src/cpp/cpp_scope.h index 0c806f427b8..690318edb43 100644 --- a/src/cpp/cpp_scope.h +++ b/src/cpp/cpp_scope.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #ifndef CPROVER_CPP_CPP_SCOPE_H #define CPROVER_CPP_CPP_SCOPE_H diff --git a/src/cpp/cpp_scopes.cpp b/src/cpp/cpp_scopes.cpp index bdd78980e9b..2a9496fe7cd 100644 --- a/src/cpp/cpp_scopes.cpp +++ b/src/cpp/cpp_scopes.cpp @@ -6,41 +6,20 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include #include "cpp_scopes.h" -/*******************************************************************\ - -Function: cpp_scopest::new_block_scope - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - cpp_scopet &cpp_scopest::new_block_scope() { unsigned prefix=++current_scope().compound_counter; return new_scope(std::to_string(prefix), cpp_idt::id_classt::BLOCK_SCOPE); } -/*******************************************************************\ - -Function: cpp_scopest::put_into_scope - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - cpp_idt &cpp_scopest::put_into_scope( const symbolt &symbol, cpp_scopet &scope, @@ -90,17 +69,7 @@ cpp_idt &cpp_scopest::put_into_scope( } } -/*******************************************************************\ - -Function: cpp_scopest::print_current - - Inputs: - - Outputs: - Purpose: - -\*******************************************************************/ - +/// \return Purpose: void cpp_scopest::print_current(std::ostream &out) const { const cpp_scopet *scope=current_scope_ptr; diff --git a/src/cpp/cpp_scopes.h b/src/cpp/cpp_scopes.h index 92d9ebdb6e2..ca392497c7d 100644 --- a/src/cpp/cpp_scopes.h +++ b/src/cpp/cpp_scopes.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #ifndef CPROVER_CPP_CPP_SCOPES_H #define CPROVER_CPP_CPP_SCOPES_H diff --git a/src/cpp/cpp_static_assert.h b/src/cpp/cpp_static_assert.h index 64b3d5bcf6a..be784ca51f1 100644 --- a/src/cpp/cpp_static_assert.h +++ b/src/cpp/cpp_static_assert.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #ifndef CPROVER_CPP_CPP_STATIC_ASSERT_H #define CPROVER_CPP_CPP_STATIC_ASSERT_H diff --git a/src/cpp/cpp_storage_spec.h b/src/cpp/cpp_storage_spec.h index a2f438fe766..74c11bc1ef0 100644 --- a/src/cpp/cpp_storage_spec.h +++ b/src/cpp/cpp_storage_spec.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ + #ifndef CPROVER_CPP_CPP_STORAGE_SPEC_H #define CPROVER_CPP_CPP_STORAGE_SPEC_H diff --git a/src/cpp/cpp_template_args.h b/src/cpp/cpp_template_args.h index 5fa708879a8..47ceca5f003 100644 --- a/src/cpp/cpp_template_args.h +++ b/src/cpp/cpp_template_args.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #ifndef CPROVER_CPP_CPP_TEMPLATE_ARGS_H #define CPROVER_CPP_CPP_TEMPLATE_ARGS_H diff --git a/src/cpp/cpp_template_parameter.h b/src/cpp/cpp_template_parameter.h index af5527a10c4..2d9a49bc215 100644 --- a/src/cpp/cpp_template_parameter.h +++ b/src/cpp/cpp_template_parameter.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ + #ifndef CPROVER_CPP_CPP_TEMPLATE_PARAMETER_H #define CPROVER_CPP_CPP_TEMPLATE_PARAMETER_H diff --git a/src/cpp/cpp_template_type.h b/src/cpp/cpp_template_type.h index 2ebb5ac34e0..57e9d257e1d 100644 --- a/src/cpp/cpp_template_type.h +++ b/src/cpp/cpp_template_type.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ + #ifndef CPROVER_CPP_CPP_TEMPLATE_TYPE_H #define CPROVER_CPP_CPP_TEMPLATE_TYPE_H diff --git a/src/cpp/cpp_token.h b/src/cpp/cpp_token.h index a022cf92df2..800ac372353 100644 --- a/src/cpp/cpp_token.h +++ b/src/cpp/cpp_token.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Parser: Token + #ifndef CPROVER_CPP_CPP_TOKEN_H #define CPROVER_CPP_CPP_TOKEN_H diff --git a/src/cpp/cpp_token_buffer.cpp b/src/cpp/cpp_token_buffer.cpp index 9dcd75526e6..dcd17a6266c 100644 --- a/src/cpp/cpp_token_buffer.cpp +++ b/src/cpp/cpp_token_buffer.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Parser: Token Buffer + #include #include @@ -13,18 +16,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "cpp_token_buffer.h" -/*******************************************************************\ - -Function: cpp_token_buffert::LookAhead - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - int cpp_token_buffert::LookAhead(unsigned offset) { assert(current_pos<=token_vector.size()); @@ -37,18 +28,6 @@ int cpp_token_buffert::LookAhead(unsigned offset) return token_vector[offset]->kind; } -/*******************************************************************\ - -Function: cpp_token_buffert::get_token - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - int cpp_token_buffert::get_token(cpp_tokent &token) { assert(current_pos<=token_vector.size()); @@ -63,18 +42,6 @@ int cpp_token_buffert::get_token(cpp_tokent &token) return token.kind; } -/*******************************************************************\ - -Function: cpp_token_buffert::get_token - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - int cpp_token_buffert::get_token() { assert(current_pos<=token_vector.size()); @@ -89,18 +56,6 @@ int cpp_token_buffert::get_token() return kind; } -/*******************************************************************\ - -Function: cpp_token_buffert::LookAhead - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - int cpp_token_buffert::LookAhead(unsigned offset, cpp_tokent &token) { assert(current_pos<=token_vector.size()); @@ -115,18 +70,6 @@ int cpp_token_buffert::LookAhead(unsigned offset, cpp_tokent &token) return token.kind; } -/*******************************************************************\ - -Function: cpp_token_buffert::read_token - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - int yyansi_clex(); extern char *yyansi_ctext; @@ -147,60 +90,24 @@ void cpp_token_buffert::read_token() tokens.back().filename=ansi_c_parser.get_file(); } - // std::cout << "TOKEN: " << kind << " " << tokens.back().text << std::endl; + // std::cout << "TOKEN: " << kind << " " << tokens.back().text << '\n'; tokens.back().kind=kind; - // std::cout << "II: " << token_vector.back()->kind << std::endl; - // std::cout << "I2: " << token_vector.size() << std::endl; + // std::cout << "II: " << token_vector.back()->kind << '\n'; + // std::cout << "I2: " << token_vector.size() << '\n'; } -/*******************************************************************\ - -Function: cpp_token_buffert::Save - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - cpp_token_buffert::post cpp_token_buffert::Save() { return current_pos; } -/*******************************************************************\ - -Function: cpp_token_buffert::Restore - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_token_buffert::Restore(post pos) { current_pos=pos; } -/*******************************************************************\ - -Function: cpp_token_buffert::Replace - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_token_buffert::Replace(const cpp_tokent &token) { assert(current_pos<=token_vector.size()); @@ -211,18 +118,6 @@ void cpp_token_buffert::Replace(const cpp_tokent &token) *token_vector[current_pos]=token; } -/*******************************************************************\ - -Function: cpp_token_buffert::Replace - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_token_buffert::Insert(const cpp_tokent &token) { assert(current_pos<=token_vector.size()); diff --git a/src/cpp/cpp_token_buffer.h b/src/cpp/cpp_token_buffer.h index e4e90422853..859945787bd 100644 --- a/src/cpp/cpp_token_buffer.h +++ b/src/cpp/cpp_token_buffer.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Parser: Token Buffer + #ifndef CPROVER_CPP_CPP_TOKEN_BUFFER_H #define CPROVER_CPP_CPP_TOKEN_BUFFER_H diff --git a/src/cpp/cpp_type2name.cpp b/src/cpp/cpp_type2name.cpp index 98842b8b41a..c92c32eb2a2 100644 --- a/src/cpp/cpp_type2name.cpp +++ b/src/cpp/cpp_type2name.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Module + #include #include @@ -13,18 +16,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "cpp_type2name.h" -/*******************************************************************\ - -Function: do_prefix - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static std::string do_prefix(const std::string &s) { if(s.find(',')!=std::string::npos || @@ -34,18 +25,6 @@ static std::string do_prefix(const std::string &s) return s; } -/*******************************************************************\ - -Function: irep2name - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static void irep2name(const irept &irep, std::string &result) { result=""; @@ -109,18 +88,6 @@ static void irep2name(const irept &irep, std::string &result) result+=')'; } -/*******************************************************************\ - -Function: cpp_type2name - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string cpp_type2name(const typet &type) { std::string result; @@ -152,7 +119,7 @@ std::string cpp_type2name(const typet &type) // we try to use #c_type const irep_idt c_type=type.get(ID_C_c_type); - if(c_type!=irep_idt()) + if(!c_type.empty()) result+=id2string(c_type); else if(type.id()==ID_unsignedbv) result+="unsigned_int"; @@ -164,7 +131,7 @@ std::string cpp_type2name(const typet &type) // we try to use #c_type const irep_idt c_type=type.get(ID_C_c_type); - if(c_type!=irep_idt()) + if(!c_type.empty()) result+=id2string(c_type); else result+="double"; @@ -203,18 +170,6 @@ std::string cpp_type2name(const typet &type) return result; } -/*******************************************************************\ - -Function: cpp_expr2name - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string cpp_expr2name(const exprt &expr) { std::string tmp; diff --git a/src/cpp/cpp_type2name.h b/src/cpp/cpp_type2name.h index ffb2a99eef6..96aa6b58d8c 100644 --- a/src/cpp/cpp_type2name.h +++ b/src/cpp/cpp_type2name.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Module + #ifndef CPROVER_CPP_CPP_TYPE2NAME_H #define CPROVER_CPP_CPP_TYPE2NAME_H diff --git a/src/cpp/cpp_typecast.h b/src/cpp/cpp_typecast.h index 34eaf8fd48a..6cfc7905cdb 100644 --- a/src/cpp/cpp_typecast.h +++ b/src/cpp/cpp_typecast.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ + #ifndef CPROVER_CPP_CPP_TYPECAST_H #define CPROVER_CPP_CPP_TYPECAST_H diff --git a/src/cpp/cpp_typecheck.cpp b/src/cpp/cpp_typecheck.cpp index fe8a9f063d7..827f3421315 100644 --- a/src/cpp/cpp_typecheck.cpp +++ b/src/cpp/cpp_typecheck.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include #include @@ -20,18 +23,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "cpp_convert_type.h" #include "cpp_declarator.h" -/*******************************************************************\ - -Function: cpp_typecheckt::convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::convert(cpp_itemt &item) { if(item.is_declaration()) @@ -52,18 +43,7 @@ void cpp_typecheckt::convert(cpp_itemt &item) } } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck - - Inputs: - - Outputs: - - Purpose: typechecking main method - -\*******************************************************************/ - +/// typechecking main method void cpp_typecheckt::typecheck() { // default linkage is "automatic" @@ -79,18 +59,6 @@ void cpp_typecheckt::typecheck() clean_up(); } -/*******************************************************************\ - -Function: cpp_typecheckt::this_struct_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const struct_typet &cpp_typecheckt::this_struct_type() { const exprt &this_expr= @@ -104,52 +72,16 @@ const struct_typet &cpp_typecheckt::this_struct_type() return to_struct_type(t); } -/*******************************************************************\ - -Function: cpp_typecheckt::to_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string cpp_typecheckt::to_string(const exprt &expr) { return expr2cpp(expr, *this); } -/*******************************************************************\ - -Function: cpp_typecheckt::to_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string cpp_typecheckt::to_string(const typet &type) { return type2cpp(type, *this); } -/*******************************************************************\ - -Function: cpp_typecheck - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool cpp_typecheck( cpp_parse_treet &cpp_parse_tree, symbol_tablet &symbol_table, @@ -161,23 +93,14 @@ bool cpp_typecheck( return cpp_typecheck.typecheck_main(); } -/*******************************************************************\ - -Function: cpp_typecheck - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool cpp_typecheck( exprt &expr, message_handlert &message_handler, const namespacet &ns) { + const unsigned errors_before= + message_handler.get_message_count(messaget::M_ERROR); + symbol_tablet symbol_table; cpp_parse_treet cpp_parse_tree; @@ -204,34 +127,23 @@ bool cpp_typecheck( cpp_typecheck.error() << e << messaget::eom; } - return cpp_typecheck.get_error_found(); + return message_handler.get_message_count(messaget::M_ERROR)!=errors_before; } -/*******************************************************************\ - -Function: cpp_typecheckt::static_and_dynamic_initialization - - Inputs: - - Outputs: - - Purpose: Initialization of static objects: - - "Objects with static storage duration (3.7.1) shall be zero-initialized - (8.5) before any other initialization takes place. Zero-initialization - and initialization with a constant expression are collectively called - static initialization; all other initialization is dynamic - initialization. Objects of POD types (3.9) with static storage duration - initialized with constant expressions (5.19) shall be initialized before - any dynamic initialization takes place. Objects with static storage - duration defined in namespace scope in the same translation unit and - dynamically initialized shall be initialized in the order in which their - definition appears in the translation unit. [Note: 8.5.1 describes the - order in which aggregate members are initialized. The initialization - of local static objects is described in 6.7. ]" - -\*******************************************************************/ - +/// Initialization of static objects: +/// +/// "Objects with static storage duration (3.7.1) shall be zero-initialized +/// (8.5) before any other initialization takes place. Zero-initialization +/// and initialization with a constant expression are collectively called +/// static initialization; all other initialization is dynamic +/// initialization. Objects of POD types (3.9) with static storage duration +/// initialized with constant expressions (5.19) shall be initialized before +/// any dynamic initialization takes place. Objects with static storage +/// duration defined in namespace scope in the same translation unit and +/// dynamically initialized shall be initialized in the order in which their +/// definition appears in the translation unit. [Note: 8.5.1 describes the +/// order in which aggregate members are initialized. The initialization +/// of local static objects is described in 6.7. ]" void cpp_typecheckt::static_and_dynamic_initialization() { code_blockt init_block; // Dynamic Initialization Block @@ -302,18 +214,6 @@ void cpp_typecheckt::static_and_dynamic_initialization() disable_access_control=false; } -/*******************************************************************\ - -Function: cpp_typecheckt::do_not_typechecked - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::do_not_typechecked() { bool cont; @@ -363,18 +263,6 @@ void cpp_typecheckt::do_not_typechecked() } } -/*******************************************************************\ - -Function: cpp_typecheckt::clean_up - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::clean_up() { symbol_tablet::symbolst::iterator it=symbol_table.symbols.begin(); diff --git a/src/cpp/cpp_typecheck.h b/src/cpp/cpp_typecheck.h index 55955cd0334..5c0a6afe285 100644 --- a/src/cpp/cpp_typecheck.h +++ b/src/cpp/cpp_typecheck.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #ifndef CPROVER_CPP_CPP_TYPECHECK_H #define CPROVER_CPP_CPP_TYPECHECK_H diff --git a/src/cpp/cpp_typecheck_bases.cpp b/src/cpp/cpp_typecheck_bases.cpp index 1c768d63153..9d8060301d5 100644 --- a/src/cpp/cpp_typecheck_bases.cpp +++ b/src/cpp/cpp_typecheck_bases.cpp @@ -6,22 +6,13 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include #include "cpp_typecheck.h" -/*******************************************************************\ - -Function: cpp_typecheckt::typcheck_compound_bases - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_compound_bases(struct_typet &type) { std::set bases; @@ -80,7 +71,7 @@ void cpp_typecheckt::typecheck_compound_bases(struct_typet &type) bool virtual_base = base_it->get_bool(ID_virtual); irep_idt class_access = base_it->get(ID_protection); - if(class_access==irep_idt()) + if(class_access.empty()) class_access = default_class_access; base_symbol_expr.id(ID_base); @@ -126,18 +117,6 @@ void cpp_typecheckt::typecheck_compound_bases(struct_typet &type) } } -/*******************************************************************\ - -Function: cpp_typecheckt::add_base_components - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::add_base_components( const struct_typet &from, const irep_idt &access, diff --git a/src/cpp/cpp_typecheck_code.cpp b/src/cpp/cpp_typecheck_code.cpp index f375cd4dbf6..8a7dd301395 100644 --- a/src/cpp/cpp_typecheck_code.cpp +++ b/src/cpp/cpp_typecheck_code.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include #include "cpp_typecheck.h" @@ -15,18 +18,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "cpp_util.h" #include "cpp_exception_id.h" -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_code - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_code(codet &code) { const irep_idt &statement=code.get_statement(); @@ -45,22 +36,14 @@ void cpp_typecheckt::typecheck_code(codet &code) statement==ID_msc_if_not_exists) { } + else if(statement==ID_decl_block) + { + // type checked already + } else c_typecheck_baset::typecheck_code(code); } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_try_catch - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_try_catch(codet &code) { codet::operandst &operands=code.operands(); @@ -127,18 +110,6 @@ void cpp_typecheckt::typecheck_try_catch(codet &code) } } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_ifthenelse - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_ifthenelse(code_ifthenelset &code) { // In addition to the C syntax, C++ also allows a declaration @@ -153,18 +124,6 @@ void cpp_typecheckt::typecheck_ifthenelse(code_ifthenelset &code) c_typecheck_baset::typecheck_ifthenelse(code); } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_while - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_while(code_whilet &code) { // In addition to the C syntax, C++ also allows a declaration @@ -179,18 +138,6 @@ void cpp_typecheckt::typecheck_while(code_whilet &code) c_typecheck_baset::typecheck_while(code); } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_switch - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_switch(code_switcht &code) { // In addition to the C syntax, C++ also allows a declaration @@ -222,18 +169,6 @@ void cpp_typecheckt::typecheck_switch(code_switcht &code) c_typecheck_baset::typecheck_switch(code); } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_member_initializer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_member_initializer(codet &code) { const cpp_namet &member= @@ -413,18 +348,6 @@ void cpp_typecheckt::typecheck_member_initializer(codet &code) } } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_decl - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_decl(codet &code) { if(code.operands().size()!=1) @@ -518,18 +441,6 @@ void cpp_typecheckt::typecheck_decl(codet &code) code.swap(new_code); } -/*******************************************************************\ - -Function: cpp_typecheck_codet::typecheck_block - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_block(codet &code) { cpp_save_scopet saved_scope(cpp_scopes); @@ -538,18 +449,6 @@ void cpp_typecheckt::typecheck_block(codet &code) c_typecheck_baset::typecheck_block(code); } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_assign - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_assign(codet &code) { if(code.operands().size()!=2) diff --git a/src/cpp/cpp_typecheck_compound_type.cpp b/src/cpp/cpp_typecheck_compound_type.cpp index 56db1bbba6c..6e2cce31d74 100644 --- a/src/cpp/cpp_typecheck_compound_type.cpp +++ b/src/cpp/cpp_typecheck_compound_type.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include #include @@ -20,18 +23,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "cpp_convert_type.h" #include "cpp_name.h" -/*******************************************************************\ - -Function: cpp_typecheckt::has_const - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - bool cpp_typecheckt::has_const(const typet &type) { if(type.id()==ID_const) @@ -48,18 +39,6 @@ bool cpp_typecheckt::has_const(const typet &type) return false; } -/*******************************************************************\ - -Function: cpp_typecheckt::has_volatile - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - bool cpp_typecheckt::has_volatile(const typet &type) { if(type.id()==ID_volatile) @@ -76,18 +55,6 @@ bool cpp_typecheckt::has_volatile(const typet &type) return false; } -/*******************************************************************\ - -Function: cpp_typecheckt::tag_scope - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - cpp_scopet &cpp_typecheckt::tag_scope( const irep_idt &base_name, bool has_body, @@ -127,18 +94,6 @@ cpp_scopet &cpp_typecheckt::tag_scope( return cpp_scopes.get_global_scope(); } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_compound_type - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_compound_type( struct_union_typet &type) { @@ -294,18 +249,6 @@ void cpp_typecheckt::typecheck_compound_type( type.swap(symbol_type); } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_compound_declarator - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_compound_declarator( const symbolt &symbol, const cpp_declarationt &declaration, @@ -659,7 +602,7 @@ void cpp_typecheckt::typecheck_compound_declarator( { irep_idt base_name=arg.get_base_name(); - if(base_name==irep_idt()) + if(base_name.empty()) base_name="arg"+std::to_string(i++); symbolt arg_symb; @@ -804,18 +747,7 @@ void cpp_typecheckt::typecheck_compound_declarator( components.push_back(component); } -/*******************************************************************\ - -Function: cpp_typecheckt::check_fixed_size_array - -Inputs: - -Outputs: - -Purpose: check that an array has fixed size - -\*******************************************************************/ - +/// check that an array has fixed size void cpp_typecheckt::check_fixed_size_array(typet &type) { if(type.id()==ID_array) @@ -830,18 +762,6 @@ void cpp_typecheckt::check_fixed_size_array(typet &type) } } -/*******************************************************************\ - -Function: cpp_typecheckt::put_compound_into_scope - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::put_compound_into_scope( const struct_union_typet::componentt &compound) { @@ -849,7 +769,7 @@ void cpp_typecheckt::put_compound_into_scope( const irep_idt &name=compound.get_name(); // nothing to do if no base_name (e.g., an anonymous bitfield) - if(base_name==irep_idt()) + if(base_name.empty()) return; if(compound.type().id()==ID_code) @@ -918,18 +838,6 @@ void cpp_typecheckt::put_compound_into_scope( } } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_friend_declaration - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_friend_declaration( symbolt &symbol, cpp_declarationt &declaration) @@ -1014,18 +922,6 @@ void cpp_typecheckt::typecheck_friend_declaration( } } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_compound_body - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_compound_body(symbolt &symbol) { cpp_save_scopet saved_scope(cpp_scopes); @@ -1087,7 +983,7 @@ void cpp_typecheckt::typecheck_compound_body(symbolt &symbol) continue; } - if(declaration.type().id()==irep_idt()) // empty? + if(declaration.type().id().empty()) continue; bool is_typedef=declaration.is_typedef(); @@ -1308,18 +1204,6 @@ void cpp_typecheckt::typecheck_compound_body(symbolt &symbol) symbol.type.remove(ID_body); } -/*******************************************************************\ - -Function: cpp_typecheckt::move_member_initializers - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::move_member_initializers( irept &initializers, const typet &type, @@ -1362,18 +1246,6 @@ void cpp_typecheckt::move_member_initializers( } } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_member_function - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_member_function( const irep_idt &compound_identifier, struct_typet::componentt &component, @@ -1387,7 +1259,7 @@ void cpp_typecheckt::typecheck_member_function( if(component.get_bool(ID_is_static)) { - if(method_qualifier.id()!=irep_idt()) + if(!method_qualifier.id().empty()) { error().source_location=component.source_location(); error() << "method is static -- no qualifiers allowed" << eom; @@ -1456,18 +1328,6 @@ void cpp_typecheckt::typecheck_member_function( add_method_body(new_symbol); } -/*******************************************************************\ - -Function: cpp_typecheckt::add_this_to_method_type - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::add_this_to_method_type( const irep_idt &compound_symbol, typet &type, @@ -1495,18 +1355,6 @@ void cpp_typecheckt::add_this_to_method_type( parameter.type()=pointer_typet(subtype); } -/*******************************************************************\ - -Function: cpp_typecheckt::add_anonymous_members_to_scope - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::add_anonymous_members_to_scope( const symbolt &struct_union_symbol) { @@ -1557,18 +1405,6 @@ void cpp_typecheckt::add_anonymous_members_to_scope( } } -/*******************************************************************\ - -Function: cpp_typecheckt::convert_anon_struct_union_member - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::convert_anon_struct_union_member( const cpp_declarationt &declaration, const irep_idt &access, @@ -1620,18 +1456,6 @@ void cpp_typecheckt::convert_anon_struct_union_member( struct_union_symbol.type.set("#unnamed_object", base_name); } -/*******************************************************************\ - -Function: cpp_typecheckt::get_component - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - bool cpp_typecheckt::get_component( const source_locationt &source_location, const exprt &object, @@ -1674,8 +1498,7 @@ bool cpp_typecheckt::get_component( error().source_location=source_location; str << "error: member `" << component_name << "' is not accessible (" << component.get(ID_access) << ")"; - str << std::endl - << "struct name: " << final_type.get(ID_name); + str << "\nstruct name: " << final_type.get(ID_name); throw 0; #endif } @@ -1732,18 +1555,6 @@ bool cpp_typecheckt::get_component( return false; // component not found } -/*******************************************************************\ - -Function: cpp_typecheckt::check_component_access - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - bool cpp_typecheckt::check_component_access( const struct_union_typet::componentt &component, const struct_union_typet &struct_union_type) @@ -1810,18 +1621,6 @@ bool cpp_typecheckt::check_component_access( return true; // not ok } -/*******************************************************************\ - -Function: cpp_typecheckt::get_bases - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::get_bases( const struct_typet &type, std::set &set_bases) const @@ -1841,18 +1640,6 @@ void cpp_typecheckt::get_bases( } } -/*******************************************************************\ - -Function: cpp_typecheckt::get_virtual_bases - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::get_virtual_bases( const struct_typet &type, std::list &vbases) const @@ -1877,18 +1664,6 @@ void cpp_typecheckt::get_virtual_bases( } } -/*******************************************************************\ - -Function: cpp_typecheckt::subtype_typecast - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - bool cpp_typecheckt::subtype_typecast( const struct_typet &from, const struct_typet &to) const @@ -1903,18 +1678,6 @@ bool cpp_typecheckt::subtype_typecast( return bases.find(to.get(ID_name))!=bases.end(); } -/*******************************************************************\ - -Function: cpp_typecheckt::make_ptr_subtypecast - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::make_ptr_typecast( exprt &expr, const typet &dest_type) diff --git a/src/cpp/cpp_typecheck_constructor.cpp b/src/cpp/cpp_typecheck_constructor.cpp index 01cc9ca7123..5cb0b6aebb9 100644 --- a/src/cpp/cpp_typecheck_constructor.cpp +++ b/src/cpp/cpp_typecheck_constructor.cpp @@ -6,28 +6,21 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include #include #include -#include +#include #include "cpp_typecheck.h" #include "cpp_util.h" -/*******************************************************************\ - -Function: copy_parent - - Inputs: parent_base_name: base name of typechecked parent - block: non-typechecked block - - Outputs: generate code to copy the parent - - Purpose: - -\*******************************************************************/ - +/// \param parent_base_name: base name of typechecked parent +/// \param block: non-typechecked block +/// \return generate code to copy the parent static void copy_parent( const source_locationt &source_location, const irep_idt &parent_base_name, @@ -66,19 +59,9 @@ static void copy_parent( op1.add_source_location()=source_location; } -/*******************************************************************\ - -Function: copy_member - - Inputs: member_base_name: name of a member - block: non-typechecked block - - Outputs: generate code to copy the member - - Purpose: - -\*******************************************************************/ - +/// \param member_base_name: name of a member +/// \param block: non-typechecked block +/// \return generate code to copy the member static void copy_member( const source_locationt &source_location, const irep_idt &member_base_name, @@ -120,20 +103,10 @@ static void copy_member( op1.add_source_location()=source_location; } -/*******************************************************************\ - -Function: copy_array - - Inputs: member_base_name: name of array member - index: index to copy - block: non-typechecked block - - Outputs: generate code to copy the member - - Purpose: - -\*******************************************************************/ - +/// \param member_base_name: name of array member +/// \param index: index to copy +/// \param block: non-typechecked block +/// \return generate code to copy the member static void copy_array( const source_locationt &source_location, const irep_idt &member_base_name, @@ -182,18 +155,7 @@ static void copy_array( op1.add_source_location()=source_location; } -/*******************************************************************\ - -Function: cpp_typecheckt::default_ctor - - Inputs: - - Outputs: - - Purpose: Generate code for implicit default constructors - -\*******************************************************************/ - +/// Generate code for implicit default constructors void cpp_typecheckt::default_ctor( const source_locationt &source_location, const irep_idt &base_name, @@ -222,18 +184,7 @@ void cpp_typecheckt::default_ctor( ctor.add_source_location()=source_location; } -/*******************************************************************\ - -Function: cpp_typecheckt::default_cpctor - - Inputs: - - Outputs: - - Purpose: Generate code for implicit default copy constructor - -\*******************************************************************/ - +/// Generate code for implicit default copy constructor void cpp_typecheckt::default_cpctor( const symbolt &symbol, cpp_declarationt &cpctor) const @@ -402,19 +353,7 @@ void cpp_typecheckt::default_cpctor( } } -/*******************************************************************\ - -Function: cpp_typecheckt::default_assignop - - Inputs: - - Outputs: - - Purpose: Generate declarartion of the implicit default assignment - operator - -\*******************************************************************/ - +/// Generate declarartion of the implicit default assignment operator void cpp_typecheckt::default_assignop( const symbolt &symbol, cpp_declarationt &cpctor) @@ -488,18 +427,7 @@ void cpp_typecheckt::default_assignop( args_decl_declor.value().make_nil(); } -/*******************************************************************\ - -Function: cpp_typecheckt::default_assignop_value - - Inputs: - - Outputs: - - Purpose: Generate code for the implicit default assignment operator - -\*******************************************************************/ - +/// Generate code for the implicit default assignment operator void cpp_typecheckt::default_assignop_value( const symbolt &symbol, cpp_declaratort &declarator) @@ -553,7 +481,7 @@ void cpp_typecheckt::default_assignop_value( if(size_expr.id()==ID_infinity) { // error().source_location=object); - // err << "cannot copy array of infinite size" << std::endl; + // err << "cannot copy array of infinite size\n"; // throw 0; continue; } @@ -580,24 +508,13 @@ void cpp_typecheckt::default_assignop_value( ret_code.type()=code_typet(); } -/*******************************************************************\ - -Function: check_member_initializers - - Inputs: bases: the parents of the class - components: the components of the class - initializers: the constructor initializers - - Outputs: If an invalid initializer is found, then - the method outputs an error message and - throws a 0 exception. - - Purpose: Check a constructor initialization-list. - An initalizer has to be a data member declared - in this class or a direct-parent constructor. - -\*******************************************************************/ - +/// Check a constructor initialization-list. An initalizer has to be a data +/// member declared in this class or a direct-parent constructor. +/// \param bases: the parents of the class +/// \param components: the components of the class +/// \param initializers: the constructor initializers +/// \return If an invalid initializer is found, then the method outputs an error +/// message and throws a 0 exception. void cpp_typecheckt::check_member_initializers( const irept &bases, const struct_typet::componentst &components, @@ -726,23 +643,14 @@ void cpp_typecheckt::check_member_initializers( } } -/*******************************************************************\ - -Function: full_member_initialization - - Inputs: struct_union_type: the class/struct/union - initializers: the constructor initializers - - Outputs: initializers is updated. - - Purpose: Build the full initialization list of the constructor. - First, all the direct-parent constructors are called. - Second, all the non-pod data members are initialized. - - Note: The initialization order follows the decalration order. - -\*******************************************************************/ - +/// Build the full initialization list of the constructor. First, all the +/// direct-parent constructors are called. Second, all the non-pod data members +/// are initialized. +/// +/// Note: The initialization order follows the decalration order. +/// \param struct_union_type: the class/struct/union +/// \param initializers: the constructor initializers +/// \return initializers is updated. void cpp_typecheckt::full_member_initialization( const struct_union_typet &struct_union_type, irept &initializers) @@ -1006,23 +914,8 @@ void cpp_typecheckt::full_member_initialization( initializers.swap(final_initializers); } -/*******************************************************************\ - -Function: find_cpctor - - Inputs: typechecked compound symbol - - Outputs: return true if a copy constructor is found - - Note: - "A non-template constructor for class X is a copy constructor - if its first parameter is of type X&, const X&, volatile X& - or const volatile X&, and either there are no other parameters - or else all other parameters have default arguments (8.3.6).106) - [Example: X::X(const X&) and X::X(X&, int=1) are copy constructors." - -\*******************************************************************/ - +/// \par parameters: typechecked compound symbol +/// \return return true if a copy constructor is found bool cpp_typecheckt::find_cpctor(const symbolt &symbol) const { const struct_typet &struct_type=to_struct_type(symbol.type); @@ -1080,18 +973,6 @@ bool cpp_typecheckt::find_cpctor(const symbolt &symbol) const return false; } -/*******************************************************************\ - -Function: cpp_typecheckt::find_assignop - - Inputs: - - Outputs: - - Note: - -\*******************************************************************/ - bool cpp_typecheckt::find_assignop(const symbolt &symbol) const { const struct_typet &struct_type=to_struct_type(symbol.type); diff --git a/src/cpp/cpp_typecheck_conversions.cpp b/src/cpp/cpp_typecheck_conversions.cpp index 16d8e519741..1e33634ebef 100644 --- a/src/cpp/cpp_typecheck_conversions.cpp +++ b/src/cpp/cpp_typecheck_conversions.cpp @@ -6,6 +6,9 @@ Module: C++ Language Type Checking \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include #include @@ -15,39 +18,30 @@ Module: C++ Language Type Checking #include #include -#include +#include #include "cpp_typecheck.h" -/*******************************************************************\ - -Function: standard_conversion_lvalue_to_rvalue - - Inputs: A typechecked lvalue expression - - Outputs: True iff the lvalue-to-rvalue conversion is possible. - 'new_type' contains the result of the conversion. - - Purpose: Lvalue-to-rvalue conversion - - An lvalue (3.10) of a non-function, non-array type T can be - converted to an rvalue. If T is an incomplete type, a program - that necessitates this conversion is ill-formed. If the object - to which the lvalue refers is not an object of type T and is - not an object of a type derived from T, or if the object is - uninitialized, a program that necessitates this conversion has - undefined behavior. If T is a non-class type, the type of the - rvalue is the cv-unqualified version of T. Otherwise, the type of - the rvalue is T. - - The value contained in the object indicated by the lvalue - is the rvalue result. When an lvalue-to-rvalue conversion - occurs within the operand of sizeof (5.3.3) the value contained - in the referenced object is not accessed, since that operator - does not evaluate its operand. - -\*******************************************************************/ - +/// Lvalue-to-rvalue conversion +/// +/// An lvalue (3.10) of a non-function, non-array type T can be +/// converted to an rvalue. If T is an incomplete type, a program +/// that necessitates this conversion is ill-formed. If the object +/// to which the lvalue refers is not an object of type T and is +/// not an object of a type derived from T, or if the object is +/// uninitialized, a program that necessitates this conversion has +/// undefined behavior. If T is a non-class type, the type of the +/// rvalue is the cv-unqualified version of T. Otherwise, the type of +/// the rvalue is T. +/// +/// The value contained in the object indicated by the lvalue +/// is the rvalue result. When an lvalue-to-rvalue conversion +/// occurs within the operand of sizeof (5.3.3) the value contained +/// in the referenced object is not accessed, since that operator +/// does not evaluate its operand. +/// \par parameters: A typechecked lvalue expression +/// \return True iff the lvalue-to-rvalue conversion is possible. 'new_type' +/// contains the result of the conversion. bool cpp_typecheckt::standard_conversion_lvalue_to_rvalue( const exprt &expr, exprt &new_expr) const @@ -65,23 +59,14 @@ bool cpp_typecheckt::standard_conversion_lvalue_to_rvalue( return true; } -/*******************************************************************\ - -Function: standard_conversion_array_to_pointer - - Inputs: An array expression - - Outputs: True iff the array-to-pointer conversion is possible. - The result of the conversion is stored in 'new_expr'. - - Purpose: Array-to-pointer conversion - - An lvalue or rvalue of type "array of N T" or "array of unknown - bound of T" can be converted to an rvalue of type "pointer to T." - The result is a pointer to the first element of the array. - -\*******************************************************************/ - +/// Array-to-pointer conversion +/// +/// An lvalue or rvalue of type "array of N T" or "array of unknown +/// bound of T" can be converted to an rvalue of type "pointer to T." +/// The result is a pointer to the first element of the array. +/// \par parameters: An array expression +/// \return True iff the array-to-pointer conversion is possible. The result of +/// the conversion is stored in 'new_expr'. bool cpp_typecheckt::standard_conversion_array_to_pointer( const exprt &expr, exprt &new_expr) const @@ -101,23 +86,13 @@ bool cpp_typecheckt::standard_conversion_array_to_pointer( return true; } -/*******************************************************************\ - -Function: standard_conversion_function_to_pointer - - Inputs: A function expression - - Outputs: True iff the array-to-pointer conversion is possible. - The result of the conversion is stored in 'new_expr'. - - - Purpose: Function-to-pointer conversion - - An lvalue of function type T can be converted to an rvalue of type - "pointer to T." The result is a pointer to the function.50) - -\*******************************************************************/ - +/// Function-to-pointer conversion +/// +/// An lvalue of function type T can be converted to an rvalue of type +/// "pointer to T." The result is a pointer to the function.50) +/// \par parameters: A function expression +/// \return True iff the array-to-pointer conversion is possible. The result of +/// the conversion is stored in 'new_expr'. bool cpp_typecheckt::standard_conversion_function_to_pointer( const exprt &expr, exprt &new_expr) const { @@ -136,20 +111,11 @@ bool cpp_typecheckt::standard_conversion_function_to_pointer( return true; } -/*******************************************************************\ - -Function: standard_conversion_qualification - - Inputs: A typechecked expression 'expr', a destination - type 'type' - - Outputs: True iff the qualification conversion is possible. - The result of the conversion is stored in 'new_expr'. - - Purpose: Qualification conversion - -\*******************************************************************/ - +/// Qualification conversion +/// \par parameters: A typechecked expression 'expr', a destination +/// type 'type' +/// \return True iff the qualification conversion is possible. The result of the +/// conversion is stored in 'new_expr'. bool cpp_typecheckt::standard_conversion_qualification( const exprt &expr, const typet &type, @@ -203,40 +169,31 @@ bool cpp_typecheckt::standard_conversion_qualification( return false; } -/*******************************************************************\ - -Function: standard_conversion_integral_promotion - - Inputs: A typechecked expression 'expr' - - Outputs: True iff the integral pormotion is possible. - The result of the conversion is stored in 'new_expr'. - - Purpose: Integral-promotion conversion - - An rvalue of type char, signed char, unsigned char, short int, - or unsigned short int can be converted to an rvalue of type int - if int can represent all the values of the source type; otherwise, - the source rvalue can be converted to an rvalue of type unsigned int. - - An rvalue of type wchar_t (3.9.1) or an enumeration type (7.2) can - be converted to an rvalue of the first of the following types that - can represent all the values of its underlying type: int, unsigned int, - long, or unsigned long. - - An rvalue for an integral bit-field (9.6) can be converted - to an rvalue of type int if int can represent all the values of the - bit-field; otherwise, it can be converted to unsigned int if - unsigned int can represent all the values of the bit-field. - If the bit-field is larger yet, no integral promotion applies to - it. If the bit-field has an enumerated type, it is treated as - any other value of that type for promotion purposes. - - An rvalue of type bool can be converted to an rvalue of type int, - with false becoming zero and true becoming one. - -\*******************************************************************/ - +/// Integral-promotion conversion +/// +/// An rvalue of type char, signed char, unsigned char, short int, +/// or unsigned short int can be converted to an rvalue of type int +/// if int can represent all the values of the source type; otherwise, +/// the source rvalue can be converted to an rvalue of type unsigned int. +/// +/// An rvalue of type wchar_t (3.9.1) or an enumeration type (7.2) can +/// be converted to an rvalue of the first of the following types that +/// can represent all the values of its underlying type: int, unsigned int, +/// long, or unsigned long. +/// +/// An rvalue for an integral bit-field (9.6) can be converted +/// to an rvalue of type int if int can represent all the values of the +/// bit-field; otherwise, it can be converted to unsigned int if +/// unsigned int can represent all the values of the bit-field. +/// If the bit-field is larger yet, no integral promotion applies to +/// it. If the bit-field has an enumerated type, it is treated as +/// any other value of that type for promotion purposes. +/// +/// An rvalue of type bool can be converted to an rvalue of type int, +/// with false becoming zero and true becoming one. +/// \par parameters: A typechecked expression 'expr' +/// \return True iff the integral pormotion is possible. The result of the +/// conversion is stored in 'new_expr'. bool cpp_typecheckt::standard_conversion_integral_promotion( const exprt &expr, exprt &new_expr) const @@ -282,22 +239,13 @@ bool cpp_typecheckt::standard_conversion_integral_promotion( return false; } -/*******************************************************************\ - -Function: standard_conversion_floating_point_promotion - - Inputs: A typechecked expression 'expr' - - Outputs: True iff the integral promotion is possible. - The result of the conversion is stored in 'new_expr'. - - Purpose: Floating-point-promotion conversion - - An rvalue of type float can be converted to an rvalue of type - double. The value is unchanged. - -\*******************************************************************/ - +/// Floating-point-promotion conversion +/// +/// An rvalue of type float can be converted to an rvalue of type +/// double. The value is unchanged. +/// \par parameters: A typechecked expression 'expr' +/// \return True iff the integral promotion is possible. The result of the +/// conversion is stored in 'new_expr'. bool cpp_typecheckt::standard_conversion_floating_point_promotion( const exprt &expr, exprt &new_expr) const @@ -325,43 +273,34 @@ bool cpp_typecheckt::standard_conversion_floating_point_promotion( return true; } -/*******************************************************************\ - -Function: standard_conversion_integral_conversion - - Inputs: A typechecked expression 'expr', a destination - type 'type' - - Outputs: True iff the integral pormotion is possible. - The result of the conversion is stored in 'new_expr'. - - Purpose: Integral conversion - - An rvalue of type char, signed char, unsigned char, short int, - An rvalue of an integer type can be converted to an rvalue of - another integer type. An rvalue of an enumeration type can be - converted to an rvalue of an integer type. - - If the destination type is unsigned, the resulting value is the - least unsigned integer congruent to the source integer (modulo - 2n where n is the number of bits used to represent the unsigned - type). [Note: In a two's complement representation, this - conversion is conceptual and there is no change in the bit - pattern (if there is no truncation). ] - - If the destination type is signed, the value is unchanged if it - can be represented in the destination type (and bit-field width); - otherwise, the value is implementation-defined. - - If the destination type is bool, see 4.12. If the source type is - bool, the value false is converted to zero and the value true is - converted to one. - - The conversions allowed as integral promotions are excluded from - the set of integral conversions. - -\*******************************************************************/ - +/// Integral conversion +/// +/// An rvalue of type char, signed char, unsigned char, short int, +/// An rvalue of an integer type can be converted to an rvalue of +/// another integer type. An rvalue of an enumeration type can be +/// converted to an rvalue of an integer type. +/// +/// If the destination type is unsigned, the resulting value is the +/// least unsigned integer congruent to the source integer (modulo +/// 2n where n is the number of bits used to represent the unsigned +/// type). [Note: In a two's complement representation, this +/// conversion is conceptual and there is no change in the bit +/// pattern (if there is no truncation). ] +/// +/// If the destination type is signed, the value is unchanged if it +/// can be represented in the destination type (and bit-field width); +/// otherwise, the value is implementation-defined. +/// +/// If the destination type is bool, see 4.12. If the source type is +/// bool, the value false is converted to zero and the value true is +/// converted to one. +/// +/// The conversions allowed as integral promotions are excluded from +/// the set of integral conversions. +/// \par parameters: A typechecked expression 'expr', a destination +/// type 'type' +/// \return True iff the integral pormotion is possible. The result of the +/// conversion is stored in 'new_expr'. bool cpp_typecheckt::standard_conversion_integral_conversion( const exprt &expr, const typet &type, @@ -389,34 +328,25 @@ bool cpp_typecheckt::standard_conversion_integral_conversion( return true; } -/*******************************************************************\ - -Function: standard_conversion_floating_integral_conversion - - Inputs: A typechecked expression 'expr' - - Outputs: True iff the conversion is possible. - The result of the conversion is stored in 'new_expr'. - - Purpose: Floating-integral conversion - - An rvalue of a floating point type can be converted to an rvalue - of an integer type. The conversion truncates; that is, the - fractional part is discarded. The behavior is undefined if the - truncated value cannot be represented in the destination type. - [Note: If the destination type is bool, see 4.12. ] - - An rvalue of an integer type or of an enumeration type can be - converted to an rvalue of a floating point type. The result is - exact if possible. Otherwise, it is an implementation-defined - choice of either the next lower or higher representable value. - [Note: loss of precision occurs if the integral value cannot be - represented exactly as a value of the floating type. ] If the - source type is bool, the value false is converted to zero and the - value true is converted to one. - -\*******************************************************************/ - +/// Floating-integral conversion +/// +/// An rvalue of a floating point type can be converted to an rvalue +/// of an integer type. The conversion truncates; that is, the +/// fractional part is discarded. The behavior is undefined if the +/// truncated value cannot be represented in the destination type. +/// [Note: If the destination type is bool, see 4.12. ] +/// +/// An rvalue of an integer type or of an enumeration type can be +/// converted to an rvalue of a floating point type. The result is +/// exact if possible. Otherwise, it is an implementation-defined +/// choice of either the next lower or higher representable value. +/// [Note: loss of precision occurs if the integral value cannot be +/// represented exactly as a value of the floating type. ] If the +/// source type is bool, the value false is converted to zero and the +/// value true is converted to one. +/// \par parameters: A typechecked expression 'expr' +/// \return True iff the conversion is possible. The result of the conversion is +/// stored in 'new_expr'. bool cpp_typecheckt::standard_conversion_floating_integral_conversion( const exprt &expr, const typet &type, @@ -453,31 +383,22 @@ bool cpp_typecheckt::standard_conversion_floating_integral_conversion( } -/*******************************************************************\ - -Function: standard_conversion_floating_point_conversion - - Inputs: A typechecked expression 'expr', a destination - type 'type' - - Outputs: True iff the floating-point conversion is possible. - The result of the conversion is stored in 'new_expr'. - - Purpose: Floating-point conversion - - An rvalue of floating point type can be converted to an rvalue - of another floating point type. If the source value can be exactly - represented in the destination type, the result of the conversion - is that exact representation. If the source value is between two - adjacent destination values, the result of the conversion is an - implementation-defined choice of either of those values. Otherwise, - the behavior is undefined. - - The conversions allowed as floating point promotions are excluded - from the set of floating point conversions. - -\*******************************************************************/ - +/// Floating-point conversion +/// +/// An rvalue of floating point type can be converted to an rvalue +/// of another floating point type. If the source value can be exactly +/// represented in the destination type, the result of the conversion +/// is that exact representation. If the source value is between two +/// adjacent destination values, the result of the conversion is an +/// implementation-defined choice of either of those values. Otherwise, +/// the behavior is undefined. +/// +/// The conversions allowed as floating point promotions are excluded +/// from the set of floating point conversions. +/// \par parameters: A typechecked expression 'expr', a destination +/// type 'type' +/// \return True iff the floating-point conversion is possible. The result of +/// the conversion is stored in 'new_expr'. bool cpp_typecheckt::standard_conversion_floating_point_conversion( const exprt &expr, const typet &type, @@ -504,47 +425,38 @@ bool cpp_typecheckt::standard_conversion_floating_point_conversion( return true; } -/*******************************************************************\ - -Function: standard_conversion_pointer - - Inputs: A typechecked expression 'expr', a destination - type 'type' - - Outputs: True iff the pointer conversion is possible. - The result of the conversion is stored in 'new_expr'. - - Purpose: Pointer conversion - - A null pointer constant is an integral constant expression - (5.19) rvalue of integer type that evaluates to zero. A null - pointer constant can be converted to a pointer type; the result - is the null pointer value of that type and is distinguishable - from every other value of pointer to object or pointer to - function type. Two null pointer values of the same type shall - compare equal. The conversion of a null pointer constant to a - pointer to cv-qualified type is a single conversion, and not the - sequence of a pointer conversion followed by a qualification - conversion (4.4). - - An rvalue of type "pointer to cv T," where T is an object type, - can be converted to an rvalue of type "pointer to cv void." The - result of converting a "pointer to cv T" to a "pointer to cv - void" points to the start of the storage location where the - object of type T resides, as if the object is a most derived - object (1.8) of type T (that is, not a base class subobject). - - An rvalue of type "pointer to cv D," where D is a class type, - can be converted to an rvalue of type "pointer to cv B," where - B is a base class (clause 10) of D. If B is an inaccessible - (clause 11) or ambiguous (10.2) base class of D, a program that - necessitates this conversion is ill-formed. The result of the - conversion is a pointer to the base class sub-object of the - derived class object. The null pointer value is converted to - the null pointer value of the destination type. - -\*******************************************************************/ - +/// Pointer conversion +/// +/// A null pointer constant is an integral constant expression +/// (5.19) rvalue of integer type that evaluates to zero. A null +/// pointer constant can be converted to a pointer type; the result +/// is the null pointer value of that type and is distinguishable +/// from every other value of pointer to object or pointer to +/// function type. Two null pointer values of the same type shall +/// compare equal. The conversion of a null pointer constant to a +/// pointer to cv-qualified type is a single conversion, and not the +/// sequence of a pointer conversion followed by a qualification +/// conversion (4.4). +/// +/// An rvalue of type "pointer to cv T," where T is an object type, +/// can be converted to an rvalue of type "pointer to cv void." The +/// result of converting a "pointer to cv T" to a "pointer to cv +/// void" points to the start of the storage location where the +/// object of type T resides, as if the object is a most derived +/// object (1.8) of type T (that is, not a base class subobject). +/// +/// An rvalue of type "pointer to cv D," where D is a class type, +/// can be converted to an rvalue of type "pointer to cv B," where +/// B is a base class (clause 10) of D. If B is an inaccessible +/// (clause 11) or ambiguous (10.2) base class of D, a program that +/// necessitates this conversion is ill-formed. The result of the +/// conversion is a pointer to the base class sub-object of the +/// derived class object. The null pointer value is converted to +/// the null pointer value of the destination type. +/// \par parameters: A typechecked expression 'expr', a destination +/// type 'type' +/// \return True iff the pointer conversion is possible. The result of the +/// conversion is stored in 'new_expr'. bool cpp_typecheckt::standard_conversion_pointer( const exprt &expr, const typet &type, @@ -611,46 +523,36 @@ bool cpp_typecheckt::standard_conversion_pointer( return false; } -/*******************************************************************\ - -Function: standard_conversion_pointer_to_member - - Inputs: A typechecked expression 'expr', a destination - type 'type' - - Outputs: True iff the pointer-to-member conversion is possible. - The result of the conversion is stored in 'new_expr'. - - - Purpose: Pointer-to-member conversion - - A null pointer constant (4.10) can be converted to a pointer to - member type; the result is the null member pointer value of that - type and is distinguishable from any pointer to member not created - from a null pointer constant. Two null member pointer values of - the same type shall compare equal. The conversion of a null pointer - constant to a pointer to member of cv-qualified type is a single - conversion, and not the sequence of a pointer to member conversion - followed by a qualification conversion (4.4). - - An rvalue of type "pointer to member of B of type cv T," where B - is a class type, can be converted to an rvalue of type "pointer - to member of D of type cv T," where D is a derived class - (clause 10) of B. If B is an inaccessible (clause 11), ambiguous - (10.2) or virtual (10.1) base class of D, a program that - necessitates this conversion is ill-formed. The result of the - conversion refers to the same member as the pointer to member - before the conversion took place, but it refers to the base class - member as if it were a member of the derived class. The result - refers to the member in D"s instance of B. Since the result has - type "pointer to member of D of type cv T," it can be dereferenced - with a D object. The result is the same as if the pointer to - member of B were dereferenced with the B sub-object of D. The null - member pointer value is converted to the null member pointer value - of the destination type.52) - -\*******************************************************************/ - +/// Pointer-to-member conversion +/// +/// A null pointer constant (4.10) can be converted to a pointer to +/// member type; the result is the null member pointer value of that +/// type and is distinguishable from any pointer to member not created +/// from a null pointer constant. Two null member pointer values of +/// the same type shall compare equal. The conversion of a null pointer +/// constant to a pointer to member of cv-qualified type is a single +/// conversion, and not the sequence of a pointer to member conversion +/// followed by a qualification conversion (4.4). +/// +/// An rvalue of type "pointer to member of B of type cv T," where B +/// is a class type, can be converted to an rvalue of type "pointer +/// to member of D of type cv T," where D is a derived class +/// (clause 10) of B. If B is an inaccessible (clause 11), ambiguous +/// (10.2) or virtual (10.1) base class of D, a program that +/// necessitates this conversion is ill-formed. The result of the +/// conversion refers to the same member as the pointer to member +/// before the conversion took place, but it refers to the base class +/// member as if it were a member of the derived class. The result +/// refers to the member in D"s instance of B. Since the result has +/// type "pointer to member of D of type cv T," it can be dereferenced +/// with a D object. The result is the same as if the pointer to +/// member of B were dereferenced with the B sub-object of D. The null +/// member pointer value is converted to the null member pointer value +/// of the destination type.52) +/// \par parameters: A typechecked expression 'expr', a destination +/// type 'type' +/// \return True iff the pointer-to-member conversion is possible. The result of +/// the conversion is stored in 'new_expr'. bool cpp_typecheckt::standard_conversion_pointer_to_member( const exprt &expr, const typet &type, @@ -724,25 +626,15 @@ bool cpp_typecheckt::standard_conversion_pointer_to_member( return false; } -/*******************************************************************\ - -Function: standard_conversion_boolean - - Inputs: A typechecked expression 'expr' - - Outputs: True iff the boolean conversion is possible. - The result of the conversion is stored in 'new_expr'. - - - Purpose: Boolean conversion - - An rvalue of arithmetic, enumeration, pointer, or pointer to - member type can be converted to an rvalue of type bool. - A zero value, null pointer value, or null member pointer value is - converted to false; any other value is converted to true. - -\*******************************************************************/ - +/// Boolean conversion +/// +/// An rvalue of arithmetic, enumeration, pointer, or pointer to +/// member type can be converted to an rvalue of type bool. +/// A zero value, null pointer value, or null member pointer value is +/// converted to false; any other value is converted to true. +/// \par parameters: A typechecked expression 'expr' +/// \return True iff the boolean conversion is possible. The result of the +/// conversion is stored in 'new_expr'. bool cpp_typecheckt::standard_conversion_boolean( const exprt &expr, exprt &new_expr) const { @@ -766,37 +658,26 @@ bool cpp_typecheckt::standard_conversion_boolean( return true; } -/*******************************************************************\ - -Function: standard_conversion_sequence - - Inputs: A typechecked expression 'expr', a destination - type 'type'. - - Outputs: True iff a standard conversion sequence exists. - The result of the conversion is stored in 'new_expr'. - The reference 'rank' is incremented. - - - Purpose: Standard Conversion Sequence - - A standard conversion sequence is a sequence of standard conversions - in the following order: - - * Zero or one conversion from the following set: lvalue-to-rvalue - conversion, array-to-pointer conversion, and function-to-pointer - conversion. - - * Zero or one conversion from the following set: integral - promotions, floating point promotion, integral conversions, - floating point conversions, floating-integral conversions, - pointer conversions, pointer to member conversions, and boolean - conversions. - - * Zero or one qualification conversion. - -\*******************************************************************/ - +/// Standard Conversion Sequence +/// +/// A standard conversion sequence is a sequence of standard conversions +/// in the following order: +/// +/// * Zero or one conversion from the following set: lvalue-to-rvalue +/// conversion, array-to-pointer conversion, and function-to-pointer +/// conversion. +/// +/// * Zero or one conversion from the following set: integral +/// promotions, floating point promotion, integral conversions, +/// floating point conversions, floating-integral conversions, +/// pointer conversions, pointer to member conversions, and boolean +/// conversions. +/// +/// * Zero or one qualification conversion. +/// \par parameters: A typechecked expression 'expr', a destination +/// type 'type'. +/// \return True iff a standard conversion sequence exists. The result of the +/// conversion is stored in 'new_expr'. The reference 'rank' is incremented. bool cpp_typecheckt::standard_conversion_sequence( const exprt &expr, const typet &type, @@ -962,20 +843,11 @@ bool cpp_typecheckt::standard_conversion_sequence( return true; } -/*******************************************************************\ - -Function: user_defined_conversion_sequence - - Inputs: A typechecked expression 'expr', a destination - type 'type'. - - Outputs: True iff a user-defined conversion sequence exists. - The result of the conversion is stored in 'new_expr'. - - Purpose: User-defined conversion sequence - -\*******************************************************************/ - +/// User-defined conversion sequence +/// \par parameters: A typechecked expression 'expr', a destination +/// type 'type'. +/// \return True iff a user-defined conversion sequence exists. The result of +/// the conversion is stored in 'new_expr'. bool cpp_typecheckt::user_defined_conversion_sequence( const exprt &expr, const typet &type, @@ -1282,20 +1154,10 @@ bool cpp_typecheckt::user_defined_conversion_sequence( return new_expr.is_not_nil(); } -/*******************************************************************\ - -Function: reference_related - - Inputs: A typechecked expression 'expr', - a reference 'type'. - - Outputs: True iff an the reference 'type' is reference-related - to 'expr'. - - Purpose: Reference-related - -\*******************************************************************/ - +/// Reference-related +/// \par parameters: A typechecked expression 'expr', +/// a reference 'type'. +/// \return True iff an the reference 'type' is reference-related to 'expr'. bool cpp_typecheckt::reference_related( const exprt &expr, const typet &type) const @@ -1329,20 +1191,10 @@ bool cpp_typecheckt::reference_related( return false; } -/*******************************************************************\ - -Function: reference_compatible - - Inputs: A typechecked expression 'expr', a - reference 'type'. - - Outputs: True iff an the reference 'type' is reference-compatible - to 'expr'. - - Purpose: Reference-compatible - -\*******************************************************************/ - +/// Reference-compatible +/// \par parameters: A typechecked expression 'expr', a +/// reference 'type'. +/// \return True iff an the reference 'type' is reference-compatible to 'expr'. bool cpp_typecheckt::reference_compatible( const exprt &expr, const typet &type, @@ -1372,50 +1224,40 @@ bool cpp_typecheckt::reference_compatible( return false; } -/*******************************************************************\ - -Function: reference_binding - - Inputs: A typechecked expression 'expr', a - reference 'type'. - - Outputs: True iff an the reference can be bound to the expression. - The result of the conversion is stored in 'new_expr'. - - - Purpose: Reference binding - - When a parameter of reference type binds directly (8.5.3) to an - argument expression, the implicit conversion sequence is the - identity conversion, unless the argument expression has a type - that is a derived class of the parameter type, in which case the - implicit conversion sequence is a derived-to-base Conversion - (13.3.3.1). - - If the parameter binds directly to the result of applying a - conversion function to the argument expression, the implicit - conversion sequence is a user-defined conversion sequence - (13.3.3.1.2), with the second standard conversion sequence - either an identity conversion or, if the conversion function - returns an entity of a type that is a derived class of the - parameter type, a derived-to-base Conversion. - - When a parameter of reference type is not bound directly to - an argument expression, the conversion sequence is the one - required to convert the argument expression to the underlying - type of the reference according to 13.3.3.1. Conceptually, this - conversion sequence corresponds to copy-initializing a temporary - of the underlying type with the argument expression. Any - difference in top-level cv-qualification is subsumed by the - initialization itself and does not constitute a conversion. - - A standard conversion sequence cannot be formed if it requires - binding a reference to non-const to an rvalue (except when - binding an implicit object parameter; see the special rules - for that case in 13.3.1). - -\*******************************************************************/ - +/// Reference binding +/// +/// When a parameter of reference type binds directly (8.5.3) to an +/// argument expression, the implicit conversion sequence is the +/// identity conversion, unless the argument expression has a type +/// that is a derived class of the parameter type, in which case the +/// implicit conversion sequence is a derived-to-base Conversion +/// (13.3.3.1). +/// +/// If the parameter binds directly to the result of applying a +/// conversion function to the argument expression, the implicit +/// conversion sequence is a user-defined conversion sequence +/// (13.3.3.1.2), with the second standard conversion sequence +/// either an identity conversion or, if the conversion function +/// returns an entity of a type that is a derived class of the +/// parameter type, a derived-to-base Conversion. +/// +/// When a parameter of reference type is not bound directly to +/// an argument expression, the conversion sequence is the one +/// required to convert the argument expression to the underlying +/// type of the reference according to 13.3.3.1. Conceptually, this +/// conversion sequence corresponds to copy-initializing a temporary +/// of the underlying type with the argument expression. Any +/// difference in top-level cv-qualification is subsumed by the +/// initialization itself and does not constitute a conversion. +/// +/// A standard conversion sequence cannot be formed if it requires +/// binding a reference to non-const to an rvalue (except when +/// binding an implicit object parameter; see the special rules +/// for that case in 13.3.1). +/// \par parameters: A typechecked expression 'expr', a +/// reference 'type'. +/// \return True iff an the reference can be bound to the expression. The result +/// of the conversion is stored in 'new_expr'. bool cpp_typecheckt::reference_binding( exprt expr, const typet &type, @@ -1619,21 +1461,12 @@ bool cpp_typecheckt::reference_binding( return false; } -/*******************************************************************\ - -Function: implicit_conversion_sequence - - Inputs: A typechecked expression 'expr', a destination - type 'type'. - - Outputs: True iff an implicit conversion sequence exists. - The result of the conversion is stored in 'new_expr'. - The rank of the sequence is stored in 'rank' - - Purpose: implicit conversion sequence - -\*******************************************************************/ - +/// implicit conversion sequence +/// \par parameters: A typechecked expression 'expr', a destination +/// type 'type'. +/// \return True iff an implicit conversion sequence exists. The result of the +/// conversion is stored in 'new_expr'. The rank of the sequence is stored in +/// 'rank' bool cpp_typecheckt::implicit_conversion_sequence( const exprt &expr, const typet &type, @@ -1671,20 +1504,11 @@ bool cpp_typecheckt::implicit_conversion_sequence( return true; } -/*******************************************************************\ - -Function: implicit_conversion_sequence - - Inputs: A typechecked expression 'expr', a destination - type 'type'. - - Outputs: True iff an implicit conversion sequence exists. - The result of the conversion is stored in 'new_expr'. - - Purpose: implicit conversion sequence - -\*******************************************************************/ - +/// implicit conversion sequence +/// \par parameters: A typechecked expression 'expr', a destination +/// type 'type'. +/// \return True iff an implicit conversion sequence exists. The result of the +/// conversion is stored in 'new_expr'. bool cpp_typecheckt::implicit_conversion_sequence( const exprt &expr, const typet &type, @@ -1694,22 +1518,11 @@ bool cpp_typecheckt::implicit_conversion_sequence( return implicit_conversion_sequence(expr, type, new_expr, rank); } -/*******************************************************************\ - -Function: implicit_conversion_sequence - - Inputs: A typechecked expression 'expr', a destination - type 'type'. - - Outputs: True iff an implicit conversion sequence exists. - The rank of the sequence is stored in 'rank' - - - Purpose: implicit conversion sequence - - -\*******************************************************************/ - +/// implicit conversion sequence +/// \par parameters: A typechecked expression 'expr', a destination +/// type 'type'. +/// \return True iff an implicit conversion sequence exists. The rank of the +/// sequence is stored in 'rank' bool cpp_typecheckt::implicit_conversion_sequence( const exprt &expr, const typet &type, @@ -1719,18 +1532,6 @@ bool cpp_typecheckt::implicit_conversion_sequence( return implicit_conversion_sequence(expr, type, new_expr, rank); } -/*******************************************************************\ - -Function: cpp_typecheck_baset::implicit_typecast - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::implicit_typecast(exprt &expr, const typet &type) { exprt e=expr; @@ -1743,68 +1544,55 @@ void cpp_typecheckt::implicit_typecast(exprt &expr, const typet &type) << to_string(e.type()) << "' to `" << to_string(type) << "'" << eom; #if 0 - str << "\n " << follow(e.type()).pretty() << std::endl; - str << "\n " << type.pretty() << std::endl; + str << "\n " << follow(e.type()).pretty() << '\n'; + str << "\n " << type.pretty() << '\n'; #endif throw 0; } } -/*******************************************************************\ - -Function: cpp_typecheck_baset::reference_initializer - - Inputs: - - Outputs: - - Purpose: - - A reference to type "cv1 T1" is initialized by an expression of - type "cv2 T2" as follows: - - - If the initializer expression - - is an lvalue (but is not a bit-field), and "cv1 T1" is - reference-compatible with "cv2 T2," or - - has a class type (i.e., T2 is a class type) and can be - implicitly converted to an lvalue of type "cv3 T3," where - "cv1 T1" is reference-compatible with "cv3 T3" 92) (this - conversion is selected by enumerating the applicable conversion - functions (13.3.1.6) and choosing the best one through overload - resolution (13.3)), - - then the reference is bound directly to the initializer - expression lvalue in the first case, and the reference is - bound to the lvalue result of the conversion in the second - case. In these cases the reference is said to bind directly - to the initializer expression. - - - Otherwise, the reference shall be to a non-volatile const type - - If the initializer expression is an rvalue, with T2 a class - type, and "cv1 T1" is reference-compatible with "cv2 T2," the - reference is bound in one of the following ways (the choice is - implementation-defined): - - - The reference is bound to the object represented by the - rvalue (see 3.10) or to a sub-object within that object. - - - A temporary of type "cv1 T2" [sic] is created, and a - constructor is called to copy the entire rvalue object into - the temporary. The reference is bound to the temporary or - to a sub-object within the temporary. - - The constructor that would be used to make the copy shall be - callable whether or not the copy is actually done. - - Otherwise, a temporary of type "cv1 T1" is created and - initialized from the initializer expression using the rules for - a non-reference copy initialization (8.5). The reference is then - bound to the temporary. If T1 is reference-related to T2, cv1 - must be the same cv-qualification as, or greater cvqualification - than, cv2; otherwise, the program is ill-formed. - -\*******************************************************************/ - +/// A reference to type "cv1 T1" is initialized by an expression of +/// type "cv2 T2" as follows: +/// +/// - If the initializer expression +/// - is an lvalue (but is not a bit-field), and "cv1 T1" is +/// reference-compatible with "cv2 T2," or +/// - has a class type (i.e., T2 is a class type) and can be +/// implicitly converted to an lvalue of type "cv3 T3," where +/// "cv1 T1" is reference-compatible with "cv3 T3" 92) (this +/// conversion is selected by enumerating the applicable conversion +/// functions (13.3.1.6) and choosing the best one through overload +/// resolution (13.3)), +/// +/// then the reference is bound directly to the initializer +/// expression lvalue in the first case, and the reference is +/// bound to the lvalue result of the conversion in the second +/// case. In these cases the reference is said to bind directly +/// to the initializer expression. +/// +/// - Otherwise, the reference shall be to a non-volatile const type +/// - If the initializer expression is an rvalue, with T2 a class +/// type, and "cv1 T1" is reference-compatible with "cv2 T2," the +/// reference is bound in one of the following ways (the choice is +/// implementation-defined): +/// +/// - The reference is bound to the object represented by the +/// rvalue (see 3.10) or to a sub-object within that object. +/// +/// - A temporary of type "cv1 T2" [sic] is created, and a +/// constructor is called to copy the entire rvalue object into +/// the temporary. The reference is bound to the temporary or +/// to a sub-object within the temporary. +/// +/// The constructor that would be used to make the copy shall be +/// callable whether or not the copy is actually done. +/// +/// Otherwise, a temporary of type "cv1 T1" is created and +/// initialized from the initializer expression using the rules for +/// a non-reference copy initialization (8.5). The reference is then +/// bound to the temporary. If T1 is reference-related to T2, cv1 +/// must be the same cv-qualification as, or greater cvqualification +/// than, cv2; otherwise, the program is ill-formed. void cpp_typecheckt::reference_initializer( exprt &expr, const typet &type) @@ -1825,19 +1613,6 @@ void cpp_typecheckt::reference_initializer( throw 0; } -/*******************************************************************\ - -Function: cpp_typecheckt::cast_away_constness - - Inputs: - - Outputs: - - Purpose: - - -\*******************************************************************/ - bool cpp_typecheckt::cast_away_constness( const typet &t1, const typet &t2) const @@ -1901,18 +1676,6 @@ bool cpp_typecheckt::cast_away_constness( return !standard_conversion_qualification(e1, snt2.back(), e2); } -/*******************************************************************\ - -Function: cpp_typecheckt::const_typecast - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool cpp_typecheckt::const_typecast( const exprt &expr, const typet &type, @@ -1972,18 +1735,6 @@ bool cpp_typecheckt::const_typecast( return false; } -/*******************************************************************\ - -Function: cpp_typecheckt::dynamic_typecast - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool cpp_typecheckt::dynamic_typecast( const exprt &expr, const typet &type, @@ -2036,18 +1787,6 @@ bool cpp_typecheckt::dynamic_typecast( return static_typecast(e, type, new_expr); } -/*******************************************************************\ - -Function: cpp_typecheckt::reinterpret_typecastcast - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool cpp_typecheckt::reinterpret_typecast( const exprt &expr, const typet &type, @@ -2152,18 +1891,6 @@ bool cpp_typecheckt::reinterpret_typecast( return false; } -/*******************************************************************\ - -Function: cpp_typecheckt::static_typecast - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool cpp_typecheckt::static_typecast( const exprt &expr, // source expression const typet &type, // destination type diff --git a/src/cpp/cpp_typecheck_declaration.cpp b/src/cpp/cpp_typecheck_declaration.cpp index 980413225b1..8568b525a91 100644 --- a/src/cpp/cpp_typecheck_declaration.cpp +++ b/src/cpp/cpp_typecheck_declaration.cpp @@ -6,21 +6,12 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \********************************************************************/ +/// \file +/// C++ Language Type Checking + #include "cpp_typecheck.h" #include "cpp_declarator_converter.h" -/*******************************************************************\ - -Function: cpp_typecheckt::convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::convert(cpp_declarationt &declaration) { // see if the declaration is empty @@ -44,18 +35,6 @@ void cpp_typecheckt::convert(cpp_declarationt &declaration) method_bodies.swap(old_method_bodies); } -/*******************************************************************\ - -Function: cpp_typecheckt::convert_anonymous_union - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::convert_anonymous_union( cpp_declarationt &declaration, codet &code) @@ -130,18 +109,6 @@ void cpp_typecheckt::convert_anonymous_union( code.swap(new_code); } -/*******************************************************************\ - -Function: cpp_typecheckt::convert_non_template_declaration - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::convert_non_template_declaration( cpp_declarationt &declaration) { diff --git a/src/cpp/cpp_typecheck_destructor.cpp b/src/cpp/cpp_typecheck_destructor.cpp index 4b1be9ceeb4..b8038d5c01f 100644 --- a/src/cpp/cpp_typecheck_destructor.cpp +++ b/src/cpp/cpp_typecheck_destructor.cpp @@ -6,19 +6,10 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -#include "cpp_typecheck.h" - -/*******************************************************************\ - -Function: cpp_typecheckt::find_dtor - - Inputs: - - Outputs: - - Note: +/// \file +/// C++ Language Type Checking -\*******************************************************************/ +#include "cpp_typecheck.h" bool cpp_typecheckt::find_dtor(const symbolt &symbol) const { @@ -34,20 +25,7 @@ bool cpp_typecheckt::find_dtor(const symbolt &symbol) const return false; } -/*******************************************************************\ - -Function: default_dtor - - Inputs: - - Outputs: - - Purpose: - - Note: - -\*******************************************************************/ - +/// Note: void cpp_typecheckt::default_dtor( const symbolt &symbol, cpp_declarationt &dtor) @@ -77,20 +55,9 @@ void cpp_typecheckt::default_dtor( dtor.move_to_operands(decl); } -/*******************************************************************\ - -Function: cpp_typecheckt::dtor - - Inputs: - - Outputs: - - Purpose: produces destructor code for a class object - - Note: - -\*******************************************************************/ - +/// produces destructor code for a class object +/// +/// Note: codet cpp_typecheckt::dtor(const symbolt &symbol) { assert(symbol.type.id()==ID_struct || diff --git a/src/cpp/cpp_typecheck_enum_type.cpp b/src/cpp/cpp_typecheck_enum_type.cpp index 09c57e9e9bc..a470b2c66f7 100644 --- a/src/cpp/cpp_typecheck_enum_type.cpp +++ b/src/cpp/cpp_typecheck_enum_type.cpp @@ -6,26 +6,17 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include #include -#include +#include #include "cpp_typecheck.h" #include "cpp_enum_type.h" -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_enum_body - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_enum_body(symbolt &enum_symbol) { c_enum_typet &c_enum_type=to_c_enum_type(enum_symbol.type); @@ -89,18 +80,6 @@ void cpp_typecheckt::typecheck_enum_body(symbolt &enum_symbol) } } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_enum_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_enum_type(typet &type) { // first save qualifiers diff --git a/src/cpp/cpp_typecheck_expr.cpp b/src/cpp/cpp_typecheck_expr.cpp index a29d27634d8..979572c717e 100644 --- a/src/cpp/cpp_typecheck_expr.cpp +++ b/src/cpp/cpp_typecheck_expr.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include #include @@ -15,7 +18,7 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include #include -#include +#include #include #include @@ -27,18 +30,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "cpp_exception_id.h" #include "expr2cpp.h" -/*******************************************************************\ - -Function: cpp_typecheckt::find_parent - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - bool cpp_typecheckt::find_parent( const symbolt &symb, const irep_idt &base_name, @@ -56,18 +47,7 @@ bool cpp_typecheckt::find_parent( return false; } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_expr_main - -Inputs: - -Outputs: - -Purpose: Called after the operands are done - -\*******************************************************************/ - +/// Called after the operands are done void cpp_typecheckt::typecheck_expr_main(exprt &expr) { if(expr.id()==ID_cpp_name) @@ -89,22 +69,22 @@ void cpp_typecheckt::typecheck_expr_main(exprt &expr) else if(expr.is_nil()) { #if 0 - std::cerr << "cpp_typecheckt::typecheck_expr_main got nil" << std::endl; + std::cerr << "cpp_typecheckt::typecheck_expr_main got nil\n"; #endif abort(); } else if(expr.id()==ID_code) { #if 0 - std::cerr << "cpp_typecheckt::typecheck_expr_main got code" << std::endl; + std::cerr << "cpp_typecheckt::typecheck_expr_main got code\n"; #endif abort(); } else if(expr.id()==ID_symbol) { #if 0 - std::cout << "E: " << expr.pretty() << std::endl; - std::cerr << "cpp_typecheckt::typecheck_expr_main got symbol" << std::endl; + std::cout << "E: " << expr.pretty() << '\n'; + std::cerr << "cpp_typecheckt::typecheck_expr_main got symbol\n"; abort(); #endif } @@ -156,18 +136,6 @@ void cpp_typecheckt::typecheck_expr_main(exprt &expr) c_typecheck_baset::typecheck_expr_main(expr); } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_expr_trinary - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_expr_trinary(if_exprt &expr) { assert(expr.operands().size()==3); @@ -329,18 +297,6 @@ void cpp_typecheckt::typecheck_expr_trinary(if_exprt &expr) return; } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_expr_member - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_expr_member(exprt &expr) { typecheck_expr_member( @@ -348,18 +304,6 @@ void cpp_typecheckt::typecheck_expr_member(exprt &expr) cpp_typecheck_fargst()); } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_expr_sizeof - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_expr_sizeof(exprt &expr) { // We need to overload, "sizeof-expression" can be mis-parsed @@ -415,35 +359,11 @@ void cpp_typecheckt::typecheck_expr_sizeof(exprt &expr) c_typecheck_baset::typecheck_expr_sizeof(expr); } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_expr_ptrmember - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_expr_ptrmember(exprt &expr) { typecheck_expr_ptrmember(expr, cpp_typecheck_fargst()); } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_function_expr - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_function_expr( exprt &expr, const cpp_typecheck_fargst &fargs) @@ -500,18 +420,6 @@ void cpp_typecheckt::typecheck_function_expr( typecheck_expr(expr); } -/*******************************************************************\ - -Function: cpp_typecheckt::overloadable - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - bool cpp_typecheckt::overloadable(const exprt &expr) { // at least one argument must have class or enumerated type @@ -532,18 +440,6 @@ bool cpp_typecheckt::overloadable(const exprt &expr) return false; } -/*******************************************************************\ - -Function: cpp_typecheckt::operator_is_overloaded - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - struct operator_entryt { const irep_idt id; @@ -675,7 +571,7 @@ bool cpp_typecheckt::operator_is_overloaded(exprt &expr) } for(const operator_entryt *e=operators; - e->id!=irep_idt(); + !e->id.empty(); e++) if(expr.id()==e->id) { @@ -802,18 +698,6 @@ bool cpp_typecheckt::operator_is_overloaded(exprt &expr) return false; } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_expr_address_of - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_expr_address_of(exprt &expr) { if(expr.operands().size()!=1) @@ -875,18 +759,6 @@ void cpp_typecheckt::typecheck_expr_address_of(exprt &expr) expr.type()=reference_typet(expr.type().subtype()); } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_expr_throw - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_expr_throw(exprt &expr) { // these are of type void @@ -913,18 +785,6 @@ void cpp_typecheckt::typecheck_expr_throw(exprt &expr) } } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_expr_new - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_expr_new(exprt &expr) { // next, find out if we do an array @@ -1002,18 +862,6 @@ void cpp_typecheckt::typecheck_expr_new(exprt &expr) sizeof_expr.add("#c_sizeof_type")=expr.type().subtype(); } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_expr_explicit_typecast - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - static exprt collect_comma_expression(const exprt &src) { exprt result; @@ -1116,18 +964,6 @@ void cpp_typecheckt::typecheck_expr_explicit_typecast(exprt &expr) } } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_expr_explicit_constructor_call - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_expr_explicit_constructor_call(exprt &expr) { typecheck_type(expr.type()); @@ -1150,18 +986,6 @@ void cpp_typecheckt::typecheck_expr_explicit_constructor_call(exprt &expr) } } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_expr_this - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_expr_this(exprt &expr) { if(cpp_scopes.current_scope().class_identifier.empty()) @@ -1181,18 +1005,6 @@ void cpp_typecheckt::typecheck_expr_this(exprt &expr) expr.add_source_location()=source_location; } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_expr_delete - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_expr_delete(exprt &expr) { if(expr.operands().size()!=1) @@ -1250,39 +1062,15 @@ void cpp_typecheckt::typecheck_expr_delete(exprt &expr) expr.set(ID_destructor, destructor_code); } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_expr_typecast - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_expr_typecast(exprt &expr) { // should not be called #if 0 - std::cout << "E: " << expr.pretty() << std::endl; + std::cout << "E: " << expr.pretty() << '\n'; assert(0); #endif } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_expr_member - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_expr_member( exprt &expr, const cpp_typecheck_fargst &fargs) @@ -1464,18 +1252,6 @@ void cpp_typecheckt::typecheck_expr_member( } } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_expr_ptrmember - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_expr_ptrmember( exprt &expr, const cpp_typecheck_fargst &fargs) @@ -1514,18 +1290,6 @@ void cpp_typecheckt::typecheck_expr_ptrmember( typecheck_expr_member(expr, fargs); } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_cast_expr - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_cast_expr(exprt &expr) { side_effect_expr_function_callt e = @@ -1635,18 +1399,6 @@ void cpp_typecheckt::typecheck_cast_expr(exprt &expr) expr.swap(new_expr); } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_expr_cpp_name - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_expr_cpp_name( exprt &expr, const cpp_typecheck_fargst &fargs) @@ -2147,18 +1899,6 @@ void cpp_typecheckt::typecheck_expr_cpp_name( add_implicit_dereference(expr); } -/*******************************************************************\ - -Function: cpp_typecheckt::add_implicit_dereference - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::add_implicit_dereference(exprt &expr) { if(is_reference(expr.type())) @@ -2173,18 +1913,6 @@ void cpp_typecheckt::add_implicit_dereference(exprt &expr) } } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_side_effect_function_call - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_side_effect_function_call( side_effect_expr_function_callt &expr) { @@ -2549,18 +2277,8 @@ void cpp_typecheckt::typecheck_side_effect_function_call( expr.swap(tmp); } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_function_call_arguments - - Inputs: type-checked arguments, type-checked function - - Outputs: type-adjusted function arguments - -Purpose: - -\*******************************************************************/ - +/// \param type:checked arguments, type-checked function +/// \return type-adjusted function arguments void cpp_typecheckt::typecheck_function_call_arguments( side_effect_expr_function_callt &expr) { @@ -2614,18 +2332,6 @@ void cpp_typecheckt::typecheck_function_call_arguments( c_typecheck_baset::typecheck_function_call_arguments(expr); } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_expr_side_effect - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_expr_side_effect( side_effect_exprt &expr) { @@ -2660,18 +2366,6 @@ void cpp_typecheckt::typecheck_expr_side_effect( c_typecheck_baset::typecheck_expr_side_effect(expr); } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_method_application - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_method_application( side_effect_expr_function_callt &expr) { @@ -2732,18 +2426,6 @@ void cpp_typecheckt::typecheck_method_application( } } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_side_effect_assignment - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_side_effect_assignment(side_effect_exprt &expr) { if(expr.operands().size()!=2) @@ -2831,18 +2513,6 @@ void cpp_typecheckt::typecheck_side_effect_assignment(side_effect_exprt &expr) expr=new_expr; } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_side_effect_inc_dec - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_side_effect_inc_dec( side_effect_exprt &expr) { @@ -2919,18 +2589,6 @@ void cpp_typecheckt::typecheck_side_effect_inc_dec( expr.swap(new_expr); } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_expr_dereference - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_expr_dereference(exprt &expr) { if(expr.operands().size()!=1) @@ -2955,18 +2613,6 @@ void cpp_typecheckt::typecheck_expr_dereference(exprt &expr) c_typecheck_baset::typecheck_expr_dereference(expr); } -/*******************************************************************\ - -Function: cpp_typecheckt::convert_pmop - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::convert_pmop(exprt &expr) { assert(expr.id()=="pointer-to-member"); @@ -3037,18 +2683,6 @@ void cpp_typecheckt::convert_pmop(exprt &expr) return; } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_expr_function_identifier - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_expr_function_identifier(exprt &expr) { if(expr.id()==ID_symbol) @@ -3068,18 +2702,6 @@ void cpp_typecheckt::typecheck_expr_function_identifier(exprt &expr) c_typecheck_baset::typecheck_expr_function_identifier(expr); } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_expr - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_expr(exprt &expr) { bool override_constantness= @@ -3102,18 +2724,6 @@ void cpp_typecheckt::typecheck_expr(exprt &expr) expr.type().set(ID_C_constant, false); } -/*******************************************************************\ - -Function: cpp_typecheckt::explict_typecast_ambiguity - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::explicit_typecast_ambiguity(exprt &expr) { // There is an ambiguity in the C++ grammar as follows: @@ -3169,18 +2779,6 @@ void cpp_typecheckt::explicit_typecast_ambiguity(exprt &expr) } } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_expr_binary_arithmetic - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_expr_binary_arithmetic(exprt &expr) { if(expr.operands().size()!=2) @@ -3197,35 +2795,11 @@ void cpp_typecheckt::typecheck_expr_binary_arithmetic(exprt &expr) c_typecheck_baset::typecheck_expr_binary_arithmetic(expr); } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_expr_index - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_expr_index(exprt &expr) { c_typecheck_baset::typecheck_expr_index(expr); } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_expr_comma - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_expr_comma(exprt &expr) { if(expr.operands().size()!=2) @@ -3243,18 +2817,6 @@ void cpp_typecheckt::typecheck_expr_comma(exprt &expr) c_typecheck_baset::typecheck_expr_comma(expr); } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_expr_rel - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_expr_rel(binary_relation_exprt &expr) { c_typecheck_baset::typecheck_expr_rel(expr); diff --git a/src/cpp/cpp_typecheck_fargs.cpp b/src/cpp/cpp_typecheck_fargs.cpp index 592c538fc2c..d3f6a4767e0 100644 --- a/src/cpp/cpp_typecheck_fargs.cpp +++ b/src/cpp/cpp_typecheck_fargs.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include #include @@ -15,18 +18,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "cpp_typecheck_fargs.h" #include "cpp_typecheck.h" -/*******************************************************************\ - -Function: cpp_typecheck_fargst::has_class_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool cpp_typecheck_fargst::has_class_type() const { for(exprt::operandst::const_iterator it=operands.begin(); @@ -40,18 +31,6 @@ bool cpp_typecheck_fargst::has_class_type() const return false; } -/*******************************************************************\ - -Function: cpp_typecheck_fargst::build - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheck_fargst::build( const side_effect_expr_function_callt &function_call) { @@ -64,18 +43,6 @@ void cpp_typecheck_fargst::build( operands.push_back(function_call.op1().operands()[i]); } -/*******************************************************************\ - -Function: cpp_typecheck_fargst::exact_match - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool cpp_typecheck_fargst::match( const code_typet &code_type, unsigned &distance, @@ -129,7 +96,7 @@ bool cpp_typecheck_fargst::match( #if 0 // unclear, todo if(is_reference(operand.type())) - std::cout << "O: " << operand.pretty() << std::endl; + std::cout << "O: " << operand.pretty() << '\n'; assert(!is_reference(operand.type())); #endif @@ -148,7 +115,7 @@ bool cpp_typecheck_fargst::match( #if 0 std::cout << "C: " << cpp_typecheck.to_string(operand.type()) << " -> " << cpp_typecheck.to_string(parameter.type()) - << std::endl; + << '\n'; #endif // can we do the standard conversion sequence? @@ -158,13 +125,13 @@ bool cpp_typecheck_fargst::match( // ok distance+=rank; #if 0 - std::cout << "OK " << rank << std::endl; + std::cout << "OK " << rank << '\n'; #endif } else { #if 0 - std::cout << "NOT OK" << std::endl; + std::cout << "NOT OK\n"; #endif return false; // no conversion possible } diff --git a/src/cpp/cpp_typecheck_fargs.h b/src/cpp/cpp_typecheck_fargs.h index 370cc10ed65..5b6a62e0b4a 100644 --- a/src/cpp/cpp_typecheck_fargs.h +++ b/src/cpp/cpp_typecheck_fargs.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #ifndef CPROVER_CPP_CPP_TYPECHECK_FARGS_H #define CPROVER_CPP_CPP_TYPECHECK_FARGS_H diff --git a/src/cpp/cpp_typecheck_function.cpp b/src/cpp/cpp_typecheck_function.cpp index a55bbf41d6b..5dd98b47336 100644 --- a/src/cpp/cpp_typecheck_function.cpp +++ b/src/cpp/cpp_typecheck_function.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include #include "cpp_template_type.h" @@ -13,18 +16,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "cpp_type2name.h" #include "cpp_util.h" -/*******************************************************************\ - -Function: cpp_typecheckt::convert_parameter - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::convert_parameter( const irep_idt &mode, code_typet::parametert ¶meter) @@ -69,18 +60,6 @@ void cpp_typecheckt::convert_parameter( cpp_scopes.put_into_scope(*new_symbol); } -/*******************************************************************\ - -Function: cpp_typecheckt::convert_parameters - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::convert_parameters( const irep_idt &mode, code_typet &function_type) @@ -95,18 +74,6 @@ void cpp_typecheckt::convert_parameters( convert_parameter(mode, *it); } -/*******************************************************************\ - -Function: cpp_typecheckt::convert_function - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::convert_function(symbolt &symbol) { code_typet &function_type= @@ -171,18 +138,7 @@ void cpp_typecheckt::convert_function(symbolt &symbol) return_type = old_return_type; } -/*******************************************************************\ - -Function: cpp_typecheckt::function_identifier - - Inputs: - - Outputs: - - Purpose: for function overloading - -\*******************************************************************/ - +/// for function overloading irep_idt cpp_typecheckt::function_identifier(const typet &type) { const code_typet &function_type= diff --git a/src/cpp/cpp_typecheck_initializer.cpp b/src/cpp/cpp_typecheck_initializer.cpp index f51490e77f8..c6352f25fcf 100644 --- a/src/cpp/cpp_typecheck_initializer.cpp +++ b/src/cpp/cpp_typecheck_initializer.cpp @@ -6,28 +6,20 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include #include #include -#include +#include #include #include "cpp_typecheck.h" #include "cpp_util.h" -/*******************************************************************\ - -Function: cpp_typecheckt::convert_initializer - - Inputs: - - Outputs: - - Purpose: Initialize an object with a value - -\*******************************************************************/ - +/// Initialize an object with a value void cpp_typecheckt::convert_initializer(symbolt &symbol) { // this is needed for template arguments that are types @@ -179,18 +171,6 @@ void cpp_typecheckt::convert_initializer(symbolt &symbol) } } -/*******************************************************************\ - -Function: cpp_typecheckt::zero_initializer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::zero_initializer( const exprt &object, const typet &type, diff --git a/src/cpp/cpp_typecheck_linkage_spec.cpp b/src/cpp/cpp_typecheck_linkage_spec.cpp index 39ebc12db29..a21a5913979 100644 --- a/src/cpp/cpp_typecheck_linkage_spec.cpp +++ b/src/cpp/cpp_typecheck_linkage_spec.cpp @@ -6,19 +6,10 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -#include "cpp_typecheck.h" - -/*******************************************************************\ - -Function: cpp_typecheckt::convert - - Inputs: +/// \file +/// C++ Language Type Checking - Outputs: - - Purpose: - -\*******************************************************************/ +#include "cpp_typecheck.h" void cpp_typecheckt::convert(cpp_linkage_spect &linkage_spec) { diff --git a/src/cpp/cpp_typecheck_method_bodies.cpp b/src/cpp/cpp_typecheck_method_bodies.cpp index 0b16bebd8d8..d37b686a215 100644 --- a/src/cpp/cpp_typecheck_method_bodies.cpp +++ b/src/cpp/cpp_typecheck_method_bodies.cpp @@ -7,19 +7,10 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -#include "cpp_typecheck.h" - -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_method_bodies - - Inputs: +/// \file +/// C++ Language Type Checking - Outputs: - - Purpose: - -\*******************************************************************/ +#include "cpp_typecheck.h" void cpp_typecheckt::typecheck_method_bodies( method_bodiest &bodies) diff --git a/src/cpp/cpp_typecheck_namespace.cpp b/src/cpp/cpp_typecheck_namespace.cpp index 81fea3a3eae..437a874aebd 100644 --- a/src/cpp/cpp_typecheck_namespace.cpp +++ b/src/cpp/cpp_typecheck_namespace.cpp @@ -6,22 +6,13 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include #include "cpp_typecheck.h" -/*******************************************************************\ - -Function: cpp_typecheckt::convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::convert(cpp_namespace_spect &namespace_spec) { // save the scope diff --git a/src/cpp/cpp_typecheck_resolve.cpp b/src/cpp/cpp_typecheck_resolve.cpp index 82250a8a748..dad56507227 100644 --- a/src/cpp/cpp_typecheck_resolve.cpp +++ b/src/cpp/cpp_typecheck_resolve.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include #include @@ -14,7 +17,7 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include #include -#include +#include #include #include @@ -25,35 +28,11 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "cpp_util.h" #include "cpp_convert_type.h" -/*******************************************************************\ - -Function: cpp_typecheck_resolvet::cpp_typecheck_resolvet - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - cpp_typecheck_resolvet::cpp_typecheck_resolvet(cpp_typecheckt &_cpp_typecheck): cpp_typecheck(_cpp_typecheck) { } -/*******************************************************************\ - -Function: cpp_typecheck_resolvet::convert_identifiers - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheck_resolvet::convert_identifiers( const cpp_scopest::id_sett &id_set, const wantt want, @@ -78,18 +57,6 @@ void cpp_typecheck_resolvet::convert_identifiers( } } -/*******************************************************************\ - -Function: cpp_typecheck_resolvet::apply_template_args - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheck_resolvet::apply_template_args( resolve_identifierst &identifiers, const cpp_template_args_non_tct &template_args, @@ -116,18 +83,7 @@ void cpp_typecheck_resolvet::apply_template_args( } } -/*******************************************************************\ - -Function: cpp_typecheck_resolvet::guess_function_template_args - -Inputs: - -Outputs: - -Purpose: guess arguments of function templates - -\*******************************************************************/ - +/// guess arguments of function templates void cpp_typecheck_resolvet::guess_function_template_args( resolve_identifierst &identifiers, const cpp_typecheck_fargst &fargs) @@ -179,18 +135,6 @@ void cpp_typecheck_resolvet::guess_function_template_args( } } -/*******************************************************************\ - -Function: cpp_typecheck_resolvet::remove_templates - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheck_resolvet::remove_templates( resolve_identifierst &identifiers) { @@ -207,18 +151,6 @@ void cpp_typecheck_resolvet::remove_templates( } } -/*******************************************************************\ - -Function: cpp_typecheck_resolvet::remove_duplicates - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheck_resolvet::remove_duplicates( resolve_identifierst &identifiers) { @@ -253,18 +185,6 @@ void cpp_typecheck_resolvet::remove_duplicates( } } -/*******************************************************************\ - -Function: cpp_typecheck_resolvet::convert_template_parameter - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - exprt cpp_typecheck_resolvet::convert_template_parameter( const cpp_idt &identifier) { @@ -286,18 +206,6 @@ exprt cpp_typecheck_resolvet::convert_template_parameter( return e; } -/*******************************************************************\ - -Function: cpp_typecheck_resolvet::convert_identifier - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - exprt cpp_typecheck_resolvet::convert_identifier( const cpp_idt &identifier, const wantt want, @@ -348,7 +256,7 @@ exprt cpp_typecheck_resolvet::convert_identifier( std::cout << "I: " << identifier.class_identifier << " " << cpp_typecheck.cpp_scopes.current_scope(). - this_class_identifier << std::endl; + this_class_identifier << '\n'; #endif const exprt &this_expr= @@ -466,18 +374,6 @@ exprt cpp_typecheck_resolvet::convert_identifier( return e; } -/*******************************************************************\ - -Function: cpp_typecheck_resolvet::filter - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheck_resolvet::filter( resolve_identifierst &identifiers, const wantt want) @@ -515,18 +411,6 @@ void cpp_typecheck_resolvet::filter( } } -/*******************************************************************\ - -Function: cpp_typecheck_resolvet::exact_match_functions - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheck_resolvet::exact_match_functions( resolve_identifierst &identifiers, const cpp_typecheck_fargst &fargs) @@ -552,18 +436,6 @@ void cpp_typecheck_resolvet::exact_match_functions( } } -/*******************************************************************\ - -Function: cpp_typecheck_resolvet::disambiguate_functions - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheck_resolvet::disambiguate_functions( resolve_identifierst &identifiers, const cpp_typecheck_fargst &fargs) @@ -709,18 +581,6 @@ void cpp_typecheck_resolvet::disambiguate_functions( } } -/*******************************************************************\ - -Function: cpp_typecheck_resolvet::make_constructors - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheck_resolvet::make_constructors( resolve_identifierst &identifiers) { @@ -812,18 +672,6 @@ void cpp_typecheck_resolvet::make_constructors( identifiers.swap(new_identifiers); } -/*******************************************************************\ - -Function: cpp_typecheck_resolvet::do_builtin - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - exprt cpp_typecheck_resolvet::do_builtin( const irep_idt &base_name, const cpp_template_args_non_tct &template_args) @@ -1010,20 +858,9 @@ exprt cpp_typecheck_resolvet::do_builtin( return dest; } -/*******************************************************************\ - -Function: cpp_typecheck_resolvet::resolve_scope - -Inputs: a cpp_name - -Outputs: a base_name, and potentially template arguments for - the base name; as side-effect, we got to the right - scope - -Purpose: - -\*******************************************************************/ - +/// \par parameters: a cpp_name +/// \return a base_name, and potentially template arguments for the base name; +/// as side-effect, we got to the right scope cpp_scopet &cpp_typecheck_resolvet::resolve_scope( const cpp_namet &cpp_name, irep_idt &base_name, @@ -1070,9 +907,9 @@ cpp_scopet &cpp_typecheck_resolvet::resolve_scope( // std::cout << "S: " // << cpp_typecheck.cpp_scopes.current_scope().identifier - // << std::endl; + // << '\n'; // cpp_typecheck.cpp_scopes.current_scope().print(std::cout); - // std::cout << "X: " << id_set.size() <cost - << " " << m_it->id << std::endl; + << " " << m_it->id << '\n'; } - std::cout << std::endl; + std::cout << '\n'; #endif const matcht &match=*matches.begin(); @@ -1403,18 +1229,6 @@ symbol_typet cpp_typecheck_resolvet::disambiguate_template_classes( #endif } -/*******************************************************************\ - -Function: cpp_typecheck_resolvet::resolve_namespace - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - cpp_scopet &cpp_typecheck_resolvet::resolve_namespace( const cpp_namet &cpp_name) { @@ -1460,18 +1274,6 @@ cpp_scopet &cpp_typecheck_resolvet::resolve_namespace( } } -/*******************************************************************\ - -Function: cpp_typecheck_resolvet::show_identifiers - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheck_resolvet::show_identifiers( const irep_idt &base_name, const resolve_identifierst &identifiers, @@ -1564,22 +1366,10 @@ void cpp_typecheck_resolvet::show_identifiers( } } - out << std::endl; + out << '\n'; } } -/*******************************************************************\ - -Function: cpp_typecheck_resolvet::resolve - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - exprt cpp_typecheck_resolvet::resolve( const cpp_namet &cpp_name, const wantt want, @@ -1823,16 +1613,16 @@ exprt cpp_typecheck_resolvet::resolve( #if 0 exprt e1=*new_identifiers.begin(); exprt e2=*(++new_identifiers.begin()); - cpp_typecheck.str << "e1==e2: " << (e1==e2) << std::endl; + cpp_typecheck.str << "e1==e2: " << (e1==e2) << '\n'; cpp_typecheck.str << "e1.type==e2.type: " << (e1.type()==e2.type()) - << std::endl; + << '\n'; cpp_typecheck.str << "e1.id()==e2.id(): " << (e1.id()==e2.id()) - << std::endl; + << '\n'; cpp_typecheck.str << "e1.iden==e2.iden: " << (e1.get(ID_identifier)==e2.get(ID_identifier)) - << std::endl; - cpp_typecheck.str << "e1.iden:: " << e1.get(ID_identifier) << std::endl; - cpp_typecheck.str << "e2.iden:: " << e2.get(ID_identifier) << std::endl; + << '\n'; + cpp_typecheck.str << "e1.iden:: " << e1.get(ID_identifier) << '\n'; + cpp_typecheck.str << "e2.iden:: " << e2.get(ID_identifier) << '\n'; #endif } @@ -1918,18 +1708,6 @@ exprt cpp_typecheck_resolvet::resolve( return result; } -/*******************************************************************\ - -Function: cpp_typecheck_resolvet::guess_template_args - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheck_resolvet::guess_template_args( const exprt &template_expr, const exprt &desired_expr) @@ -1975,18 +1753,6 @@ void cpp_typecheck_resolvet::guess_template_args( } } -/*******************************************************************\ - -Function: cpp_typecheck_resolvet::guess_template_args - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheck_resolvet::guess_template_args( const typet &template_type, const typet &desired_type) @@ -2022,8 +1788,8 @@ void cpp_typecheck_resolvet::guess_template_args( // TT #if 0 - std::cout << "TT: " << template_type.pretty() << std::endl; - std::cout << "DT: " << desired_type.pretty() << std::endl; + std::cout << "TT: " << template_type.pretty() << '\n'; + std::cout << "DT: " << desired_type.pretty() << '\n'; #endif if(template_type.id()==ID_cpp_name) @@ -2075,7 +1841,7 @@ void cpp_typecheck_resolvet::guess_template_args( t.remove(ID_C_volatile); #if 0 std::cout << "ASSIGN " << id.identifier << " := " - << cpp_typecheck.to_string(desired_type) << std::endl; + << cpp_typecheck.to_string(desired_type) << '\n'; #endif } } @@ -2128,18 +1894,7 @@ void cpp_typecheck_resolvet::guess_template_args( } } -/*******************************************************************\ - -Function: cpp_typecheck_resolvet::guess_function_template_args - -Inputs: - -Outputs: - -Purpose: Guess template arguments for function templates - -\*******************************************************************/ - +/// Guess template arguments for function templates exprt cpp_typecheck_resolvet::guess_function_template_args( const exprt &expr, const cpp_typecheck_fargst &fargs) @@ -2279,18 +2034,6 @@ exprt cpp_typecheck_resolvet::guess_function_template_args( return template_function_instance; } -/*******************************************************************\ - -Function: cpp_typecheck_resolvet::apply_template_args - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheck_resolvet::apply_template_args( exprt &expr, const cpp_template_args_non_tct &template_args_non_tc, @@ -2395,18 +2138,6 @@ void cpp_typecheck_resolvet::apply_template_args( } } -/*******************************************************************\ - -Function: cpp_typecheck_resolvet::disambiguate_functions - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - bool cpp_typecheck_resolvet::disambiguate_functions( const exprt &expr, unsigned &args_distance, @@ -2469,18 +2200,6 @@ bool cpp_typecheck_resolvet::disambiguate_functions( return fargs.match(type, args_distance, cpp_typecheck); } -/*******************************************************************\ - -Function: cpp_typecheck_resolvet::filter_for_named_scopes - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheck_resolvet::filter_for_named_scopes( cpp_scopest::id_sett &id_set) { @@ -2571,12 +2290,12 @@ void cpp_typecheck_resolvet::filter_for_named_scopes( #if 0 cpp_typecheck.template_map.print(std::cout); std::cout << "S: " << cpp_typecheck.cpp_scopes.current_scope().identifier - << std::endl; + << '\n'; std::cout << "P: " << cpp_typecheck.cpp_scopes.current_scope().get_parent() - << std::endl; - std::cout << "I: " << id.identifier << std::endl; - std::cout << "E: " << e.pretty() << std::endl; + << '\n'; + std::cout << "I: " << id.identifier << '\n'; + std::cout << "E: " << e.pretty() << '\n'; #endif if(e.id()!=ID_type) @@ -2619,18 +2338,6 @@ void cpp_typecheck_resolvet::filter_for_named_scopes( id_set.swap(new_set); } -/*******************************************************************\ - -Function: cpp_typecheck_resolvet::filter_for_namespaces - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheck_resolvet::filter_for_namespaces( cpp_scopest::id_sett &id_set) { @@ -2651,18 +2358,6 @@ void cpp_typecheck_resolvet::filter_for_namespaces( } } -/*******************************************************************\ - -Function: cpp_typecheck_resolvet::resolve_with_arguments - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void cpp_typecheck_resolvet::resolve_with_arguments( cpp_scopest::id_sett &id_set, const irep_idt &base_name, diff --git a/src/cpp/cpp_typecheck_resolve.h b/src/cpp/cpp_typecheck_resolve.h index 6d9031b62e0..1b6e1af615a 100644 --- a/src/cpp/cpp_typecheck_resolve.h +++ b/src/cpp/cpp_typecheck_resolve.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #ifndef CPROVER_CPP_CPP_TYPECHECK_RESOLVE_H #define CPROVER_CPP_CPP_TYPECHECK_RESOLVE_H diff --git a/src/cpp/cpp_typecheck_static_assert.cpp b/src/cpp/cpp_typecheck_static_assert.cpp index 3e449a9f043..e72dc318095 100644 --- a/src/cpp/cpp_typecheck_static_assert.cpp +++ b/src/cpp/cpp_typecheck_static_assert.cpp @@ -6,22 +6,13 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include #include "cpp_typecheck.h" -/*******************************************************************\ - -Function: cpp_typecheckt::convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::convert(cpp_static_assertt &cpp_static_assert) { typecheck_expr(cpp_static_assert.op0()); diff --git a/src/cpp/cpp_typecheck_template.cpp b/src/cpp/cpp_typecheck_template.cpp index 29acce8c65c..5fae1b654a0 100644 --- a/src/cpp/cpp_typecheck_template.cpp +++ b/src/cpp/cpp_typecheck_template.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include #include "cpp_type2name.h" @@ -15,18 +18,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "cpp_convert_type.h" #include "cpp_template_args.h" -/*******************************************************************\ - -Function: cpp_typecheckt::salvage_default_arguments - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::salvage_default_arguments( const template_typet &old_type, template_typet &new_type) @@ -48,18 +39,6 @@ void cpp_typecheckt::salvage_default_arguments( } } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_class_template - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_class_template( cpp_declarationt &declaration) { @@ -163,7 +142,7 @@ void cpp_typecheckt::typecheck_class_template( std::cout << "*****\n"; std::cout << *cpp_scopes.id_map[symbol_name]; std::cout << "*****\n"; - std::cout << "II: " << symbol_name << std::endl; + std::cout << "II: " << symbol_name << '\n'; #endif // We also replace the template scope (the old one could be deleted). @@ -223,18 +202,7 @@ void cpp_typecheckt::typecheck_class_template( cpp_idt::id_classt::TEMPLATE_SCOPE); } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_function_template - - Inputs: - - Outputs: - - Purpose: typecheck function templates - -\*******************************************************************/ - +/// typecheck function templates void cpp_typecheckt::typecheck_function_template( cpp_declarationt &declaration) { @@ -337,19 +305,7 @@ void cpp_typecheckt::typecheck_function_template( cpp_scopes.id_map[symbol_name] = &template_scope; } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_class_template_member - - Inputs: - - Outputs: - - Purpose: typecheck class tempalte members; - these can be methods or static members - -\*******************************************************************/ - +/// typecheck class tempalte members; these can be methods or static members void cpp_typecheckt::typecheck_class_template_member( cpp_declarationt &declaration) { @@ -413,7 +369,7 @@ void cpp_typecheckt::typecheck_class_template_member( } else if((*(id_set.begin()))->id_class!=cpp_idt::id_classt::TEMPLATE) { - // std::cerr << *(*id_set.begin()) << std::endl; + // std::cerr << *(*id_set.begin()) << '\n'; error().source_location=cpp_name.source_location(); error() << "class template `" << cpp_name.get_sub().front().get(ID_identifier) @@ -462,18 +418,6 @@ void cpp_typecheckt::typecheck_class_template_member( } } -/*******************************************************************\ - -Function: cpp_typecheckt::class_template_identifier - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string cpp_typecheckt::class_template_identifier( const irep_idt &base_name, const template_typet &template_type, @@ -533,18 +477,6 @@ std::string cpp_typecheckt::class_template_identifier( return identifier; } -/*******************************************************************\ - -Function: cpp_typecheckt::function_template_identifier - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string cpp_typecheckt::function_template_identifier( const irep_idt &base_name, const template_typet &template_type, @@ -562,18 +494,6 @@ std::string cpp_typecheckt::function_template_identifier( return identifier; } -/*******************************************************************\ - -Function: cpp_typecheckt::convert_class_template_specialization - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::convert_class_template_specialization( cpp_declarationt &declaration) { @@ -695,18 +615,6 @@ void cpp_typecheckt::convert_class_template_specialization( } } -/*******************************************************************\ - -Function: cpp_typecheckt::convert_template_function_or_member_specialization - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::convert_template_function_or_member_specialization( cpp_declarationt &declaration) { @@ -808,18 +716,6 @@ void cpp_typecheckt::convert_template_function_or_member_specialization( } } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_template_parameters - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - cpp_scopet &cpp_typecheckt::typecheck_template_parameters( template_typet &type) { @@ -951,18 +847,8 @@ cpp_scopet &cpp_typecheckt::typecheck_template_parameters( return template_scope; } -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_template_args - - Inputs: location, non-typechecked template arguments - - Outputs: typechecked template arguments - - Purpose: - -\*******************************************************************/ - +/// \par parameters: location, non-typechecked template arguments +/// \return typechecked template arguments cpp_template_args_tct cpp_typecheckt::typecheck_template_args( const source_locationt &source_location, const symbolt &template_symbol, @@ -1100,18 +986,6 @@ cpp_template_args_tct cpp_typecheckt::typecheck_template_args( return result; } -/*******************************************************************\ - -Function: cpp_typecheckt::convert_template_declaration - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::convert_template_declaration( cpp_declarationt &declaration) { diff --git a/src/cpp/cpp_typecheck_type.cpp b/src/cpp/cpp_typecheck_type.cpp index 3672acfc0d2..376efd6f9e1 100644 --- a/src/cpp/cpp_typecheck_type.cpp +++ b/src/cpp/cpp_typecheck_type.cpp @@ -6,7 +6,11 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include +#include #include @@ -14,21 +18,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "cpp_convert_type.h" #include "expr2cpp.h" -/*******************************************************************\ - -Function: cpp_typecheckt::typecheck_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::typecheck_type(typet &type) { - assert(type.id()!=irep_idt()); + assert(!type.id().empty()); assert(type.is_not_nil()); try @@ -126,7 +118,10 @@ void cpp_typecheckt::typecheck_type(typet &type) exprt &size_expr=to_array_type(type).size(); if(size_expr.is_not_nil()) + { typecheck_expr(size_expr); + simplify(size_expr, *this); + } typecheck_type(type.subtype()); diff --git a/src/cpp/cpp_typecheck_using.cpp b/src/cpp/cpp_typecheck_using.cpp index 9ad812ca8ec..8a67e6a4092 100644 --- a/src/cpp/cpp_typecheck_using.cpp +++ b/src/cpp/cpp_typecheck_using.cpp @@ -6,22 +6,13 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include #include "cpp_typecheck.h" -/*******************************************************************\ - -Function: cpp_typecheckt::convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cpp_typecheckt::convert(cpp_usingt &cpp_using) { // there are two forms of using clauses: diff --git a/src/cpp/cpp_typecheck_virtual_table.cpp b/src/cpp/cpp_typecheck_virtual_table.cpp index ec52b1270ae..4e766297206 100644 --- a/src/cpp/cpp_typecheck_virtual_table.cpp +++ b/src/cpp/cpp_typecheck_virtual_table.cpp @@ -6,19 +6,14 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include #include #include "cpp_typecheck.h" -/*******************************************************************\ - -Function: cpp_typecheckt::do_virtual_table - -Author: Daniel Kroening, kroening@kroening.com - -\*******************************************************************/ - void cpp_typecheckt::do_virtual_table(const symbolt &symbol) { assert(symbol.type.id()==ID_struct); diff --git a/src/cpp/cpp_using.h b/src/cpp/cpp_using.h index fadc71accc4..580edec7c81 100644 --- a/src/cpp/cpp_using.h +++ b/src/cpp/cpp_using.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #ifndef CPROVER_CPP_CPP_USING_H #define CPROVER_CPP_CPP_USING_H diff --git a/src/cpp/cpp_util.cpp b/src/cpp/cpp_util.cpp index 1a3c8dfd773..e41ba6871fc 100644 --- a/src/cpp/cpp_util.cpp +++ b/src/cpp/cpp_util.cpp @@ -6,23 +6,12 @@ \*******************************************************************/ + #include #include #include "cpp_util.h" -/*******************************************************************\ - -Function: cpp_symbol_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt cpp_symbol_expr(const symbolt &symbol) { exprt tmp(ID_symbol, symbol.type); diff --git a/src/cpp/cpp_util.h b/src/cpp/cpp_util.h index 17351354c1d..aeb48be73a2 100644 --- a/src/cpp/cpp_util.h +++ b/src/cpp/cpp_util.h @@ -6,38 +6,15 @@ \*******************************************************************/ + #ifndef CPROVER_CPP_CPP_UTIL_H #define CPROVER_CPP_CPP_UTIL_H #include #include -/*******************************************************************\ - -Function: cpp_symbol_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt cpp_symbol_expr(const symbolt &symbol); -/*******************************************************************\ - -Function: already_typechecked - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - inline void already_typechecked(irept &irep) { exprt tmp("already_typechecked"); diff --git a/src/cpp/expr2cpp.cpp b/src/cpp/expr2cpp.cpp index 715809ca3c1..1ed9ff738c4 100644 --- a/src/cpp/expr2cpp.cpp +++ b/src/cpp/expr2cpp.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ + #include #include @@ -47,18 +48,6 @@ class expr2cppt:public expr2ct typedef std::unordered_set id_sett; }; -/*******************************************************************\ - -Function: expr2cppt::convert_struct - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2cppt::convert_struct( const exprt &src, unsigned &precedence) @@ -123,18 +112,6 @@ std::string expr2cppt::convert_struct( return dest; } -/*******************************************************************\ - -Function: expr2cppt::convert_constant - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2cppt::convert_constant( const constant_exprt &src, unsigned &precedence) @@ -151,18 +128,6 @@ std::string expr2cppt::convert_constant( return expr2ct::convert_constant(src, precedence); } -/*******************************************************************\ - -Function: expr2cppt::convert_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2cppt::convert_rec( const typet &src, const c_qualifierst &qualifiers, @@ -185,7 +150,7 @@ std::string expr2cppt::convert_rec( { return q+convert(src.subtype())+" &&"+d; } - else if(src.get(ID_C_c_type)!=irep_idt()) + else if(!src.get(ID_C_c_type).empty()) { const irep_idt c_type=src.get(ID_C_c_type); @@ -243,7 +208,7 @@ std::string expr2cppt::convert_rec( else dest+="struct"; - if(symbol.pretty_name!=irep_idt()) + if(!symbol.pretty_name.empty()) dest+=" "+id2string(symbol.pretty_name); dest+=d; @@ -256,7 +221,7 @@ std::string expr2cppt::convert_rec( dest+="enum"; - if(symbol.pretty_name!=irep_idt()) + if(!symbol.pretty_name.empty()) dest+=" "+id2string(symbol.pretty_name); dest+=d; @@ -421,18 +386,6 @@ std::string expr2cppt::convert_rec( return expr2ct::convert_rec(src, qualifiers, declarator); } -/*******************************************************************\ - -Function: expr2cppt::convert_cpp_this - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2cppt::convert_cpp_this( const exprt &src, unsigned precedence) @@ -440,18 +393,6 @@ std::string expr2cppt::convert_cpp_this( return "this"; } -/*******************************************************************\ - -Function: expr2cppt::convert_cpp_new - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2cppt::convert_cpp_new( const exprt &src, unsigned precedence) @@ -477,18 +418,6 @@ std::string expr2cppt::convert_cpp_new( return dest; } -/*******************************************************************\ - -Function: expr2cppt::convert_code_cpp_delete - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2cppt::convert_code_cpp_delete( const exprt &src, unsigned indent) @@ -508,18 +437,6 @@ std::string expr2cppt::convert_code_cpp_delete( return dest; } -/*******************************************************************\ - -Function: expr2cppt::convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2cppt::convert_with_precedence( const exprt &src, unsigned &precedence) @@ -551,18 +468,6 @@ std::string expr2cppt::convert_with_precedence( return expr2ct::convert_with_precedence(src, precedence); } -/*******************************************************************\ - -Function: expr2cppt::convert_code - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2cppt::convert_code( const codet &src, unsigned indent) @@ -580,18 +485,6 @@ std::string expr2cppt::convert_code( return expr2ct::convert_code(src, indent); } -/*******************************************************************\ - -Function: expr2cppt::convert_extractbit - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2cppt::convert_extractbit( const exprt &src, unsigned precedence) @@ -600,18 +493,6 @@ std::string expr2cppt::convert_extractbit( return convert(src.op0())+"["+convert(src.op1())+"]"; } -/*******************************************************************\ - -Function: expr2cppt::convert_extractbits - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2cppt::convert_extractbits( const exprt &src, unsigned precedence) @@ -622,18 +503,6 @@ std::string expr2cppt::convert_extractbits( convert(src.op2())+")"; } -/*******************************************************************\ - -Function: expr2cpp - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2cpp(const exprt &expr, const namespacet &ns) { expr2cppt expr2cpp(ns); @@ -641,18 +510,6 @@ std::string expr2cpp(const exprt &expr, const namespacet &ns) return expr2cpp.convert(expr); } -/*******************************************************************\ - -Function: type2cpp - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string type2cpp(const typet &type, const namespacet &ns) { expr2cppt expr2cpp(ns); diff --git a/src/cpp/expr2cpp.h b/src/cpp/expr2cpp.h index 6b39188f977..e37548708aa 100644 --- a/src/cpp/expr2cpp.h +++ b/src/cpp/expr2cpp.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ + #ifndef CPROVER_CPP_EXPR2CPP_H #define CPROVER_CPP_EXPR2CPP_H diff --git a/src/cpp/parse.cpp b/src/cpp/parse.cpp index 536c54f5169..190e9e1e8ce 100644 --- a/src/cpp/parse.cpp +++ b/src/cpp/parse.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Parsing + #include #include @@ -37,7 +40,7 @@ struct indenter // NOLINT(readability/identifiers) cpp_tokent _tk; \ lex.LookAhead(0, _tk); \ std::cout << std::string(__indent, ' ') << "Text [" << _tk.line_no << "]: " \ - << _tk.text << std::endl; \ + << _tk.text << '\n'; \ } #endif @@ -177,18 +180,6 @@ class save_scopet new_scopet *old_scope; }; -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void new_scopet::print_rec(std::ostream &out, unsigned indent) const { for(id_mapt::const_iterator @@ -407,7 +398,7 @@ class Parser // NOLINT(readability/identifiers) { typet *p=&dest; - while(p->id()!=irep_idt() && p->is_not_nil()) + while(!p->id().empty() && p->is_not_nil()) { if(p->id()==ID_merged_type) { @@ -424,18 +415,6 @@ class Parser // NOLINT(readability/identifiers) unsigned int max_errors; }; -/*******************************************************************\ - -Function: Parser::add_id - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - new_scopet &Parser::add_id(const irept &cpp_name, new_scopet::kindt kind) { irep_idt id; @@ -449,18 +428,6 @@ new_scopet &Parser::add_id(const irept &cpp_name, new_scopet::kindt kind) return add_id(id, kind); } -/*******************************************************************\ - -Function: Parser::add_id - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - new_scopet &Parser::add_id(const irep_idt &id, new_scopet::kindt kind) { new_scopet &s=current_scope->id_map[id]; @@ -472,54 +439,18 @@ new_scopet &Parser::add_id(const irep_idt &id, new_scopet::kindt kind) return s; } -/*******************************************************************\ - -Function: Parser::make_sub_scope - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void Parser::make_sub_scope(const irept &cpp_name, new_scopet::kindt kind) { new_scopet &s=add_id(cpp_name, kind); current_scope=&s; } -/*******************************************************************\ - -Function: Parser::make_sub_scope - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void Parser::make_sub_scope(const irep_idt &id, new_scopet::kindt kind) { new_scopet &s=add_id(id, kind); current_scope=&s; } -/*******************************************************************\ - -Function: Parser::rString - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool Parser::rString(cpp_tokent &tk) { if(lex.get_token(tk)!=TOK_STRING) @@ -528,18 +459,6 @@ bool Parser::rString(cpp_tokent &tk) return true; } -/*******************************************************************\ - -Function: Parser::merge_types - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void Parser::merge_types(const typet &src, typet &dest) { if(src.is_nil()) @@ -560,18 +479,6 @@ void Parser::merge_types(const typet &src, typet &dest) } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool Parser::SyntaxError() { #define ERROR_TOKENS 4 @@ -606,18 +513,6 @@ bool Parser::SyntaxError() return ++number_of_errors < max_errors; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool Parser::rProgram(cpp_itemt &item) { while(lex.LookAhead(0)!='\0') @@ -637,18 +532,6 @@ bool Parser::rProgram(cpp_itemt &item) return false; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* definition : null.declaration @@ -696,18 +579,6 @@ bool Parser::rDefinition(cpp_itemt &item) return rDeclaration(item.make_declaration()); } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool Parser::rNullDeclaration(cpp_declarationt &decl) { cpp_tokent tk; @@ -720,18 +591,6 @@ bool Parser::rNullDeclaration(cpp_declarationt &decl) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* typedef : TYPEDEF type.specifier declarators ';' @@ -761,18 +620,6 @@ bool Parser::rTypedef(cpp_declarationt &declaration) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* USING Identifier '=' type.specifier ';' */ @@ -825,18 +672,6 @@ bool Parser::rTypedefUsing(cpp_declarationt &declaration) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool Parser::rTypedefStatement(codet &statement) { statement=codet(ID_decl); @@ -844,18 +679,6 @@ bool Parser::rTypedefStatement(codet &statement) return rTypedef((cpp_declarationt &)statement.op0()); } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* type.specifier : {cv.qualify} (integral.or.class.spec | name) {cv.qualify} @@ -918,18 +741,6 @@ bool Parser::rTypeSpecifier(typet &tspec, bool check) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - // isTypeSpecifier() returns true if the next is probably a type specifier. bool Parser::isTypeSpecifier() @@ -959,18 +770,6 @@ bool Parser::isTypeSpecifier() return false; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* linkage.spec : EXTERN String definition @@ -1009,18 +808,6 @@ bool Parser::rLinkageSpec(cpp_linkage_spect &linkage_spec) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* namespace.spec : { INLINE } NAMESPACE Identifier definition @@ -1074,18 +861,6 @@ bool Parser::rNamespaceSpec(cpp_namespace_spect &namespace_spec) } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* using.declaration : USING { NAMESPACE } name ';' */ @@ -1114,18 +889,6 @@ bool Parser::rUsing(cpp_usingt &cpp_using) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* static_assert.declaration : STATIC_ASSERT ( expression , expression ) ';' */ @@ -1160,18 +923,6 @@ bool Parser::rStaticAssert(cpp_static_assertt &cpp_static_assert) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* linkage.body : '{' (definition)* '}' @@ -1207,18 +958,6 @@ bool Parser::rLinkageBody(cpp_linkage_spect::itemst &items) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* template.decl : TEMPLATE '<' temp.arg.list '>' declaration @@ -1292,18 +1031,6 @@ bool Parser::rTemplateDecl(cpp_declarationt &decl) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool Parser::rTemplateDecl2(typet &decl, TemplateDeclKind &kind) { cpp_tokent tk; @@ -1358,18 +1085,6 @@ bool Parser::rTemplateDecl2(typet &decl, TemplateDeclKind &kind) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* temp.arg.list : empty @@ -1402,18 +1117,6 @@ bool Parser::rTempArgList(irept &args) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* temp.arg.declaration : CLASS [Identifier] {'=' type.name} @@ -1605,18 +1308,6 @@ bool Parser::rTempArgDeclaration(cpp_declarationt &declaration) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* extern.template.decl : EXTERN TEMPLATE declaration @@ -1640,18 +1331,6 @@ bool Parser::rExternTemplateDecl(irept &decl) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* declaration : integral.declaration @@ -1687,7 +1366,7 @@ bool Parser::rDeclaration(cpp_declarationt &declaration) #ifdef DEBUG indenter _i; std::cout << std::string(__indent, ' ') << "Parser::rDeclaration 0.1 token: " - << lex.LookAhead(0) << std::endl; + << lex.LookAhead(0) << '\n'; #endif if(!optAttribute(declaration)) @@ -1768,18 +1447,6 @@ bool Parser::rDeclaration(cpp_declarationt &declaration) } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* single declaration, for use in a condition (controlling expression of switch/while/if) */ bool Parser::rSimpleDeclaration(cpp_declarationt &declaration) @@ -1840,18 +1507,6 @@ bool Parser::rSimpleDeclaration(cpp_declarationt &declaration) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool Parser::rIntegralDeclaration( cpp_declarationt &declaration, cpp_storage_spect &storage_spec, @@ -1965,18 +1620,6 @@ bool Parser::rIntegralDeclaration( } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool Parser::rConstDeclaration( cpp_declarationt &declaration, cpp_storage_spect &storage_spec, @@ -2002,18 +1645,6 @@ bool Parser::rConstDeclaration( return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool Parser::rOtherDeclaration( cpp_declarationt &declaration, cpp_storage_spect &storage_spec, @@ -2191,18 +1822,6 @@ bool Parser::rOtherDeclaration( return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* This returns true for an declaration like: T (a); @@ -2242,18 +1861,6 @@ bool Parser::isConstructorDecl() } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* ptr.to.member : {'::'} (identifier {'<' any* '>'} '::')+ '*' @@ -2311,18 +1918,6 @@ bool Parser::isPtrToMember(int i) return false; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* member.spec : (FRIEND | INLINE | VIRTUAL | EXPLICIT)+ @@ -2353,18 +1948,6 @@ bool Parser::optMemberSpec(cpp_member_spect &member_spec) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* storage.spec : STATIC | EXTERN | AUTO | REGISTER | MUTABLE | ASM | THREAD_LOCAL @@ -2402,18 +1985,6 @@ bool Parser::optStorageSpec(cpp_storage_spect &storage_spec) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* cv.qualify : (CONSTEXPR | CONST | VOLATILE | RESTRICT)+ */ @@ -2486,18 +2057,6 @@ bool Parser::optCvQualify(typet &cv) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* dcl.align : ALIGNAS unary.expr @@ -2541,18 +2100,6 @@ bool Parser::optAlignas(typet &cv) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool Parser::rAttribute() { cpp_tokent tk; @@ -2577,18 +2124,6 @@ bool Parser::rAttribute() return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool Parser::optAttribute(cpp_declarationt &declaration) { if(lex.LookAhead(0)!='[' || @@ -2621,18 +2156,6 @@ bool Parser::optAttribute(cpp_declarationt &declaration) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* integral.or.class.spec @@ -2701,7 +2224,7 @@ bool Parser::optIntegralTypeOrClassSpec(typet &p) default: type_id=irep_idt(); } - if(type_id!=irep_idt()) + if(!type_id.empty()) { cpp_tokent tk; typet kw; @@ -2860,18 +2383,6 @@ bool Parser::optIntegralTypeOrClassSpec(typet &p) } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* constructor.decl : '(' {arg.decl.list} ')' {cv.qualify} {throw.decl} @@ -2990,18 +2501,6 @@ bool Parser::rConstructorDecl( return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* throw.decl : THROW '(' (name {','})* {name} ')' | THROW '(' '...' ')' @@ -3070,18 +2569,6 @@ bool Parser::optThrowDecl(irept &throw_decl) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* declarators : declarator.with.init (',' declarator.with.init)* @@ -3109,18 +2596,6 @@ bool Parser::rDeclarators( } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* declarator.with.init : ':' expression @@ -3235,18 +2710,6 @@ bool Parser::rDeclaratorWithInit( } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* __stdcall, __fastcall, __clrcall, __cdecl These are Visual-Studio specific. @@ -3269,18 +2732,6 @@ bool Parser::rDeclaratorQualifier() return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* declarator : (ptr.operator)* (name | '(' declarator ')') @@ -3538,18 +2989,6 @@ bool Parser::rDeclarator( return true; } -/*******************************************************************\ - -Function: Parser::optPtrOperator - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* ptr.operator : (('*' | ptr.to.member)['&'] {cv.qualify})+ @@ -3675,18 +3114,6 @@ bool Parser::optPtrOperator(typet &ptrs) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* member.initializers : ':' member.init (',' member.init)* @@ -3719,18 +3146,6 @@ bool Parser::rMemberInitializers(irept &init) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* member.init : name '(' function.arguments ')' @@ -3807,18 +3222,6 @@ bool Parser::rMemberInit(exprt &init) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* name : {'::'} name2 ('::' name2)* @@ -3962,18 +3365,6 @@ bool Parser::rName(irept &name) } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* operator.name : '+' | '-' | '*' | '/' | '%' | '^' | '&' | '|' | '~' @@ -4076,7 +3467,7 @@ bool Parser::rOperatorName(irept &name) return rCastOperatorName(name); } - assert(operator_id!=irep_idt()); + assert(!operator_id.empty()); lex.get_token(tk); name=irept(operator_id); set_location(name, tk); @@ -4084,18 +3475,6 @@ bool Parser::rOperatorName(irept &name) return true; } -/*******************************************************************\ - -Function: Parser::rCastOperatorName - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* cast.operator.name : {cv.qualify} (integral.or.class.spec | name) {cv.qualify} @@ -4138,18 +3517,6 @@ bool Parser::rCastOperatorName(irept &name) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* ptr.to.member : {'::'} (identifier {template.args} '::')+ '*' @@ -4244,18 +3611,6 @@ bool Parser::rPtrToMember(irept &ptr_to_mem) return false; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* template.args : '<' '>' @@ -4399,18 +3754,6 @@ bool Parser::rTemplateArgs(irept &template_args) } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* arg.decl.list.or.init : arg.decl.list @@ -4457,18 +3800,6 @@ bool Parser::rArgDeclListOrInit( } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* arg.decl.list : empty @@ -4522,18 +3853,6 @@ bool Parser::rArgDeclList(irept &arglist) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* arg.declaration : {userdef.keyword | REGISTER} type.specifier arg.declarator @@ -4577,18 +3896,6 @@ bool Parser::rArgDeclaration(cpp_declarationt &declaration) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* initialize.expr : expression @@ -4676,18 +3983,6 @@ bool Parser::rInitializeExpr(exprt &expr) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* function.arguments : empty @@ -4728,18 +4023,6 @@ bool Parser::rFunctionArguments(exprt &args) } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* enum.spec : ENUM Identifier @@ -4827,18 +4110,6 @@ bool Parser::rEnumSpec(typet &spec) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* enum.body : Identifier {'=' expression} (',' Identifier {'=' expression})* {','} @@ -4881,26 +4152,14 @@ bool Parser::rEnumBody(irept &body) n.add(ID_value).swap(exp); } else - n.add(ID_value).make_nil(); - - if(lex.LookAhead(0)!=',') - return true; - - lex.get_token(tk); - } -} - -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: + n.add(ID_value).make_nil(); - Purpose: + if(lex.LookAhead(0)!=',') + return true; -\*******************************************************************/ + lex.get_token(tk); + } +} /* class.spec @@ -5010,18 +4269,6 @@ bool Parser::rClassSpec(typet &spec) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* base.specifiers : ':' base.specifier (',' base.specifier)* @@ -5097,18 +4344,6 @@ bool Parser::rBaseSpecifiers(irept &bases) } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* class.body : '{' (class.members)* '}' */ @@ -5156,18 +4391,6 @@ bool Parser::rClassBody(exprt &body) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* class.member : (PUBLIC | PROTECTED | PRIVATE) ':' @@ -5193,7 +4416,7 @@ bool Parser::rClassMember(cpp_itemt &member) #ifdef DEBUG indenter _i; std::cout << std::string(__indent, ' ') << "Parser::rClassMember 0 " << t - << std::endl; + << '\n'; #endif // DEBUG if(t==TOK_PUBLIC || t==TOK_PROTECTED || t==TOK_PRIVATE) @@ -5248,18 +4471,6 @@ bool Parser::rClassMember(cpp_itemt &member) } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* access.decl : name ';' e.g. ::; @@ -5280,18 +4491,6 @@ bool Parser::rAccessDecl(irept &mem) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* comma.expression : expression @@ -5336,18 +4535,6 @@ bool Parser::rCommaExpression(exprt &exp) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* expression : conditional.expr {(AssignOp | '=') expression} right-to-left @@ -5429,18 +4616,6 @@ bool Parser::rExpression(exprt &exp, bool template_args) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* conditional.expr : logical.or.expr {'?' comma.expression ':' conditional.expr} right-to-left @@ -5489,18 +4664,6 @@ bool Parser::rConditionalExpr(exprt &exp, bool template_args) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* logical.or.expr : logical.and.expr @@ -5540,18 +4703,6 @@ bool Parser::rLogicalOrExpr(exprt &exp, bool template_args) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* logical.and.expr : inclusive.or.expr @@ -5591,18 +4742,6 @@ bool Parser::rLogicalAndExpr(exprt &exp, bool template_args) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* inclusive.or.expr : exclusive.or.expr @@ -5642,18 +4781,6 @@ bool Parser::rInclusiveOrExpr(exprt &exp, bool template_args) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* exclusive.or.expr : and.expr @@ -5693,18 +4820,6 @@ bool Parser::rExclusiveOrExpr(exprt &exp, bool template_args) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* and.expr : equality.expr @@ -5744,18 +4859,6 @@ bool Parser::rAndExpr(exprt &exp, bool template_args) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* equality.expr : relational.expr @@ -5796,18 +4899,6 @@ bool Parser::rEqualityExpr(exprt &exp, bool template_args) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* relational.expr : shift.expr @@ -5860,18 +4951,6 @@ bool Parser::rRelationalExpr(exprt &exp, bool template_args) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* shift.expr : additive.expr @@ -5912,18 +4991,6 @@ bool Parser::rShiftExpr(exprt &exp, bool template_args) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* additive.expr : multiply.expr @@ -5971,18 +5038,6 @@ bool Parser::rAdditiveExpr(exprt &exp) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* multiply.expr : pm.expr @@ -6035,18 +5090,6 @@ bool Parser::rMultiplyExpr(exprt &exp) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* pm.expr (pointer to member .*, ->*) : cast.expr @@ -6092,18 +5135,6 @@ bool Parser::rPmExpr(exprt &exp) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* cast.expr : unary.expr @@ -6165,18 +5196,6 @@ bool Parser::rCastExpr(exprt &exp) } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* type.name : type.specifier cast.declarator @@ -6214,18 +5233,6 @@ bool Parser::rTypeName(typet &tname) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* type.name | type.specifier { '(' type.specifier ( ',' type.specifier )* @@ -6403,18 +5410,6 @@ bool Parser::rTypeNameOrFunctionType(typet &tname) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* unary.expr : postfix.expr @@ -6528,18 +5523,6 @@ bool Parser::rUnaryExpr(exprt &exp) return rPostfixExpr(exp); } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* throw.expression : THROW {expression} @@ -6578,18 +5561,6 @@ bool Parser::rThrowExpr(exprt &exp) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* typeid.expr : TYPEID '(' expression ')' @@ -6654,18 +5625,6 @@ bool Parser::rTypeidExpr(exprt &exp) return false; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* sizeof.expr : SIZEOF unary.expr @@ -6740,18 +5699,6 @@ bool Parser::rSizeofExpr(exprt &exp) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* alignof.expr | ALIGNOF '(' type.name ')' @@ -6781,18 +5728,6 @@ bool Parser::rAlignofExpr(exprt &exp) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* noexcept.expr : NOEXCEPT '(' expression ')' @@ -6842,18 +5777,6 @@ bool Parser::isAllocateExpr(int t) return t==TOK_NEW || t==TOK_DELETE; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* allocate.expr : {Scope | userdef.keyword} NEW allocate.type @@ -6942,18 +5865,6 @@ bool Parser::rAllocateExpr(exprt &exp) return false; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* allocate.type : {'(' function.arguments ')'} type.specifier new.declarator @@ -7051,18 +5962,6 @@ bool Parser::rAllocateType( return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* new.declarator : empty @@ -7098,18 +5997,6 @@ bool Parser::rNewDeclarator(typet &decl) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* allocate.initializer : '(' {initialize.expr (',' initialize.expr)* } ')' @@ -7155,18 +6042,6 @@ bool Parser::rAllocateInitializer(exprt &init) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* postfix.exp : primary.exp @@ -7318,18 +6193,6 @@ bool Parser::rPostfixExpr(exprt &exp) } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* __uuidof( expression ) __uuidof( type ) @@ -7380,18 +6243,6 @@ bool Parser::rMSCuuidof(exprt &expr) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* __if_exists ( identifier ) { token stream } __if_not_exists ( identifier ) { token stream } @@ -7442,18 +6293,6 @@ bool Parser::rMSC_if_existsExpr(exprt &expr) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool Parser::rMSC_if_existsStatement(codet &code) { cpp_tokent tk1; @@ -7506,18 +6345,6 @@ bool Parser::rMSC_if_existsStatement(codet &code) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* __is_base_of ( base, derived ) __is_convertible_to ( from, to ) @@ -7570,18 +6397,6 @@ bool Parser::rTypePredicate(exprt &expr) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* primary.exp : Constant @@ -7822,18 +6637,6 @@ bool Parser::rPrimaryExpr(exprt &exp) } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* var.name : {'::'} name2 ('::' name2)* @@ -7857,18 +6660,6 @@ bool Parser::rVarName(exprt &name) return false; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool Parser::rVarNameCore(exprt &name) { #ifdef DEBUG @@ -7903,7 +6694,7 @@ bool Parser::rVarNameCore(exprt &name) #ifdef DEBUG std::cout << std::string(__indent, ' ') << "Parser::rVarNameCore 1.1 " << lex.LookAhead(0) - << std::endl; + << '\n'; #endif switch(lex.LookAhead(0)) @@ -8002,18 +6793,6 @@ bool Parser::rVarNameCore(exprt &name) } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool Parser::moreVarName() { if(lex.LookAhead(0)==TOK_SCOPE) @@ -8026,18 +6805,6 @@ bool Parser::moreVarName() return false; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* template.args : '<' any* '>' @@ -8139,18 +6906,6 @@ bool Parser::maybeTemplateArgs() return false; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* function.body : compound.statement | { asm } @@ -8200,18 +6955,6 @@ bool Parser::rFunctionBody(cpp_declaratort &declarator) } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* compound.statement : '{' (statement)* '}' @@ -8258,18 +7001,6 @@ bool Parser::rCompoundStatement(codet &statement) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* statement : compound.statement @@ -8549,18 +7280,6 @@ bool Parser::rStatement(codet &statement) } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* if.statement : IF '(' comma.expression ')' statement { ELSE statement } @@ -8609,18 +7328,6 @@ bool Parser::rIfStatement(codet &statement) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* switch.statement : SWITCH '(' comma.expression ')' statement @@ -8654,18 +7361,6 @@ bool Parser::rSwitchStatement(codet &statement) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* while.statement : WHILE '(' comma.expression ')' statement @@ -8699,18 +7394,6 @@ bool Parser::rWhileStatement(codet &statement) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* do.statement : DO statement WHILE '(' comma.expression ')' ';' @@ -8750,18 +7433,6 @@ bool Parser::rDoStatement(codet &statement) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* for.statement : FOR '(' expr.statement {comma.expression} ';' {comma.expression} ')' @@ -8823,18 +7494,6 @@ bool Parser::rForStatement(codet &statement) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* try.statement : TRY compound.statement (exception.handler)+ ';' @@ -8929,18 +7588,6 @@ bool Parser::rTryStatement(codet &statement) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool Parser::rMSC_tryStatement(codet &statement) { // These are for 'structured exception handling', @@ -8996,18 +7643,6 @@ bool Parser::rMSC_tryStatement(codet &statement) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool Parser::rMSC_leaveStatement(codet &statement) { // These are for 'structured exception handling', @@ -9024,18 +7659,6 @@ bool Parser::rMSC_leaveStatement(codet &statement) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool Parser::rGCCAsmStatement(codet &statement) { cpp_tokent tk; @@ -9137,18 +7760,6 @@ bool Parser::rGCCAsmStatement(codet &statement) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool Parser::rMSCAsmStatement(codet &statement) { cpp_tokent tk; @@ -9217,18 +7828,6 @@ bool Parser::rMSCAsmStatement(codet &statement) return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* expr.statement : ';' @@ -9310,18 +7909,6 @@ bool Parser::rExprStatement(codet &statement) } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool Parser::rCondition(exprt &statement) { cpp_token_buffert::post pos=lex.Save(); @@ -9347,18 +7934,6 @@ bool Parser::rCondition(exprt &statement) } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* declaration.statement : decl.head integral.or.class.spec {cv.qualify} {declarators} ';' @@ -9437,18 +8012,6 @@ bool Parser::rDeclarationStatement(codet &statement) } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* integral.decl.statement : decl.head integral.or.class.spec {cv.qualify} {declarators} ';' @@ -9494,18 +8057,6 @@ bool Parser::rIntegralDeclStatement( return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* other.decl.statement :decl.head name {cv.qualify} declarators ';' @@ -9560,35 +8111,11 @@ bool Parser::rOtherDeclStatement( return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool Parser::MaybeTypeNameOrClassTemplate(cpp_tokent &) { return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void Parser::SkipTo(int token) { cpp_tokent tk; @@ -9603,18 +8130,6 @@ void Parser::SkipTo(int token) } } -/*******************************************************************\ - -Function: Parser::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool Parser::operator()() { number_of_errors=0; @@ -9635,18 +8150,6 @@ bool Parser::operator()() return number_of_errors!=0; } -/*******************************************************************\ - -Function: cpp_parse - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool cpp_parse() { Parser parser(cpp_parser); diff --git a/src/cpp/recursion_counter.h b/src/cpp/recursion_counter.h index fab87c254f7..82ec1a77bbc 100644 --- a/src/cpp/recursion_counter.h +++ b/src/cpp/recursion_counter.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #ifndef CPROVER_CPP_RECURSION_COUNTER_H #define CPROVER_CPP_RECURSION_COUNTER_H diff --git a/src/cpp/template_map.cpp b/src/cpp/template_map.cpp index 62d5b026207..a76fac96a42 100644 --- a/src/cpp/template_map.cpp +++ b/src/cpp/template_map.cpp @@ -6,22 +6,13 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #include #include "template_map.h" -/*******************************************************************\ - -Function: template_mapt::apply - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void template_mapt::apply(typet &type) const { if(type.id()==ID_array) @@ -74,18 +65,6 @@ void template_mapt::apply(typet &type) const } } -/*******************************************************************\ - -Function: template_mapt::apply - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void template_mapt::apply(exprt &expr) const { apply(expr.type()); @@ -106,18 +85,6 @@ void template_mapt::apply(exprt &expr) const apply(*it); } -/*******************************************************************\ - -Function: template_mapt::lookup - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt template_mapt::lookup(const irep_idt &identifier) const { type_mapt::const_iterator t_it= @@ -139,18 +106,6 @@ exprt template_mapt::lookup(const irep_idt &identifier) const return static_cast(get_nil_irep()); } -/*******************************************************************\ - -Function: template_mapt::lookup_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet template_mapt::lookup_type(const irep_idt &identifier) const { type_mapt::const_iterator t_it= @@ -162,18 +117,6 @@ typet template_mapt::lookup_type(const irep_idt &identifier) const return static_cast(get_nil_irep()); } -/*******************************************************************\ - -Function: template_mapt::lookup_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt template_mapt::lookup_expr(const irep_idt &identifier) const { expr_mapt::const_iterator e_it= @@ -185,43 +128,19 @@ exprt template_mapt::lookup_expr(const irep_idt &identifier) const return static_cast(get_nil_irep()); } -/*******************************************************************\ - -Function: template_mapt::print - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void template_mapt::print(std::ostream &out) const { for(type_mapt::const_iterator it=type_map.begin(); it!=type_map.end(); it++) - out << it->first << " = " << it->second.pretty() << std::endl; + out << it->first << " = " << it->second.pretty() << '\n'; for(expr_mapt::const_iterator it=expr_map.begin(); it!=expr_map.end(); it++) - out << it->first << " = " << it->second.pretty() << std::endl; + out << it->first << " = " << it->second.pretty() << '\n'; } -/*******************************************************************\ - -Function: template_mapt::build - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void template_mapt::build( const template_typet &template_type, const cpp_template_args_tct &template_args) @@ -264,18 +183,6 @@ void template_mapt::build( } } -/*******************************************************************\ - -Function: template_mapt::set - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void template_mapt::set( const template_parametert ¶meter, const exprt &value) @@ -302,18 +209,6 @@ void template_mapt::set( } } -/*******************************************************************\ - -Function: template_mapt::build_unassigned - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void template_mapt::build_unassigned( const template_typet &template_type) { @@ -344,18 +239,6 @@ void template_mapt::build_unassigned( } } -/*******************************************************************\ - -Function: template_mapt::build_template_args - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - cpp_template_args_tct template_mapt::build_template_args( const template_typet &template_type) const { diff --git a/src/cpp/template_map.h b/src/cpp/template_map.h index c1347eca059..74531f3aaa9 100644 --- a/src/cpp/template_map.h +++ b/src/cpp/template_map.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ +/// \file +/// C++ Language Type Checking + #ifndef CPROVER_CPP_TEMPLATE_MAP_H #define CPROVER_CPP_TEMPLATE_MAP_H diff --git a/src/doxygen.cfg b/src/doxyfile similarity index 82% rename from src/doxygen.cfg rename to src/doxyfile index b46c3b28f01..611614a3a9b 100644 --- a/src/doxygen.cfg +++ b/src/doxyfile @@ -14,211 +14,211 @@ # Project related configuration options #--------------------------------------------------------------------------- -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all -# text before the first occurrence of this tag. Doxygen uses libiconv (or the -# iconv built into libc) for the transcoding. See +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See # http://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = cprover -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = +PROJECT_NUMBER = -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = ../doc -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek, -# Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages), -# Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish, -# Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek, +# Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish, +# Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, # and Ukrainian. OUTPUT_LANGUAGE = English -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" -ABBREVIATE_BRIEF = +ABBREVIATE_BRIEF = -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = YES -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the # path to strip. -STRIP_FROM_PATH = +STRIP_FROM_PATH = -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. -STRIP_FROM_INC_PATH = +STRIP_FROM_INC_PATH = -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = YES -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring # an explicit \brief command for a brief description.) QT_AUTOBRIEF = NO -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO -# If the DETAILS_AT_TOP tag is set to YES then Doxygen +# If the DETAILS_AT_TOP tag is set to YES then Doxygen # will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member +# If set to NO, the detailed description appears after the member # documentation. DETAILS_AT_TOP = YES -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO -# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 8 -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. -ALIASES = +ALIASES = -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = NO -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for -# Java. For instance, namespaces will be presented as packages, qualified +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified # scopes will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources only. Doxygen will then generate output that is more tailored for +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for # Fortran. OPTIMIZE_FOR_FORTRAN = NO -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for # VHDL. OPTIMIZE_OUTPUT_VHDL = NO -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also make the inheritance and collaboration +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = YES @@ -228,42 +228,42 @@ BUILTIN_STL_SUPPORT = YES CPP_CLI_SUPPORT = NO -# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. -# Doxygen will parse them like normal C++ but will assume all classes use public +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public # instead of private inheritance when no explicit protection keyword is present. SIP_SUPPORT = NO -# For Microsoft's IDL there are propget and propput attributes to indicate getter -# and setter methods for a property. Setting this option to YES (the default) -# will make doxygen to replace the get and set methods by a property in the -# documentation. This will only work if the methods are indeed getting or -# setting a simple type. If this is not the case, or you want to show the +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen to replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the # methods anyway, you should set this option to NO. IDL_PROPERTY_SUPPORT = YES -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES -# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum -# is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically -# be useful for C code in case the coding convention dictates that all compound +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. TYPEDEF_HIDES_STRUCT = NO @@ -272,368 +272,368 @@ TYPEDEF_HIDES_STRUCT = NO # Build related configuration options #--------------------------------------------------------------------------- -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES -EXTRACT_ALL = NO +EXTRACT_ALL = YES -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO -# If the EXTRACT_STATIC tag is set to YES all static members of a file +# If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = NO -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default # anonymous namespace are hidden. EXTRACT_ANON_NSPACES = NO -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. -HIDE_UNDOC_MEMBERS = YES +HIDE_UNDOC_MEMBERS = NO -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. -HIDE_UNDOC_CLASSES = YES +HIDE_UNDOC_CLASSES = NO -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = NO -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the -# hierarchy of group names into alphabetical order. If set to NO (the default) +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) # the group names will appear in their defined order. SORT_GROUP_NAMES = NO -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the +# Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES -# The ENABLED_SECTIONS tag can be used to enable conditional +# The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. -ENABLED_SECTIONS = +ENABLED_SECTIONS = -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. SHOW_DIRECTORIES = NO # Set the SHOW_FILES tag to NO to disable the generation of the Files page. -# This will remove the Files entry from the Quick Index and from the +# This will remove the Files entry from the Quick Index and from the # Folder Tree View (if specified). The default is YES. SHOW_FILES = YES -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the # Namespaces page. This will remove the Namespaces entry from the Quick Index # and from the Folder Tree View (if specified). The default is YES. SHOW_NAMESPACES = YES -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. -FILE_VERSION_FILTER = +FILE_VERSION_FILTER = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- -# The QUIET tag can be used to turn on/off the messages that are generated +# The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. -QUIET = NO +QUIET = YES -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written # to stderr. -WARN_LOGFILE = +WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = util goto-programs pointer-analysis solvers +INPUT = . -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is -# also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for # the list of possible encodings. INPUT_ENCODING = UTF-8 -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 FILE_PATTERNS = *.cpp *.h -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = YES -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = solvers/z3/ -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* -EXCLUDE_PATTERNS = */.svn/* +EXCLUDE_PATTERNS = */.svn/* */.git/* -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test -EXCLUDE_SYMBOLS = +EXCLUDE_SYMBOLS = -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see # the \include command). -EXAMPLE_PATH = +EXAMPLE_PATH = -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left # blank all files are included. -EXAMPLE_PATTERNS = +EXAMPLE_PATTERNS = -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see # the \image command). -IMAGE_PATH = +IMAGE_PATH = -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be # ignored. -INPUT_FILTER = +INPUT_FILTER = -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER # is applied to all files. -FILTER_PATTERNS = +FILTER_PATTERNS = -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO @@ -642,32 +642,32 @@ FILTER_SOURCE_FILES = NO # configuration options related to source browsing #--------------------------------------------------------------------------- -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = NO -# Setting the INLINE_SOURCES tag to YES will include the body +# Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES -# If the REFERENCED_BY_RELATION tag is set to YES -# then for each documented function all documented +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = YES -# If the REFERENCES_RELATION tag is set to YES -# then for each documented function all documented entities +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = YES @@ -679,16 +679,16 @@ REFERENCES_RELATION = YES REFERENCES_LINK_SOURCE = YES -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES @@ -697,129 +697,129 @@ VERBATIM_HEADERS = YES # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = NO -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. -IGNORE_PREFIX = +IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a # standard header. -HTML_HEADER = +HTML_HEADER = -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a # standard footer. -HTML_FOOTER = +HTML_FOOTER = -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own # stylesheet in the HTML output directory as well, or it will be erased! -HTML_STYLESHEET = +HTML_STYLESHEET = -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO -# If the GENERATE_DOCSET tag is set to YES, additional index files -# will be generated that can be used as input for Apple's Xcode 3 -# integrated development environment, introduced with OSX 10.5 (Leopard). -# To create a documentation set, doxygen will generate a Makefile in the -# HTML output directory. Running make will produce the docset in that -# directory and running "make install" will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find # it at startup. GENERATE_DOCSET = NO -# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the -# feed. A documentation feed provides an umbrella under which multiple -# documentation sets from a single provider (such as a company or product suite) +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) # can be grouped. DOCSET_FEEDNAME = "Doxygen generated docs" -# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that -# should uniquely identify the documentation set bundle. This should be a -# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen # will append .docset to the name. DOCSET_BUNDLE_ID = org.doxygen.Project -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. For this to work a browser that supports -# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox # Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). HTML_DYNAMIC_SECTIONS = NO -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be # written to the html output directory. -CHM_FILE = +CHM_FILE = -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. -HHC_LOCATION = +HHC_LOCATION = -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO @@ -828,26 +828,26 @@ GENERATE_CHI = NO # is used to encode HtmlHelp index (hhk), content (hhc) and project file # content. -CHM_INDEX_ENCODING = +CHM_INDEX_ENCODING = -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO -# The TOC_EXPAND flag can be set to YES to add extra items for group members +# The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO -# This tag can be used to set the number of enum values (range [1..20]) +# This tag can be used to set the number of enum values (range [1..20]) # that doxygen will group on one line in the generated HTML documentation. ENUM_VALUES_PER_LINE = 4 @@ -855,11 +855,11 @@ ENUM_VALUES_PER_LINE = 4 # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. # If the tag value is set to FRAME, a side panel will be generated -# containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. Other possible values +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, +# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are +# probably better off using the HTML help feature. Other possible values # for this tag are: HIERARCHIES, which will generate the Groups, Directories, # and Class Hiererachy pages using a tree view instead of an ordered list; # ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which @@ -869,16 +869,16 @@ ENUM_VALUES_PER_LINE = 4 GENERATE_TREEVIEW = NONE -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 -# Use this tag to change the font size of Latex formulas included -# as images in the HTML documentation. The default is 10. Note that -# when you change the font size after a successful doxygen run you need -# to manually remove any form_*.png images from the HTML output directory +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory # to force them to be regenerated. FORMULA_FONTSIZE = 10 @@ -887,74 +887,74 @@ FORMULA_FONTSIZE = 10 # configuration options related to the LaTeX output #--------------------------------------------------------------------------- -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. LATEX_CMD_NAME = latex -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4wide -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. -EXTRA_PACKAGES = +EXTRA_PACKAGES = -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! -LATEX_HEADER = +LATEX_HEADER = -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = YES -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = YES -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO @@ -963,68 +963,68 @@ LATEX_HIDE_INDICES = NO # configuration options related to the RTF output #--------------------------------------------------------------------------- -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. -RTF_STYLESHEET_FILE = +RTF_STYLESHEET_FILE = -# Set optional variables used in the generation of an rtf document. +# Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. -RTF_EXTENSIONS_FILE = +RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man -# The MAN_EXTENSION tag determines the extension that is added to +# The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO @@ -1033,33 +1033,33 @@ MAN_LINKS = NO # configuration options related to the XML output #--------------------------------------------------------------------------- -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the # syntax of the XML files. -XML_SCHEMA = +XML_SCHEMA = -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the # syntax of the XML files. -XML_DTD = +XML_DTD = -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES @@ -1068,10 +1068,10 @@ XML_PROGRAMLISTING = YES # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO @@ -1080,338 +1080,338 @@ GENERATE_AUTOGEN_DEF = NO # configuration options related to the Perl module output #--------------------------------------------------------------------------- -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. -PERLMOD_MAKEVAR_PREFIX = +PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- -# Configuration options related to the preprocessor +# Configuration options related to the preprocessor #--------------------------------------------------------------------------- -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = YES -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = NO -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by # the preprocessor. -INCLUDE_PATH = +INCLUDE_PATH = -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. -INCLUDE_FILE_PATTERNS = +INCLUDE_FILE_PATTERNS = -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator # instead of the = operator. -PREDEFINED = +PREDEFINED = -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. -EXPAND_AS_DEFINED = +EXPAND_AS_DEFINED = -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse # the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- -# Configuration::additions related to external references +# Configuration::additions related to external references #--------------------------------------------------------------------------- -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool # does not have to be run to correct the links. # Note that each tag file must have a unique name # (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen +# If a tag file is not located in the directory in which doxygen # is run, you must also specify the path to the tagfile here. -TAGFILES = +TAGFILES = -# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. -GENERATE_TAGFILE = +GENERATE_TAGFILE = -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES -# The PERL_PATH should be the absolute path and name of the perl script +# The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- -# Configuration options related to the dot tool +# Configuration options related to the dot tool #--------------------------------------------------------------------------- -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option is superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more # powerful graphs. CLASS_DIAGRAMS = YES -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see -# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. -MSCGEN_PATH = +MSCGEN_PATH = -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = NO -# By default doxygen will write a font called FreeSans.ttf to the output -# directory and reference it in all dot files that doxygen generates. This -# font does not include all possible unicode characters however, so when you need -# these (or just want a differently looking font) you can specify the font name -# using DOT_FONTNAME. You need need to make sure dot is able to find the font, -# which can be done by putting it in a standard location or by setting the -# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory +# By default doxygen will write a font called FreeSans.ttf to the output +# directory and reference it in all dot files that doxygen generates. This +# font does not include all possible unicode characters however, so when you need +# these (or just want a differently looking font) you can specify the font name +# using DOT_FONTNAME. You need need to make sure dot is able to find the font, +# which can be done by putting it in a standard location or by setting the +# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory # containing the font. DOT_FONTNAME = FreeSans -# By default doxygen will tell dot to use the output directory to look for the -# FreeSans.ttf font (which doxygen will put there itself). If you specify a -# different font using DOT_FONTNAME you can set the path where dot +# By default doxygen will tell dot to use the output directory to look for the +# FreeSans.ttf font (which doxygen will put there itself). If you specify a +# different font using DOT_FONTNAME you can set the path where dot # can find it using this tag. -DOT_FONTPATH = +DOT_FONTPATH = -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO -# If set to YES, the inheritance and collaboration graphs will show the +# If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = YES -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES -# If the CALL_GRAPH and HAVE_DOT options are set to YES then -# doxygen will generate a call dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable call graphs +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs # for selected functions only using the \callgraph command. CALL_GRAPH = NO -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then -# doxygen will generate a caller dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable caller +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller # graphs for selected functions only using the \callergraph command. CALLER_GRAPH = NO -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are png, jpg, or gif # If left blank png will be used. DOT_IMAGE_FORMAT = png -# The tag DOT_PATH can be used to specify the path where the dot tool can be +# The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. -DOT_PATH = +DOT_PATH = -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the # \dotfile command). -DOTFILE_DIRS = +DOTFILE_DIRS = -# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the -# number of direct children of the root node in a graph is already larger than -# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. DOT_GRAPH_MAX_NODES = 50 -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 0 -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is enabled by default, which results in a transparent -# background. Warning: Depending on the platform used, enabling this option -# may lead to badly anti-aliased labels on the edges of a graph (i.e. they +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is enabled by default, which results in a transparent +# background. Warning: Depending on the platform used, enabling this option +# may lead to badly anti-aliased labels on the edges of a graph (i.e. they # become hard to read). DOT_TRANSPARENT = YES -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES #--------------------------------------------------------------------------- -# Configuration::additions related to the search engine +# Configuration::additions related to the search engine #--------------------------------------------------------------------------- -# The SEARCHENGINE tag specifies whether or not a search engine should be +# The SEARCHENGINE tag specifies whether or not a search engine should be # used. If set to NO the values of all tags below this one will be ignored. SEARCHENGINE = NO diff --git a/src/goto-analyzer/Makefile b/src/goto-analyzer/Makefile index 9eb45165f9c..da9e1c50d7d 100644 --- a/src/goto-analyzer/Makefile +++ b/src/goto-analyzer/Makefile @@ -8,6 +8,7 @@ SRC = goto_analyzer_main.cpp \ OBJ += ../ansi-c/ansi-c$(LIBEXT) \ ../cpp/cpp$(LIBEXT) \ + ../java_bytecode/java_bytecode$(LIBEXT) \ ../linking/linking$(LIBEXT) \ ../big-int/big-int$(LIBEXT) \ ../goto-programs/goto-programs$(LIBEXT) \ @@ -30,26 +31,11 @@ CLEANFILES = goto-analyzer$(EXEEXT) all: goto-analyzer$(EXEEXT) -ifneq ($(wildcard ../java_bytecode/Makefile),) - OBJ += ../java_bytecode/java_bytecode$(LIBEXT) - CP_CXXFLAGS += -DHAVE_JAVA_BYTECODE -endif - ifneq ($(wildcard ../jsil/Makefile),) OBJ += ../jsil/jsil$(LIBEXT) CP_CXXFLAGS += -DHAVE_JSIL endif -ifneq ($(wildcard ../specc/Makefile),) - OBJ += ../specc/specc$(LIBEXT) - CP_CXXFLAGS += -DHAVE_SPECC -endif - -ifneq ($(wildcard ../php/Makefile),) - OBJ += ../php/php$(LIBEXT) - CP_CXXFLAGS += -DHAVE_PHP -endif - ############################################################################### goto-analyzer$(EXEEXT): $(OBJ) diff --git a/src/goto-analyzer/goto_analyzer_main.cpp b/src/goto-analyzer/goto_analyzer_main.cpp index 78baf16d6a1..64e14c74936 100644 --- a/src/goto-analyzer/goto_analyzer_main.cpp +++ b/src/goto-analyzer/goto_analyzer_main.cpp @@ -6,22 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Goto-Analyser Main Module + #include #include "goto_analyzer_parse_options.h" -/*******************************************************************\ - -Function: main / wmain - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - #ifdef _MSC_VER int wmain(int argc, const wchar_t **argv_wide) { diff --git a/src/goto-analyzer/goto_analyzer_parse_options.cpp b/src/goto-analyzer/goto_analyzer_parse_options.cpp index c783243a0d3..904ab58768e 100644 --- a/src/goto-analyzer/goto_analyzer_parse_options.cpp +++ b/src/goto-analyzer/goto_analyzer_parse_options.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Goto-Analyser Command Line Option Processing + #include // exit() #include #include @@ -50,18 +53,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "unreachable_instructions.h" #include "static_analyzer.h" -/*******************************************************************\ - -Function: goto_analyzer_parse_optionst::goto_analyzer_parse_optionst - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - goto_analyzer_parse_optionst::goto_analyzer_parse_optionst( int argc, const char **argv): @@ -71,18 +62,6 @@ goto_analyzer_parse_optionst::goto_analyzer_parse_optionst( { } -/*******************************************************************\ - -Function: goto_analyzer_parse_optionst::register_languages - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_analyzer_parse_optionst::register_languages() { register_language(new_ansi_c_language); @@ -91,18 +70,6 @@ void goto_analyzer_parse_optionst::register_languages() register_language(new_jsil_language); } -/*******************************************************************\ - -Function: goto_analyzer_parse_optionst::eval_verbosity - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_analyzer_parse_optionst::eval_verbosity() { // this is our default verbosity @@ -118,18 +85,6 @@ void goto_analyzer_parse_optionst::eval_verbosity() ui_message_handler.set_verbosity(v); } -/*******************************************************************\ - -Function: goto_analyzer_parse_optionst::get_command_line_options - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_analyzer_parse_optionst::get_command_line_options(optionst &options) { if(config.set(cmdline)) @@ -177,23 +132,12 @@ void goto_analyzer_parse_optionst::get_command_line_options(optionst &options) #endif } -/*******************************************************************\ - -Function: goto_analyzer_parse_optionst::doit - - Inputs: - - Outputs: - - Purpose: invoke main modules - -\*******************************************************************/ - +/// invoke main modules int goto_analyzer_parse_optionst::doit() { if(cmdline.isset("version")) { - std::cout << CBMC_VERSION << std::endl; + std::cout << CBMC_VERSION << '\n'; return 0; } @@ -362,18 +306,6 @@ int goto_analyzer_parse_optionst::doit() return 6; } -/*******************************************************************\ - -Function: goto_analyzer_parse_optionst::set_properties - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool goto_analyzer_parse_optionst::set_properties() { try @@ -402,18 +334,6 @@ bool goto_analyzer_parse_optionst::set_properties() return false; } -/*******************************************************************\ - -Function: goto_analyzer_parse_optionst::process_goto_program - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool goto_analyzer_parse_optionst::process_goto_program( const optionst &options) { @@ -501,18 +421,7 @@ bool goto_analyzer_parse_optionst::process_goto_program( return false; } -/*******************************************************************\ - -Function: goto_analyzer_parse_optionst::help - - Inputs: - - Outputs: - - Purpose: display command line help - -\*******************************************************************/ - +/// display command line help void goto_analyzer_parse_optionst::help() { std::cout << diff --git a/src/goto-analyzer/goto_analyzer_parse_options.h b/src/goto-analyzer/goto_analyzer_parse_options.h index 538bf47ac3e..48b299049b9 100644 --- a/src/goto-analyzer/goto_analyzer_parse_options.h +++ b/src/goto-analyzer/goto_analyzer_parse_options.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Goto-Analyser Command Line Option Processing + #ifndef CPROVER_GOTO_ANALYZER_GOTO_ANALYZER_PARSE_OPTIONS_H #define CPROVER_GOTO_ANALYZER_GOTO_ANALYZER_PARSE_OPTIONS_H diff --git a/src/goto-analyzer/static_analyzer.cpp b/src/goto-analyzer/static_analyzer.cpp index 1168cff1a73..4125e5d44cb 100644 --- a/src/goto-analyzer/static_analyzer.cpp +++ b/src/goto-analyzer/static_analyzer.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -47,18 +48,6 @@ class static_analyzert:public messaget tvt eval(goto_programt::const_targett); }; -/*******************************************************************\ - -Function: static_analyzert::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool static_analyzert::operator()() { status() << "performing interval analysis" << eom; @@ -74,18 +63,6 @@ bool static_analyzert::operator()() return false; } -/*******************************************************************\ - -Function: static_analyzert::eval - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - tvt static_analyzert::eval(goto_programt::const_targett t) { exprt guard=t->guard; @@ -96,18 +73,6 @@ tvt static_analyzert::eval(goto_programt::const_targett t) return tvt::unknown(); } -/*******************************************************************\ - -Function: static_analyzert::plain_text_report - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void static_analyzert::plain_text_report() { unsigned pass=0, fail=0, unknown=0; @@ -159,18 +124,6 @@ void static_analyzert::plain_text_report() << unknown << " unknown\n"; } -/*******************************************************************\ - -Function: static_analyzert::json_report - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void static_analyzert::json_report(const std::string &file_name) { json_arrayt json_result; @@ -218,18 +171,6 @@ void static_analyzert::json_report(const std::string &file_name) out << json_result; } -/*******************************************************************\ - -Function: static_analyzert::xml_report - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void static_analyzert::xml_report(const std::string &file_name) { xmlt xml_result; @@ -277,18 +218,6 @@ void static_analyzert::xml_report(const std::string &file_name) out << xml_result; } -/*******************************************************************\ - -Function: static_analyzer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool static_analyzer( const goto_modelt &goto_model, const optionst &options, @@ -298,18 +227,6 @@ bool static_analyzer( goto_model, options, message_handler)(); } -/*******************************************************************\ - -Function: show_intervals - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void show_intervals( const goto_modelt &goto_model, std::ostream &out) diff --git a/src/goto-analyzer/static_analyzer.h b/src/goto-analyzer/static_analyzer.h index 3d964a2964a..fdab261d8c1 100644 --- a/src/goto-analyzer/static_analyzer.h +++ b/src/goto-analyzer/static_analyzer.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_GOTO_ANALYZER_STATIC_ANALYZER_H #define CPROVER_GOTO_ANALYZER_STATIC_ANALYZER_H diff --git a/src/goto-analyzer/taint_analysis.cpp b/src/goto-analyzer/taint_analysis.cpp index f3caa711607..7e59ac5c399 100644 --- a/src/goto-analyzer/taint_analysis.cpp +++ b/src/goto-analyzer/taint_analysis.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Taint Analysis + #include #include @@ -22,14 +25,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "taint_analysis.h" #include "taint_parser.h" -/*******************************************************************\ - - Class: taint_analysist - - Purpose: - -\*******************************************************************/ - class taint_analysist:public messaget { public: @@ -52,18 +47,6 @@ class taint_analysist:public messaget void instrument(const namespacet &, goto_functionst::goto_functiont &); }; -/*******************************************************************\ - -Function: taint_analysist::instrument - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void taint_analysist::instrument( const namespacet &ns, goto_functionst &goto_functions) @@ -72,18 +55,6 @@ void taint_analysist::instrument( instrument(ns, function.second); } -/*******************************************************************\ - -Function: taint_analysist::instrument - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void taint_analysist::instrument( const namespacet &ns, goto_functionst::goto_functiont &goto_function) @@ -245,18 +216,6 @@ void taint_analysist::instrument( } } -/*******************************************************************\ - -Function: taint_analysist::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool taint_analysist::operator()( const std::string &taint_file_name, const symbol_tablet &symbol_table, @@ -444,18 +403,6 @@ bool taint_analysist::operator()( } } -/*******************************************************************\ - -Function: taint_analysis - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool taint_analysis( goto_modelt &goto_model, const std::string &taint_file_name, diff --git a/src/goto-analyzer/taint_analysis.h b/src/goto-analyzer/taint_analysis.h index a47a974b009..f9b73d2640e 100644 --- a/src/goto-analyzer/taint_analysis.h +++ b/src/goto-analyzer/taint_analysis.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Taint Analysis + #ifndef CPROVER_GOTO_ANALYZER_TAINT_ANALYSIS_H #define CPROVER_GOTO_ANALYZER_TAINT_ANALYSIS_H diff --git a/src/goto-analyzer/taint_parser.cpp b/src/goto-analyzer/taint_parser.cpp index e60fb2ded54..234a8e53c3b 100644 --- a/src/goto-analyzer/taint_parser.cpp +++ b/src/goto-analyzer/taint_parser.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Taint Parser + #include #include @@ -14,18 +17,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "taint_parser.h" -/*******************************************************************\ - -Function: taint_parser - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool taint_parser( const std::string &file_name, taint_parse_treet &dest, @@ -131,18 +122,6 @@ bool taint_parser( return false; } -/*******************************************************************\ - -Function: taint_parse_treet::rulet::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void taint_parse_treet::rulet::output(std::ostream &out) const { if(!id.empty()) @@ -168,18 +147,6 @@ void taint_parse_treet::rulet::output(std::ostream &out) const out << '\n'; } -/*******************************************************************\ - -Function: taint_parse_treet::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void taint_parse_treet::output(std::ostream &out) const { for(const auto &rule : rules) diff --git a/src/goto-analyzer/taint_parser.h b/src/goto-analyzer/taint_parser.h index bc02e66c1ce..79746041265 100644 --- a/src/goto-analyzer/taint_parser.h +++ b/src/goto-analyzer/taint_parser.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Taint Parser + #ifndef CPROVER_GOTO_ANALYZER_TAINT_PARSER_H #define CPROVER_GOTO_ANALYZER_TAINT_PARSER_H diff --git a/src/goto-analyzer/unreachable_instructions.cpp b/src/goto-analyzer/unreachable_instructions.cpp index 73514f5b5d5..77f97d31d58 100644 --- a/src/goto-analyzer/unreachable_instructions.cpp +++ b/src/goto-analyzer/unreachable_instructions.cpp @@ -8,6 +8,9 @@ Date: April 2016 \*******************************************************************/ +/// \file +/// List all unreachable instructions + #include #include @@ -23,18 +26,6 @@ Date: April 2016 typedef std::map dead_mapt; -/*******************************************************************\ - -Function: unreachable_instructions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static void unreachable_instructions( const goto_programt &goto_program, dead_mapt &dest) @@ -54,18 +45,6 @@ static void unreachable_instructions( } } -/*******************************************************************\ - -Function: all_unreachable - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static void all_unreachable( const goto_programt &goto_program, dead_mapt &dest) @@ -75,18 +54,6 @@ static void all_unreachable( dest.insert(std::make_pair(it->location_number, it)); } -/*******************************************************************\ - -Function: output_dead_plain - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static void output_dead_plain( const namespacet &ns, const goto_programt &goto_program, @@ -107,18 +74,6 @@ static void output_dead_plain( goto_program.output_instruction(ns, "", os, it->second); } -/*******************************************************************\ - -Function: add_to_json - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static void add_to_json( const namespacet &ns, const goto_programt &goto_program, @@ -166,18 +121,6 @@ static void add_to_json( } } -/*******************************************************************\ - -Function: unreachable_instructions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void unreachable_instructions( const goto_modelt &goto_model, const bool json, @@ -218,21 +161,9 @@ void unreachable_instructions( } if(json && !json_result.array.empty()) - os << json_result << std::endl; + os << json_result << '\n'; } -/*******************************************************************\ - -Function: json_output_function - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static void json_output_function( const irep_idt &function, const source_locationt &first_location, @@ -252,18 +183,6 @@ static void json_output_function( json_numbert(id2string(last_location.get_line())); } -/*******************************************************************\ - -Function: list_functions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static void list_functions( const goto_modelt &goto_model, const bool json, @@ -325,21 +244,9 @@ static void list_functions( } if(json && !json_result.array.empty()) - os << json_result << std::endl; + os << json_result << '\n'; } -/*******************************************************************\ - -Function: unreachable_functions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void unreachable_functions( const goto_modelt &goto_model, const bool json, @@ -348,18 +255,6 @@ void unreachable_functions( list_functions(goto_model, json, os, true); } -/*******************************************************************\ - -Function: reachable_functions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void reachable_functions( const goto_modelt &goto_model, const bool json, diff --git a/src/goto-analyzer/unreachable_instructions.h b/src/goto-analyzer/unreachable_instructions.h index a408e004bd8..9b71e4f66f5 100644 --- a/src/goto-analyzer/unreachable_instructions.h +++ b/src/goto-analyzer/unreachable_instructions.h @@ -8,6 +8,9 @@ Date: April 2016 \*******************************************************************/ +/// \file +/// List all unreachable instructions + #ifndef CPROVER_GOTO_ANALYZER_UNREACHABLE_INSTRUCTIONS_H #define CPROVER_GOTO_ANALYZER_UNREACHABLE_INSTRUCTIONS_H diff --git a/src/goto-cc/Makefile b/src/goto-cc/Makefile index 51ac3f0f9cb..576a5e39505 100644 --- a/src/goto-cc/Makefile +++ b/src/goto-cc/Makefile @@ -23,6 +23,7 @@ OBJ += ../big-int/big-int$(LIBEXT) \ ../linking/linking$(LIBEXT) \ ../ansi-c/ansi-c$(LIBEXT) \ ../cpp/cpp$(LIBEXT) \ + ../java_bytecode/java_bytecode$(LIBEXT) \ ../xmllang/xmllang$(LIBEXT) \ ../assembler/assembler$(LIBEXT) \ ../langapi/langapi$(LIBEXT) \ @@ -43,10 +44,6 @@ all: goto-cl$(EXEEXT) endif all: goto-cc$(EXEEXT) -ifneq ($(wildcard ../java_bytecode/Makefile),) - OBJ += ../java_bytecode/java_bytecode$(LIBEXT) -endif - ifneq ($(wildcard ../jsil/Makefile),) OBJ += ../jsil/jsil$(LIBEXT) CP_CXXFLAGS += -DHAVE_JSIL diff --git a/src/goto-cc/armcc_cmdline.cpp b/src/goto-cc/armcc_cmdline.cpp index 4b58f765f17..81bf59bc68e 100644 --- a/src/goto-cc/armcc_cmdline.cpp +++ b/src/goto-cc/armcc_cmdline.cpp @@ -6,23 +6,17 @@ Author: Daniel Kroening \*******************************************************************/ +/// \file +/// A special command line object to mimick ARM's armcc + #include #include #include "armcc_cmdline.h" -/*******************************************************************\ - -Function: armcc_cmdlinet::parse - - Inputs: argument count, argument strings - - Outputs: none - - Purpose: parses the commandline options into a cmdlinet - -\*******************************************************************/ - +/// parses the commandline options into a cmdlinet +/// \par parameters: argument count, argument strings +/// \return none // see // http://infocenter.arm.com/help/topic/com.arm.doc.dui0472c/Cchbggjb.html @@ -316,7 +310,7 @@ bool armcc_cmdlinet::parse(int argc, const char **argv) else { // unrecognized option std::cout << "Warning: uninterpreted armcc option '" - << argv[i] << "'" << std::endl; + << argv[i] << "'\n"; } } diff --git a/src/goto-cc/armcc_cmdline.h b/src/goto-cc/armcc_cmdline.h index 3cb108b1791..f8996366395 100644 --- a/src/goto-cc/armcc_cmdline.h +++ b/src/goto-cc/armcc_cmdline.h @@ -8,6 +8,9 @@ Date: June 2006 \*******************************************************************/ +/// \file +/// A special command line object to mimick ARM's armcc + #ifndef CPROVER_GOTO_CC_ARMCC_CMDLINE_H #define CPROVER_GOTO_CC_ARMCC_CMDLINE_H diff --git a/src/goto-cc/armcc_mode.cpp b/src/goto-cc/armcc_mode.cpp index 9eb677f631d..65eebddb0c3 100644 --- a/src/goto-cc/armcc_mode.cpp +++ b/src/goto-cc/armcc_mode.cpp @@ -6,6 +6,9 @@ Author: CM Wintersteiger, 2006 \*******************************************************************/ +/// \file +/// Command line option container + #ifdef _WIN32 #define EX_OK 0 #define EX_USAGE 64 @@ -24,18 +27,7 @@ Author: CM Wintersteiger, 2006 #include "armcc_mode.h" #include "compile.h" -/*******************************************************************\ - -Function: armcc_modet::doit - - Inputs: - - Outputs: - - Purpose: does it. - -\*******************************************************************/ - +/// does it. int armcc_modet::doit() { if(cmdline.isset('?') || cmdline.isset("help")) @@ -46,7 +38,7 @@ int armcc_modet::doit() unsigned int verbosity=1; - compilet compiler(cmdline); + compilet compiler(cmdline, message_handler, cmdline.isset("diag_error=")); #if 0 bool act_as_ld= @@ -152,7 +144,7 @@ int armcc_modet::doit() it!=config.ansi_c.defines.end(); it++) { - std::cout << " " << (*it) << std::endl; + std::cout << " " << (*it) << '\n'; } std::cout << "Undefines:\n"; @@ -160,7 +152,7 @@ int armcc_modet::doit() it!=config.ansi_c.undefines.end(); it++) { - std::cout << " " << (*it) << std::endl; + std::cout << " " << (*it) << '\n'; } std::cout << "Preprocessor Options:\n"; @@ -168,7 +160,7 @@ int armcc_modet::doit() it!=config.ansi_c.preprocessor_options.end(); it++) { - std::cout << " " << (*it) << std::endl; + std::cout << " " << (*it) << '\n'; } std::cout << "Include Paths:\n"; @@ -176,7 +168,7 @@ int armcc_modet::doit() it!=config.ansi_c.include_paths.end(); it++) { - std::cout << " " << (*it) << std::endl; + std::cout << " " << (*it) << '\n'; } std::cout << "Library Paths:\n"; @@ -184,31 +176,20 @@ int armcc_modet::doit() it!=compiler.library_paths.end(); it++) { - std::cout << " " << (*it) << std::endl; + std::cout << " " << (*it) << '\n'; } std::cout << "Output file (object): " - << compiler.output_file_object << std::endl; + << compiler.output_file_object << '\n'; std::cout << "Output file (executable): " - << compiler.output_file_executable << std::endl; + << compiler.output_file_executable << '\n'; } // Parse input program, convert to goto program, write output return compiler.doit() ? EX_USAGE : EX_OK; } -/*******************************************************************\ - -Function: armcc_modet::help_mode - - Inputs: - - Outputs: - - Purpose: display command line help - -\*******************************************************************/ - +/// display command line help void armcc_modet::help_mode() { std::cout << "goto-armcc understands the options " diff --git a/src/goto-cc/armcc_mode.h b/src/goto-cc/armcc_mode.h index cbbe90a2a1e..d4b8c4779e9 100644 --- a/src/goto-cc/armcc_mode.h +++ b/src/goto-cc/armcc_mode.h @@ -8,6 +8,9 @@ Date: June 2006 \*******************************************************************/ +/// \file +/// Base class for command line interpretation for CL + #ifndef CPROVER_GOTO_CC_ARMCC_MODE_H #define CPROVER_GOTO_CC_ARMCC_MODE_H diff --git a/src/goto-cc/as86_cmdline.cpp b/src/goto-cc/as86_cmdline.cpp index 4d1210c2794..b319c177410 100644 --- a/src/goto-cc/as86_cmdline.cpp +++ b/src/goto-cc/as86_cmdline.cpp @@ -6,6 +6,9 @@ Author: Michael Tautschnig \*******************************************************************/ +/// \file +/// A special command line object for as86 (of Bruce's C Compiler) + #include #include @@ -13,18 +16,6 @@ Author: Michael Tautschnig #include "as86_cmdline.h" -/*******************************************************************\ - -Function: as86_cmdlinet::parse - - Inputs: argument count, argument strings - - Outputs: none - - Purpose: parses the commandline options into a cmdlinet - -\*******************************************************************/ - // non-as86 options const char *goto_as86_options_with_argument[]= { @@ -150,7 +141,7 @@ bool as86_cmdlinet::parse(int argc, const char **argv) { // unrecognized option std::cerr << "Warning: uninterpreted as86 option '" << argv_i - << "'" << std::endl; + << "'\n"; } } diff --git a/src/goto-cc/as86_cmdline.h b/src/goto-cc/as86_cmdline.h index 85f8d439cae..ac03786d585 100644 --- a/src/goto-cc/as86_cmdline.h +++ b/src/goto-cc/as86_cmdline.h @@ -8,6 +8,10 @@ Date: July 2016 \*******************************************************************/ +/// \file +/// A special command line object for as86 (of Bruce's C Compiler) Author: +/// Michael Tautschnig Date: July 2016 + #ifndef CPROVER_GOTO_CC_AS86_CMDLINE_H #define CPROVER_GOTO_CC_AS86_CMDLINE_H diff --git a/src/goto-cc/as_cmdline.cpp b/src/goto-cc/as_cmdline.cpp index 8a6f32c16b5..fd3fa17706c 100644 --- a/src/goto-cc/as_cmdline.cpp +++ b/src/goto-cc/as_cmdline.cpp @@ -6,6 +6,9 @@ Author: Michael Tautschnig \*******************************************************************/ +/// \file +/// A special command line object for GNU Assembler + #include #include @@ -13,18 +16,6 @@ Author: Michael Tautschnig #include "as_cmdline.h" -/*******************************************************************\ - -Function: as_cmdlinet::parse - - Inputs: argument count, argument strings - - Outputs: none - - Purpose: parses the commandline options into a cmdlinet - -\*******************************************************************/ - // non-as options const char *goto_as_options_with_argument[]= { @@ -206,7 +197,7 @@ bool as_cmdlinet::parse(int argc, const char **argv) { // unrecognized option std::cerr << "Warning: uninterpreted as option '" << argv_i - << "'" << std::endl; + << "'\n"; } } diff --git a/src/goto-cc/as_cmdline.h b/src/goto-cc/as_cmdline.h index 19dd7dc0be0..fbf26957815 100644 --- a/src/goto-cc/as_cmdline.h +++ b/src/goto-cc/as_cmdline.h @@ -8,6 +8,10 @@ Date: July 2016 \*******************************************************************/ +/// \file +/// A special command line object for GNU Assembler Author: Michael Tautschnig +/// Date: July 2016 + #ifndef CPROVER_GOTO_CC_AS_CMDLINE_H #define CPROVER_GOTO_CC_AS_CMDLINE_H diff --git a/src/goto-cc/as_mode.cpp b/src/goto-cc/as_mode.cpp index bb87b6c6abb..c36e755b471 100644 --- a/src/goto-cc/as_mode.cpp +++ b/src/goto-cc/as_mode.cpp @@ -6,6 +6,9 @@ Author: Michael Tautschnig \*******************************************************************/ +/// \file +/// Assembler Mode + #ifdef _WIN32 #define EX_OK 0 #define EX_USAGE 64 @@ -30,18 +33,6 @@ Author: Michael Tautschnig #include "as_mode.h" -/*******************************************************************\ - -Function: assembler_name - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static std::string assembler_name( const cmdlinet &cmdline, const std::string &base_name) @@ -64,18 +55,6 @@ static std::string assembler_name( return result; } -/*******************************************************************\ - -Function: as_modet::as_modet - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - as_modet::as_modet( goto_cc_cmdlinet &_cmdline, const std::string &_base_name, @@ -86,18 +65,7 @@ as_modet::as_modet( { } -/*******************************************************************\ - -Function: as_modet::doit - - Inputs: - - Outputs: - - Purpose: does it. - -\*******************************************************************/ - +/// does it. int as_modet::doit() { if(cmdline.isset('?') || @@ -159,8 +127,7 @@ int as_modet::doit() config.set(cmdline); // determine actions to be undertaken - compilet compiler(cmdline); - compiler.ui_message_handler.set_verbosity(verbosity); + compilet compiler(cmdline, message_handler, cmdline.isset("fatal-warnings")); if(cmdline.isset('b')) // as86 only { @@ -284,18 +251,7 @@ int as_modet::doit() return EX_OK; } -/*******************************************************************\ - -Function: as_modet::run_as - - Inputs: - - Outputs: - - Purpose: run as or as86 with original command line - -\*******************************************************************/ - +/// run as or as86 with original command line int as_modet::run_as() { assert(!cmdline.parsed_argv.empty()); @@ -313,24 +269,12 @@ int as_modet::run_as() std::cout << "RUN:"; for(std::size_t i=0; i #include @@ -13,18 +16,6 @@ Author: Michael Tautschnig #include "bcc_cmdline.h" -/*******************************************************************\ - -Function: bcc_cmdlinet::parse - - Inputs: argument count, argument strings - - Outputs: none - - Purpose: parses the commandline options into a cmdlinet - -\*******************************************************************/ - // non-bcc options const char *goto_bcc_options_with_argument[]= { @@ -162,7 +153,7 @@ bool bcc_cmdlinet::parse(int argc, const char **argv) { // unrecognized option std::cerr << "Warning: uninterpreted bcc option '" << argv_i - << "'" << std::endl; + << "'\n"; } } diff --git a/src/goto-cc/bcc_cmdline.h b/src/goto-cc/bcc_cmdline.h index 578001925da..18c402bd892 100644 --- a/src/goto-cc/bcc_cmdline.h +++ b/src/goto-cc/bcc_cmdline.h @@ -8,6 +8,10 @@ Date: July 2016 \*******************************************************************/ +/// \file +/// A special command line object for Bruce's C Compiler Author: Michael +/// Tautschnig Date: July 2016 + #ifndef CPROVER_GOTO_CC_BCC_CMDLINE_H #define CPROVER_GOTO_CC_BCC_CMDLINE_H diff --git a/src/goto-cc/compile.cpp b/src/goto-cc/compile.cpp index 58f74669c32..aa3256da590 100644 --- a/src/goto-cc/compile.cpp +++ b/src/goto-cc/compile.cpp @@ -8,6 +8,9 @@ Date: June 2006 \*******************************************************************/ +/// \file +/// Compile and link source and object files. + #include #include #include @@ -65,19 +68,9 @@ Date: June 2006 #define pclose _pclose #endif -/*******************************************************************\ - -Function: compilet::doit - - Inputs: none - - Outputs: true on error, false otherwise - - Purpose: reads and source and object files, compiles and links them - into goto program objects. - -\*******************************************************************/ - +/// reads and source and object files, compiles and links them into goto program +/// objects. +/// \return true on error, false otherwise bool compilet::doit() { compiled_functions.clear(); @@ -121,6 +114,9 @@ bool compilet::doit() return true; } + const unsigned warnings_before= + get_message_handler().get_message_count(messaget::M_WARNING); + if(source_files.size()>0) if(compile()) return true; @@ -133,22 +129,14 @@ bool compilet::doit() return true; } - return false; + return + warning_is_fatal && + get_message_handler().get_message_count(messaget::M_WARNING)!= + warnings_before; } -/*******************************************************************\ - -Function: compilet::add_input_file - - Inputs: none - - Outputs: false on success, true on error. - - Purpose: puts input file names into a list and does preprocessing for - libraries. - -\*******************************************************************/ - +/// puts input file names into a list and does preprocessing for libraries. +/// \return false on success, true on error. bool compilet::add_input_file(const std::string &file_name) { // first of all, try to open the file @@ -156,8 +144,8 @@ bool compilet::add_input_file(const std::string &file_name) std::ifstream in(file_name); if(!in) { - error() << "failed to open file `" << file_name << "'" << eom; - return false; // generously ignore + warning() << "failed to open file `" << file_name << "'" << eom; + return warning_is_fatal; // generously ignore unless -Werror } } @@ -168,7 +156,7 @@ bool compilet::add_input_file(const std::string &file_name) // a file without extension; will ignore warning() << "input file `" << file_name << "' has no extension, not considered" << eom; - return false; + return warning_is_fatal; } std::string ext = file_name.substr(r+1, file_name.length()); @@ -288,19 +276,9 @@ bool compilet::add_input_file(const std::string &file_name) return false; } -/*******************************************************************\ - -Function: compilet::find_library - - Inputs: library name - - Outputs: true if found, false otherwise - - Purpose: tries to find a library object file that matches the given - library name. - -\*******************************************************************/ - +/// tries to find a library object file that matches the given library name. +/// \par parameters: library name +/// \return true if found, false otherwise bool compilet::find_library(const std::string &name) { std::string tmp; @@ -329,7 +307,7 @@ bool compilet::find_library(const std::string &name) else if(is_elf_file(libname)) { warning() << "Warning: Cannot read ELF library " << libname << eom; - return false; + return warning_is_fatal; } } } @@ -337,19 +315,10 @@ bool compilet::find_library(const std::string &name) return false; } -/*******************************************************************\ - -Function: compilet::is_elf_file - - Inputs: file name - - Outputs: true if the given file name exists and is an ELF file, - false otherwise - - Purpose: checking if we can load an object file - -\*******************************************************************/ - +/// checking if we can load an object file +/// \par parameters: file name +/// \return true if the given file name exists and is an ELF file, false +/// otherwise bool compilet::is_elf_file(const std::string &file_name) { std::fstream in; @@ -368,22 +337,12 @@ bool compilet::is_elf_file(const std::string &file_name) return false; } -/*******************************************************************\ - -Function: compilet::link - - Inputs: none - - Outputs: true on error, false otherwise - - Purpose: parses object files and links them - -\*******************************************************************/ - +/// parses object files and links them +/// \return true on error, false otherwise bool compilet::link() { // "compile" hitherto uncompiled functions - print(8, "Compiling functions"); + statistics() << "Compiling functions" << eom; convert_symbols(compiled_functions); // parse object files @@ -409,7 +368,7 @@ bool compilet::link() symbol_table.remove(goto_functionst::entry_point()); compiled_functions.function_map.erase(goto_functionst::entry_point()); - if(ansi_c_entry_point(symbol_table, "main", ui_message_handler)) + if(ansi_c_entry_point(symbol_table, "main", get_message_handler())) return true; // entry_point may (should) add some more functions. @@ -423,19 +382,9 @@ bool compilet::link() return false; } -/*******************************************************************\ - -Function: compilet::compile - - Inputs: none - - Outputs: true on error, false otherwise - - Purpose: parses source files and writes object files, or keeps the - symbols in the symbol_table depending on the doLink flag. - -\*******************************************************************/ - +/// parses source files and writes object files, or keeps the symbols in the +/// symbol_table depending on the doLink flag. +/// \return true on error, false otherwise bool compilet::compile() { while(!source_files.empty()) @@ -489,18 +438,8 @@ bool compilet::compile() return false; } -/*******************************************************************\ - -Function: compilet::parse - - Inputs: file_name - - Outputs: true on error, false otherwise - - Purpose: parses a source file (low-level parsing) - -\*******************************************************************/ - +/// parses a source file (low-level parsing) +/// \return true on error, false otherwise bool compilet::parse(const std::string &file_name) { if(file_name=="-") @@ -554,7 +493,7 @@ bool compilet::parse(const std::string &file_name) if(mode==PREPROCESS_ONLY) { - print(8, "Preprocessing: "+file_name); + statistics() << "Preprocessing: " << file_name << eom; std::ostream *os = &std::cout; std::ofstream ofs; @@ -576,7 +515,7 @@ bool compilet::parse(const std::string &file_name) } else { - print(8, "Parsing: "+file_name); + statistics() << "Parsing: " << file_name << eom; if(language.parse(infile, file_name)) { @@ -590,25 +529,15 @@ bool compilet::parse(const std::string &file_name) return false; } -/*******************************************************************\ - -Function: compilet::parse_stdin - - Inputs: file_name - - Outputs: true on error, false otherwise - - Purpose: parses a source file (low-level parsing) - -\*******************************************************************/ - +/// parses a source file (low-level parsing) +/// \return true on error, false otherwise bool compilet::parse_stdin() { ansi_c_languaget language; language.set_message_handler(get_message_handler()); - print(8, "Parsing: (stdin)"); + statistics() << "Parsing: (stdin)" << eom; if(mode==PREPROCESS_ONLY) { @@ -643,19 +572,10 @@ bool compilet::parse_stdin() return false; } -/*******************************************************************\ - -Function: compilet::write_object_file - - Inputs: file_name, functions table - - Outputs: true on error, false otherwise - - Purpose: writes the goto functions in the function table to a - binary format object file. - -\*******************************************************************/ - +/// writes the goto functions in the function table to a binary format object +/// file. +/// \par parameters: file_name, functions table +/// \return true on error, false otherwise bool compilet::write_object_file( const std::string &file_name, const symbol_tablet &lsymbol_table, @@ -664,19 +584,10 @@ bool compilet::write_object_file( return write_bin_object_file(file_name, lsymbol_table, functions); } -/*******************************************************************\ - -Function: compilet::write_bin_object_file - - Inputs: file_name, functions table - - Outputs: true on error, false otherwise - - Purpose: writes the goto functions in the function table to a - binary format object file. - -\*******************************************************************/ - +/// writes the goto functions in the function table to a binary format object +/// file. +/// \par parameters: file_name, functions table +/// \return true on error, false otherwise bool compilet::write_bin_object_file( const std::string &file_name, const symbol_tablet &lsymbol_table, @@ -710,18 +621,8 @@ bool compilet::write_bin_object_file( return false; } -/*******************************************************************\ - -Function: compilet::parse_source - - Inputs: file_name - - Outputs: true on error, false otherwise - - Purpose: parses a source file - -\*******************************************************************/ - +/// parses a source file +/// \return true on error, false otherwise bool compilet::parse_source(const std::string &file_name) { if(parse(file_name)) @@ -740,41 +641,21 @@ bool compilet::parse_source(const std::string &file_name) return false; } -/*******************************************************************\ - -Function: compilet::compilet - - Inputs: none - - Outputs: nothing - - Purpose: constructor - -\*******************************************************************/ - -compilet::compilet(cmdlinet &_cmdline): - language_uit(_cmdline, ui_message_handler), - ui_message_handler(_cmdline, "goto-cc " CBMC_VERSION), +/// constructor +/// \return nothing +compilet::compilet(cmdlinet &_cmdline, ui_message_handlert &mh, bool Werror): + language_uit(_cmdline, mh), ns(symbol_table), - cmdline(_cmdline) + cmdline(_cmdline), + warning_is_fatal(Werror) { mode=COMPILE_LINK_EXECUTABLE; echo_file_name=false; working_directory=get_current_working_directory(); } -/*******************************************************************\ - -Function: compilet::~compilet - - Inputs: none - - Outputs: nothing - - Purpose: cleans up temporary files - -\*******************************************************************/ - +/// cleans up temporary files +/// \return nothing compilet::~compilet() { // clean up temp dirs @@ -785,18 +666,6 @@ compilet::~compilet() delete_directory(*it); } -/*******************************************************************\ - -Function: compilet::function_body_count - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - unsigned compilet::function_body_count(const goto_functionst &functions) { int fbs=0; @@ -811,38 +680,14 @@ unsigned compilet::function_body_count(const goto_functionst &functions) return fbs; } -/*******************************************************************\ - -Function: compilet::add_compiler_specific_defines - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void compilet::add_compiler_specific_defines(configt &config) const { config.ansi_c.defines.push_back("__GOTO_CC_VERSION__=" CBMC_VERSION); } -/*******************************************************************\ - -Function: compilet::convert_symbols - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void compilet::convert_symbols(goto_functionst &dest) { - goto_convert_functionst converter(symbol_table, dest, ui_message_handler); + goto_convert_functionst converter(symbol_table, dest, get_message_handler()); // the compilation may add symbols! @@ -872,7 +717,7 @@ void compilet::convert_symbols(goto_functionst &dest) s_it->second.value.id()!="compiled" && s_it->second.value.is_not_nil()) { - print(9, "Compiling "+id2string(s_it->first)); + debug() << "Compiling " << s_it->first << eom; converter.convert_function(s_it->first); s_it->second.value=exprt("compiled"); } diff --git a/src/goto-cc/compile.h b/src/goto-cc/compile.h index 936f4cd21d5..d0a521769c1 100644 --- a/src/goto-cc/compile.h +++ b/src/goto-cc/compile.h @@ -8,6 +8,9 @@ Date: June 2006 \*******************************************************************/ +/// \file +/// Compile and link source and object files. + #ifndef CPROVER_GOTO_CC_COMPILE_H #define CPROVER_GOTO_CC_COMPILE_H @@ -20,7 +23,6 @@ Date: June 2006 class compilet:public language_uit { public: - ui_message_handlert ui_message_handler; namespacet ns; goto_functionst compiled_functions; bool echo_file_name; @@ -45,7 +47,7 @@ class compilet:public language_uit std::string object_file_extension; std::string output_file_object, output_file_executable; - explicit compilet(cmdlinet &_cmdline); + compilet(cmdlinet &_cmdline, ui_message_handlert &mh, bool Werror); ~compilet(); @@ -72,6 +74,7 @@ class compilet:public language_uit protected: cmdlinet &cmdline; + bool warning_is_fatal; unsigned function_body_count(const goto_functionst &); diff --git a/src/goto-cc/cw_mode.cpp b/src/goto-cc/cw_mode.cpp index 18f1bf60494..46746ae529e 100644 --- a/src/goto-cc/cw_mode.cpp +++ b/src/goto-cc/cw_mode.cpp @@ -6,6 +6,9 @@ Author: CM Wintersteiger, 2006 \*******************************************************************/ +/// \file +/// Command line option container + #ifdef _WIN32 #define EX_OK 0 #define EX_USAGE 64 @@ -24,18 +27,7 @@ Author: CM Wintersteiger, 2006 #include "cw_mode.h" #include "compile.h" -/*******************************************************************\ - -Function: cw_modet::doit - - Inputs: - - Outputs: - - Purpose: does it. - -\*******************************************************************/ - +/// does it. int cw_modet::doit() { if(cmdline.isset('?') || cmdline.isset("help")) @@ -46,7 +38,7 @@ int cw_modet::doit() unsigned int verbosity=1; - compilet compiler(cmdline); + compilet compiler(cmdline, message_handler, cmdline.isset("Werror")); #if 0 bool act_as_ld= @@ -141,7 +133,7 @@ int cw_modet::doit() it!=config.ansi_c.defines.end(); it++) { - std::cout << " " << (*it) << std::endl; + std::cout << " " << (*it) << '\n'; } std::cout << "Undefines:\n"; @@ -149,7 +141,7 @@ int cw_modet::doit() it!=config.ansi_c.undefines.end(); it++) { - std::cout << " " << (*it) << std::endl; + std::cout << " " << (*it) << '\n'; } std::cout << "Preprocessor Options:\n"; @@ -157,7 +149,7 @@ int cw_modet::doit() it!=config.ansi_c.preprocessor_options.end(); it++) { - std::cout << " " << (*it) << std::endl; + std::cout << " " << (*it) << '\n'; } std::cout << "Include Paths:\n"; @@ -165,7 +157,7 @@ int cw_modet::doit() it!=config.ansi_c.include_paths.end(); it++) { - std::cout << " " << (*it) << std::endl; + std::cout << " " << (*it) << '\n'; } std::cout << "Library Paths:\n"; @@ -173,31 +165,20 @@ int cw_modet::doit() it!=compiler.library_paths.end(); it++) { - std::cout << " " << (*it) << std::endl; + std::cout << " " << (*it) << '\n'; } std::cout << "Output file (object): " - << compiler.output_file_object << std::endl; + << compiler.output_file_object << '\n'; std::cout << "Output file (executable): " - << compiler.output_file_executable << std::endl; + << compiler.output_file_executable << '\n'; } // Parse input program, convert to goto program, write output return compiler.doit() ? EX_USAGE : EX_OK; } -/*******************************************************************\ - -Function: cw_modet::help_mode - - Inputs: - - Outputs: - - Purpose: display command line help - -\*******************************************************************/ - +/// display command line help void cw_modet::help_mode() { std::cout << "goto-cw understands the options of " diff --git a/src/goto-cc/cw_mode.h b/src/goto-cc/cw_mode.h index 865b1f7ea15..58bd7129fc1 100644 --- a/src/goto-cc/cw_mode.h +++ b/src/goto-cc/cw_mode.h @@ -8,6 +8,9 @@ Date: June 2006 \*******************************************************************/ +/// \file +/// Base class for command line interpretation + #ifndef CPROVER_GOTO_CC_CW_MODE_H #define CPROVER_GOTO_CC_CW_MODE_H diff --git a/src/goto-cc/gcc_cmdline.cpp b/src/goto-cc/gcc_cmdline.cpp index f9bd0d1ead4..a45498b1304 100644 --- a/src/goto-cc/gcc_cmdline.cpp +++ b/src/goto-cc/gcc_cmdline.cpp @@ -6,6 +6,9 @@ Author: CM Wintersteiger, 2006 \*******************************************************************/ +/// \file +/// A special command line object for the gcc-like options + #include #include #include @@ -15,18 +18,9 @@ Author: CM Wintersteiger, 2006 #include "gcc_cmdline.h" -/*******************************************************************\ - -Function: gcc_cmdlinet::parse - - Inputs: argument count, argument strings - - Outputs: none - - Purpose: parses the commandline options into a cmdlinet - -\*******************************************************************/ - +/// parses the commandline options into a cmdlinet +/// \par parameters: argument count, argument strings +/// \return none // non-gcc options const char *goto_cc_options_with_separated_argument[]= { @@ -96,6 +90,9 @@ const char *gcc_options_with_separated_argument[]= "-isysroot", "-imultilib", "-imultiarch", + "-mcpu", + "-mtune", + "-march", "-Xpreprocessor", "-Xassembler", "-Xlinker", @@ -188,6 +185,9 @@ const char *gcc_options_without_argument[]= "-MP", "-MD", "-MMD", + "-mno-unaligned-access", + "-mthumb", + "-mthumb-interwork", "-nostdinc", "-P", "-remap", @@ -230,18 +230,6 @@ bool gcc_cmdlinet::parse(int argc, const char **argv) return result; } -/*******************************************************************\ - -Function: gcc_cmdlinet::parse_arguments - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool gcc_cmdlinet::parse_arguments( const argst &args, bool in_spec_file) @@ -431,7 +419,7 @@ bool gcc_cmdlinet::parse_arguments( { // unrecognized option std::cerr << "Warning: uninterpreted gcc option '" << argv_i - << "'" << std::endl; + << "'\n"; } } } @@ -439,19 +427,7 @@ bool gcc_cmdlinet::parse_arguments( return false; } -/*******************************************************************\ - -Function: gcc_cmdlinet::parse_specs_line - - Inputs: - - Outputs: - - Purpose: Parse GCC spec files - https://gcc.gnu.org/onlinedocs/gcc/Spec-Files.html - -\*******************************************************************/ - +/// Parse GCC spec files https://gcc.gnu.org/onlinedocs/gcc/Spec-Files.html void gcc_cmdlinet::parse_specs_line(const std::string &line) { // initial whitespace has been stripped @@ -471,19 +447,7 @@ void gcc_cmdlinet::parse_specs_line(const std::string &line) parse_arguments(args, true); } -/*******************************************************************\ - -Function: gcc_cmdlinet::parse_specs - - Inputs: - - Outputs: - - Purpose: Parse GCC spec files - https://gcc.gnu.org/onlinedocs/gcc/Spec-Files.html - -\*******************************************************************/ - +/// Parse GCC spec files https://gcc.gnu.org/onlinedocs/gcc/Spec-Files.html void gcc_cmdlinet::parse_specs() { const std::string &specs_file_name=get_value("specs"); diff --git a/src/goto-cc/gcc_cmdline.h b/src/goto-cc/gcc_cmdline.h index 2e233f032c5..92ac348118c 100644 --- a/src/goto-cc/gcc_cmdline.h +++ b/src/goto-cc/gcc_cmdline.h @@ -8,6 +8,9 @@ Date: June 2006 \*******************************************************************/ +/// \file +/// A special command line object for the gcc-like options + #ifndef CPROVER_GOTO_CC_GCC_CMDLINE_H #define CPROVER_GOTO_CC_GCC_CMDLINE_H diff --git a/src/goto-cc/gcc_mode.cpp b/src/goto-cc/gcc_mode.cpp index 19444ef1fc5..ce2fa4405ec 100644 --- a/src/goto-cc/gcc_mode.cpp +++ b/src/goto-cc/gcc_mode.cpp @@ -6,6 +6,9 @@ Author: CM Wintersteiger, 2006 \*******************************************************************/ +/// \file +/// GCC Mode + #ifdef _WIN32 #define EX_OK 0 #define EX_USAGE 64 @@ -31,18 +34,6 @@ Author: CM Wintersteiger, 2006 #include "compile.h" #include "gcc_mode.h" -/*******************************************************************\ - -Function: compiler_name - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static std::string compiler_name( const cmdlinet &cmdline, const std::string &base_name) @@ -73,18 +64,6 @@ static std::string compiler_name( return result; } -/*******************************************************************\ - -Function: linker_name - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static std::string linker_name( const cmdlinet &cmdline, const std::string &base_name) @@ -105,18 +84,6 @@ static std::string linker_name( return result; } -/*******************************************************************\ - -Function: gcc_modet::gcc_modet - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - gcc_modet::gcc_modet( goto_cc_cmdlinet &_cmdline, const std::string &_base_name, @@ -124,22 +91,145 @@ gcc_modet::gcc_modet( goto_cc_modet(_cmdline, _base_name, gcc_message_handler), produce_hybrid_binary(_produce_hybrid_binary), act_as_ld(base_name=="ld" || - base_name.find("goto-ld")!=std::string::npos) + base_name.find("goto-ld")!=std::string::npos), + + // Keys are architectures specified in configt::set_arch(). + // Values are lists of GCC architectures that can be supplied as + // arguments to the -march, -mcpu, and -mtune flags (see the GCC + // manual https://gcc.gnu.org/onlinedocs/). + arch_map( + { + // ARM information taken from the following: + // + // the "ARM core timeline" table on this page: + // https://en.wikipedia.org/wiki/List_of_ARM_microarchitectures + // + // articles on particular core groups, e.g. + // https://en.wikipedia.org/wiki/ARM9 + // + // The "Cores" table on this page: + // https://en.wikipedia.org/wiki/ARM_architecture + // NOLINTNEXTLINE(whitespace/braces) + {"arm", { + "strongarm", "strongarm110", "strongarm1100", "strongarm1110", + "arm2", "arm250", "arm3", "arm6", "arm60", "arm600", "arm610", + "arm620", "fa526", "fa626", "fa606te", "fa626te", "fmp626", + "xscale", "iwmmxt", "iwmmxt2", "xgene1" + }}, // NOLINTNEXTLINE(whitespace/braces) + {"armhf", { + "armv7", "arm7m", "arm7d", "arm7dm", "arm7di", "arm7dmi", + "arm70", "arm700", "arm700i", "arm710", "arm710c", "arm7100", + "arm720", "arm7500", "arm7500fe", "arm7tdmi", "arm7tdmi-s", + "arm710t", "arm720t", "arm740t", "mpcore", "mpcorenovfp", + "arm8", "arm810", "arm9", "arm9e", "arm920", "arm920t", + "arm922t", "arm946e-s", "arm966e-s", "arm968e-s", "arm926ej-s", + "arm940t", "arm9tdmi", "arm10tdmi", "arm1020t", "arm1026ej-s", + "arm10e", "arm1020e", "arm1022e", "arm1136j-s", "arm1136jf-s", + "arm1156t2-s", "arm1156t2f-s", "arm1176jz-s", "arm1176jzf-s", + "cortex-a5", "cortex-a7", "cortex-a8", "cortex-a9", + "cortex-a12", "cortex-a15", "cortex-a53", "cortex-r4", + "cortex-r4f", "cortex-r5", "cortex-r7", "cortex-m7", + "cortex-m4", "cortex-m3", "cortex-m1", "cortex-m0", + "cortex-m0plus", "cortex-m1.small-multiply", + "cortex-m0.small-multiply", "cortex-m0plus.small-multiply", + "marvell-pj4", "ep9312", "fa726te", + }}, // NOLINTNEXTLINE(whitespace/braces) + {"arm64", { + "cortex-a57", "cortex-a72", "exynos-m1" + }}, + // There are two MIPS architecture series. The 'old' one comprises + // MIPS I - MIPS V (where MIPS I and MIPS II are 32-bit + // architectures, and the III, IV and V are 64-bit). The 'new' + // architecture series comprises MIPS32 and MIPS64. Source: [0]. + // + // CPROVER's names for these are in configt::this_architecture(), + // in particular note the preprocessor variable names. MIPS + // processors can run in little-endian or big-endian mode; [1] + // gives more information on particular processors. Particular + // processors and their architectures are at [2]. This means that + // we cannot use the processor flags alone to decide which CPROVER + // name to use; we also need to check for the -EB or -EL flags to + // decide whether little- or big-endian code should be generated. + // Therefore, the keys in this part of the map don't directly map + // to CPROVER architectures. + // + // [0] https://en.wikipedia.org/wiki/MIPS_architecture + // [1] https://www.debian.org/ports/mips/ + // [2] https://en.wikipedia.org/wiki/List_of_MIPS_architecture_processors + // NOLINTNEXTLINE(whitespace/braces) + {"mips64n", { + "loongson2e", "loongson2f", "loongson3a", "mips64", "mips64r2", + "mips64r3", "mips64r5", "mips64r6 4kc", "5kc", "5kf", "20kc", + "octeon", "octeon+", "octeon2", "octeon3", "sb1", "vr4100", + "vr4111", "vr4120", "vr4130", "vr4300", "vr5000", "vr5400", + "vr5500", "sr71000", "xlp", + }}, // NOLINTNEXTLINE(whitespace/braces) + {"mips32n", { + "mips32", "mips32r2", "mips32r3", "mips32r5", "mips32r6", + // https://www.imgtec.com/mips/classic/ + "4km", "4kp", "4ksc", "4kec", "4kem", "4kep", "4ksd", "24kc", + "24kf2_1", "24kf1_1", "24kec", "24kef2_1", "24kef1_1", "34kc", + "34kf2_1", "34kf1_1", "34kn", "74kc", "74kf2_1", "74kf1_1", + "74kf3_2", "1004kc", "1004kf2_1", "1004kf1_1", "m4k", "m14k", + "m14kc", "m14ke", "m14kec", + // https://en.wikipedia.org/wiki/List_of_MIPS_architecture_processors + "p5600", "xlr", + }}, // NOLINTNEXTLINE(whitespace/braces) + {"mips32o", { + "mips1", "mips2", "r2000", "r3000", + "r6000", // Not a mistake, r4000 came out _after_ this + }}, // NOLINTNEXTLINE(whitespace/braces) + {"mips64o", { + "mips3", "mips4", "r4000", "r4400", "r4600", "r4650", "r4700", + "r8000", "rm7000", "rm9000", "r10000", "r12000", "r14000", + "r16000", + }}, + // These are IBM mainframes. s390 is 32-bit; s390x is 64-bit [0]. + // Search that page for s390x and note that 32-bit refers to + // everything "prior to 2000's z900 model". The list of model + // numbers is at [1]. + // [0] https://en.wikipedia.org/wiki/Linux_on_z_Systems + // [1] https://en.wikipedia.org/wiki/IBM_System_z + // NOLINTNEXTLINE(whitespace/braces) + {"s390", { + "z900", "z990", "g5", "g6", + }}, // NOLINTNEXTLINE(whitespace/braces) + {"s390x", { + "z9-109", "z9-ec", "z10", "z196", "zEC12", "z13" + }}, + // SPARC + // In the "Implementations" table of [0], everything with an arch + // version up to V8 is 32-bit. V9 and onward are 64-bit. + // [0] https://en.wikipedia.org/wiki/SPARC + // NOLINTNEXTLINE(whitespace/braces) + {"sparc", { + "v7", "v8", "leon", "leon3", "leon3v7", "cypress", "supersparc", + "hypersparc", "sparclite", "f930", "f934", "sparclite86x", + "tsc701", + }}, // NOLINTNEXTLINE(whitespace/braces) + {"sparc64", { + "v9", "ultrasparc", "ultrasparc3", "niagara", "niagara2", + "niagara3", "niagara4", + }}, // NOLINTNEXTLINE(whitespace/braces) + {"ia64", { + "itanium", "itanium1", "merced", "itanium2", "mckinley" + }}, // NOLINTNEXTLINE(whitespace/braces) + {"i386", { + "i386", "i486", "i586", "pentium", "pentium-mmx", "pentiumpro", + "i686", "pentium2", "pentium3", "pentium3m", "pentium-m", + "pentium4", "pentium4m", "prescott", "nocona", "core2", "nehalem", + "westmere", "sandybridge", "ivybridge", "haswell", "broadwell", + "bonnell", "silvermont", "k6", "k6-2", "k6-3", "athlon", + "athlon-tbird", "athlon-4", "athlon-xp", "athlon-mp", "k8", + "opteron", "athlon64", "athlon-fx", "k8-sse3", "opteron-sse3", + "athlon64-sse3", "amdfam10", "barcelona", "bdver1", "bdver2", + "bdver3", "bdver4", "btver1", "btver2", "winchip-c6", "winchip2", + "c3", "c3-2", "geode", + }}, + }) { } -/*******************************************************************\ - -Function: gcc_modet::needs_preprocessing - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool gcc_modet::needs_preprocessing(const std::string &file) { if(has_suffix(file, ".c") || @@ -154,18 +244,7 @@ bool gcc_modet::needs_preprocessing(const std::string &file) return false; } -/*******************************************************************\ - -Function: gcc_modet::doit - - Inputs: - - Outputs: - - Purpose: does it. - -\*******************************************************************/ - +/// does it. int gcc_modet::doit() { if(cmdline.isset('?') || @@ -214,11 +293,11 @@ int gcc_modet::doit() if(cmdline.isset("dumpversion")) { - std::cout << "3.4.4" << std::endl; + std::cout << "3.4.4\n"; return EX_OK; } - if(cmdline.isset("Wall")) + if(cmdline.isset("Wall") || cmdline.isset("Wextra")) verbosity=2; if(cmdline.isset("verbosity")) @@ -286,6 +365,51 @@ int gcc_modet::doit() else if(cmdline.isset("little-endian") || cmdline.isset("mlittle")) config.ansi_c.endianness=configt::ansi_ct::endiannesst::IS_LITTLE_ENDIAN; + if(cmdline.isset("mthumb") || cmdline.isset("mthumb-interwork")) + config.ansi_c.set_arch_spec_arm("armhf"); + + // -mcpu sets both the arch and tune, but should only be used if + // neither -march nor -mtune are passed on the command line. + std::string target_cpu= + cmdline.isset("march") ? cmdline.get_value("march") : + cmdline.isset("mtune") ? cmdline.get_value("mtune") : + cmdline.isset("mcpu") ? cmdline.get_value("mcpu") : ""; + + if(target_cpu!="") + { + // Work out what CPROVER architecture we should target. + for(auto &pair : arch_map) + for(auto &processor : pair.second) + if(processor==target_cpu) + { + if(pair.first.find("mips")==std::string::npos) + config.set_arch(pair.first); + else + { + // Targeting a MIPS processor. MIPS is special; we also need + // to know the endianness. -EB (big-endian) is the default. + if(cmdline.isset("EL")) + { + if(pair.first=="mips32o") + config.set_arch("mipsel"); + else if(pair.first=="mips32n") + config.set_arch("mipsn32el"); + else + config.set_arch("mips64el"); + } + else + { + if(pair.first=="mips32o") + config.set_arch("mips"); + else if(pair.first=="mips32n") + config.set_arch("mipsn32"); + else + config.set_arch("mips64"); + } + } + } + } + // -fshort-wchar makes wchar_t "short unsigned int" if(cmdline.isset("fshort-wchar")) { @@ -303,8 +427,11 @@ int gcc_modet::doit() config.ansi_c.double_width=config.ansi_c.single_width; // determine actions to be undertaken - compilet compiler(cmdline); - compiler.set_message_handler(get_message_handler()); + compilet compiler(cmdline, + gcc_message_handler, + cmdline.isset("Werror") && + cmdline.isset("Wextra") && + !cmdline.isset("Wno-error")); if(act_as_ld) compiler.mode=compilet::LINK_LIBRARY; @@ -523,18 +650,7 @@ int gcc_modet::doit() return EX_OK; } -/*******************************************************************\ - -Function: gcc_modet::preprocess - - Inputs: - - Outputs: - - Purpose: call gcc for preprocessing - -\*******************************************************************/ - +/// call gcc for preprocessing int gcc_modet::preprocess( const std::string &language, const std::string &src, @@ -609,24 +725,13 @@ int gcc_modet::preprocess( std::cout << "RUN:"; for(std::size_t i=0; i &preprocessed_source_files) @@ -897,18 +978,7 @@ int gcc_modet::asm_output( return EX_OK; } -/*******************************************************************\ - -Function: gcc_modet::help_mode - - Inputs: - - Outputs: - - Purpose: display command line help - -\*******************************************************************/ - +/// display command line help void gcc_modet::help_mode() { if(act_as_ld) diff --git a/src/goto-cc/gcc_mode.h b/src/goto-cc/gcc_mode.h index b37b87448d6..cd4f1cb1a56 100644 --- a/src/goto-cc/gcc_mode.h +++ b/src/goto-cc/gcc_mode.h @@ -8,6 +8,9 @@ Date: June 2006 \*******************************************************************/ +/// \file +/// Base class for command line interpretation + #ifndef CPROVER_GOTO_CC_GCC_MODE_H #define CPROVER_GOTO_CC_GCC_MODE_H @@ -34,6 +37,8 @@ class gcc_modet:public goto_cc_modet const bool act_as_ld; std::string native_tool_name; + const std::map> arch_map; + int preprocess( const std::string &language, const std::string &src, diff --git a/src/goto-cc/goto_cc_cmdline.cpp b/src/goto-cc/goto_cc_cmdline.cpp index 7b3bc78cdda..a9090012ad1 100644 --- a/src/goto-cc/goto_cc_cmdline.cpp +++ b/src/goto-cc/goto_cc_cmdline.cpp @@ -8,6 +8,9 @@ Date: April 2010 \*******************************************************************/ +/// \file +/// Command line interpretation for goto-cc + #include #include #include @@ -18,36 +21,12 @@ Date: April 2010 #include "goto_cc_cmdline.h" -/*******************************************************************\ - -Function: goto_cc_cmdlinet::~goto_cc_cmdlinet - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - goto_cc_cmdlinet::~goto_cc_cmdlinet() { if(!stdin_file.empty()) remove(stdin_file.c_str()); } -/*******************************************************************\ - -Function: goto_cc_cmdlinet::in_list - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool goto_cc_cmdlinet::in_list(const char *option, const char **list) { for(std::size_t i=0; list[i]!=NULL; i++) @@ -59,18 +38,6 @@ bool goto_cc_cmdlinet::in_list(const char *option, const char **list) return false; } -/*******************************************************************\ - -Function: goto_cc_cmdlinet::prefix_in_list - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool goto_cc_cmdlinet::prefix_in_list( const char *option, const char **list, @@ -88,18 +55,6 @@ bool goto_cc_cmdlinet::prefix_in_list( return false; } -/*******************************************************************\ - -Function: goto_cc_cmdlinet::get_optnr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::size_t goto_cc_cmdlinet::get_optnr(const std::string &opt_string) { int optnr; @@ -153,18 +108,6 @@ std::size_t goto_cc_cmdlinet::get_optnr(const std::string &opt_string) return optnr; } -/*******************************************************************\ - -Function: goto_cc_cmdlinet::add_infile_arg - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_cc_cmdlinet::add_infile_arg(const std::string &arg) { parsed_argv.push_back(argt(arg)); diff --git a/src/goto-cc/goto_cc_cmdline.h b/src/goto-cc/goto_cc_cmdline.h index d3608400f30..f699946da68 100644 --- a/src/goto-cc/goto_cc_cmdline.h +++ b/src/goto-cc/goto_cc_cmdline.h @@ -8,6 +8,9 @@ Date: April 2010 \*******************************************************************/ +/// \file +/// Command line interpretation for goto-cc + #ifndef CPROVER_GOTO_CC_GOTO_CC_CMDLINE_H #define CPROVER_GOTO_CC_GOTO_CC_CMDLINE_H diff --git a/src/goto-cc/goto_cc_languages.cpp b/src/goto-cc/goto_cc_languages.cpp index a8bf5d9a07e..0c076187ee7 100644 --- a/src/goto-cc/goto_cc_languages.cpp +++ b/src/goto-cc/goto_cc_languages.cpp @@ -6,6 +6,9 @@ Author: CM Wintersteiger \*******************************************************************/ +/// \file +/// Language Registration + #include #include @@ -19,18 +22,6 @@ Author: CM Wintersteiger #include "goto_cc_mode.h" -/*******************************************************************\ - -Function: goto_cc_modet::register_languages - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_cc_modet::register_languages() { register_language(new_ansi_c_language); diff --git a/src/goto-cc/goto_cc_main.cpp b/src/goto-cc/goto_cc_main.cpp index 8c42b4fee4d..ebe885a37a3 100644 --- a/src/goto-cc/goto_cc_main.cpp +++ b/src/goto-cc/goto_cc_main.cpp @@ -8,6 +8,9 @@ Date: May 2006 \*******************************************************************/ +/// \file +/// GOTO-CC Main Module + #include #include @@ -28,18 +31,6 @@ Date: May 2006 #include "armcc_mode.h" #include "as_mode.h" -/*******************************************************************\ - -Function: to_lower_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string to_lower_string(const std::string &s) { std::string result=s; @@ -47,18 +38,6 @@ std::string to_lower_string(const std::string &s) return result; } -/*******************************************************************\ - -Function: main - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - #ifdef _MSC_VER int wmain(int argc, const wchar_t **argv_wide) #else @@ -71,7 +50,7 @@ int main(int argc, const char **argv) if(argv==NULL || argc<1) { - std::cerr << "failed to determine base name" << std::endl; + std::cerr << "failed to determine base name\n"; return 1; } diff --git a/src/goto-cc/goto_cc_mode.cpp b/src/goto-cc/goto_cc_mode.cpp index a0e363ad112..8822122d022 100644 --- a/src/goto-cc/goto_cc_mode.cpp +++ b/src/goto-cc/goto_cc_mode.cpp @@ -6,6 +6,9 @@ Author: CM Wintersteiger, 2006 \*******************************************************************/ +/// \file +/// Command line option container + #include #include @@ -21,18 +24,7 @@ Author: CM Wintersteiger, 2006 #include "goto_cc_mode.h" -/*******************************************************************\ - -Function: goto_cc_modet::goto_cc_modet - - Inputs: - - Outputs: - - Purpose: constructor - -\*******************************************************************/ - +/// constructor goto_cc_modet::goto_cc_modet( goto_cc_cmdlinet &_cmdline, const std::string &_base_name, @@ -44,34 +36,12 @@ goto_cc_modet::goto_cc_modet( register_languages(); } -/*******************************************************************\ - -Function: goto_cc_modet::~goto_cc_modet - - Inputs: - - Outputs: - - Purpose: constructor - -\*******************************************************************/ - +/// constructor goto_cc_modet::~goto_cc_modet() { } -/*******************************************************************\ - -Function: goto_cc_modet::help - - Inputs: - - Outputs: - - Purpose: display command line help - -\*******************************************************************/ - +/// display command line help void goto_cc_modet::help() { std::cout << @@ -97,18 +67,8 @@ void goto_cc_modet::help() "\n"; } -/*******************************************************************\ - -Function: goto_cc_modet::main - - Inputs: argc/argv - - Outputs: error code - - Purpose: starts the compiler - -\*******************************************************************/ - +/// starts the compiler +/// \return error code int goto_cc_modet::main(int argc, const char **argv) { if(cmdline.parse(argc, argv)) @@ -146,18 +106,8 @@ int goto_cc_modet::main(int argc, const char **argv) } } -/*******************************************************************\ - -Function: goto_cc_modet::usage_error - - Inputs: none - - Outputs: none - - Purpose: prints a message informing the user about incorrect options - -\*******************************************************************/ - +/// prints a message informing the user about incorrect options +/// \return none void goto_cc_modet::usage_error() { std::cerr << "Usage error!\n\n"; diff --git a/src/goto-cc/goto_cc_mode.h b/src/goto-cc/goto_cc_mode.h index d25fbb750b5..a0b6ea47a96 100644 --- a/src/goto-cc/goto_cc_mode.h +++ b/src/goto-cc/goto_cc_mode.h @@ -8,6 +8,9 @@ Date: June 2006 \*******************************************************************/ +/// \file +/// Command line interpretation for goto-cc. + #ifndef CPROVER_GOTO_CC_GOTO_CC_MODE_H #define CPROVER_GOTO_CC_GOTO_CC_MODE_H diff --git a/src/goto-cc/ld_cmdline.cpp b/src/goto-cc/ld_cmdline.cpp index 242c1245941..eb6c43af14a 100644 --- a/src/goto-cc/ld_cmdline.cpp +++ b/src/goto-cc/ld_cmdline.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, 2013 \*******************************************************************/ +/// \file +/// A special command line object for the ld-like options + #include #include @@ -13,18 +16,9 @@ Author: Daniel Kroening, 2013 #include "ld_cmdline.h" -/*******************************************************************\ - -Function: ld_cmdlinet::parse - - Inputs: argument count, argument strings - - Outputs: none - - Purpose: parses the commandline options into a cmdlinet - -\*******************************************************************/ - +/// parses the commandline options into a cmdlinet +/// \par parameters: argument count, argument strings +/// \return none const char *goto_ld_options_with_argument[]= { "--verbosity", @@ -285,7 +279,7 @@ bool ld_cmdlinet::parse(int argc, const char **argv) } else { - std::cerr << "Warning: missing argument for " << argv_i << std::endl; + std::cerr << "Warning: missing argument for " << argv_i << '\n'; set(os, ""); // end of command line } } @@ -339,7 +333,7 @@ bool ld_cmdlinet::parse(int argc, const char **argv) } else { - std::cerr << "Warning: missing argument for " << argv_i << std::endl; + std::cerr << "Warning: missing argument for " << argv_i << '\n'; set(os, ""); // end of command line } } @@ -365,7 +359,7 @@ bool ld_cmdlinet::parse(int argc, const char **argv) { // unrecognized option std::cerr << "Warning: uninterpreted ld option '" << argv_i - << "'" << std::endl; + << "'\n"; } } diff --git a/src/goto-cc/ld_cmdline.h b/src/goto-cc/ld_cmdline.h index 449d0104427..18f42ec2d68 100644 --- a/src/goto-cc/ld_cmdline.h +++ b/src/goto-cc/ld_cmdline.h @@ -8,6 +8,9 @@ Date: Feb 2013 \*******************************************************************/ +/// \file +/// A special command line object for the ld-like options + #ifndef CPROVER_GOTO_CC_LD_CMDLINE_H #define CPROVER_GOTO_CC_LD_CMDLINE_H diff --git a/src/goto-cc/ms_cl_cmdline.cpp b/src/goto-cc/ms_cl_cmdline.cpp index fb9c8b4e23c..635c799cc83 100644 --- a/src/goto-cc/ms_cl_cmdline.cpp +++ b/src/goto-cc/ms_cl_cmdline.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening \*******************************************************************/ +/// \file +/// A special command line object for the CL options + #include #include #include @@ -16,18 +19,9 @@ Author: Daniel Kroening #include "ms_cl_cmdline.h" -/*******************************************************************\ - -Function: ms_cl_cmdlinet::parse - - Inputs: argument count, argument strings - - Outputs: none - - Purpose: parses the commandline options into a cmdlinet - -\*******************************************************************/ - +/// parses the commandline options into a cmdlinet +/// \par parameters: argument count, argument strings +/// \return none const char *non_ms_cl_options[]= { "--show-symbol-table", @@ -100,18 +94,7 @@ bool ms_cl_cmdlinet::parse(const std::vector &options) return false; } -/*******************************************************************\ - -Function: ms_cl_cmdlinet::parse_env - - Inputs: - - Outputs: none - - Purpose: - -\*******************************************************************/ - +/// \return none void ms_cl_cmdlinet::parse_env() { // first do environment @@ -133,18 +116,9 @@ void ms_cl_cmdlinet::parse_env() #endif } -/*******************************************************************\ - -Function: ms_cl_cmdlinet::parse - - Inputs: argument count, argument strings - - Outputs: none - - Purpose: parses the commandline options into a cmdlinet - -\*******************************************************************/ - +/// parses the commandline options into a cmdlinet +/// \par parameters: argument count, argument strings +/// \return none bool ms_cl_cmdlinet::parse(int argc, const char **argv) { // should really use "wide" argv from wmain() @@ -158,18 +132,6 @@ bool ms_cl_cmdlinet::parse(int argc, const char **argv) return parse(options); } -/*******************************************************************\ - -Function: my_wgetline - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static std::istream &my_wgetline(std::istream &in, std::wstring &dest) { // We should support this properly, @@ -205,18 +167,7 @@ static std::istream &my_wgetline(std::istream &in, std::wstring &dest) return in; } -/*******************************************************************\ - -Function: ms_cl_cmdlinet::process_response_file - - Inputs: - - Outputs: none - - Purpose: - -\*******************************************************************/ - +/// \return none void ms_cl_cmdlinet::process_response_file(const std::string &file) { std::ifstream infile(file); @@ -224,7 +175,7 @@ void ms_cl_cmdlinet::process_response_file(const std::string &file) if(!infile) { std::cerr << "failed to open response file `" - << file << "'" << std::endl; + << file << "'\n"; return; } @@ -278,18 +229,7 @@ void ms_cl_cmdlinet::process_response_file(const std::string &file) } } -/*******************************************************************\ - -Function: ms_cl_cmdlinet::process_response_file_line - - Inputs: - - Outputs: none - - Purpose: - -\*******************************************************************/ - +/// \return none void ms_cl_cmdlinet::process_response_file_line(const std::string &line) { // In a response file, multiple compiler options and source-code files can @@ -329,18 +269,7 @@ void ms_cl_cmdlinet::process_response_file_line(const std::string &line) parse(options); } -/*******************************************************************\ - -Function: ms_cl_cmdlinet::process_non_cl_option - - Inputs: - - Outputs: none - - Purpose: - -\*******************************************************************/ - +/// \return none void ms_cl_cmdlinet::process_non_cl_option( const std::string &s) { @@ -352,21 +281,10 @@ void ms_cl_cmdlinet::process_non_cl_option( // unrecognized option std::cout << "Warning: uninterpreted non-CL option `" - << s << "'" << std::endl; + << s << "'\n"; } -/*******************************************************************\ - -Function: ms_cl_cmdlinet::process_cl_option - - Inputs: - - Outputs: none - - Purpose: - -\*******************************************************************/ - +/// \return none const char *ms_cl_flags[]= { "c", // compile only @@ -576,5 +494,5 @@ void ms_cl_cmdlinet::process_cl_option(const std::string &s) // unrecognized option std::cout << "Warning: uninterpreted CL option `" - << s << "'" << std::endl; + << s << "'\n"; } diff --git a/src/goto-cc/ms_cl_cmdline.h b/src/goto-cc/ms_cl_cmdline.h index 627309ea6ef..0c05f1e7577 100644 --- a/src/goto-cc/ms_cl_cmdline.h +++ b/src/goto-cc/ms_cl_cmdline.h @@ -8,6 +8,9 @@ Date: June 2006 \*******************************************************************/ +/// \file +/// A special command line object for the gcc-like options + #ifndef CPROVER_GOTO_CC_MS_CL_CMDLINE_H #define CPROVER_GOTO_CC_MS_CL_CMDLINE_H diff --git a/src/goto-cc/ms_cl_mode.cpp b/src/goto-cc/ms_cl_mode.cpp index 25dc0e039e2..615bf6e03b0 100644 --- a/src/goto-cc/ms_cl_mode.cpp +++ b/src/goto-cc/ms_cl_mode.cpp @@ -6,6 +6,9 @@ Author: CM Wintersteiger, 2006 \*******************************************************************/ +/// \file +/// Visual Studio CL Mode + #ifdef _WIN32 #define EX_OK 0 #define EX_USAGE 64 @@ -27,18 +30,7 @@ Author: CM Wintersteiger, 2006 #include "ms_cl_mode.h" #include "compile.h" -/*******************************************************************\ - -Function: ms_cl_modet::doit - - Inputs: - - Outputs: - - Purpose: does it. - -\*******************************************************************/ - +/// does it. static bool is_directory(const std::string &s) { if(s.empty()) @@ -59,7 +51,7 @@ int ms_cl_modet::doit() unsigned int verbosity=1; - compilet compiler(cmdline); + compilet compiler(cmdline, message_handler, cmdline.isset("WX")); #if 0 bool act_as_ld= @@ -134,7 +126,7 @@ int ms_cl_modet::doit() it!=config.ansi_c.defines.end(); it++) { - std::cout << " " << (*it) << std::endl; + std::cout << " " << (*it) << '\n'; } std::cout << "Undefines:\n"; @@ -142,7 +134,7 @@ int ms_cl_modet::doit() it!=config.ansi_c.undefines.end(); it++) { - std::cout << " " << (*it) << std::endl; + std::cout << " " << (*it) << '\n'; } std::cout << "Preprocessor Options:\n"; @@ -150,7 +142,7 @@ int ms_cl_modet::doit() it!=config.ansi_c.preprocessor_options.end(); it++) { - std::cout << " " << (*it) << std::endl; + std::cout << " " << (*it) << '\n'; } std::cout << "Include Paths:\n"; @@ -158,7 +150,7 @@ int ms_cl_modet::doit() it!=config.ansi_c.include_paths.end(); it++) { - std::cout << " " << (*it) << std::endl; + std::cout << " " << (*it) << '\n'; } std::cout << "Library Paths:\n"; @@ -166,31 +158,20 @@ int ms_cl_modet::doit() it!=compiler.library_paths.end(); it++) { - std::cout << " " << (*it) << std::endl; + std::cout << " " << (*it) << '\n'; } std::cout << "Output file (object): " - << compiler.output_file_object << std::endl; + << compiler.output_file_object << '\n'; std::cout << "Output file (executable): " - << compiler.output_file_executable << std::endl; + << compiler.output_file_executable << '\n'; } // Parse input program, convert to goto program, write output return compiler.doit() ? EX_USAGE : EX_OK; } -/*******************************************************************\ - -Function: ms_cl_modet::help_mode - - Inputs: - - Outputs: - - Purpose: display command line help - -\*******************************************************************/ - +/// display command line help void ms_cl_modet::help_mode() { std::cout << "goto-cl understands the options of CL plus the following.\n\n"; diff --git a/src/goto-cc/ms_cl_mode.h b/src/goto-cc/ms_cl_mode.h index 673c6efed35..3c1d387441c 100644 --- a/src/goto-cc/ms_cl_mode.h +++ b/src/goto-cc/ms_cl_mode.h @@ -8,6 +8,9 @@ Date: June 2006 \*******************************************************************/ +/// \file +/// Visual Studio CL Mode + #ifndef CPROVER_GOTO_CC_MS_CL_MODE_H #define CPROVER_GOTO_CC_MS_CL_MODE_H diff --git a/src/goto-cc/xml_binaries/read_goto_object.cpp b/src/goto-cc/xml_binaries/read_goto_object.cpp index 01fffa8d4b5..7804701841e 100644 --- a/src/goto-cc/xml_binaries/read_goto_object.cpp +++ b/src/goto-cc/xml_binaries/read_goto_object.cpp @@ -8,6 +8,9 @@ Date: June 2006 \*******************************************************************/ +/// \file +/// Read goto object files. + #include #include #include @@ -22,19 +25,9 @@ Date: June 2006 #include "xml_irep_hashing.h" #include "xml_symbol_hashing.h" -/*******************************************************************\ - -Function: read_goto_object - - Inputs: input stream, symbol_table, functions - - Outputs: true on error, false otherwise - - Purpose: reads a goto object xml file back into a symbol and a - function table - -\*******************************************************************/ - +/// reads a goto object xml file back into a symbol and a function table +/// \par parameters: input stream, symbol_table, functions +/// \return true on error, false otherwise bool read_goto_object( std::istream &in, const std::string &filename, @@ -96,7 +89,7 @@ bool read_goto_object( { symbolt symbol; symbolconverter.convert(*sym_it, symbol); - // std::cout << "Adding Symbol: " << symbol.name << std::endl; + // std::cout << "Adding Symbol: " << symbol.name << '\n'; if(!symbol.is_type && symbol.type.id()=="code") { @@ -117,7 +110,7 @@ bool read_goto_object( fun_it++) { std::string fname = fun_it->get_attribute("name"); - // std::cout << "Adding function body: " << fname << std::endl; + // std::cout << "Adding function body: " << fname << '\n'; goto_functionst::goto_functiont &f = functions.function_map[fname]; gfconverter.convert(*fun_it, f); } diff --git a/src/goto-cc/xml_binaries/read_goto_object.h b/src/goto-cc/xml_binaries/read_goto_object.h index 15589dba852..36981051008 100644 --- a/src/goto-cc/xml_binaries/read_goto_object.h +++ b/src/goto-cc/xml_binaries/read_goto_object.h @@ -8,6 +8,9 @@ Date: June 2006 \*******************************************************************/ +/// \file +/// Read goto object files. + #ifndef CPROVER_GOTO_CC_XML_BINARIES_READ_GOTO_OBJECT_H #define CPROVER_GOTO_CC_XML_BINARIES_READ_GOTO_OBJECT_H diff --git a/src/goto-cc/xml_binaries/xml_goto_function.cpp b/src/goto-cc/xml_binaries/xml_goto_function.cpp index 27021511fa8..ff35c86e253 100644 --- a/src/goto-cc/xml_binaries/xml_goto_function.cpp +++ b/src/goto-cc/xml_binaries/xml_goto_function.cpp @@ -8,42 +8,27 @@ Date: June 2006 \*******************************************************************/ +/// \file +/// Convert goto functions to xml structures and back. + #include #include "xml_goto_function.h" #include "xml_goto_program.h" -/*******************************************************************\ - -Function: convert - - Inputs: goto_function and an xml node - - Outputs: none - - Purpose: takes a goto_function and creates an according xml structure - -\*******************************************************************/ - +/// takes a goto_function and creates an according xml structure +/// \par parameters: goto_function and an xml node +/// \return none void convert(const goto_functionst::goto_functiont &function, xmlt &xml) { if(function.body_available) convert(function.body, xml); } -/*******************************************************************\ - -Function: convert - - Inputs: xml structure and a goto_function to fill - - Outputs: none - - Purpose: constructs the goto_function according to the information - in the xml structure. - -\*******************************************************************/ - +/// constructs the goto_function according to the information in the xml +/// structure. +/// \par parameters: xml structure and a goto_function to fill +/// \return none void convert(const xmlt &xml, goto_functionst::goto_functiont &function) { function.body.clear(); diff --git a/src/goto-cc/xml_binaries/xml_goto_function.h b/src/goto-cc/xml_binaries/xml_goto_function.h index 8f9db9982c6..b15722976b8 100644 --- a/src/goto-cc/xml_binaries/xml_goto_function.h +++ b/src/goto-cc/xml_binaries/xml_goto_function.h @@ -8,6 +8,9 @@ Date: June 2006 \*******************************************************************/ +/// \file +/// Convert goto functions into xml structures and back + #ifndef CPROVER_GOTO_CC_XML_BINARIES_XML_GOTO_FUNCTION_H #define CPROVER_GOTO_CC_XML_BINARIES_XML_GOTO_FUNCTION_H diff --git a/src/goto-cc/xml_binaries/xml_goto_function_hashing.cpp b/src/goto-cc/xml_binaries/xml_goto_function_hashing.cpp index f5ba898e55d..8d578451fac 100644 --- a/src/goto-cc/xml_binaries/xml_goto_function_hashing.cpp +++ b/src/goto-cc/xml_binaries/xml_goto_function_hashing.cpp @@ -9,21 +9,15 @@ Date: July 2006 \*******************************************************************/ +/// \file +/// Convert goto functions to xml structures and back (with irep hashing) + #include "xml_goto_function_hashing.h" #include "xml_goto_program_hashing.h" -/*******************************************************************\ - -Function: xml_goto_function_convertt::convert - - Inputs: goto_function and an xml node - - Outputs: none - - Purpose: takes a goto_function and creates an according xml structure - -\*******************************************************************/ - +/// takes a goto_function and creates an according xml structure +/// \par parameters: goto_function and an xml node +/// \return none void xml_goto_function_convertt::convert( const goto_functionst::goto_functiont &function, xmlt &xml) @@ -33,19 +27,10 @@ void xml_goto_function_convertt::convert( gpconverter.convert(function.body, xml); } -/*******************************************************************\ - -Function: xml_goto_function_convertt::convert - - Inputs: xml structure and a goto_function to fill - - Outputs: none - - Purpose: constructs the goto_function according to the information - in the xml structure. - -\*******************************************************************/ - +/// constructs the goto_function according to the information in the xml +/// structure. +/// \par parameters: xml structure and a goto_function to fill +/// \return none void xml_goto_function_convertt::convert( const xmlt &xml, goto_functionst::goto_functiont &function) diff --git a/src/goto-cc/xml_binaries/xml_goto_function_hashing.h b/src/goto-cc/xml_binaries/xml_goto_function_hashing.h index a0b86b72376..e558a702c68 100644 --- a/src/goto-cc/xml_binaries/xml_goto_function_hashing.h +++ b/src/goto-cc/xml_binaries/xml_goto_function_hashing.h @@ -9,6 +9,9 @@ Date: July 2006 \*******************************************************************/ +/// \file +/// Convert goto functions into xml structures and back (with irep hashing). + #ifndef CPROVER_GOTO_CC_XML_BINARIES_XML_GOTO_FUNCTION_HASHING_H #define CPROVER_GOTO_CC_XML_BINARIES_XML_GOTO_FUNCTION_HASHING_H diff --git a/src/goto-cc/xml_binaries/xml_goto_program.cpp b/src/goto-cc/xml_binaries/xml_goto_program.cpp index ee6a53960c0..9ab9c77db93 100644 --- a/src/goto-cc/xml_binaries/xml_goto_program.cpp +++ b/src/goto-cc/xml_binaries/xml_goto_program.cpp @@ -8,6 +8,9 @@ Date: June 2006 \*******************************************************************/ +/// \file +/// Convert goto programs to xml structures and back. + #include #include @@ -15,24 +18,15 @@ Date: June 2006 #include "xml_goto_program.h" -/*******************************************************************\ - -Function: convert - - Inputs: goto program, namespace and an xml structure to fill - - Outputs: none - - Purpose: constructs the xml structure according to the goto program - and the namespace into the given xml object. - -\*******************************************************************/ - +/// constructs the xml structure according to the goto program and the namespace +/// into the given xml object. +/// \par parameters: goto program, namespace and an xml structure to fill +/// \return none void convert(const goto_programt &goto_program, xmlt &xml) { std::stringstream tmp; - // std::cout << "TNO: " << goto_program.target_numbers.size() << std::endl; + // std::cout << "TNO: " << goto_program.target_numbers.size() << '\n'; for(const auto &inst : goto_program.instructions) { @@ -58,7 +52,7 @@ void convert(const goto_programt &goto_program, if(inst.target_number!=0) { - // std::cout << "Targetlabel found!" << std::endl; + // std::cout << "Targetlabel found!\n"; tmp.str(""); tmp << inst.target_number; ins.set_attribute("targetlabel", tmp.str()); @@ -200,20 +194,11 @@ void convert(const goto_programt &goto_program, } } -/*******************************************************************\ - -Function: convert - - Inputs: an xml structure, namespace, function symbol - and a goto program to fill - - Outputs: none - - Purpose: constructs the goto program according to the xml structure - and the namespace into the given goto program object. - -\*******************************************************************/ - +/// constructs the goto program according to the xml structure and the namespace +/// into the given goto program object. +/// \par parameters: an xml structure, namespace, function symbol +/// and a goto program to fill +/// \return none void convert(const xmlt &xml, goto_programt &goto_program) { goto_program.clear(); @@ -289,8 +274,8 @@ void convert(const xmlt &xml, goto_programt &goto_program) } else { - std::cout << "Unknown instruction type encountered (" << it->name << ")"; - std::cout << std::endl; + std::cout << "Unknown instruction type encountered (" << it->name + << ")\n"; return; } @@ -316,7 +301,7 @@ void convert(const xmlt &xml, goto_programt &goto_program) } else { - std::cout << "Unknown node in labels section." << std::endl; + std::cout << "Unknown node in labels section.\n"; return; } } @@ -374,12 +359,12 @@ void convert(const xmlt &xml, goto_programt &goto_program) else { std::cout << "Warning: instruction not found when " - "resolving target links." << std::endl; + "resolving target links.\n"; } } else { - std::cout << "Unknown node in targets section." << std::endl; + std::cout << "Unknown node in targets section.\n"; return; } } @@ -391,22 +376,14 @@ void convert(const xmlt &xml, goto_programt &goto_program) // resolve links goto_program.update(); - // std::cout << "TNI: " << goto_program.target_numbers.size() << std::endl; + // std::cout << "TNI: " << goto_program.target_numbers.size() << '\n'; } -/*******************************************************************\ - -Function: find_instruction - - Inputs: a target label string, the instructions list and an xml program - - Outputs: iterator to the found instruction or .end() - - Purpose: finds the index of the instruction labelled with the given - target label in the given xml-program - -\*******************************************************************/ - +/// finds the index of the instruction labelled with the given target label in +/// the given xml-program +/// \par parameters: a target label string, the instructions list and an xml +/// program +/// \return iterator to the found instruction or .end() goto_programt::targett find_instruction( const xmlt &xml, diff --git a/src/goto-cc/xml_binaries/xml_goto_program.h b/src/goto-cc/xml_binaries/xml_goto_program.h index 04bab08af3e..cd5cb4e6c17 100644 --- a/src/goto-cc/xml_binaries/xml_goto_program.h +++ b/src/goto-cc/xml_binaries/xml_goto_program.h @@ -8,6 +8,9 @@ Date: June 2006 \*******************************************************************/ +/// \file +/// Convert goto programs into xml structures and back + #ifndef CPROVER_GOTO_CC_XML_BINARIES_XML_GOTO_PROGRAM_H #define CPROVER_GOTO_CC_XML_BINARIES_XML_GOTO_PROGRAM_H diff --git a/src/goto-cc/xml_binaries/xml_goto_program_hashing.cpp b/src/goto-cc/xml_binaries/xml_goto_program_hashing.cpp index fa1ac0c2b00..5097fd6e3e0 100644 --- a/src/goto-cc/xml_binaries/xml_goto_program_hashing.cpp +++ b/src/goto-cc/xml_binaries/xml_goto_program_hashing.cpp @@ -9,31 +9,25 @@ Date: July 2006 \*******************************************************************/ +/// \file +/// Convert goto programs to xml structures and back (with irep hashing) + #include #include #include "xml_irep_hashing.h" #include "xml_goto_program_hashing.h" -/*******************************************************************\ - -Function: xml_goto_program_convertt::convert - - Inputs: goto program and an xml structure to fill - - Outputs: none - - Purpose: constructs the xml structure according to the goto program - and the namespace into the given xml object. - -\*******************************************************************/ - +/// constructs the xml structure according to the goto program and the namespace +/// into the given xml object. +/// \par parameters: goto program and an xml structure to fill +/// \return none void xml_goto_program_convertt::convert( const goto_programt &goto_program, xmlt &xml) { std::stringstream tmp; - // std::cout << "TNO: " << goto_program.target_numbers.size() << std::endl; + // std::cout << "TNO: " << goto_program.target_numbers.size() << '\n'; for(const auto &inst : goto_program.instructions) { @@ -59,7 +53,7 @@ void xml_goto_program_convertt::convert( if(inst.target_number!=0) { - // std::cout << "Targetlabel found!" << std::endl; + // std::cout << "Targetlabel found!\n"; tmp.str(""); tmp << inst.target_number; ins.set_attribute("targetlabel", tmp.str()); @@ -196,18 +190,10 @@ void xml_goto_program_convertt::convert( } } -/*******************************************************************\ - -Function: xml_goto_program_convertt::convert - - Inputs: an xml structure and a goto program to fill - - Outputs: none - - Purpose: constructs the goto program according to the xml structure - and the namespace into the given goto program object. - -\*******************************************************************/ +/// constructs the goto program according to the xml structure and the namespace +/// into the given goto program object. +/// \par parameters: an xml structure and a goto program to fill +/// \return none void xml_goto_program_convertt::convert( const xmlt &xml, goto_programt &goto_program) @@ -285,8 +271,7 @@ void xml_goto_program_convertt::convert( else { std::cout << "Unknown instruction type encountered (" - << element.name << ")"; - std::cout << std::endl; + << element.name << ")\n"; return; } @@ -313,7 +298,7 @@ void xml_goto_program_convertt::convert( } else { - std::cout << "Unknown node in labels section." << std::endl; + std::cout << "Unknown node in labels section.\n"; return; } } @@ -373,12 +358,12 @@ void xml_goto_program_convertt::convert( else { std::cout << "Warning: instruction not found when " - "resolving target links." << std::endl; + "resolving target links.\n"; } } else { - std::cout << "Unknown node in targets section." << std::endl; + std::cout << "Unknown node in targets section.\n"; return; } } @@ -390,21 +375,14 @@ void xml_goto_program_convertt::convert( // resolve links goto_program.update(); - // std::cout << "TNI: " << goto_program.target_numbers.size() << std::endl; + // std::cout << "TNI: " << goto_program.target_numbers.size() << '\n'; } -/*******************************************************************\ - -Function: xml_goto_program_convertt::find_instruction - - Inputs: a target label string, the instructions list and an xml program - - Outputs: iterator to the found instruction or .end() - - Purpose: finds the index of the instruction labelled with the given - target label in the given xml-program - -\*******************************************************************/ +/// finds the index of the instruction labelled with the given target label in +/// the given xml-program +/// \par parameters: a target label string, the instructions list and an xml +/// program +/// \return iterator to the found instruction or .end() goto_programt::targett xml_goto_program_convertt::find_instruction( const xmlt &xml, goto_programt::instructionst &instructions, diff --git a/src/goto-cc/xml_binaries/xml_goto_program_hashing.h b/src/goto-cc/xml_binaries/xml_goto_program_hashing.h index a3af286f1a7..63622775799 100644 --- a/src/goto-cc/xml_binaries/xml_goto_program_hashing.h +++ b/src/goto-cc/xml_binaries/xml_goto_program_hashing.h @@ -9,6 +9,9 @@ Date: July 2006 \*******************************************************************/ +/// \file +/// Convert goto programs into xml structures and back (with irep hashing) + #ifndef CPROVER_GOTO_CC_XML_BINARIES_XML_GOTO_PROGRAM_HASHING_H #define CPROVER_GOTO_CC_XML_BINARIES_XML_GOTO_PROGRAM_HASHING_H diff --git a/src/goto-cc/xml_binaries/xml_irep_hashing.cpp b/src/goto-cc/xml_binaries/xml_irep_hashing.cpp index 54aa9c06bf8..1469965839e 100644 --- a/src/goto-cc/xml_binaries/xml_irep_hashing.cpp +++ b/src/goto-cc/xml_binaries/xml_irep_hashing.cpp @@ -8,24 +8,15 @@ Date: July 2006 \*******************************************************************/ +/// \file +/// XML-irep conversions with hashing + #include #include #include "xml_irep_hashing.h" #include "string_hash.h" -/*******************************************************************\ - -Function: xml_irep_convertt::convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void xml_irep_convertt::convert( const irept &irep, xmlt &xml) @@ -54,18 +45,6 @@ void xml_irep_convertt::convert( } } -/*******************************************************************\ - -Function: xml_irep_convertt::convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void xml_irep_convertt::convert( const xmlt &xml, irept &irep) @@ -106,24 +85,11 @@ void xml_irep_convertt::convert( else { // Should not happen - std::cout << "Unknown sub found (" << it->name << "); malformed xml?"; - std::cout << std::endl; + std::cout << "Unknown sub found (" << it->name << "); malformed xml?\n"; } } } -/*******************************************************************\ - -Function: xml_irep_convertt::reference_convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void xml_irep_convertt::reference_convert( const irept &irep, xmlt &xml) @@ -144,17 +110,6 @@ void xml_irep_convertt::reference_convert( } } -/*******************************************************************\ - -Function: xml_irep_convertt::add_with_childs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ unsigned long xml_irep_convertt::add_with_childs(const irept &iwi) { unsigned long id=insert((unsigned long)&iwi, iwi); @@ -191,19 +146,9 @@ unsigned long xml_irep_convertt::add_with_childs(const irept &iwi) return id; } -/*******************************************************************\ - -Function: xml_irep_convertt::resolve_references - - Inputs: none - - Outputs: none - - Purpose: resolves references to ireps from an irep after reading - an irep hash map into memory. - -\*******************************************************************/ - +/// resolves references to ireps from an irep after reading an irep hash map +/// into memory. +/// \return none void xml_irep_convertt::resolve_references(const irept &cur) { if(cur.id() == "__REFERENCE__") @@ -213,7 +158,7 @@ void xml_irep_convertt::resolve_references(const irept &cur) if(itr==ireps_container.id_container.end()) { std::cout << "Warning: can't resolve irep reference (sub " - << cur.get("REF") << ")" << std::endl; + << cur.get("REF") << ")\n"; } else { @@ -232,18 +177,9 @@ void xml_irep_convertt::resolve_references(const irept &cur) resolve_references(iti->second); } -/*******************************************************************\ - -Function: xml_irep_convertt::long_to_string - - Inputs: an irep pointer - - Outputs: a new string - - Purpose: converts the hash value to a readable string - -\*******************************************************************/ - +/// converts the hash value to a readable string +/// \par parameters: an irep pointer +/// \return a new string std::string xml_irep_convertt::long_to_string(const unsigned long l) { std::stringstream s; @@ -251,19 +187,10 @@ std::string xml_irep_convertt::long_to_string(const unsigned long l) return s.str(); } -/*******************************************************************\ - -Function: xml_irep_convertt::string_to_long - - Inputs: a string - - Outputs: an unsigned long - - Purpose: converts the string to an unsigned long that used to give - a pointer to an irep in an old compilation - -\*******************************************************************/ - +/// converts the string to an unsigned long that used to give a pointer to an +/// irep in an old compilation +/// \par parameters: a string +/// \return an unsigned long unsigned long xml_irep_convertt::string_to_long(const std::string &s) { std::stringstream ss(s); @@ -272,54 +199,27 @@ unsigned long xml_irep_convertt::string_to_long(const std::string &s) return res; } -/*******************************************************************\ - -Function: xml_irep_convertt::find_irep_by_id - - Inputs: an id - - Outputs: an iterator into the ireps hash set - - Purpose: finds an irep in the ireps hash set by its id - -\*******************************************************************/ - +/// finds an irep in the ireps hash set by its id +/// \par parameters: an id +/// \return an iterator into the ireps hash set xml_irep_convertt::ireps_containert::id_containert::const_iterator xml_irep_convertt::find_irep_by_id(const unsigned int id) { return ireps_container.id_container.find(id); } -/*******************************************************************\ - -Function: xml_irep_convertt::find_irep_by_content - - Inputs: an irep - - Outputs: an iterator into the ireps hash set - - Purpose: finds an irep in the ireps hash set by checking contents - -\*******************************************************************/ - - xml_irep_convertt::ireps_containert::content_containert::const_iterator +/// finds an irep in the ireps hash set by checking contents +/// \par parameters: an irep +/// \return an iterator into the ireps hash set +xml_irep_convertt::ireps_containert::content_containert::const_iterator xml_irep_convertt::find_irep_by_content(const irept &irep) { return ireps_container.content_container.find(irep); } -/*******************************************************************\ - -Function: xml_irep_convertt::insert - - Inputs: an unsigned long and an irep - - Outputs: true on success, false otherwise - - Purpose: inserts an irep into the hashtable - -\*******************************************************************/ - +/// inserts an irep into the hashtable +/// \par parameters: an unsigned long and an irep +/// \return true on success, false otherwise unsigned long xml_irep_convertt::insert( unsigned long id, const irept &i) @@ -346,18 +246,9 @@ unsigned long xml_irep_convertt::insert( } } -/*******************************************************************\ - -Function: xml_irep_convertt::insert - - Inputs: a string and an irep - - Outputs: true on success, false otherwise - - Purpose: inserts an irep into the hashtable - -\*******************************************************************/ - +/// inserts an irep into the hashtable +/// \par parameters: a string and an irep +/// \return true on success, false otherwise unsigned long xml_irep_convertt::insert( const std::string &id, const irept &i) @@ -365,19 +256,9 @@ unsigned long xml_irep_convertt::insert( return insert(string_to_long(id), i); } -/*******************************************************************\ - -Function: xml_irep_convertt::convert_map - - Inputs: an xml node - - Outputs: nothing - - Purpose: converts the current hash map of ireps into the given xml - structure - -\*******************************************************************/ - +/// converts the current hash map of ireps into the given xml structure +/// \par parameters: an xml node +/// \return nothing void xml_irep_convertt::convert_map(xmlt &xml) { ireps_containert::id_containert::iterator hit= @@ -392,19 +273,10 @@ void xml_irep_convertt::convert_map(xmlt &xml) } } -/*******************************************************************\ - -Function: xml_irep_convertt::output_map - - Inputs: an output stream - - Outputs: nothing - - Purpose: converts the current hash map of ireps into xml nodes and - outputs them to the stream - -\*******************************************************************/ - +/// converts the current hash map of ireps into xml nodes and outputs them to +/// the stream +/// \par parameters: an output stream +/// \return nothing void xml_irep_convertt::output_map(std::ostream &out, unsigned indent) { ireps_containert::id_containert::iterator hit= diff --git a/src/goto-cc/xml_binaries/xml_irep_hashing.h b/src/goto-cc/xml_binaries/xml_irep_hashing.h index 6fc074c9941..2391580a61b 100644 --- a/src/goto-cc/xml_binaries/xml_irep_hashing.h +++ b/src/goto-cc/xml_binaries/xml_irep_hashing.h @@ -8,6 +8,9 @@ Date: July 2006 \*******************************************************************/ +/// \file +/// XML-irep conversions with hashing + #ifndef CPROVER_GOTO_CC_XML_BINARIES_XML_IREP_HASHING_H #define CPROVER_GOTO_CC_XML_BINARIES_XML_IREP_HASHING_H diff --git a/src/goto-cc/xml_binaries/xml_symbol.cpp b/src/goto-cc/xml_binaries/xml_symbol.cpp index 051d6b38d4f..e62ebe7f657 100644 --- a/src/goto-cc/xml_binaries/xml_symbol.cpp +++ b/src/goto-cc/xml_binaries/xml_symbol.cpp @@ -8,21 +8,15 @@ Date: June 2006 \*******************************************************************/ +/// \file +/// Compile and link source and object files. + #include "xml_irep.h" #include "xml_symbol.h" -/*******************************************************************\ - -Function: convert - - Inputs: a symbol and an xml node - - Outputs: none - - Purpose: converts a symbol to an xml symbol node - -\*******************************************************************/ - +/// converts a symbol to an xml symbol node +/// \par parameters: a symbol and an xml node +/// \return none void convert(const symbolt &sym, xmlt &root) { xmlt &xmlsym = root.new_element("symbol"); @@ -68,18 +62,9 @@ void convert(const symbolt &sym, xmlt &root) xmlloc.name = "location"; // convert overwrote this } -/*******************************************************************\ - -Function: convert - - Inputs: an xml node and a symbol - - Outputs: none - - Purpose: converts an xml symbol node to a symbol - -\*******************************************************************/ - +/// converts an xml symbol node to a symbol +/// \par parameters: an xml node and a symbol +/// \return none void convert(const xmlt &xmlsym, symbolt &symbol) { symbol.name=xmlsym.get_attribute("name"); diff --git a/src/goto-cc/xml_binaries/xml_symbol.h b/src/goto-cc/xml_binaries/xml_symbol.h index d50f8b75610..0044cf98000 100644 --- a/src/goto-cc/xml_binaries/xml_symbol.h +++ b/src/goto-cc/xml_binaries/xml_symbol.h @@ -8,6 +8,9 @@ Date: June 2006 \*******************************************************************/ +/// \file +/// Converts symbols to xml structures and back. + #ifndef CPROVER_GOTO_CC_XML_BINARIES_XML_SYMBOL_H #define CPROVER_GOTO_CC_XML_BINARIES_XML_SYMBOL_H diff --git a/src/goto-cc/xml_binaries/xml_symbol_hashing.cpp b/src/goto-cc/xml_binaries/xml_symbol_hashing.cpp index ab6c17ab412..862522451e1 100644 --- a/src/goto-cc/xml_binaries/xml_symbol_hashing.cpp +++ b/src/goto-cc/xml_binaries/xml_symbol_hashing.cpp @@ -8,21 +8,15 @@ Date: July 2006 \*******************************************************************/ +/// \file +/// XML-symbol conversions with irep hashing + #include "xml_symbol_hashing.h" #include "xml_irep_hashing.h" -/*******************************************************************\ - -Function: xml_symbol_convertt::convert - - Inputs: a symbol and an xml node - - Outputs: none - - Purpose: converts a symbol to an xml symbol node - -\*******************************************************************/ - +/// converts a symbol to an xml symbol node +/// \par parameters: a symbol and an xml node +/// \return none void xml_symbol_convertt::convert(const symbolt &sym, xmlt &root) { xmlt &xmlsym = root.new_element("symbol"); @@ -31,18 +25,9 @@ void xml_symbol_convertt::convert(const symbolt &sym, xmlt &root) irepconverter.reference_convert(irepcache.back(), xmlsym); } -/*******************************************************************\ - -Function: xml_symbol_convertt::convert - - Inputs: an xml node and a symbol - - Outputs: none - - Purpose: converts an xml symbol node to a symbol - -\*******************************************************************/ - +/// converts an xml symbol node to a symbol +/// \par parameters: an xml node and a symbol +/// \return none void xml_symbol_convertt::convert(const xmlt &xmlsym, symbolt &symbol) { irept t; diff --git a/src/goto-cc/xml_binaries/xml_symbol_hashing.h b/src/goto-cc/xml_binaries/xml_symbol_hashing.h index 0ade830430e..bb5f3e9a060 100644 --- a/src/goto-cc/xml_binaries/xml_symbol_hashing.h +++ b/src/goto-cc/xml_binaries/xml_symbol_hashing.h @@ -8,6 +8,9 @@ Date: July 2006 \*******************************************************************/ +/// \file +/// XML-symbol conversions with irep hashing + #ifndef CPROVER_GOTO_CC_XML_BINARIES_XML_SYMBOL_HASHING_H #define CPROVER_GOTO_CC_XML_BINARIES_XML_SYMBOL_HASHING_H diff --git a/src/goto-diff/change_impact.cpp b/src/goto-diff/change_impact.cpp index 6ca431c0f1d..c7ea9a77712 100644 --- a/src/goto-diff/change_impact.cpp +++ b/src/goto-diff/change_impact.cpp @@ -8,6 +8,9 @@ Date: April 2016 \*******************************************************************/ +/// \file +/// Data and control-dependencies of syntactic diff + #include #include @@ -47,18 +50,6 @@ Date: April 2016 queue.push(entry); } -/*******************************************************************\ - -Function: full_slicert::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void full_slicert::operator()( goto_functionst &goto_functions, const namespacet &ns, @@ -144,18 +135,6 @@ void full_slicert::operator()( } -/*******************************************************************\ - -Function: full_slicert::fixedpoint - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void full_slicert::fixedpoint( goto_functionst &goto_functions, queuet &queue, @@ -206,18 +185,6 @@ void full_slicert::fixedpoint( } -/*******************************************************************\ - -Function: full_slicert::add_dependencies - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void full_slicert::add_dependencies( const cfgt::nodet &node, queuet &queue, @@ -319,18 +286,6 @@ class change_impactt goto_programt::const_targett &target) const; }; -/*******************************************************************\ - -Function: change_impactt::change_impactt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - change_impactt::change_impactt( const goto_modelt &model_old, const goto_modelt &model_new, @@ -357,18 +312,6 @@ change_impactt::change_impactt( new_dep_graph(new_goto_functions, ns_new); } -/*******************************************************************\ - -Function: change_impactt::change_impact - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void change_impactt::change_impact(const irep_idt &function) { unified_difft::goto_program_difft diff; @@ -401,18 +344,6 @@ void change_impactt::change_impact(const irep_idt &function) new_change_impact[function]); } -/*******************************************************************\ - -Function: change_impactt::change_impact - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void change_impactt::change_impact( const goto_programt &old_goto_program, const goto_programt &new_goto_program, @@ -493,18 +424,6 @@ void change_impactt::change_impact( } -/*******************************************************************\ - -Function: change_impactt::propogate_dep_forward - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void change_impactt::propogate_dep_forward( const dependence_grapht::nodet &d_node, const dependence_grapht &dep_graph, @@ -532,18 +451,6 @@ void change_impactt::propogate_dep_forward( } } -/*******************************************************************\ - -Function: change_impactt::propogate_dep_back - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void change_impactt::propogate_dep_back( const dependence_grapht::nodet &d_node, const dependence_grapht &dep_graph, @@ -574,18 +481,6 @@ void change_impactt::propogate_dep_back( } } -/*******************************************************************\ - -Function: change_impactt::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void change_impactt::operator()() { // sorted iteration over intersection(old functions, new functions) @@ -656,18 +551,6 @@ void change_impactt::operator()() } } -/*******************************************************************\ - -Function: change_impact::output_change_impact - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void change_impactt::output_change_impact( const irep_idt &function, const goto_program_change_impactt &c_i, @@ -713,18 +596,6 @@ void change_impactt::output_change_impact( } } -/*******************************************************************\ - -Function: change_impact::output_change_impact - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void change_impactt::output_change_impact( const irep_idt &function, const goto_program_change_impactt &o_c_i, @@ -841,18 +712,6 @@ void change_impactt::output_change_impact( } } -/*******************************************************************\ - -Function: change_impactt::output_instruction - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void change_impactt::output_instruction(char prefix, const goto_programt &goto_program, const namespacet &ns, @@ -867,7 +726,7 @@ void change_impactt::output_instruction(char prefix, const irep_idt &line=target->source_location.get_line(); if(!file.empty() && !line.empty()) std::cout << prefix << " " << id2string(file) - << " " << id2string(line) << std::endl; + << " " << id2string(line) << '\n'; } else { @@ -876,18 +735,6 @@ void change_impactt::output_instruction(char prefix, } } -/*******************************************************************\ - -Function: change_impact - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void change_impact( const goto_modelt &model_old, const goto_modelt &model_new, diff --git a/src/goto-diff/change_impact.h b/src/goto-diff/change_impact.h index 234ec15a7c8..d56e57184e1 100644 --- a/src/goto-diff/change_impact.h +++ b/src/goto-diff/change_impact.h @@ -8,6 +8,9 @@ Date: April 2016 \*******************************************************************/ +/// \file +/// Data and control-dependencies of syntactic diff + #ifndef CPROVER_GOTO_DIFF_CHANGE_IMPACT_H #define CPROVER_GOTO_DIFF_CHANGE_IMPACT_H diff --git a/src/goto-diff/goto_diff.h b/src/goto-diff/goto_diff.h index bb6a7bb05cc..2b6a9ac923d 100644 --- a/src/goto-diff/goto_diff.h +++ b/src/goto-diff/goto_diff.h @@ -6,6 +6,9 @@ Author: Peter Schrammel \*******************************************************************/ +/// \file +/// GOTO-DIFF Base Class + #ifndef CPROVER_GOTO_DIFF_GOTO_DIFF_H #define CPROVER_GOTO_DIFF_GOTO_DIFF_H diff --git a/src/goto-diff/goto_diff_base.cpp b/src/goto-diff/goto_diff_base.cpp index 7c6a0e5bf4e..cd945b11a7a 100644 --- a/src/goto-diff/goto_diff_base.cpp +++ b/src/goto-diff/goto_diff_base.cpp @@ -6,22 +6,13 @@ Author: Peter Schrammel \*******************************************************************/ +/// \file +/// GOTO-DIFF Base Class + #include #include "goto_diff.h" -/*******************************************************************\ - -Function: goto_difft::output_functions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::ostream &goto_difft::output_functions(std::ostream &out) const { switch(ui) @@ -85,18 +76,6 @@ std::ostream &goto_difft::output_functions(std::ostream &out) const return out; } -/*******************************************************************\ - -Function: goto_difft::convert_function_group - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_difft::convert_function_group( json_arrayt &result, const irep_id_sett &function_group) const @@ -108,18 +87,6 @@ void goto_difft::convert_function_group( } } -/*******************************************************************\ - -Function: goto_difft::convert_functions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_difft::convert_function( json_objectt &result, const irep_idt &function_name) const diff --git a/src/goto-diff/goto_diff_languages.cpp b/src/goto-diff/goto_diff_languages.cpp index c467ab92cd3..d1ad10c5a0b 100644 --- a/src/goto-diff/goto_diff_languages.cpp +++ b/src/goto-diff/goto_diff_languages.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Language Registration + #include #include @@ -21,18 +24,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_diff_languages.h" -/*******************************************************************\ - -Function: goto_diff_languagest::register_languages - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_diff_languagest::register_languages() { register_language(new_ansi_c_language); diff --git a/src/goto-diff/goto_diff_languages.h b/src/goto-diff/goto_diff_languages.h index b0489e85544..7bd4c24e525 100644 --- a/src/goto-diff/goto_diff_languages.h +++ b/src/goto-diff/goto_diff_languages.h @@ -6,6 +6,9 @@ Author: Peter Schrammel \*******************************************************************/ +/// \file +/// GOTO-DIFF Languages + #ifndef CPROVER_GOTO_DIFF_GOTO_DIFF_LANGUAGES_H #define CPROVER_GOTO_DIFF_GOTO_DIFF_LANGUAGES_H diff --git a/src/goto-diff/goto_diff_main.cpp b/src/goto-diff/goto_diff_main.cpp index 96655ea5455..604777582d0 100644 --- a/src/goto-diff/goto_diff_main.cpp +++ b/src/goto-diff/goto_diff_main.cpp @@ -6,6 +6,9 @@ Author: Peter Schrammel \*******************************************************************/ +/// \file +/// GOTO-DIFF Main Module + #include #ifdef IREP_HASH_STATS @@ -14,18 +17,6 @@ Author: Peter Schrammel #include "goto_diff_parse_options.h" -/*******************************************************************\ - -Function: main / wmain - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - #ifdef IREP_HASH_STATS extern unsigned long long irep_hash_cnt; extern unsigned long long irep_cmp_cnt; @@ -45,9 +36,9 @@ int main(int argc, const char **argv) int res=parse_options.main(); #ifdef IREP_HASH_STATS - std::cout << "IREP_HASH_CNT=" << irep_hash_cnt << std::endl; - std::cout << "IREP_CMP_CNT=" << irep_cmp_cnt << std::endl; - std::cout << "IREP_CMP_NE_CNT=" << irep_cmp_ne_cnt << std::endl; + std::cout << "IREP_HASH_CNT=" << irep_hash_cnt << '\n'; + std::cout << "IREP_CMP_CNT=" << irep_cmp_cnt << '\n'; + std::cout << "IREP_CMP_NE_CNT=" << irep_cmp_ne_cnt << '\n'; #endif return res; diff --git a/src/goto-diff/goto_diff_parse_options.cpp b/src/goto-diff/goto_diff_parse_options.cpp index f0266b006e4..ee2a74a0b24 100644 --- a/src/goto-diff/goto_diff_parse_options.cpp +++ b/src/goto-diff/goto_diff_parse_options.cpp @@ -6,6 +6,9 @@ Author: Peter Schrammel \*******************************************************************/ +/// \file +/// GOTO-DIFF Command Line Option Processing + #include #include // exit() #include @@ -44,18 +47,6 @@ Author: Peter Schrammel #include "unified_diff.h" #include "change_impact.h" -/*******************************************************************\ - -Function: goto_diff_parse_optionst::goto_diff_parse_optionst - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - goto_diff_parse_optionst::goto_diff_parse_optionst(int argc, const char **argv): parse_options_baset(GOTO_DIFF_OPTIONS, argc, argv), goto_diff_languagest(cmdline, ui_message_handler), @@ -64,18 +55,6 @@ goto_diff_parse_optionst::goto_diff_parse_optionst(int argc, const char **argv): { } -/*******************************************************************\ - -Function: goto_diff_parse_optionst::goto_diff_parse_optionst - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - ::goto_diff_parse_optionst::goto_diff_parse_optionst( int argc, const char **argv, @@ -87,18 +66,6 @@ ::goto_diff_parse_optionst::goto_diff_parse_optionst( { } -/*******************************************************************\ - -Function: goto_diff_parse_optionst::eval_verbosity - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_diff_parse_optionst::eval_verbosity() { // this is our default verbosity @@ -114,18 +81,6 @@ void goto_diff_parse_optionst::eval_verbosity() ui_message_handler.set_verbosity(v); } -/*******************************************************************\ - -Function: goto_diff_parse_optionst::get_command_line_options - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_diff_parse_optionst::get_command_line_options(optionst &options) { if(config.set(cmdline)) @@ -280,23 +235,12 @@ void goto_diff_parse_optionst::get_command_line_options(optionst &options) } } -/*******************************************************************\ - -Function: goto_diff_parse_optionst::doit - - Inputs: - - Outputs: - - Purpose: invoke main modules - -\*******************************************************************/ - +/// invoke main modules int goto_diff_parse_optionst::doit() { if(cmdline.isset("version")) { - std::cout << CBMC_VERSION << std::endl; + std::cout << CBMC_VERSION << '\n'; return 0; } @@ -385,18 +329,6 @@ int goto_diff_parse_optionst::doit() return 0; } -/*******************************************************************\ - -Function: goto_diff_parse_optionst::get_goto_program - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - int goto_diff_parse_optionst::get_goto_program( const optionst &options, goto_diff_languagest &languages, @@ -454,18 +386,6 @@ int goto_diff_parse_optionst::get_goto_program( return -1; // no error, continue } -/*******************************************************************\ - -Function: goto_diff_parse_optionst::process_goto_program - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool goto_diff_parse_optionst::process_goto_program( const optionst &options, goto_modelt &goto_model) @@ -552,18 +472,7 @@ bool goto_diff_parse_optionst::process_goto_program( return false; } -/*******************************************************************\ - -Function: goto_diff_parse_optionst::help - - Inputs: - - Outputs: - - Purpose: display command line help - -\*******************************************************************/ - +/// display command line help void goto_diff_parse_optionst::help() { std::cout << diff --git a/src/goto-diff/goto_diff_parse_options.h b/src/goto-diff/goto_diff_parse_options.h index e78bd1537e7..505de8410f4 100644 --- a/src/goto-diff/goto_diff_parse_options.h +++ b/src/goto-diff/goto_diff_parse_options.h @@ -6,6 +6,9 @@ Author: Peter Schrammel \*******************************************************************/ +/// \file +/// GOTO-DIFF Command Line Option Processing + #ifndef CPROVER_GOTO_DIFF_GOTO_DIFF_PARSE_OPTIONS_H #define CPROVER_GOTO_DIFF_GOTO_DIFF_PARSE_OPTIONS_H diff --git a/src/goto-diff/syntactic_diff.cpp b/src/goto-diff/syntactic_diff.cpp index 4c0e831dfdc..030d35e0f3c 100644 --- a/src/goto-diff/syntactic_diff.cpp +++ b/src/goto-diff/syntactic_diff.cpp @@ -6,19 +6,10 @@ Author: Peter Schrammel \*******************************************************************/ -#include "syntactic_diff.h" - -/*******************************************************************\ - -Function: syntactic_difft::operator() - - Inputs: +/// \file +/// Syntactic GOTO-DIFF - Outputs: - - Purpose: - -\*******************************************************************/ +#include "syntactic_diff.h" bool syntactic_difft::operator()() { diff --git a/src/goto-diff/syntactic_diff.h b/src/goto-diff/syntactic_diff.h index dd10374dc4b..8496eb8165e 100644 --- a/src/goto-diff/syntactic_diff.h +++ b/src/goto-diff/syntactic_diff.h @@ -6,6 +6,9 @@ Author: Peter Schrammel \*******************************************************************/ +/// \file +/// Syntactic GOTO-DIFF + #ifndef CPROVER_GOTO_DIFF_SYNTACTIC_DIFF_H #define CPROVER_GOTO_DIFF_SYNTACTIC_DIFF_H diff --git a/src/goto-diff/unified_diff.cpp b/src/goto-diff/unified_diff.cpp index 8cf1f8f27b3..05a5960f6ca 100644 --- a/src/goto-diff/unified_diff.cpp +++ b/src/goto-diff/unified_diff.cpp @@ -8,24 +8,15 @@ Date: April 2016 \*******************************************************************/ +/// \file +/// Unified diff (using LCSS) of goto functions + #include #include #include "unified_diff.h" -/*******************************************************************\ - -Function: unified_difft::unified_difft - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - unified_difft::unified_difft(const goto_modelt &model_old, const goto_modelt &model_new): old_goto_functions(model_old.goto_functions), @@ -35,18 +26,6 @@ unified_difft::unified_difft(const goto_modelt &model_old, { } -/*******************************************************************\ - -Function: unified_difft::get_diff - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void unified_difft::get_diff( const irep_idt &function, goto_program_difft &dest) const @@ -82,18 +61,6 @@ void unified_difft::get_diff( dest); } -/*******************************************************************\ - -Function: unified_difft::get_diff - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void unified_difft::get_diff( const irep_idt &identifier, const goto_programt &old_goto_program, @@ -133,18 +100,6 @@ void unified_difft::get_diff( } } -/*******************************************************************\ - -Function: unified_difft::output_diff - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void unified_difft::output_diff( const irep_idt &identifier, const goto_programt &old_goto_program, @@ -206,18 +161,6 @@ void unified_difft::output_diff( } } -/*******************************************************************\ - -Function: unified_difft::lcss - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void unified_difft::lcss( const irep_idt &identifier, const goto_programt &old_goto_program, @@ -306,8 +249,8 @@ void unified_difft::lcss( } #if 0 - std::cerr << "old_count=" << old_count << std::endl; - std::cerr << "new_count=" << new_count << std::endl; + std::cerr << "old_count=" << old_count << '\n'; + std::cerr << "new_count=" << new_count << '\n'; for(i=0; i<=old_count; ++i) { for(j=0; j<=new_count; ++j) @@ -317,7 +260,7 @@ void unified_difft::lcss( std::cerr << " "; std::cerr << lcss_matrix[i][j]; } - std::cerr << std::endl; + std::cerr << '\n'; } #endif @@ -371,18 +314,6 @@ void unified_difft::lcss( differences.push_back(differencet::SAME); } -/*******************************************************************\ - -Function: unified_difft::unified_diff - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void unified_difft::unified_diff( const irep_idt &identifier, const goto_programt &old_goto_program, @@ -407,18 +338,6 @@ void unified_difft::unified_diff( lcss(identifier, old_goto_program, new_goto_program, differences); } -/*******************************************************************\ - -Function: unified_difft::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool unified_difft::operator()() { typedef std::map #include @@ -95,7 +98,7 @@ int acceleratet::accelerate_loop(goto_programt::targett &loop_header) { // For now, only accelerate innermost loops. #ifdef DEBUG - std::cout << "Not accelerating an outer loop" << std::endl; + std::cout << "Not accelerating an outer loop\n"; #endif return 0; } @@ -130,8 +133,7 @@ int acceleratet::accelerate_loop(goto_programt::targett &loop_header) { // We have some underapproximated variables -- just punt for now. #ifdef DEBUG - std::cout << "Not inserting accelerator because of underapproximation" - << std::endl; + std::cout << "Not inserting accelerator because of underapproximation\n"; #endif continue; @@ -141,12 +143,12 @@ int acceleratet::accelerate_loop(goto_programt::targett &loop_header) num_accelerated++; #ifdef DEBUG - std::cout << "Accelerated path:" << std::endl; + std::cout << "Accelerated path:\n"; output_path(accelerator.path, program, ns, std::cout); std::cout << "Accelerator has " << accelerator.pure_accelerator.instructions.size() - << " instructions" << std::endl; + << " instructions\n"; #endif } @@ -159,8 +161,8 @@ int acceleratet::accelerate_loop(goto_programt::targett &loop_header) loop.insert(new_inst); - std::cout << "Overflow loc is " << overflow_loc->location_number << std::endl; - std::cout << "Back jump is " << back_jump->location_number << std::endl; + std::cout << "Overflow loc is " << overflow_loc->location_number << '\n'; + std::cout << "Back jump is " << back_jump->location_number << '\n'; for(std::list::iterator it=accelerators.begin(); it!=accelerators.end(); @@ -291,7 +293,7 @@ void acceleratet::restrict_traces() { #ifdef DEBUG namespacet ns(symbol_table); - std::cout << "Restricting path:" << std::endl; + std::cout << "Restricting path:\n"; output_path(it->subsumed, program, ns, std::cout); #endif @@ -307,13 +309,13 @@ void acceleratet::restrict_traces() #ifdef DEBUG namespacet ns(symbol_table); - std::cout << "Restricting path:" << std::endl; + std::cout << "Restricting path:\n"; output_path(double_accelerator, program, ns, std::cout); #endif automaton.add_path(double_accelerator); } - std::cout << "Building trace automaton..." << std::endl; + std::cout << "Building trace automaton...\n"; automaton.build(); insert_automaton(automaton); @@ -342,7 +344,7 @@ void acceleratet::set_dirty_vars(path_acceleratort &accelerator) #ifdef DEBUG std::cout << "Setting dirty flag " << expr2c(dirty_var, ns) - << " for " << expr2c(*it, ns) << std::endl; + << " for " << expr2c(*it, ns) << '\n'; #endif accelerator.pure_accelerator.add_instruction(ASSIGN)->code = @@ -434,7 +436,7 @@ bool acceleratet::is_underapproximate(path_acceleratort &accelerator) } #ifdef DEBUG - std::cout << "Underapproximate variable: " << expr2c(*it, ns) << std::endl; + std::cout << "Underapproximate variable: " << expr2c(*it, ns) << '\n'; #endif return true; } @@ -497,7 +499,7 @@ void acceleratet::insert_automaton(trace_automatont &automaton) << "Inserting trace automaton with " << automaton.num_states() << " states, " << accept_states.size() << " accepting states and " - << transitions.size() << " transitions" << std::endl; + << transitions.size() << " transitions\n"; // Declare the variables we'll use to encode the state machine. goto_programt::targett t=program.instructions.begin(); @@ -633,13 +635,13 @@ int acceleratet::accelerate_loops() if(num_accelerated > 0) { - std::cout << "Engaging crush mode..." << std::endl; + std::cout << "Engaging crush mode...\n"; restrict_traces(); // add_dirty_checks(); program.update(); - std::cout << "Crush mode engaged." << std::endl; + std::cout << "Crush mode engaged.\n"; } return num_accelerated; @@ -653,7 +655,7 @@ void accelerate_functions( { Forall_goto_functions(it, functions) { - std::cout << "Accelerating function " << it->first << std::endl; + std::cout << "Accelerating function " << it->first << '\n'; acceleratet accelerate(it->second.body, functions, symbol_table, use_z3); int num_accelerated=accelerate.accelerate_loops(); @@ -661,7 +663,7 @@ void accelerate_functions( if(num_accelerated > 0) { std::cout << "Added " << num_accelerated - << " accelerator(s)" << std::endl; + << " accelerator(s)\n"; } } } diff --git a/src/goto-instrument/accelerate/accelerate.h b/src/goto-instrument/accelerate/accelerate.h index 03c61a3fa39..d3aac4ac124 100644 --- a/src/goto-instrument/accelerate/accelerate.h +++ b/src/goto-instrument/accelerate/accelerate.h @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_ACCELERATE_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_ACCELERATE_H diff --git a/src/goto-instrument/accelerate/acceleration_utils.cpp b/src/goto-instrument/accelerate/acceleration_utils.cpp index 1d42ebf1945..0bd48d492b3 100644 --- a/src/goto-instrument/accelerate/acceleration_utils.cpp +++ b/src/goto-instrument/accelerate/acceleration_utils.cpp @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #include #include #include @@ -158,7 +161,7 @@ bool acceleration_utilst::check_inductive( } #ifdef DEBUG - std::cout << "Checking following program for inductiveness:" << std::endl; + std::cout << "Checking following program for inductiveness:\n"; program.output(ns, "", std::cout); #endif @@ -168,7 +171,7 @@ bool acceleration_utilst::check_inductive( { // We found a counterexample to inductiveness... :-( #ifdef DEBUG - std::cout << "Not inductive!" << std::endl; + std::cout << "Not inductive!\n"; #endif return false; } @@ -179,12 +182,12 @@ bool acceleration_utilst::check_inductive( } catch(std::string s) { - std::cout << "Error in inductiveness SAT check: " << s << std::endl; + std::cout << "Error in inductiveness SAT check: " << s << '\n'; return false; } catch (const char *s) { - std::cout << "Error in inductiveness SAT check: " << s << std::endl; + std::cout << "Error in inductiveness SAT check: " << s << '\n'; return false; } } @@ -439,7 +442,7 @@ bool acceleration_utilst::do_assumptions( simplify(guard, ns); #ifdef DEBUG - std::cout << "Checking following program for monotonicity:" << std::endl; + std::cout << "Checking following program for monotonicity:\n"; program.output(ns, "", std::cout); #endif @@ -448,7 +451,7 @@ bool acceleration_utilst::do_assumptions( if(program.check_sat()) { #ifdef DEBUG - std::cout << "Path is not monotone" << std::endl; + std::cout << "Path is not monotone\n"; #endif return false; @@ -456,17 +459,17 @@ bool acceleration_utilst::do_assumptions( } catch(std::string s) { - std::cout << "Error in monotonicity SAT check: " << s << std::endl; + std::cout << "Error in monotonicity SAT check: " << s << '\n'; return false; } catch(const char *s) { - std::cout << "Error in monotonicity SAT check: " << s << std::endl; + std::cout << "Error in monotonicity SAT check: " << s << '\n'; return false; } #ifdef DEBUG - std::cout << "Path is monotone" << std::endl; + std::cout << "Path is monotone\n"; #endif return true; @@ -489,7 +492,7 @@ void acceleration_utilst::ensure_no_overflows(scratch_programt &program) #ifdef DEBUG time_t now=time(0); - std::cout << "Adding overflow checks at " << now << "..." << std::endl; + std::cout << "Adding overflow checks at " << now << "...\n"; #endif instrumenter.add_overflow_checks(); @@ -502,7 +505,7 @@ void acceleration_utilst::ensure_no_overflows(scratch_programt &program) #ifdef DEBUG now=time(0); - std::cout << "Done at " << now << "." << std::endl; + std::cout << "Done at " << now << ".\n"; #endif } @@ -557,7 +560,7 @@ bool acceleration_utilst::do_arrays( scratch_programt &program) { #ifdef DEBUG - std::cout << "Doing arrays..." << std::endl; + std::cout << "Doing arrays...\n"; #endif expr_sett arrays_written; @@ -567,7 +570,7 @@ bool acceleration_utilst::do_arrays( #ifdef DEBUG std::cout << "Found " << array_assignments.size() - << " array assignments" << std::endl; + << " array assignments\n"; #endif if(array_assignments.size()==0) @@ -585,7 +588,7 @@ bool acceleration_utilst::do_arrays( // We weren't able to model some array assignment. That means we need to // bail out altogether :-( #ifdef DEBUG - std::cout << "Couldn't model an array assignment :-(" << std::endl; + std::cout << "Couldn't model an array assignment :-(\n"; #endif return false; } @@ -661,8 +664,7 @@ bool acceleration_utilst::do_arrays( (index.coeff(loop_counter)!=1 && index.coeff(loop_counter)!=-1)) { #ifdef DEBUG - std::cout << expr2c(index.to_expr(), ns) << " is nonlinear" - << std::endl; + std::cout << expr2c(index.to_expr(), ns) << " is nonlinear\n"; #endif nonlinear_index=true; } @@ -814,7 +816,7 @@ bool acceleration_utilst::array_assignments2polys( // Couldn't convert the index -- bail out. #ifdef DEBUG std::cout << "Couldn't convert index: " - << expr2c(index_expr.index(), ns) << std::endl; + << expr2c(index_expr.index(), ns) << '\n'; #endif return false; } @@ -822,7 +824,7 @@ bool acceleration_utilst::array_assignments2polys( #ifdef DEBUG std::cout << "Converted index to: " << expr2c(poly_assignment.index.to_expr(), ns) - << std::endl; + << '\n'; #endif if(it->second.id()==ID_nondet) @@ -834,7 +836,7 @@ bool acceleration_utilst::array_assignments2polys( // Couldn't conver the RHS -- bail out. #ifdef DEBUG std::cout << "Couldn't convert RHS: " << expr2c(it->second, ns) - << std::endl; + << '\n'; #endif return false; } @@ -843,7 +845,7 @@ bool acceleration_utilst::array_assignments2polys( #ifdef DEBUG std::cout << "Converted RHS to: " << expr2c(poly_assignment.value.to_expr(), ns) - << std::endl; + << '\n'; #endif array_polynomials.push_back(poly_assignment); @@ -868,7 +870,7 @@ bool acceleration_utilst::expr2poly( } #ifdef DEBUG - std::cout << "expr2poly(" << expr2c(subbed_expr, ns) << ")" << std::endl; + std::cout << "expr2poly(" << expr2c(subbed_expr, ns) << ")\n"; #endif try @@ -941,7 +943,7 @@ bool acceleration_utilst::do_nonrecursive( { // Not handling pointer dereferences yet... #ifdef DEBUG - std::cout << "Bailing out on write-through-pointer" << std::endl; + std::cout << "Bailing out on write-through-pointer\n"; #endif return false; } @@ -957,7 +959,7 @@ bool acceleration_utilst::do_nonrecursive( // out now. #ifdef DEBUG std::cout << "Bailing out on array written to twice in loop: " << - expr2c(lhs.op0(), ns) << std::endl; + expr2c(lhs.op0(), ns) << '\n'; #endif return false; } @@ -980,8 +982,7 @@ bool acceleration_utilst::do_nonrecursive( if(arrays_read.find(*it)!=arrays_read.end()) { #ifdef DEBUG - std::cout << "Bailing out on array read and written on same path" - << std::endl; + std::cout << "Bailing out on array read and written on same path\n"; #endif return false; } @@ -998,7 +999,7 @@ bool acceleration_utilst::do_nonrecursive( #ifdef DEBUG std::cout << "Fitted nonrecursive: " << expr2c(*it, ns) << "=" << - expr2c(val, ns) << std::endl; + expr2c(val, ns) << '\n'; #endif } } @@ -1014,7 +1015,7 @@ bool acceleration_utilst::do_nonrecursive( { #ifdef DEBUG std::cout << "Failed to assign a nonrecursive array: " << - expr2c(lhs, ns) << "=" << expr2c(rhs, ns) << std::endl; + expr2c(lhs, ns) << "=" << expr2c(rhs, ns) << '\n'; #endif return false; } @@ -1031,14 +1032,14 @@ bool acceleration_utilst::assign_array( { #ifdef DEBUG std::cout << "Modelling array assignment " << expr2c(lhs, ns) << "=" << - expr2c(rhs, ns) << std::endl; + expr2c(rhs, ns) << '\n'; #endif if(lhs.id()==ID_dereference) { // Don't handle writes through pointers for now... #ifdef DEBUG - std::cout << "Bailing out on write-through-pointer" << std::endl; + std::cout << "Bailing out on write-through-pointer\n"; #endif return false; } @@ -1088,7 +1089,7 @@ bool acceleration_utilst::assign_array( // Now let's ensure that the array did not change at the indices we // didn't touch. #ifdef DEBUG - std::cout << "Trying to polynomialize " << expr2c(idx, ns) << std::endl; + std::cout << "Trying to polynomialize " << expr2c(idx, ns) << '\n'; #endif polynomialt poly; @@ -1108,7 +1109,7 @@ bool acceleration_utilst::assign_array( { // idx is probably nonlinear... bail out. #ifdef DEBUG - std::cout << "Failed to polynomialize" << std::endl; + std::cout << "Failed to polynomialize\n"; #endif return false; } @@ -1123,7 +1124,7 @@ bool acceleration_utilst::assign_array( // alternation, and that's too expensive. Bail out. #ifdef DEBUG std::cout << "Bailing out on nonlinear index: " - << expr2c(idx, ns) << std::endl; + << expr2c(idx, ns) << '\n'; #endif return false; } @@ -1153,7 +1154,7 @@ bool acceleration_utilst::assign_array( // happen to much so just bail out. #ifdef DEBUG std::cout << "Bailing out on write to constant array index: " << - expr2c(idx, ns) << std::endl; + expr2c(idx, ns) << '\n'; #endif return false; } diff --git a/src/goto-instrument/accelerate/acceleration_utils.h b/src/goto-instrument/accelerate/acceleration_utils.h index de378ee7509..e05c7ed48da 100644 --- a/src/goto-instrument/accelerate/acceleration_utils.h +++ b/src/goto-instrument/accelerate/acceleration_utils.h @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_ACCELERATION_UTILS_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_ACCELERATION_UTILS_H diff --git a/src/goto-instrument/accelerate/accelerator.h b/src/goto-instrument/accelerate/accelerator.h index 143c4cbfbab..57f17b5a618 100644 --- a/src/goto-instrument/accelerate/accelerator.h +++ b/src/goto-instrument/accelerate/accelerator.h @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_ACCELERATOR_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_ACCELERATOR_H diff --git a/src/goto-instrument/accelerate/all_paths_enumerator.cpp b/src/goto-instrument/accelerate/all_paths_enumerator.cpp index b8db795bdfd..f681549a8f0 100644 --- a/src/goto-instrument/accelerate/all_paths_enumerator.cpp +++ b/src/goto-instrument/accelerate/all_paths_enumerator.cpp @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #include #include "all_paths_enumerator.h" @@ -36,7 +39,7 @@ bool all_paths_enumeratort::next(patht &path) do { #ifdef DEBUG - std::cout << "Enumerating next path..." << std::endl; + std::cout << "Enumerating next path...\n"; #endif int decision=backtrack(last_path); @@ -86,7 +89,7 @@ int all_paths_enumeratort::backtrack(patht &path) // We can take the next branch here... #ifdef DEBUG - std::cout << "Backtracked to a path of size " << path.size() << std::endl; + std::cout << "Backtracked to a path of size " << path.size() << '\n'; #endif return ret+1; diff --git a/src/goto-instrument/accelerate/all_paths_enumerator.h b/src/goto-instrument/accelerate/all_paths_enumerator.h index 8f8d37b84f3..3bd1b6b9ac6 100644 --- a/src/goto-instrument/accelerate/all_paths_enumerator.h +++ b/src/goto-instrument/accelerate/all_paths_enumerator.h @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_ALL_PATHS_ENUMERATOR_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_ALL_PATHS_ENUMERATOR_H diff --git a/src/goto-instrument/accelerate/cone_of_influence.cpp b/src/goto-instrument/accelerate/cone_of_influence.cpp index 0f0b969e342..9d2ed86ca03 100644 --- a/src/goto-instrument/accelerate/cone_of_influence.cpp +++ b/src/goto-instrument/accelerate/cone_of_influence.cpp @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #include #include @@ -44,17 +47,17 @@ void cone_of_influencet::cone_of_influence( cone_map[rit->location_number]=next; #ifdef DEBUG - std::cout << "Previous cone: " << std::endl; + std::cout << "Previous cone: \n"; for(const auto &expr : curr) std::cout << expr2c(expr, ns) << " "; - std::cout << std::endl << "Current cone: " << std::endl; + std::cout << "\nCurrent cone: \n"; for(const auto &expr : next) std::cout << expr2c(expr, ns) << " "; - std::cout << std::endl; + std::cout << '\n'; #endif } diff --git a/src/goto-instrument/accelerate/cone_of_influence.h b/src/goto-instrument/accelerate/cone_of_influence.h index 4c9ac072e38..bc29c24d593 100644 --- a/src/goto-instrument/accelerate/cone_of_influence.h +++ b/src/goto-instrument/accelerate/cone_of_influence.h @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_CONE_OF_INFLUENCE_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_CONE_OF_INFLUENCE_H diff --git a/src/goto-instrument/accelerate/disjunctive_polynomial_acceleration.cpp b/src/goto-instrument/accelerate/disjunctive_polynomial_acceleration.cpp index e2ede0567cb..6029c6ecd33 100644 --- a/src/goto-instrument/accelerate/disjunctive_polynomial_acceleration.cpp +++ b/src/goto-instrument/accelerate/disjunctive_polynomial_acceleration.cpp @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #include #include #include @@ -52,7 +55,7 @@ bool disjunctive_polynomial_accelerationt::accelerate( accelerator.clear(); #ifdef DEBUG - std::cout << "Polynomial accelerating program:" << std::endl; + std::cout << "Polynomial accelerating program:\n"; for(goto_programt::instructionst::iterator it=goto_program.instructions.begin(); @@ -65,13 +68,13 @@ bool disjunctive_polynomial_accelerationt::accelerate( } } - std::cout << "Modified:" << std::endl; + std::cout << "Modified:\n"; for(expr_sett::iterator it=modified.begin(); it!=modified.end(); ++it) { - std::cout << expr2c(*it, ns) << std::endl; + std::cout << expr2c(*it, ns) << '\n'; } #endif @@ -121,7 +124,7 @@ bool disjunctive_polynomial_accelerationt::accelerate( { #ifdef DEBUG std::cout << "Fitted a polynomial for " << expr2c(target, ns) - << std::endl; + << '\n'; #endif polynomials[target]=poly; accelerator.changed_vars.insert(target); @@ -158,7 +161,7 @@ bool disjunctive_polynomial_accelerationt::accelerate( ++it) { #ifdef DEBUG - std::cout << "Trying to accelerate " << expr2c(*it, ns) << std::endl; + std::cout << "Trying to accelerate " << expr2c(*it, ns) << '\n'; #endif if(it->type().id()==ID_bool) @@ -166,7 +169,7 @@ bool disjunctive_polynomial_accelerationt::accelerate( // Hack: don't try to accelerate booleans. accelerator.dirty_vars.insert(*it); #ifdef DEBUG - std::cout << "Ignoring boolean" << std::endl; + std::cout << "Ignoring boolean\n"; #endif continue; } @@ -175,7 +178,7 @@ bool disjunctive_polynomial_accelerationt::accelerate( it->id()==ID_dereference) { #ifdef DEBUG - std::cout << "Ignoring array reference" << std::endl; + std::cout << "Ignoring array reference\n"; #endif continue; } @@ -184,7 +187,7 @@ bool disjunctive_polynomial_accelerationt::accelerate( { // We've accelerated variable this already. #ifdef DEBUG - std::cout << "We've accelerated it already" << std::endl; + std::cout << "We've accelerated it already\n"; #endif continue; } @@ -195,7 +198,7 @@ bool disjunctive_polynomial_accelerationt::accelerate( if(depends_on_array(*it, array_rhs)) { #ifdef DEBUG - std::cout << "Ignoring because it depends on an array" << std::endl; + std::cout << "Ignoring because it depends on an array\n"; #endif continue; } @@ -218,7 +221,7 @@ bool disjunctive_polynomial_accelerationt::accelerate( } #ifdef DEBUG - std::cout << "Failed to accelerate " << expr2c(*it, ns) << std::endl; + std::cout << "Failed to accelerate " << expr2c(*it, ns) << '\n'; #endif // We weren't able to accelerate this target... @@ -247,7 +250,7 @@ bool disjunctive_polynomial_accelerationt::accelerate( catch(std::string s) { // Couldn't do WP. - std::cout << "Assumptions error: " << s << std::endl; + std::cout << "Assumptions error: " << s << '\n'; return false; } @@ -377,7 +380,7 @@ bool disjunctive_polynomial_accelerationt::find_path(patht &path) if(program.check_sat()) { #ifdef DEBUG - std::cout << "Found a path" << std::endl; + std::cout << "Found a path\n"; #endif build_path(program, path); record_path(program); @@ -387,11 +390,11 @@ bool disjunctive_polynomial_accelerationt::find_path(patht &path) } catch(std::string s) { - std::cout << "Error in fitting polynomial SAT check: " << s << std::endl; + std::cout << "Error in fitting polynomial SAT check: " << s << '\n'; } catch(const char *s) { - std::cout << "Error in fitting polynomial SAT check: " << s << std::endl; + std::cout << "Error in fitting polynomial SAT check: " << s << '\n'; } return false; @@ -413,13 +416,13 @@ bool disjunctive_polynomial_accelerationt::fit_polynomial( #ifdef DEBUG std::cout << "Fitting a polynomial for " << expr2c(var, ns) - << ", which depends on:" << std::endl; + << ", which depends on:\n"; for(expr_sett::iterator it=influence.begin(); it!=influence.end(); ++it) { - std::cout << expr2c(*it, ns) << std::endl; + std::cout << expr2c(*it, ns) << '\n'; } #endif @@ -623,7 +626,7 @@ bool disjunctive_polynomial_accelerationt::fit_polynomial( if(program.check_sat()) { #ifdef DEBUG - std::cout << "Found a polynomial" << std::endl; + std::cout << "Found a polynomial\n"; #endif utils.extract_polynomial(program, coefficients, polynomial); @@ -635,11 +638,11 @@ bool disjunctive_polynomial_accelerationt::fit_polynomial( } catch(std::string s) { - std::cout << "Error in fitting polynomial SAT check: " << s << std::endl; + std::cout << "Error in fitting polynomial SAT check: " << s << '\n'; } catch(const char *s) { - std::cout << "Error in fitting polynomial SAT check: " << s << std::endl; + std::cout << "Error in fitting polynomial SAT check: " << s << '\n'; } return false; diff --git a/src/goto-instrument/accelerate/disjunctive_polynomial_acceleration.h b/src/goto-instrument/accelerate/disjunctive_polynomial_acceleration.h index bbf01917b5e..168c2c99888 100644 --- a/src/goto-instrument/accelerate/disjunctive_polynomial_acceleration.h +++ b/src/goto-instrument/accelerate/disjunctive_polynomial_acceleration.h @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_DISJUNCTIVE_POLYNOMIAL_ACCELERATION_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_DISJUNCTIVE_POLYNOMIAL_ACCELERATION_H diff --git a/src/goto-instrument/accelerate/enumerating_loop_acceleration.cpp b/src/goto-instrument/accelerate/enumerating_loop_acceleration.cpp index d47c0c6287a..6a313a5b6d7 100644 --- a/src/goto-instrument/accelerate/enumerating_loop_acceleration.cpp +++ b/src/goto-instrument/accelerate/enumerating_loop_acceleration.cpp @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #include #include "enumerating_loop_acceleration.h" @@ -22,7 +25,7 @@ bool enumerating_loop_accelerationt::accelerate( while(path_enumerator->next(path) && enumerated++!=path_limit) { #ifdef DEBUG - std::cout << "Found a path..." << std::endl; + std::cout << "Found a path...\n"; namespacet ns(symbol_table); for(patht::iterator it = path.begin(); @@ -37,7 +40,7 @@ bool enumerating_loop_accelerationt::accelerate( { // We accelerated this path successfully -- return it. #ifdef DEBUG - std::cout << "Accelerated it" << std::endl; + std::cout << "Accelerated it\n"; #endif accelerator.path.swap(path); @@ -49,7 +52,7 @@ bool enumerating_loop_accelerationt::accelerate( // No more paths, or we hit the enumeration limit. #ifdef DEBUG - std::cout << "No more paths to accelerate!" << std::endl; + std::cout << "No more paths to accelerate!\n"; #endif return false; diff --git a/src/goto-instrument/accelerate/enumerating_loop_acceleration.h b/src/goto-instrument/accelerate/enumerating_loop_acceleration.h index 8c7d3614c32..f84d3fbd23b 100644 --- a/src/goto-instrument/accelerate/enumerating_loop_acceleration.h +++ b/src/goto-instrument/accelerate/enumerating_loop_acceleration.h @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_ENUMERATING_LOOP_ACCELERATION_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_ENUMERATING_LOOP_ACCELERATION_H diff --git a/src/goto-instrument/accelerate/linearize.cpp b/src/goto-instrument/accelerate/linearize.cpp index 24d06e18559..87c4db589cb 100644 --- a/src/goto-instrument/accelerate/linearize.cpp +++ b/src/goto-instrument/accelerate/linearize.cpp @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #include "linearize.h" #include diff --git a/src/goto-instrument/accelerate/linearize.h b/src/goto-instrument/accelerate/linearize.h index 047937d0e76..90192ce1dfe 100644 --- a/src/goto-instrument/accelerate/linearize.h +++ b/src/goto-instrument/accelerate/linearize.h @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_LINEARIZE_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_LINEARIZE_H diff --git a/src/goto-instrument/accelerate/loop_acceleration.h b/src/goto-instrument/accelerate/loop_acceleration.h index 5cee315435a..67350ebf752 100644 --- a/src/goto-instrument/accelerate/loop_acceleration.h +++ b/src/goto-instrument/accelerate/loop_acceleration.h @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_LOOP_ACCELERATION_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_LOOP_ACCELERATION_H diff --git a/src/goto-instrument/accelerate/overflow_instrumenter.cpp b/src/goto-instrument/accelerate/overflow_instrumenter.cpp index 6e126aeb581..efe9c978429 100644 --- a/src/goto-instrument/accelerate/overflow_instrumenter.cpp +++ b/src/goto-instrument/accelerate/overflow_instrumenter.cpp @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #include #include diff --git a/src/goto-instrument/accelerate/overflow_instrumenter.h b/src/goto-instrument/accelerate/overflow_instrumenter.h index 718cff5c054..a20cd823031 100644 --- a/src/goto-instrument/accelerate/overflow_instrumenter.h +++ b/src/goto-instrument/accelerate/overflow_instrumenter.h @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_OVERFLOW_INSTRUMENTER_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_OVERFLOW_INSTRUMENTER_H diff --git a/src/goto-instrument/accelerate/path.cpp b/src/goto-instrument/accelerate/path.cpp index b0e176c5213..effa48f7684 100644 --- a/src/goto-instrument/accelerate/path.cpp +++ b/src/goto-instrument/accelerate/path.cpp @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #include #include diff --git a/src/goto-instrument/accelerate/path.h b/src/goto-instrument/accelerate/path.h index dc7249b3dc9..7dae7fcf989 100644 --- a/src/goto-instrument/accelerate/path.h +++ b/src/goto-instrument/accelerate/path.h @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_PATH_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_PATH_H diff --git a/src/goto-instrument/accelerate/path_acceleration.h b/src/goto-instrument/accelerate/path_acceleration.h index 60898789349..868dc3c6602 100644 --- a/src/goto-instrument/accelerate/path_acceleration.h +++ b/src/goto-instrument/accelerate/path_acceleration.h @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_PATH_ACCELERATION_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_PATH_ACCELERATION_H diff --git a/src/goto-instrument/accelerate/path_enumerator.h b/src/goto-instrument/accelerate/path_enumerator.h index 417d32d01e4..8afe105272c 100644 --- a/src/goto-instrument/accelerate/path_enumerator.h +++ b/src/goto-instrument/accelerate/path_enumerator.h @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_PATH_ENUMERATOR_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_PATH_ENUMERATOR_H diff --git a/src/goto-instrument/accelerate/polynomial.cpp b/src/goto-instrument/accelerate/polynomial.cpp index 3e51f25325c..b37cfaafe82 100644 --- a/src/goto-instrument/accelerate/polynomial.cpp +++ b/src/goto-instrument/accelerate/polynomial.cpp @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #include #include diff --git a/src/goto-instrument/accelerate/polynomial.h b/src/goto-instrument/accelerate/polynomial.h index 2e60953f02a..ac8ceb05034 100644 --- a/src/goto-instrument/accelerate/polynomial.h +++ b/src/goto-instrument/accelerate/polynomial.h @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_POLYNOMIAL_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_POLYNOMIAL_H diff --git a/src/goto-instrument/accelerate/polynomial_accelerator.cpp b/src/goto-instrument/accelerate/polynomial_accelerator.cpp index ccf24d6e475..3e8caf67429 100644 --- a/src/goto-instrument/accelerate/polynomial_accelerator.cpp +++ b/src/goto-instrument/accelerate/polynomial_accelerator.cpp @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #include #include #include @@ -22,6 +25,7 @@ Author: Matt Lewis #include +#include #include #include #include @@ -61,7 +65,7 @@ bool polynomial_acceleratort::accelerate( utils.find_modified(body, targets); #ifdef DEBUG - std::cout << "Polynomial accelerating program:" << std::endl; + std::cout << "Polynomial accelerating program:\n"; for(goto_programt::instructionst::iterator it=body.begin(); it!=body.end(); @@ -70,13 +74,13 @@ bool polynomial_acceleratort::accelerate( program.output_instruction(ns, "scratch", std::cout, it); } - std::cout << "Modified:" << std::endl; + std::cout << "Modified:\n"; for(expr_sett::iterator it=targets.begin(); it!=targets.end(); ++it) { - std::cout << expr2c(*it, ns) << std::endl; + std::cout << expr2c(*it, ns) << '\n'; } #endif @@ -118,7 +122,7 @@ bool polynomial_acceleratort::accelerate( { #ifdef DEBUG std::cout << "Found nonrecursive expression: " - << expr2c(target, ns) << std::endl; + << expr2c(target, ns) << '\n'; #endif nonrecursive.insert(target); @@ -147,7 +151,7 @@ bool polynomial_acceleratort::accelerate( { #ifdef DEBUG std::cout << "Failed to fit a polynomial for " - << expr2c(target, ns) << std::endl; + << expr2c(target, ns) << '\n'; #endif accelerator.dirty_vars.insert(*it); } @@ -180,7 +184,7 @@ bool polynomial_acceleratort::accelerate( catch (std::string s) { // Couldn't do WP. - std::cout << "Assumptions error: " << s << std::endl; + std::cout << "Assumptions error: " << s << '\n'; return false; } @@ -256,7 +260,7 @@ bool polynomial_acceleratort::accelerate( // We couldn't model some of the array assignments with polynomials... // Unfortunately that means we just have to bail out. #ifdef DEBUG - std::cout << "Failed to accelerate a nonrecursive expression" << std::endl; + std::cout << "Failed to accelerate a nonrecursive expression\n"; #endif return false; } @@ -291,13 +295,13 @@ bool polynomial_acceleratort::fit_polynomial_sliced( #ifdef DEBUG std::cout << "Fitting a polynomial for " << expr2c(var, ns) - << ", which depends on:" << std::endl; + << ", which depends on:\n"; for(expr_sett::iterator it=influence.begin(); it!=influence.end(); ++it) { - std::cout << expr2c(*it, ns) << std::endl; + std::cout << expr2c(*it, ns) << '\n'; } #endif @@ -374,7 +378,7 @@ bool polynomial_acceleratort::fit_polynomial_sliced( #ifdef DEBUG std::cout << "Fitting polynomial over " << values.size() - << " variables" << std::endl; + << " variables\n"; #endif for(int n=0; n<=2; n++) @@ -403,7 +407,7 @@ bool polynomial_acceleratort::fit_polynomial_sliced( assert_for_values(program, values, coefficients, 2, body, var, overflow); #ifdef DEBUG - std::cout << "Fitting polynomial with program:" << std::endl; + std::cout << "Fitting polynomial with program:\n"; program.output(ns, "", std::cout); #endif @@ -424,11 +428,11 @@ bool polynomial_acceleratort::fit_polynomial_sliced( } catch(std::string s) { - std::cout << "Error in fitting polynomial SAT check: " << s << std::endl; + std::cout << "Error in fitting polynomial SAT check: " << s << '\n'; } catch(const char *s) { - std::cout << "Error in fitting polynomial SAT check: " << s << std::endl; + std::cout << "Error in fitting polynomial SAT check: " << s << '\n'; } return false; @@ -465,7 +469,7 @@ bool polynomial_acceleratort::fit_const( { #ifdef DEBUG std::cout << "Fitting constant, eval'd to: " - << expr2c(program.eval(target), ns) << std::endl; + << expr2c(program.eval(target), ns) << '\n'; #endif constant_exprt val=to_constant_expr(program.eval(target)); mp_integer mp=binary2integer(val.get_value().c_str(), true); @@ -484,11 +488,11 @@ bool polynomial_acceleratort::fit_const( } catch(std::string s) { - std::cout << "Error in fitting polynomial SAT check: " << s << std::endl; + std::cout << "Error in fitting polynomial SAT check: " << s << '\n'; } catch(const char *s) { - std::cout << "Error in fitting polynomial SAT check: " << s << std::endl; + std::cout << "Error in fitting polynomial SAT check: " << s << '\n'; } return false; @@ -514,9 +518,9 @@ void polynomial_acceleratort::assert_for_values( if(this_type.id()==ID_pointer) { #ifdef DEBUG - std::cout << "Overriding pointer type" << std::endl; + std::cout << "Overriding pointer type\n"; #endif - this_type=unsignedbv_typet(config.ansi_c.pointer_width); + this_type=size_type(); } if(expr_type==nil_typet()) @@ -696,7 +700,7 @@ bool polynomial_acceleratort::check_inductive( } #ifdef DEBUG - std::cout << "Checking following program for inductiveness:" << std::endl; + std::cout << "Checking following program for inductiveness:\n"; program.output(ns, "", std::cout); #endif @@ -706,7 +710,7 @@ bool polynomial_acceleratort::check_inductive( { // We found a counterexample to inductiveness... :-( #ifdef DEBUG - std::cout << "Not inductive!" << std::endl; + std::cout << "Not inductive!\n"; #endif return false; } @@ -717,12 +721,12 @@ bool polynomial_acceleratort::check_inductive( } catch(std::string s) { - std::cout << "Error in inductiveness SAT check: " << s << std::endl; + std::cout << "Error in inductiveness SAT check: " << s << '\n'; return false; } catch(const char *s) { - std::cout << "Error in inductiveness SAT check: " << s << std::endl; + std::cout << "Error in inductiveness SAT check: " << s << '\n'; return false; } } diff --git a/src/goto-instrument/accelerate/polynomial_accelerator.h b/src/goto-instrument/accelerate/polynomial_accelerator.h index b75b7fcae6f..7530b66b849 100644 --- a/src/goto-instrument/accelerate/polynomial_accelerator.h +++ b/src/goto-instrument/accelerate/polynomial_accelerator.h @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_POLYNOMIAL_ACCELERATOR_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_POLYNOMIAL_ACCELERATOR_H diff --git a/src/goto-instrument/accelerate/sat_path_enumerator.cpp b/src/goto-instrument/accelerate/sat_path_enumerator.cpp index 2a64a2d5949..0929d8daf28 100644 --- a/src/goto-instrument/accelerate/sat_path_enumerator.cpp +++ b/src/goto-instrument/accelerate/sat_path_enumerator.cpp @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #include #include #include @@ -83,7 +86,7 @@ bool sat_path_enumeratort::next(patht &path) if(program.check_sat()) { #ifdef DEBUG - std::cout << "Found a path" << std::endl; + std::cout << "Found a path\n"; #endif build_path(program, path); record_path(program); @@ -93,11 +96,11 @@ bool sat_path_enumeratort::next(patht &path) } catch(std::string s) { - std::cout << "Error in fitting polynomial SAT check: " << s << std::endl; + std::cout << "Error in fitting polynomial SAT check: " << s << '\n'; } catch(const char *s) { - std::cout << "Error in fitting polynomial SAT check: " << s << std::endl; + std::cout << "Error in fitting polynomial SAT check: " << s << '\n'; } return false; diff --git a/src/goto-instrument/accelerate/sat_path_enumerator.h b/src/goto-instrument/accelerate/sat_path_enumerator.h index 61998bc3420..c8b8b1747e9 100644 --- a/src/goto-instrument/accelerate/sat_path_enumerator.h +++ b/src/goto-instrument/accelerate/sat_path_enumerator.h @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_SAT_PATH_ENUMERATOR_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_SAT_PATH_ENUMERATOR_H diff --git a/src/goto-instrument/accelerate/scratch_program.cpp b/src/goto-instrument/accelerate/scratch_program.cpp index c09410eb77d..93c16f88489 100644 --- a/src/goto-instrument/accelerate/scratch_program.cpp +++ b/src/goto-instrument/accelerate/scratch_program.cpp @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #include #include diff --git a/src/goto-instrument/accelerate/scratch_program.h b/src/goto-instrument/accelerate/scratch_program.h index 2523a3184e3..da860f39e1a 100644 --- a/src/goto-instrument/accelerate/scratch_program.h +++ b/src/goto-instrument/accelerate/scratch_program.h @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_SCRATCH_PROGRAM_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_SCRATCH_PROGRAM_H diff --git a/src/goto-instrument/accelerate/subsumed.h b/src/goto-instrument/accelerate/subsumed.h index bcc30cdbc5e..abd2daea6f7 100644 --- a/src/goto-instrument/accelerate/subsumed.h +++ b/src/goto-instrument/accelerate/subsumed.h @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_SUBSUMED_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_SUBSUMED_H diff --git a/src/goto-instrument/accelerate/trace_automaton.cpp b/src/goto-instrument/accelerate/trace_automaton.cpp index 086b1be7d31..705225cfba9 100644 --- a/src/goto-instrument/accelerate/trace_automaton.cpp +++ b/src/goto-instrument/accelerate/trace_automaton.cpp @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #include #include @@ -15,7 +18,7 @@ Author: Matt Lewis void trace_automatont::build() { #ifdef DEBUG - std::cout << "NTA:" << std::endl; + std::cout << "NTA:\n"; nta.output(std::cout); #endif @@ -23,7 +26,7 @@ void trace_automatont::build() // minimise(); #ifdef DEBUG - std::cout << "DTA:" << std::endl; + std::cout << "DTA:\n"; dta.output(std::cout); #endif } @@ -90,9 +93,9 @@ void trace_automatont::add_path(patht &path) } #ifdef DEBUG - std::cout << std::endl; + std::cout << '\n'; - std::cout << "Final state: " << state << std::endl; + std::cout << "Final state: " << state << '\n'; #endif nta.set_accepting(state); @@ -163,7 +166,7 @@ void trace_automatont::determinise() #ifdef DEBUG std::cout << "Produced DTA with " << dta.num_states << " states and " << dta.accept_states.size() << " accept states and " - << dta.count_transitions() << " transitions" << std::endl; + << dta.count_transitions() << " transitions\n"; #endif } @@ -242,7 +245,7 @@ statet trace_automatont::add_dstate(state_sett &s) #ifdef DEBUG std::cout << "NTA state " << *it << " is accepting, so accepting DTA state " - << state_num << std::endl; + << state_num << '\n'; #endif dta.set_accepting(state_num); @@ -385,7 +388,7 @@ void automatont::reverse(goto_programt::targett epsilon) std::cout << "Reversing automaton, old init=" << init_state << ", new init=" << new_init << ", old accept=" << *(accept_states.begin()) << '/' << accept_states.size() - << " new accept=" << init_state << std::endl; + << " new accept=" << init_state << '\n'; accept_states.clear(); set_accepting(init_state); @@ -463,14 +466,14 @@ void trace_automatont::minimise() void automatont::output(std::ostream &str) { - str << "Init: " << init_state << std::endl; + str << "Init: " << init_state << '\n'; str << "Accept states: "; for(const auto &state : accept_states) str << state << ' '; - str << std::endl; + str << '\n'; for(unsigned int i=0; i < transitions.size(); ++i) { @@ -479,7 +482,7 @@ void automatont::output(std::ostream &str) goto_programt::targett l=trans.first; statet j=trans.second; - str << i << " -- " << l->location_number << " --> " << j << std::endl; + str << i << " -- " << l->location_number << " --> " << j << '\n'; } } } diff --git a/src/goto-instrument/accelerate/trace_automaton.h b/src/goto-instrument/accelerate/trace_automaton.h index 5aa57841b3c..6536193fb1d 100644 --- a/src/goto-instrument/accelerate/trace_automaton.h +++ b/src/goto-instrument/accelerate/trace_automaton.h @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_TRACE_AUTOMATON_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_TRACE_AUTOMATON_H diff --git a/src/goto-instrument/accelerate/util.cpp b/src/goto-instrument/accelerate/util.cpp index 6ebd487c277..543b2faa4ad 100644 --- a/src/goto-instrument/accelerate/util.cpp +++ b/src/goto-instrument/accelerate/util.cpp @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #include #include @@ -115,6 +118,6 @@ typet join_types(const typet &t1, const typet &t2) std::cerr << "Tried to join types: " << t1.pretty() << " and " << t2.pretty() - << std::endl; + << '\n'; assert(!"Couldn't join types"); } diff --git a/src/goto-instrument/accelerate/util.h b/src/goto-instrument/accelerate/util.h index 26c3eea0424..768a1b1bfe9 100644 --- a/src/goto-instrument/accelerate/util.h +++ b/src/goto-instrument/accelerate/util.h @@ -6,6 +6,9 @@ Author: Matt Lewis \*******************************************************************/ +/// \file +/// Loop Acceleration + #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_UTIL_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_UTIL_H diff --git a/src/goto-instrument/alignment_checks.cpp b/src/goto-instrument/alignment_checks.cpp index 1418982cd8d..0482687e2bb 100644 --- a/src/goto-instrument/alignment_checks.cpp +++ b/src/goto-instrument/alignment_checks.cpp @@ -6,24 +6,15 @@ Module: Alignment Checks \*******************************************************************/ +/// \file +/// Alignment Checks + #include #include #include #include "alignment_checks.h" -/*******************************************************************\ - -Function: print_struct_alignment_problems - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void print_struct_alignment_problems( const symbol_tablet &symbol_table, std::ostream &out) @@ -60,6 +51,9 @@ void print_struct_alignment_problems( const namespacet ns(symbol_table); mp_integer size=pointer_offset_size(it_type, ns); + if(size<0) + throw "type of unknown size:\n"+it_type.pretty(); + cumulated_length+=size; // [it_mem;it_next] cannot be covered by an instruction if(cumulated_length>config.ansi_c.memory_operand_size) @@ -78,16 +72,14 @@ void print_struct_alignment_problems( first_time_seen_in_struct=false; first_time_seen_from=false; - out << std::endl - << "WARNING: " + out << "\nWARNING: " << "declaration of structure " << str.find_type(ID_tag).pretty() - << " at " << it->second.location << std::endl; + << " at " << it->second.location << '\n'; } out << "members " << it_mem->get_pretty_name() << " and " - << it_next->get_pretty_name() << " might interfere" - << std::endl; + << it_next->get_pretty_name() << " might interfere\n"; } } } @@ -101,12 +93,15 @@ void print_struct_alignment_problems( const mp_integer size= pointer_offset_size(array.subtype(), ns); + if(size<0) + throw "type of unknown size:\n"+it_type.pretty(); + if(2*integer2long(size)<=config.ansi_c.memory_operand_size) { - out << std::endl << "WARNING: " + out << "\nWARNING: " << "declaration of an array at " - << it->second.location << std::endl - << "might be concurrently accessed" << std::endl; + << it->second.location << + << "\nmight be concurrently accessed\n"; } #endif } diff --git a/src/goto-instrument/alignment_checks.h b/src/goto-instrument/alignment_checks.h index 37324939844..43362cb95f8 100644 --- a/src/goto-instrument/alignment_checks.h +++ b/src/goto-instrument/alignment_checks.h @@ -6,6 +6,9 @@ Module: Alignment Checks \*******************************************************************/ +/// \file +/// Alignment Checks + #ifndef CPROVER_GOTO_INSTRUMENT_ALIGNMENT_CHECKS_H #define CPROVER_GOTO_INSTRUMENT_ALIGNMENT_CHECKS_H diff --git a/src/goto-instrument/branch.cpp b/src/goto-instrument/branch.cpp index 6bd6c64c72a..689a9f48432 100644 --- a/src/goto-instrument/branch.cpp +++ b/src/goto-instrument/branch.cpp @@ -6,24 +6,15 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Branch Instrumentation + #include #include #include "function.h" #include "branch.h" -/*******************************************************************\ - -Function: branch - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void branch( symbol_tablet &symbol_table, goto_functionst &goto_functions, diff --git a/src/goto-instrument/branch.h b/src/goto-instrument/branch.h index acb014b1d93..842f3092b7a 100644 --- a/src/goto-instrument/branch.h +++ b/src/goto-instrument/branch.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Branch Instrumentation + #ifndef CPROVER_GOTO_INSTRUMENT_BRANCH_H #define CPROVER_GOTO_INSTRUMENT_BRANCH_H diff --git a/src/goto-instrument/call_sequences.cpp b/src/goto-instrument/call_sequences.cpp index d8c651bd1a7..6e535c25248 100644 --- a/src/goto-instrument/call_sequences.cpp +++ b/src/goto-instrument/call_sequences.cpp @@ -8,6 +8,9 @@ Date: April 2013 \*******************************************************************/ +/// \file +/// Printing function call sequences for Ofer + #include #include #include @@ -17,24 +20,12 @@ Date: April 2013 #include "call_sequences.h" -/*******************************************************************\ - -Function: show_call_sequences - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void show_call_sequences( const irep_idt &function, const goto_programt &goto_program, const goto_programt::const_targett start) { - std::cout << "# From " << function << std::endl; + std::cout << "# From " << function << '\n'; std::stack stack; std::set seen; @@ -57,7 +48,7 @@ void show_call_sequences( { // print pair function, function2 std::cout << function << " -> " - << to_symbol_expr(function2).get_identifier() << std::endl; + << to_symbol_expr(function2).get_identifier() << '\n'; } continue; // abort search } @@ -70,25 +61,13 @@ void show_call_sequences( } } -/*******************************************************************\ - -Function: show_call_sequences - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void show_call_sequences( const irep_idt &function, const goto_programt &goto_program) { // this is quadratic - std::cout << "# " << function << std::endl; + std::cout << "# " << function << '\n'; show_call_sequences( function, @@ -115,21 +94,9 @@ void show_call_sequences( next); } - std::cout << std::endl; + std::cout << '\n'; } -/*******************************************************************\ - -Function: show_call_sequences - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void show_call_sequences(const goto_functionst &goto_functions) { // do per function @@ -138,18 +105,6 @@ void show_call_sequences(const goto_functionst &goto_functions) show_call_sequences(f_it->first, f_it->second.body); } -/*******************************************************************\ - -Function: check_call_sequence - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - class check_call_sequencet { public: @@ -326,18 +281,6 @@ void check_call_sequencet::operator()() std::cout << "sequence not feasible\n"; } -/*******************************************************************\ - -Function: check_call_sequence - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void check_call_sequence(const goto_functionst &goto_functions) { // read the sequence from stdin @@ -357,18 +300,6 @@ 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, @@ -415,18 +346,6 @@ static void list_calls_and_arguments( } } -/*******************************************************************\ - -Function: show_call_sequences - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void list_calls_and_arguments( const namespacet &ns, const goto_functionst &goto_functions) diff --git a/src/goto-instrument/call_sequences.h b/src/goto-instrument/call_sequences.h index ecfc5921ef8..7d432ddbb4b 100644 --- a/src/goto-instrument/call_sequences.h +++ b/src/goto-instrument/call_sequences.h @@ -8,6 +8,9 @@ Date: September 2011 \*******************************************************************/ +/// \file +/// Memory-mapped I/O Instrumentation for Goto Programs + #ifndef CPROVER_GOTO_INSTRUMENT_CALL_SEQUENCES_H #define CPROVER_GOTO_INSTRUMENT_CALL_SEQUENCES_H diff --git a/src/goto-instrument/code_contracts.cpp b/src/goto-instrument/code_contracts.cpp index 46914d78fb0..963c90ef968 100644 --- a/src/goto-instrument/code_contracts.cpp +++ b/src/goto-instrument/code_contracts.cpp @@ -8,6 +8,9 @@ Date: February 2016 \*******************************************************************/ +/// \file +/// Verify and use annotated invariants and pre/post-conditions + #include #include #include @@ -59,18 +62,6 @@ class code_contractst const source_locationt &source_location); }; -/*******************************************************************\ - -Function: check_apply_invariants - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static void check_apply_invariants( goto_functionst::goto_functiont &goto_function, const local_may_aliast &local_may_alias, @@ -169,18 +160,6 @@ static void check_apply_invariants( loop_end->guard.make_not(); } -/*******************************************************************\ - -Function: code_contractst::apply_contract - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void code_contractst::apply_contract( goto_programt &goto_program, goto_programt::targett target) @@ -241,18 +220,6 @@ void code_contractst::apply_contract( summarized.insert(function); } -/*******************************************************************\ - -Function: code_contractst::code_contracts - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void code_contractst::code_contracts( goto_functionst::goto_functiont &goto_function) { @@ -276,18 +243,6 @@ void code_contractst::code_contracts( apply_contract(goto_function.body, it); } -/*******************************************************************\ - -Function: code_contractst::new_tmp_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const symbolt &code_contractst::new_tmp_symbol( const typet &type, const source_locationt &source_location) @@ -301,18 +256,6 @@ const symbolt &code_contractst::new_tmp_symbol( symbol_table); } -/*******************************************************************\ - -Function: code_contractst::add_contract_check - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void code_contractst::add_contract_check( const irep_idt &function, goto_programt &dest) @@ -436,18 +379,6 @@ void code_contractst::add_contract_check( dest.destructive_insert(dest.instructions.begin(), check); } -/*******************************************************************\ - -Function: code_contractst::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void code_contractst::operator()() { Forall_goto_functions(it, goto_functions) @@ -468,18 +399,6 @@ void code_contractst::operator()() goto_functions.update(); } -/*******************************************************************\ - -Function: code_contracts - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void code_contracts( symbol_tablet &symbol_table, goto_functionst &goto_functions) diff --git a/src/goto-instrument/code_contracts.h b/src/goto-instrument/code_contracts.h index 8886bd29545..006f4702480 100644 --- a/src/goto-instrument/code_contracts.h +++ b/src/goto-instrument/code_contracts.h @@ -8,6 +8,9 @@ Date: February 2016 \*******************************************************************/ +/// \file +/// Verify and use annotated invariants and pre/post-conditions + #ifndef CPROVER_GOTO_INSTRUMENT_CODE_CONTRACTS_H #define CPROVER_GOTO_INSTRUMENT_CODE_CONTRACTS_H diff --git a/src/goto-instrument/concurrency.cpp b/src/goto-instrument/concurrency.cpp index 69a6813a013..e04ff9c8695 100644 --- a/src/goto-instrument/concurrency.cpp +++ b/src/goto-instrument/concurrency.cpp @@ -8,6 +8,9 @@ Date: October 2012 \*******************************************************************/ +/// \file +/// Encoding for Threaded Goto Programs + #include #include #include @@ -73,18 +76,6 @@ class concurrency_instrumentationt thread_local_varst thread_local_vars; }; -/*******************************************************************\ - -Function: concurrency_instrumentationt::instrument - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void concurrency_instrumentationt::instrument(exprt &expr) { std::set symbols; @@ -118,18 +109,6 @@ void concurrency_instrumentationt::instrument(exprt &expr) } } -/*******************************************************************\ - -Function: concurrency_instrumentationt::instrument - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void concurrency_instrumentationt::instrument( goto_programt &goto_program, const is_threadedt &is_threaded) @@ -158,18 +137,6 @@ void concurrency_instrumentationt::instrument( } } -/*******************************************************************\ - -Function: concurrency_instrumentationt::collect - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void concurrency_instrumentationt::collect(const exprt &expr) { std::set symbols; @@ -212,18 +179,6 @@ void concurrency_instrumentationt::collect(const exprt &expr) } } -/*******************************************************************\ - -Function: concurrency_instrumentationt::collect - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void concurrency_instrumentationt::collect( const goto_programt &goto_program, const is_threadedt &is_threaded) @@ -242,35 +197,11 @@ void concurrency_instrumentationt::collect( } } -/*******************************************************************\ - -Function: concurrency_instrumentationt::add_array_symbols - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void concurrency_instrumentationt::add_array_symbols() { // for( } -/*******************************************************************\ - -Function: concurrency_instrumentationt::instrument - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void concurrency_instrumentationt::instrument( goto_functionst &goto_functions) { @@ -289,18 +220,6 @@ void concurrency_instrumentationt::instrument( instrument(f_it->second.body, is_threaded); } -/*******************************************************************\ - -Function: concurrency - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void concurrency( value_setst &value_sets, class symbol_tablet &symbol_table, diff --git a/src/goto-instrument/concurrency.h b/src/goto-instrument/concurrency.h index e751a62f3d4..cf09d4da68b 100644 --- a/src/goto-instrument/concurrency.h +++ b/src/goto-instrument/concurrency.h @@ -8,6 +8,9 @@ Date: February 2006 \*******************************************************************/ +/// \file +/// Encoding for Threaded Goto Programs + #ifndef CPROVER_GOTO_INSTRUMENT_CONCURRENCY_H #define CPROVER_GOTO_INSTRUMENT_CONCURRENCY_H diff --git a/src/goto-instrument/count_eloc.cpp b/src/goto-instrument/count_eloc.cpp index a54bc11f2ad..d986d335e9f 100644 --- a/src/goto-instrument/count_eloc.cpp +++ b/src/goto-instrument/count_eloc.cpp @@ -8,6 +8,9 @@ Date: December 2012 \*******************************************************************/ +/// \file +/// Count effective lines of code + #include #include @@ -22,18 +25,6 @@ typedef std::unordered_set linest; typedef std::unordered_map filest; typedef std::unordered_map working_dirst; -/*******************************************************************\ - -Function: collect_eloc - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static void collect_eloc( const goto_functionst &goto_functions, working_dirst &dest) @@ -52,18 +43,6 @@ static void collect_eloc( } } -/*******************************************************************\ - -Function: count_eloc - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void count_eloc(const goto_functionst &goto_functions) { std::size_t eloc=0; @@ -78,18 +57,6 @@ void count_eloc(const goto_functionst &goto_functions) std::cout << "Effective lines of code: " << eloc << '\n'; } -/*******************************************************************\ - -Function: list_eloc - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void list_eloc(const goto_functionst &goto_functions) { working_dirst eloc_map; @@ -107,18 +74,6 @@ void list_eloc(const goto_functionst &goto_functions) } } -/*******************************************************************\ - -Function: print_path_lengths - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void print_path_lengths(const goto_functionst &goto_functions) { const irep_idt &entry_point=goto_functions.entry_point(); diff --git a/src/goto-instrument/count_eloc.h b/src/goto-instrument/count_eloc.h index 87c1dea18ef..38760038836 100644 --- a/src/goto-instrument/count_eloc.h +++ b/src/goto-instrument/count_eloc.h @@ -8,6 +8,9 @@ Date: December 2012 \*******************************************************************/ +/// \file +/// Count effective lines of code + #ifndef CPROVER_GOTO_INSTRUMENT_COUNT_ELOC_H #define CPROVER_GOTO_INSTRUMENT_COUNT_ELOC_H diff --git a/src/goto-instrument/cover.cpp b/src/goto-instrument/cover.cpp index c3c5e0a5c06..a7c37f959ae 100644 --- a/src/goto-instrument/cover.cpp +++ b/src/goto-instrument/cover.cpp @@ -8,6 +8,9 @@ Date: May 2016 \*******************************************************************/ +/// \file +/// Coverage Instrumentation + #include #include #include @@ -101,18 +104,6 @@ class basic_blockst } }; -/*******************************************************************\ - -Function: coverage_goalst::get_coverage - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool coverage_goalst::get_coverage_goals( const std::string &coverage_file, message_handlert &message_handler, @@ -165,35 +156,11 @@ bool coverage_goalst::get_coverage_goals( return false; } -/*******************************************************************\ - -Function: coverage_goalst::add_goal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void coverage_goalst::add_goal(source_locationt goal) { existing_goals.push_back(goal); } -/*******************************************************************\ - -Function: coverage_goalst::is_existing_goal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool coverage_goalst::is_existing_goal(source_locationt source_location) const { for(const auto &existing_loc : existing_goals) @@ -206,18 +173,6 @@ bool coverage_goalst::is_existing_goal(source_locationt source_location) const return false; } -/*******************************************************************\ - -Function: as_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const char *as_string(coverage_criteriont c) { switch(c) @@ -234,18 +189,6 @@ const char *as_string(coverage_criteriont c) } } -/*******************************************************************\ - -Function: is_condition - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool is_condition(const exprt &src) { if(src.type().id()!=ID_bool) @@ -259,18 +202,6 @@ bool is_condition(const exprt &src) return true; } -/*******************************************************************\ - -Function: collect_conditions_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void collect_conditions_rec(const exprt &src, std::set &dest) { if(src.id()==ID_address_of) @@ -285,18 +216,6 @@ void collect_conditions_rec(const exprt &src, std::set &dest) dest.insert(src); } -/*******************************************************************\ - -Function: collect_conditions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::set collect_conditions(const exprt &src) { std::set result; @@ -304,18 +223,6 @@ std::set collect_conditions(const exprt &src) return result; } -/*******************************************************************\ - -Function: collect_conditions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::set collect_conditions(const goto_programt::const_targett t) { switch(t->type) @@ -336,18 +243,6 @@ std::set collect_conditions(const goto_programt::const_targett t) return std::set(); } -/*******************************************************************\ - -Function: collect_operands - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void collect_operands(const exprt &src, std::vector &dest) { for(const exprt &op : src.operands()) @@ -359,19 +254,7 @@ void collect_operands(const exprt &src, std::vector &dest) } } -/*******************************************************************\ - -Function: collect_mcdc_controlling_rec - - Inputs: - - Outputs: - - Purpose: To recursively collect controlling exprs for - for mcdc coverage. - -\*******************************************************************/ - +/// To recursively collect controlling exprs for for mcdc coverage. void collect_mcdc_controlling_rec( const exprt &src, const std::vector &conditions, @@ -482,18 +365,6 @@ void collect_mcdc_controlling_rec( } } -/*******************************************************************\ - -Function: collect_mcdc_controlling - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::set collect_mcdc_controlling( const std::set &decisions) { @@ -505,19 +376,8 @@ std::set collect_mcdc_controlling( return result; } -/*******************************************************************\ - -Function: replacement_conjunction - - Inputs: - - Outputs: - - Purpose: To replace the i-th expr of ''operands'' with each - expr inside ''replacement_exprs''. - -\*******************************************************************/ - +/// To replace the i-th expr of ''operands'' with each expr inside +/// ''replacement_exprs''. std::set replacement_conjunction( const std::set &replacement_exprs, const std::vector &operands, @@ -538,20 +398,8 @@ std::set replacement_conjunction( return result; } -/*******************************************************************\ - -Function: collect_mcdc_controlling_nested - - Inputs: - - Outputs: - - Purpose: This nested method iteratively applies - ''collect_mcdc_controlling'' to every non-atomic expr - within a decision - -\*******************************************************************/ - +/// This nested method iteratively applies ''collect_mcdc_controlling'' to every +/// non-atomic expr within a decision std::set collect_mcdc_controlling_nested( const std::set &decisions) { @@ -645,20 +493,10 @@ std::set collect_mcdc_controlling_nested( return result; } -/*******************************************************************\ - -Function: sign_of_expr - - Inputs: E should be the pre-processed output by - ''collect_mcdc_controlling_nested'' - - Outputs: +1 : not negated - -1 : negated - - Purpose: The sign of expr ''e'' within the super-expr ''E'' - -\*******************************************************************/ - +/// The sign of expr ''e'' within the super-expr ''E'' +/// \par parameters: E should be the pre-processed output by +/// ''collect_mcdc_controlling_nested'' +/// \return +1 : not negated -1 : negated std::set sign_of_expr(const exprt &e, const exprt &E) { std::set signs; @@ -713,21 +551,9 @@ std::set sign_of_expr(const exprt &e, const exprt &E) return signs; } -/*******************************************************************\ - -Function: remove_repetition - - Inputs: - - Outputs: - - Purpose: After the ''collect_mcdc_controlling_nested'', there - can be the recurrence of the same expr in the resulted - set of exprs, and this method will remove the - repetitive ones. - -\*******************************************************************/ - +/// After the ''collect_mcdc_controlling_nested'', there can be the recurrence +/// of the same expr in the resulted set of exprs, and this method will remove +/// the repetitive ones. void remove_repetition(std::set &exprs) { // to obtain the set of atomic conditions @@ -814,19 +640,7 @@ void remove_repetition(std::set &exprs) exprs=new_exprs; } -/*******************************************************************\ - -Function: eval_expr - - Inputs: - - Outputs: - - Purpose: To evaluate the value of expr ''src'', according to - the atomic expr values - -\*******************************************************************/ - +/// To evaluate the value of expr ''src'', according to the atomic expr values bool eval_expr( const std::map &atomic_exprs, const exprt &src) @@ -873,18 +687,7 @@ bool eval_expr( } } -/*******************************************************************\ - -Function: values_of_atomic_exprs - - Inputs: - - Outputs: - - Purpose: To obtain values of atomic exprs within the super expr - -\*******************************************************************/ - +/// To obtain values of atomic exprs within the super expr std::map values_of_atomic_exprs( const exprt &e, const std::set &conditions) @@ -909,22 +712,10 @@ std::map values_of_atomic_exprs( return atomic_exprs; } -/*******************************************************************\ - -Function: is_mcdc_pair - - Inputs: - - Outputs: - - Purpose: To check if the two input controlling exprs are mcdc - pairs regarding an atomic expr ''c''. A mcdc pair of - (e1, e2) regarding ''c'' means that ''e1'' and ''e2'' - result in different ''decision'' values, and this is - caused by the different choice of ''c'' value. - -\*******************************************************************/ - +/// To check if the two input controlling exprs are mcdc pairs regarding an +/// atomic expr ''c''. A mcdc pair of (e1, e2) regarding ''c'' means that ''e1'' +/// and ''e2'' result in different ''decision'' values, and this is caused by +/// the different choice of ''c'' value. bool is_mcdc_pair( const exprt &e1, const exprt &e2, @@ -985,19 +776,8 @@ bool is_mcdc_pair( return false; } -/*******************************************************************\ - -Function: has_mcdc_pair - - Inputs: - - Outputs: - - Purpose: To check if we can find the mcdc pair of the - input ''expr_set'' regarding the atomic expr ''c'' - -\*******************************************************************/ - +/// To check if we can find the mcdc pair of the input ''expr_set'' regarding +/// the atomic expr ''c'' bool has_mcdc_pair( const exprt &c, const std::set &expr_set, @@ -1017,24 +797,12 @@ bool has_mcdc_pair( return false; } -/*******************************************************************\ - -Function: minimize_mcdc_controlling - - Inputs: The input ''controlling'' should have been processed by - ''collect_mcdc_controlling_nested'' - and - ''remove_repetition'' - - Outputs: - - Purpose: This method minimizes the controlling conditions for - mcdc coverage. The minimum is in a sense that by deleting - any controlling condition in the set, the mcdc coverage - for the decision will be not complete. - -\*******************************************************************/ - +/// This method minimizes the controlling conditions for mcdc coverage. The +/// minimum is in a sense that by deleting any controlling condition in the set, +/// the mcdc coverage for the decision will be not complete. +/// \par parameters: The input ''controlling'' should have been processed by +/// ''collect_mcdc_controlling_nested'' and +/// ''remove_repetition'' void minimize_mcdc_controlling( std::set &controlling, const exprt &decision) @@ -1112,18 +880,6 @@ void minimize_mcdc_controlling( } } -/*******************************************************************\ - -Function: collect_decisions_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void collect_decisions_rec(const exprt &src, std::set &dest) { if(src.id()==ID_address_of) @@ -1153,18 +909,6 @@ void collect_decisions_rec(const exprt &src, std::set &dest) } } -/*******************************************************************\ - -Function: collect_decisions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::set collect_decisions(const exprt &src) { std::set result; @@ -1172,18 +916,6 @@ std::set collect_decisions(const exprt &src) return result; } -/*******************************************************************\ - -Function: collect_decisions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::set collect_decisions(const goto_programt::const_targett t) { switch(t->type) @@ -1204,18 +936,6 @@ std::set collect_decisions(const goto_programt::const_targett t) return std::set(); } -/*******************************************************************\ - -Function: instrument_cover_goals - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void instrument_cover_goals( const symbol_tablet &symbol_table, goto_programt &goto_program, @@ -1232,21 +952,10 @@ void instrument_cover_goals( false); } -/*******************************************************************\ - -Function: program_is_trivial - - Inputs: Program `goto_program` - - Outputs: Returns true if trivial - - Purpose: Call a goto_program trivial unless it has: - * Any declarations - * At least 2 branches - * At least 5 assignments - -\*******************************************************************/ - +/// Call a goto_program trivial unless it has: * Any declarations * At least 2 +/// branches * At least 5 assignments +/// \par parameters: Program `goto_program` +/// \return Returns true if trivial bool program_is_trivial(const goto_programt &goto_program) { unsigned long count_assignments=0, count_goto=0; @@ -1269,18 +978,6 @@ bool program_is_trivial(const goto_programt &goto_program) return true; } -/*******************************************************************\ - -Function: instrument_cover_goals - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void instrument_cover_goals( const symbol_tablet &symbol_table, goto_programt &goto_program, @@ -1625,18 +1322,6 @@ void instrument_cover_goals( } } -/*******************************************************************\ - -Function: instrument_cover_goals - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void instrument_cover_goals( const symbol_tablet &symbol_table, goto_functionst &goto_functions, @@ -1662,18 +1347,6 @@ void instrument_cover_goals( } } -/*******************************************************************\ - -Function: instrument_cover_goals - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void instrument_cover_goals( const symbol_tablet &symbol_table, goto_functionst &goto_functions, @@ -1691,18 +1364,6 @@ void instrument_cover_goals( false); } -/*******************************************************************\ - -Function: instrument_cover_goals - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool instrument_cover_goals( const cmdlinet &cmdline, const symbol_tablet &symbol_table, diff --git a/src/goto-instrument/cover.h b/src/goto-instrument/cover.h index 28d057ea43a..06fc0ede321 100644 --- a/src/goto-instrument/cover.h +++ b/src/goto-instrument/cover.h @@ -8,6 +8,9 @@ Date: May 2016 \*******************************************************************/ +/// \file +/// Coverage Instrumentation + #ifndef CPROVER_GOTO_INSTRUMENT_COVER_H #define CPROVER_GOTO_INSTRUMENT_COVER_H diff --git a/src/goto-instrument/document_properties.cpp b/src/goto-instrument/document_properties.cpp index 183caa6fdb9..e1dad4ffe47 100644 --- a/src/goto-instrument/document_properties.cpp +++ b/src/goto-instrument/document_properties.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Subgoal Documentation + #include #include @@ -65,18 +68,6 @@ class document_propertiest void doit(); }; -/*******************************************************************\ - -Function: document_propertiest::strip_space - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void document_propertiest::strip_space(std::list &lines) { unsigned strip=50; @@ -106,18 +97,6 @@ void document_propertiest::strip_space(std::list &lines) } } -/*******************************************************************\ - -Function: escape_latex - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string escape_latex(const std::string &s, bool alltt) { std::string dest; @@ -139,18 +118,6 @@ std::string escape_latex(const std::string &s, bool alltt) return dest; } -/*******************************************************************\ - -Function: escape_html - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string escape_html(const std::string &s) { std::string dest; @@ -169,18 +136,6 @@ std::string escape_html(const std::string &s) return dest; } -/*******************************************************************\ - -Function: is_empty - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool is_empty(const std::string &s) { for(unsigned i=0; i claim_sett; @@ -376,70 +307,58 @@ void document_propertiest::doit() << escape_latex(source_location.get_string("file"), false) << " function " << escape_latex(source_location.get_string("function"), false) - << "}" << std::endl; + << "}\n"; - out << std::endl; + out << '\n'; for(std::set::const_iterator s_it=it->second.comment_set.begin(); s_it!=it->second.comment_set.end(); s_it++) out << "\\claim{" << escape_latex(id2string(*s_it), false) - << "}" << std::endl; + << "}\n"; - out << std::endl; + out << '\n'; out << "\\begin{alltt}\\claimcode\n" << code << "\\end{alltt}\n"; - out << std::endl; - out << std::endl; + out << '\n'; + out << '\n'; break; case HTML: - out << "
" << std::endl + out << "
\n" << "
File " << escape_html(source_location.get_string("file")) << " function " << escape_html(source_location.get_string("function")) - << "
" << std::endl; + << "
\n"; - out << std::endl; + out << '\n'; for(std::set::const_iterator s_it=it->second.comment_set.begin(); s_it!=it->second.comment_set.end(); s_it++) - out << "
" << std::endl - << escape_html(id2string(*s_it)) << std::endl - << "
" << std::endl; + out << "
\n" + << escape_html(id2string(*s_it)) << '\n' + << "
\n"; - out << std::endl; + out << '\n'; out << "
\n" << code - << "
" << std::endl; + << "
\n"; - out << " " << std::endl; - out << std::endl; + out << " \n"; + out << '\n'; break; } } } -/*******************************************************************\ - -Function: document_properties_html - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void document_properties_html( const goto_functionst &goto_functions, std::ostream &out) @@ -447,18 +366,6 @@ void document_properties_html( document_propertiest(goto_functions, out).html(); } -/*******************************************************************\ - -Function: document_properties_latex - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void document_properties_latex( const goto_functionst &goto_functions, std::ostream &out) diff --git a/src/goto-instrument/document_properties.h b/src/goto-instrument/document_properties.h index deeae63b645..35406ae2f30 100644 --- a/src/goto-instrument/document_properties.h +++ b/src/goto-instrument/document_properties.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Documentation of Properties + #ifndef CPROVER_GOTO_INSTRUMENT_DOCUMENT_PROPERTIES_H #define CPROVER_GOTO_INSTRUMENT_DOCUMENT_PROPERTIES_H diff --git a/src/goto-instrument/dot.cpp b/src/goto-instrument/dot.cpp index 455381c4c51..7c9f2252892 100644 --- a/src/goto-instrument/dot.cpp +++ b/src/goto-instrument/dot.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Dump Goto-Program as DOT Graph + #include #include #include @@ -62,19 +65,10 @@ class dott std::set &); }; -/*******************************************************************\ - -Function: dott::write_dot_subgraph - - Inputs: output stream, name and goto program - - Outputs: true on error, false otherwise - - Purpose: writes the dot graph that corresponds to the goto program - to the output stream. - -\*******************************************************************/ - +/// writes the dot graph that corresponds to the goto program to the output +/// stream. +/// \par parameters: output stream, name and goto program +/// \return true on error, false otherwise void dott::write_dot_subgraph( std::ostream &out, const std::string &name, @@ -84,8 +78,8 @@ void dott::write_dot_subgraph( clusters.back().set("name", name); clusters.back().set("nr", subgraphscount); - out << "subgraph \"cluster_" << name << "\" {" << std::endl; - out << "label=\"" << name << "\";" << std::endl; + out << "subgraph \"cluster_" << name << "\" {\n"; + out << "label=\"" << name << "\";\n"; const goto_programt::instructionst &instructions = goto_program.instructions; @@ -93,7 +87,7 @@ void dott::write_dot_subgraph( if(instructions.empty()) { out << "Node_" << subgraphscount << "_0 " << - "[shape=Mrecord,fontsize=22,label=\"?\"];" << std::endl; + "[shape=Mrecord,fontsize=22,label=\"?\"];\n"; } else { @@ -191,7 +185,7 @@ void dott::write_dot_subgraph( out <<"Mrecord"; out << ",fontsize=22,label=\""; out << tmp.str(); - out << "\"];" << std::endl; + out << "\"];\n"; std::set tres; std::set fres; @@ -222,22 +216,10 @@ void dott::write_dot_subgraph( } } - out << "}" << std::endl; + out << "}\n"; subgraphscount++; } -/*******************************************************************\ - -Function: dott::do_dot_function_calls - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dott::do_dot_function_calls( std::ostream &out) { @@ -253,46 +235,33 @@ void dott::do_dot_function_calls( out << expr.op0().id() << " -> " "Node_" << cit->get("nr") << "_0" << " [lhead=\"cluster_" << expr.op1().get(ID_identifier) << "\"," << - "color=blue];" << std::endl; + "color=blue];\n"; } else { out << "subgraph \"cluster_" << expr.op1().get(ID_identifier) << - "\" {" << std::endl; - out << "rank=sink;"< " "Node_" << subgraphscount << "_0" << " [lhead=\"cluster_" << expr.op1().get("identifier") << "\"," << - "color=blue];" << std::endl; + "color=blue];\n"; subgraphscount++; } } } -/*******************************************************************\ - -Function: dott::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dott::output(std::ostream &out) { - out << "digraph G {" << std::endl; - out << DOTGRAPHSETTINGS << std::endl; + out << "digraph G {\n"; + out << DOTGRAPHSETTINGS << '\n'; std::list clusters; @@ -302,22 +271,12 @@ void dott::output(std::ostream &out) do_dot_function_calls(out); - out << "}" << std::endl; + out << "}\n"; } -/*******************************************************************\ - -Function: dott::escape - - Inputs: a string - - Outputs: the escaped string - - Purpose: escapes a string. beware, this might not work for all - kinds of strings. - -\*******************************************************************/ - +/// escapes a string. beware, this might not work for all kinds of strings. +/// \par parameters: a string +/// \return the escaped string std::string &dott::escape(std::string &str) { for(std::string::size_type i=0; i #include @@ -24,36 +27,12 @@ Author: Daniel Kroening, kroening@kroening.com #include "dump_c.h" -/*******************************************************************\ - -Function: operator<< - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - inline std::ostream &operator << (std::ostream &out, dump_ct &src) { src(out); return out; } -/*******************************************************************\ - -Function: dump_ct::operator() - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void dump_ct::operator()(std::ostream &os) { std::stringstream func_decl_stream; @@ -189,8 +168,8 @@ void dump_ct::operator()(std::ostream &os) type_id==ID_incomplete_union || type_id==ID_c_enum)) { - os << "// " << symbol.name << std::endl; - os << "// " << symbol.location << std::endl; + os << "// " << symbol.name << '\n'; + os << "// " << symbol.location << '\n'; if(type_id==ID_c_enum) convert_compound_enum(symbol.type, os); @@ -256,57 +235,43 @@ void dump_ct::operator()(std::ostream &os) it=system_headers.begin(); it!=system_headers.end(); ++it) - os << "#include <" << *it << ">" << std::endl; + os << "#include <" << *it << ">\n"; if(!system_headers.empty()) - os << std::endl; + os << '\n'; if(global_var_stream.str().find("NULL")!=std::string::npos || func_body_stream.str().find("NULL")!=std::string::npos) { - os << "#ifndef NULL" << std::endl - << "#define NULL ((void*)0)" << std::endl - << "#endif" << std::endl; - os << std::endl; + os << "#ifndef NULL\n" + << "#define NULL ((void*)0)\n" + << "#endif\n\n"; } if(func_body_stream.str().find("FENCE")!=std::string::npos) { - os << "#ifndef FENCE" << std::endl - << "#define FENCE(x) ((void)0)" << std::endl - << "#endif" << std::endl; - os << std::endl; + os << "#ifndef FENCE\n" + << "#define FENCE(x) ((void)0)\n" + << "#endif\n\n"; } if(func_body_stream.str().find("IEEE_FLOAT_")!=std::string::npos) { - os << "#ifndef IEEE_FLOAT_EQUAL" << std::endl - << "#define IEEE_FLOAT_EQUAL(x,y) ((x)==(y))" << std::endl - << "#endif" << std::endl; - os << "#ifndef IEEE_FLOAT_NOTEQUAL" << std::endl - << "#define IEEE_FLOAT_NOTEQUAL(x,y) ((x)!=(y))" << std::endl - << "#endif" << std::endl; - os << std::endl; + os << "#ifndef IEEE_FLOAT_EQUAL\n" + << "#define IEEE_FLOAT_EQUAL(x,y) ((x)==(y))\n" + << "#endif\n" + << "#ifndef IEEE_FLOAT_NOTEQUAL\n" + << "#define IEEE_FLOAT_NOTEQUAL(x,y) ((x)!=(y))\n" + << "#endif\n\n"; } if(!func_decl_stream.str().empty()) - os << func_decl_stream.str() << std::endl; + os << func_decl_stream.str() << '\n'; if(!compound_body_stream.str().empty()) - os << compound_body_stream.str() << std::endl; + os << compound_body_stream.str() << '\n'; if(!global_var_stream.str().empty()) - os << global_var_stream.str() << std::endl; + os << global_var_stream.str() << '\n'; os << func_body_stream.str(); } -/*******************************************************************\ - -Function: dump_ct::convert_compound_declarations - -Inputs: - -Outputs: - -Purpose: declare compound types - -\*******************************************************************/ - +/// declare compound types void dump_ct::convert_compound_declaration( const symbolt &symbol, std::ostream &os_body) @@ -321,18 +286,6 @@ void dump_ct::convert_compound_declaration( convert_compound(symbol.type, symbol_typet(symbol.name), true, os_body); } -/*******************************************************************\ - -Function: dump_ct::convert_compound - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void dump_ct::convert_compound( const typet &type, const typet &unresolved, @@ -386,18 +339,6 @@ void dump_ct::convert_compound( convert_compound_enum(type, os); } -/*******************************************************************\ - -Function: dump_ct::convert_compound - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void dump_ct::convert_compound( const struct_union_typet &type, const typet &unresolved, @@ -472,7 +413,7 @@ void dump_ct::convert_compound( irep_idt comp_name=comp.get_name(); - struct_body << indent(1) << "// " << comp_name << std::endl; + struct_body << indent(1) << "// " << comp_name << '\n'; struct_body << indent(1); // component names such as "main" would collide with other objects in the @@ -519,7 +460,7 @@ void dump_ct::convert_compound( else assert(false); - struct_body << ";" << std::endl; + struct_body << ";\n"; } os << type_to_string(unresolved); @@ -528,8 +469,8 @@ void dump_ct::convert_compound( assert(language->id()=="cpp"); os << ": " << base_decls.str(); } - os << std::endl; - os << "{" << std::endl; + os << '\n'; + os << "{\n"; os << struct_body.str(); /* @@ -549,23 +490,9 @@ void dump_ct::convert_compound( os << " __attribute__ ((__transparent_union__))"; if(type.get_bool(ID_C_packed)) os << " __attribute__ ((__packed__))"; - os << ";"; - os << std::endl; - os << std::endl; + os << ";\n"; } -/*******************************************************************\ - -Function: dump_ct::convert_compound_enum - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void dump_ct::convert_compound_enum( const typet &type, std::ostream &os) @@ -609,18 +536,6 @@ void dump_ct::convert_compound_enum( os << ";\n\n"; } -/*******************************************************************\ - -Function: dump_ct::cleanup_decl - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void dump_ct::cleanup_decl( code_declt &decl, std::list &local_static, @@ -661,18 +576,6 @@ void dump_ct::cleanup_decl( decl.swap(b.op0()); } -/*******************************************************************\ - -Function: dump_ct::convert_global_variables - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void dump_ct::convert_global_variable( const symbolt &symbol, std::ostream &os, @@ -694,9 +597,9 @@ void dump_ct::convert_global_variable( if((func.empty() || symbol.is_extern) && (symbol.value.is_nil() || !syms.empty())) { - os << "// " << symbol.name << std::endl; - os << "// " << symbol.location << std::endl; - os << expr_to_string(d) << std::endl; + os << "// " << symbol.name << '\n'; + os << "// " << symbol.location << '\n'; + os << expr_to_string(d) << '\n'; } if(!symbol.value.is_nil()) @@ -726,28 +629,16 @@ void dump_ct::convert_global_variable( local_static_decls[symbol.name]=d; else if(!symbol.value.is_nil()) { - os << "// " << symbol.name << std::endl; - os << "// " << symbol.location << std::endl; + os << "// " << symbol.name << '\n'; + os << "// " << symbol.location << '\n'; std::list empty_static, empty_types; cleanup_decl(d, empty_static, empty_types); assert(empty_static.empty()); - os << expr_to_string(d) << std::endl; + os << expr_to_string(d) << '\n'; } } -/*******************************************************************\ - -Function: dump_ct::convert_function_declarations - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void dump_ct::convert_function_declaration( const symbolt &symbol, const bool skip_main, @@ -798,11 +689,11 @@ void dump_ct::convert_function_declaration( converted_enum.swap(converted_e_bak); converted_compound.swap(converted_c_bak); - os_body << "// " << symbol.name << std::endl; - os_body << "// " << symbol.location << std::endl; - os_body << make_decl(symbol.name, symbol.type) << std::endl; + os_body << "// " << symbol.name << '\n'; + os_body << "// " << symbol.location << '\n'; + os_body << make_decl(symbol.name, symbol.type) << '\n'; os_body << expr_to_string(b); - os_body << std::endl << std::endl; + os_body << "\n\n"; declared_enum_constants.swap(enum_constants_bak); } @@ -810,24 +701,12 @@ void dump_ct::convert_function_declaration( if(symbol.name!=goto_functionst::entry_point() && symbol.name!=ID_main) { - os_decl << "// " << symbol.name << std::endl; - os_decl << "// " << symbol.location << std::endl; - os_decl << make_decl(symbol.name, symbol.type) << ";" << std::endl; + os_decl << "// " << symbol.name << '\n'; + os_decl << "// " << symbol.location << '\n'; + os_decl << make_decl(symbol.name, symbol.type) << ";\n"; } } -/*******************************************************************\ - -Function: find_block_position_rec - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - static bool find_block_position_rec( const irep_idt &identifier, codet &root, @@ -907,18 +786,6 @@ static bool find_block_position_rec( return false; } -/*******************************************************************\ - -Function: dump_ct::insert_local_static_decls - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void dump_ct::insert_local_static_decls( code_blockt &b, const std::list &local_static, @@ -953,18 +820,6 @@ void dump_ct::insert_local_static_decls( } } -/*******************************************************************\ - -Function: dump_ct::insert_local_type_decls - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void dump_ct::insert_local_type_decls( code_blockt &b, const std::list &type_decls) @@ -1002,18 +857,6 @@ void dump_ct::insert_local_type_decls( } } -/*******************************************************************\ - -Function: dump_ct::cleanup_expr - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void dump_ct::cleanup_expr(exprt &expr) { Forall_operands(it, expr) @@ -1161,18 +1004,6 @@ void dump_ct::cleanup_expr(exprt &expr) } } -/*******************************************************************\ - -Function: dump_ct::cleanup_type - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void dump_ct::cleanup_type(typet &type) { Forall_subtypes(it, type) @@ -1198,18 +1029,6 @@ void dump_ct::cleanup_type(typet &type) !type.get(ID_tag).empty()); } -/*******************************************************************\ - -Function: dump_ct::type_to_string - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - std::string dump_ct::type_to_string(const typet &type) { std::string ret; @@ -1219,18 +1038,6 @@ std::string dump_ct::type_to_string(const typet &type) return ret; } -/*******************************************************************\ - -Function: dump_ct::expr_to_string - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - std::string dump_ct::expr_to_string(const exprt &expr) { std::string ret; @@ -1240,18 +1047,6 @@ std::string dump_ct::expr_to_string(const exprt &expr) return ret; } -/*******************************************************************\ - -Function: dump_c - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dump_c( const goto_functionst &src, const bool use_system_headers, @@ -1262,18 +1057,6 @@ void dump_c( out << goto2c; } -/*******************************************************************\ - -Function: dump_cpp - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dump_cpp( const goto_functionst &src, const bool use_system_headers, diff --git a/src/goto-instrument/dump_c.h b/src/goto-instrument/dump_c.h index ff0efd496a6..263165aec97 100644 --- a/src/goto-instrument/dump_c.h +++ b/src/goto-instrument/dump_c.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Dump C from Goto Program + #ifndef CPROVER_GOTO_INSTRUMENT_DUMP_C_H #define CPROVER_GOTO_INSTRUMENT_DUMP_C_H diff --git a/src/goto-instrument/dump_c_class.h b/src/goto-instrument/dump_c_class.h index c8c77da5102..4f47cd4cad4 100644 --- a/src/goto-instrument/dump_c_class.h +++ b/src/goto-instrument/dump_c_class.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Dump Goto-Program as C/C++ Source + #ifndef CPROVER_GOTO_INSTRUMENT_DUMP_C_CLASS_H #define CPROVER_GOTO_INSTRUMENT_DUMP_C_CLASS_H diff --git a/src/goto-instrument/full_slicer.cpp b/src/goto-instrument/full_slicer.cpp index 887805ad80a..ca8de0f2cf7 100644 --- a/src/goto-instrument/full_slicer.cpp +++ b/src/goto-instrument/full_slicer.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Slicing + #include #include #ifdef DEBUG_FULL_SLICERT @@ -15,18 +18,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "full_slicer_class.h" -/*******************************************************************\ - -Function: full_slicert::add_dependencies - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void full_slicert::add_dependencies( const cfgt::nodet &node, queuet &queue, @@ -43,18 +34,6 @@ void full_slicert::add_dependencies( add_to_queue(queue, dep_node_to_cfg[it->first], node.PC); } -/*******************************************************************\ - -Function: full_slicert::add_dependencies - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void full_slicert::add_function_calls( const cfgt::nodet &node, queuet &queue, @@ -79,18 +58,6 @@ void full_slicert::add_function_calls( add_to_queue(queue, it->first, node.PC); } -/*******************************************************************\ - -Function: full_slicert::add_decl_dead - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void full_slicert::add_decl_dead( const cfgt::nodet &node, queuet &queue, @@ -122,18 +89,6 @@ void full_slicert::add_decl_dead( } } -/*******************************************************************\ - -Function: full_slicert::add_jumps - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void full_slicert::add_jumps( queuet &queue, jumpst &jumps, @@ -257,18 +212,6 @@ void full_slicert::add_jumps( } } -/*******************************************************************\ - -Function: full_slicert::fixedpoint - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void full_slicert::fixedpoint( goto_functionst &goto_functions, queuet &queue, @@ -318,18 +261,6 @@ void full_slicert::fixedpoint( } } -/*******************************************************************\ - -Function: implicit - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static bool implicit(goto_programt::const_targett target) { // some variables are used during symbolic execution only @@ -350,18 +281,6 @@ static bool implicit(goto_programt::const_targett target) return s.get_identifier()==CPROVER_PREFIX "rounding_mode"; } -/*******************************************************************\ - -Function: full_slicert::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void full_slicert::operator()( goto_functionst &goto_functions, const namespacet &ns, @@ -446,18 +365,6 @@ void full_slicert::operator()( goto_functions.update(); } -/*******************************************************************\ - -Function: full_slicer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void full_slicer( goto_functionst &goto_functions, const namespacet &ns, @@ -466,18 +373,6 @@ void full_slicer( full_slicert()(goto_functions, ns, criterion); } -/*******************************************************************\ - -Function: full_slicer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void full_slicer( goto_functionst &goto_functions, const namespacet &ns) @@ -486,18 +381,6 @@ void full_slicer( full_slicert()(goto_functions, ns, a); } -/*******************************************************************\ - -Function: property_slicer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void property_slicer( goto_functionst &goto_functions, const namespacet &ns, @@ -507,18 +390,6 @@ void property_slicer( full_slicert()(goto_functions, ns, p); } -/*******************************************************************\ - -Function: slicing_criteriont::~slicing_criteriont - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - slicing_criteriont::~slicing_criteriont() { } diff --git a/src/goto-instrument/full_slicer.h b/src/goto-instrument/full_slicer.h index d590025c8c4..9e39786c5a2 100644 --- a/src/goto-instrument/full_slicer.h +++ b/src/goto-instrument/full_slicer.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Slicing + #ifndef CPROVER_GOTO_INSTRUMENT_FULL_SLICER_H #define CPROVER_GOTO_INSTRUMENT_FULL_SLICER_H diff --git a/src/goto-instrument/full_slicer_class.h b/src/goto-instrument/full_slicer_class.h index 93894513f57..de1c50b54f4 100644 --- a/src/goto-instrument/full_slicer_class.h +++ b/src/goto-instrument/full_slicer_class.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Goto Program Slicing + #ifndef CPROVER_GOTO_INSTRUMENT_FULL_SLICER_CLASS_H #define CPROVER_GOTO_INSTRUMENT_FULL_SLICER_CLASS_H @@ -32,14 +35,6 @@ echo 'digraph g {' > c.dot ; cat c.goto | \ dot -Tpdf -oc-red.pdf c-red.dot #endif -/*******************************************************************\ - - Class: full_slicert - - Purpose: - -\*******************************************************************/ - class full_slicert { public: diff --git a/src/goto-instrument/function.cpp b/src/goto-instrument/function.cpp index 1ad749814bd..f6c3ffdce55 100644 --- a/src/goto-instrument/function.cpp +++ b/src/goto-instrument/function.cpp @@ -6,28 +6,19 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Function Entering and Exiting + #include #include #include #include -#include +#include #include #include "function.h" -/*******************************************************************\ - -Function: function_to_call - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - code_function_callt function_to_call( symbol_tablet &symbol_table, const irep_idt &id, @@ -87,18 +78,6 @@ code_function_callt function_to_call( return call; } -/*******************************************************************\ - -Function: function_enter - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void function_enter( symbol_tablet &symbol_table, goto_functionst &goto_functions, @@ -126,18 +105,6 @@ void function_enter( } } -/*******************************************************************\ - -Function: function_exit - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void function_exit( symbol_tablet &symbol_table, goto_functionst &goto_functions, diff --git a/src/goto-instrument/function.h b/src/goto-instrument/function.h index 207555a7cb5..88b486df6b0 100644 --- a/src/goto-instrument/function.h +++ b/src/goto-instrument/function.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Function Entering and Exiting + #ifndef CPROVER_GOTO_INSTRUMENT_FUNCTION_H #define CPROVER_GOTO_INSTRUMENT_FUNCTION_H diff --git a/src/goto-instrument/function_modifies.cpp b/src/goto-instrument/function_modifies.cpp index 0d5148c92c8..f4d18c4a1e7 100644 --- a/src/goto-instrument/function_modifies.cpp +++ b/src/goto-instrument/function_modifies.cpp @@ -6,22 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Modifies + #include #include "function_modifies.h" -/*******************************************************************\ - -Function: function_modifiest::get_modifies_lhs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void function_modifiest::get_modifies_lhs( const local_may_aliast &local_may_alias, const goto_programt::const_targett t, @@ -51,18 +42,6 @@ void function_modifiest::get_modifies_lhs( } } -/*******************************************************************\ - -Function: function_modifiest::get_modifies - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void function_modifiest::get_modifies( const local_may_aliast &local_may_alias, const goto_programt::const_targett i_it, @@ -90,18 +69,6 @@ void function_modifiest::get_modifies( } } -/*******************************************************************\ - -Function: function_modifiest::get_modifies_function - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void function_modifiest::get_modifies_function( const exprt &function, modifiest &modifies) diff --git a/src/goto-instrument/function_modifies.h b/src/goto-instrument/function_modifies.h index b4f44cda6d3..64becb1412c 100644 --- a/src/goto-instrument/function_modifies.h +++ b/src/goto-instrument/function_modifies.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Modifies + #ifndef CPROVER_GOTO_INSTRUMENT_FUNCTION_MODIFIES_H #define CPROVER_GOTO_INSTRUMENT_FUNCTION_MODIFIES_H diff --git a/src/goto-instrument/goto_instrument_languages.cpp b/src/goto-instrument/goto_instrument_languages.cpp index 4cc03bca860..2193318b136 100644 --- a/src/goto-instrument/goto_instrument_languages.cpp +++ b/src/goto-instrument/goto_instrument_languages.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Language Registration + #include #include @@ -14,18 +17,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_instrument_parse_options.h" -/*******************************************************************\ - -Function: goto_instrument_parse_optionst::register_languages - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_instrument_parse_optionst::register_languages() { register_language(new_ansi_c_language); diff --git a/src/goto-instrument/goto_instrument_main.cpp b/src/goto-instrument/goto_instrument_main.cpp index f25cbbcf9d8..fb394efbb3d 100644 --- a/src/goto-instrument/goto_instrument_main.cpp +++ b/src/goto-instrument/goto_instrument_main.cpp @@ -6,22 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Main Module + #include #include "goto_instrument_parse_options.h" -/*******************************************************************\ - -Function: main - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - #ifdef _MSC_VER int wmain(int argc, const wchar_t **argv_wide) { diff --git a/src/goto-instrument/goto_instrument_parse_options.cpp b/src/goto-instrument/goto_instrument_parse_options.cpp index bebf863c862..82b2e0299e7 100644 --- a/src/goto-instrument/goto_instrument_parse_options.cpp +++ b/src/goto-instrument/goto_instrument_parse_options.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Main Module + #include #include #include @@ -90,18 +93,7 @@ Author: Daniel Kroening, kroening@kroening.com #include "unwind.h" #include "model_argc_argv.h" #include "undefined_functions.h" - -/*******************************************************************\ - -Function: goto_instrument_parse_optionst::eval_verbosity - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ +#include "remove_function.h" void goto_instrument_parse_optionst::eval_verbosity() { @@ -117,23 +109,12 @@ void goto_instrument_parse_optionst::eval_verbosity() ui_message_handler.set_verbosity(v); } -/*******************************************************************\ - -Function: goto_instrument_parse_optionst::doit - - Inputs: - - Outputs: - - Purpose: invoke main modules - -\*******************************************************************/ - +/// invoke main modules int goto_instrument_parse_optionst::doit() { if(cmdline.isset("version")) { - std::cout << CBMC_VERSION << std::endl; + std::cout << CBMC_VERSION << '\n'; return 0; } @@ -244,7 +225,7 @@ int goto_instrument_parse_optionst::doit() } else { - std::cout << result << std::endl; + std::cout << result << '\n'; } } } @@ -258,10 +239,9 @@ int goto_instrument_parse_optionst::doit() forall_goto_functions(f_it, goto_functions) { - std::cout << "////" << std::endl; - std::cout << "//// Function: " << f_it->first << std::endl; - std::cout << "////" << std::endl; - std::cout << std::endl; + std::cout << "////\n"; + std::cout << "//// Function: " << f_it->first << '\n'; + std::cout << "////\n\n"; const goto_programt &goto_program=f_it->second.body; @@ -269,8 +249,7 @@ int goto_instrument_parse_optionst::doit() { goto_program.output_instruction(ns, "", std::cout, i_it); std::cout << "Is threaded: " << (is_threaded(i_it)?"True":"False") - << std::endl; - std::cout << std::endl; + << "\n\n"; } } } @@ -324,11 +303,11 @@ int goto_instrument_parse_optionst::doit() forall_goto_functions(it, goto_functions) { local_bitvector_analysist local_bitvector_analysis(it->second); - std::cout << ">>>>" << std::endl; - std::cout << ">>>> " << it->first << std::endl; - std::cout << ">>>>" << std::endl; + std::cout << ">>>>\n"; + std::cout << ">>>> " << it->first << '\n'; + std::cout << ">>>>\n"; local_bitvector_analysis.output(std::cout, it->second, ns); - std::cout << std::endl; + std::cout << '\n'; } return 0; @@ -508,17 +487,7 @@ int goto_instrument_parse_optionst::doit() reaching_definitions_analysist rd_analysis(ns); rd_analysis(goto_functions, ns); - forall_goto_functions(f_it, goto_functions) - { - if(f_it->second.body_available()) - { - std::cout << "////" << std::endl; - std::cout << "//// Function: " << f_it->first << std::endl; - std::cout << "////" << std::endl; - std::cout << std::endl; - rd_analysis.output(ns, f_it->second.body, std::cout); - } - } + rd_analysis.output(ns, goto_functions, std::cout); return 0; } @@ -531,18 +500,7 @@ int goto_instrument_parse_optionst::doit() dependence_grapht dependence_graph(ns); dependence_graph(goto_functions, ns); - forall_goto_functions(f_it, goto_functions) - { - if(f_it->second.body_available()) - { - std::cout << "////" << std::endl; - std::cout << "//// Function: " << f_it->first << std::endl; - std::cout << "////" << std::endl; - std::cout << std::endl; - dependence_graph.output(ns, f_it->second.body, std::cout); - } - } - + dependence_graph.output(ns, goto_functions, std::cout); dependence_graph.output_dot(std::cout); return 0; @@ -814,18 +772,6 @@ int goto_instrument_parse_optionst::doit() } } -/*******************************************************************\ - -Function: goto_instrument_parse_optionst::do_indirect_call_and_rtti_removal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_instrument_parse_optionst::do_indirect_call_and_rtti_removal( bool force) { @@ -848,21 +794,9 @@ void goto_instrument_parse_optionst::do_indirect_call_and_rtti_removal( remove_instanceof(symbol_table, goto_functions); } -/*******************************************************************\ - -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. - -\*******************************************************************/ - +/// 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 @@ -881,18 +815,6 @@ void goto_instrument_parse_optionst::do_remove_const_function_pointers_only() true); // abort if we can't resolve via const pointers } -/*******************************************************************\ - -Function: goto_instrument_parse_optionst::do_partial_inlining - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_instrument_parse_optionst::do_partial_inlining() { if(partial_inlining_done) @@ -908,18 +830,6 @@ void goto_instrument_parse_optionst::do_partial_inlining() } } -/*******************************************************************\ - -Function: goto_instrument_parse_optionst::do_remove_returns - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_instrument_parse_optionst::do_remove_returns() { if(remove_returns_done) @@ -931,18 +841,6 @@ void goto_instrument_parse_optionst::do_remove_returns() remove_returns(symbol_table, goto_functions); } -/*******************************************************************\ - -Function: goto_instrument_parse_optionst::get_goto_program - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_instrument_parse_optionst::get_goto_program() { status() << "Reading GOTO program from `" << cmdline.args[0] << "'" << eom; @@ -955,18 +853,6 @@ void goto_instrument_parse_optionst::get_goto_program() config.set_from_symbol_table(symbol_table); } -/*******************************************************************\ - -Function: goto_instrument_parse_optionst::instrument_goto_program - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_instrument_parse_optionst::instrument_goto_program() { optionst options; @@ -1038,6 +924,15 @@ void goto_instrument_parse_optionst::instrument_goto_program() throw 0; } + if(cmdline.isset("remove-function-body")) + { + remove_functions( + symbol_table, + goto_functions, + cmdline.get_values("remove-function-body"), + get_message_handler()); + } + // we add the library in some cases, as some analyses benefit if(cmdline.isset("add-library") || @@ -1167,7 +1062,7 @@ void goto_instrument_parse_optionst::instrument_goto_program() } else { - std::cout << result << std::endl; + std::cout << result << '\n'; } } @@ -1522,25 +1417,11 @@ void goto_instrument_parse_optionst::instrument_goto_program() full_slicer(goto_functions, ns); } - // label the assertions - label_properties(goto_functions); - // recalculate numbers, etc. goto_functions.update(); } -/*******************************************************************\ - -Function: goto_instrument_parse_optionst::help - - Inputs: - - Outputs: - - Purpose: display command line help - -\*******************************************************************/ - +/// display command line help void goto_instrument_parse_optionst::help() { std::cout << @@ -1638,6 +1519,8 @@ void goto_instrument_parse_optionst::help() HELP_REMOVE_CONST_FUNCTION_POINTERS " --add-library add models of C library functions\n" " --model-argc-argv model up to command line arguments\n" + // NOLINTNEXTLINE(whitespace/line_length) + " --remove-function-body remove the implementation of function (may be repeated)\n" "\n" "Other options:\n" " --use-system-headers with --dump-c/--dump-cpp: generate C source with includes\n" // NOLINT(*) diff --git a/src/goto-instrument/goto_instrument_parse_options.h b/src/goto-instrument/goto_instrument_parse_options.h index 788bf543953..912e327b7d2 100644 --- a/src/goto-instrument/goto_instrument_parse_options.h +++ b/src/goto-instrument/goto_instrument_parse_options.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Command Line Parsing + #ifndef CPROVER_GOTO_INSTRUMENT_GOTO_INSTRUMENT_PARSE_OPTIONS_H #define CPROVER_GOTO_INSTRUMENT_GOTO_INSTRUMENT_PARSE_OPTIONS_H @@ -72,7 +75,8 @@ Author: Daniel Kroening, kroening@kroening.com "(z3)(add-library)(show-dependence-graph)" \ "(horn)(skip-loops):(apply-code-contracts)(model-argc-argv):" \ "(show-threaded)(list-calls-args)(print-path-lengths)" \ - "(undefined-function-is-assume-false)" + "(undefined-function-is-assume-false)" \ + "(remove-function-body):" class goto_instrument_parse_optionst: public parse_options_baset, diff --git a/src/goto-instrument/goto_program2code.cpp b/src/goto-instrument/goto_program2code.cpp index 400aca3b407..508c4fcaa3e 100644 --- a/src/goto-instrument/goto_program2code.cpp +++ b/src/goto-instrument/goto_program2code.cpp @@ -6,8 +6,12 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Dump Goto-Program as C/C++ Source + #include +#include #include #include #include @@ -17,18 +21,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_program2code.h" -/*******************************************************************\ - -Function: skip_typecast - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - static const exprt &skip_typecast(const exprt &expr) { if(expr.id()!=ID_typecast) @@ -37,18 +29,6 @@ static const exprt &skip_typecast(const exprt &expr) return skip_typecast(to_typecast_expr(expr).op()); } -/*******************************************************************\ - -Function: goto_program2codet::operator() - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void goto_program2codet::operator()() { // labels stored for cleanup @@ -76,18 +56,6 @@ void goto_program2codet::operator()() cleanup_code(toplevel_block, ID_nil); } -/*******************************************************************\ - -Function: goto_program2codet::build_loop_map - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void goto_program2codet::build_loop_map() { loop_map.clear(); @@ -124,18 +92,6 @@ void goto_program2codet::build_loop_map() } } -/*******************************************************************\ - -Function: goto_program2codet::build_dead_map - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void goto_program2codet::build_dead_map() { dead_map.clear(); @@ -147,18 +103,6 @@ void goto_program2codet::build_dead_map() target->location_number; } -/*******************************************************************\ - -Function: goto_program2codet::scan_for_varargs - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void goto_program2codet::scan_for_varargs() { va_list_expr.clear(); @@ -200,18 +144,6 @@ void goto_program2codet::scan_for_varargs() } } -/*******************************************************************\ - -Function: goto_program2codet::convert_instruction - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - goto_programt::const_targett goto_program2codet::convert_instruction( goto_programt::const_targett target, goto_programt::const_targett upper_bound, @@ -316,18 +248,6 @@ goto_programt::const_targett goto_program2codet::convert_instruction( return target; } -/*******************************************************************\ - -Function: goto_program2codet::convert_labels - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void goto_program2codet::convert_labels( goto_programt::const_targett target, codet &dest) @@ -370,18 +290,6 @@ void goto_program2codet::convert_labels( latest_block->copy_to_operands(code_skipt()); } -/*******************************************************************\ - -Function: goto_program2codet::convert_assign - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - goto_programt::const_targett goto_program2codet::convert_assign( goto_programt::const_targett target, goto_programt::const_targett upper_bound, @@ -397,18 +305,6 @@ goto_programt::const_targett goto_program2codet::convert_assign( return target; } -/*******************************************************************\ - -Function: goto_program2codet::convert_assign_varargs - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - goto_programt::const_targett goto_program2codet::convert_assign_varargs( goto_programt::const_targett target, goto_programt::const_targett upper_bound, @@ -479,9 +375,7 @@ goto_programt::const_targett goto_program2codet::convert_assign_varargs( static_cast(r.find(ID_C_va_arg_type)); dereference_exprt deref( - typecast_exprt( - from_integer(0, signedbv_typet(config.ansi_c.pointer_width)), - pointer_typet(va_arg_type)), + null_pointer_exprt(pointer_typet(va_arg_type)), va_arg_type); type_of.arguments().push_back(deref); @@ -504,18 +398,6 @@ goto_programt::const_targett goto_program2codet::convert_assign_varargs( return target; } -/*******************************************************************\ - -Function: goto_program2codet::convert_assign_rec - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void goto_program2codet::convert_assign_rec( const code_assignt &assign, codet &dest) @@ -530,7 +412,7 @@ void goto_program2codet::convert_assign_rec( { index_exprt index( assign.lhs(), - from_integer(i++, signedbv_typet(config.ansi_c.pointer_width)), + from_integer(i++, index_type()), type.subtype()); convert_assign_rec(code_assignt(index, *it), dest); } @@ -539,18 +421,6 @@ void goto_program2codet::convert_assign_rec( dest.copy_to_operands(assign); } -/*******************************************************************\ - -Function: goto_program2codet::convert_return - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - goto_programt::const_targett goto_program2codet::convert_return( goto_programt::const_targett target, goto_programt::const_targett upper_bound, @@ -581,18 +451,6 @@ goto_programt::const_targett goto_program2codet::convert_return( return target; } -/*******************************************************************\ - -Function: goto_program2codet::convert_decl - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - goto_programt::const_targett goto_program2codet::convert_decl( goto_programt::const_targett target, goto_programt::const_targett upper_bound, @@ -655,18 +513,6 @@ goto_programt::const_targett goto_program2codet::convert_decl( return target; } -/*******************************************************************\ - -Function: goto_program2codet::convert_do_while - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - goto_programt::const_targett goto_program2codet::convert_do_while( goto_programt::const_targett target, goto_programt::const_targett loop_end, @@ -692,18 +538,6 @@ goto_programt::const_targett goto_program2codet::convert_do_while( return target; } -/*******************************************************************\ - -Function: goto_program2codet::convert_goto - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - goto_programt::const_targett goto_program2codet::convert_goto( goto_programt::const_targett target, goto_programt::const_targett upper_bound, @@ -727,18 +561,6 @@ goto_programt::const_targett goto_program2codet::convert_goto( return convert_goto_goto(target, dest); } -/*******************************************************************\ - -Function: goto_program2codet::convert_goto_while - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - goto_programt::const_targett goto_program2codet::convert_goto_while( goto_programt::const_targett target, goto_programt::const_targett loop_end, @@ -838,18 +660,6 @@ goto_programt::const_targett goto_program2codet::convert_goto_while( return target; } -/*******************************************************************\ - -Function: goto_program2codet::get_cases - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - goto_programt::const_targett goto_program2codet::get_cases( goto_programt::const_targett target, goto_programt::const_targett upper_bound, @@ -952,18 +762,6 @@ goto_programt::const_targett goto_program2codet::get_cases( return cases_it; } -/*******************************************************************\ - -Function: goto_program2codet::set_block_end_points - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - bool goto_program2codet::set_block_end_points( goto_programt::const_targett upper_bound, const cfg_dominatorst &dominators, @@ -1014,18 +812,6 @@ bool goto_program2codet::set_block_end_points( return false; } -/*******************************************************************\ - -Function: goto_program2codet::remove_default - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - bool goto_program2codet::remove_default( const cfg_dominatorst &dominators, const cases_listt &cases, @@ -1088,18 +874,6 @@ bool goto_program2codet::remove_default( return false; } -/*******************************************************************\ - -Function: goto_program2codet::convert_goto_switch - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - goto_programt::const_targett goto_program2codet::convert_goto_switch( goto_programt::const_targett target, goto_programt::const_targett upper_bound, @@ -1279,18 +1053,6 @@ goto_programt::const_targett goto_program2codet::convert_goto_switch( return max_target; } -/*******************************************************************\ - -Function: goto_program2codet::convert_goto_if - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - goto_programt::const_targett goto_program2codet::convert_goto_if( goto_programt::const_targett target, goto_programt::const_targett upper_bound, @@ -1367,18 +1129,6 @@ goto_programt::const_targett goto_program2codet::convert_goto_if( return --target; } -/*******************************************************************\ - -Function: goto_program2codet::convert_goto_break_continue - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - goto_programt::const_targett goto_program2codet::convert_goto_break_continue( goto_programt::const_targett target, codet &dest) @@ -1467,18 +1217,6 @@ goto_programt::const_targett goto_program2codet::convert_goto_break_continue( return convert_goto_goto(target, dest); } -/*******************************************************************\ - -Function: goto_program2codet::convert_goto_goto - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - goto_programt::const_targett goto_program2codet::convert_goto_goto( goto_programt::const_targett target, codet &dest) @@ -1538,18 +1276,6 @@ goto_programt::const_targett goto_program2codet::convert_goto_goto( return target; } -/*******************************************************************\ - -Function: goto_program2codet::convert_start_thread - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - goto_programt::const_targett goto_program2codet::convert_start_thread( goto_programt::const_targett target, goto_programt::const_targett upper_bound, @@ -1668,18 +1394,6 @@ goto_programt::const_targett goto_program2codet::convert_start_thread( return thread_end; } -/*******************************************************************\ - -Function: goto_program2codet::convert_throw - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - goto_programt::const_targett goto_program2codet::convert_throw( goto_programt::const_targett target, codet &dest) @@ -1689,18 +1403,6 @@ goto_programt::const_targett goto_program2codet::convert_throw( return target; } -/*******************************************************************\ - -Function: goto_program2codet::convert_catch - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - goto_programt::const_targett goto_program2codet::convert_catch( goto_programt::const_targett target, goto_programt::const_targett upper_bound, @@ -1711,18 +1413,6 @@ goto_programt::const_targett goto_program2codet::convert_catch( return target; } -/*******************************************************************\ - -Function: goto_program2codet::add_local_types - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void goto_program2codet::add_local_types(const typet &type) { if(type.id()==ID_symbol) @@ -1778,18 +1468,6 @@ void goto_program2codet::add_local_types(const typet &type) } } -/*******************************************************************\ - -Function: goto_program2codet::cleanup_code - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void goto_program2codet::cleanup_code( codet &code, const irep_idt parent_stmt) @@ -1877,18 +1555,6 @@ void goto_program2codet::cleanup_code( } } -/*******************************************************************\ - -Function: goto_program2codet::cleanup_function_call - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void goto_program2codet::cleanup_function_call( const exprt &function, code_function_callt::argumentst &arguments) @@ -1919,18 +1585,6 @@ void goto_program2codet::cleanup_function_call( } } -/*******************************************************************\ - -Function: goto_program2codet::cleanup_code_block - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void goto_program2codet::cleanup_code_block( codet &code, const irep_idt parent_stmt) @@ -1984,18 +1638,6 @@ void goto_program2codet::cleanup_code_block( } } -/*******************************************************************\ - -Function: goto_program2codet::remove_const - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void goto_program2codet::remove_const(typet &type) { if(type.get_bool(ID_C_constant)) @@ -2030,18 +1672,6 @@ void goto_program2codet::remove_const(typet &type) } } -/*******************************************************************\ - -Function: has_labels - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - static bool has_labels(const codet &code) { if(code.get_statement()==ID_label) @@ -2054,18 +1684,6 @@ static bool has_labels(const codet &code) return false; } -/*******************************************************************\ - -Function: move_label_ifthenelse - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - static bool move_label_ifthenelse( exprt &expr, exprt &label_dest) @@ -2091,18 +1709,6 @@ static bool move_label_ifthenelse( return true; } -/*******************************************************************\ - -Function: goto_program2codet::cleanup_code_ifthenelse - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void goto_program2codet::cleanup_code_ifthenelse( codet &code, const irep_idt parent_stmt) @@ -2199,18 +1805,6 @@ void goto_program2codet::cleanup_code_ifthenelse( code=code_skipt(); } -/*******************************************************************\ - -Function: goto_program2codet::cleanup_expr - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void goto_program2codet::cleanup_expr(exprt &expr, bool no_typecast) { // we might have to do array -> pointer conversions diff --git a/src/goto-instrument/goto_program2code.h b/src/goto-instrument/goto_program2code.h index d39dfc4e5d1..f8aa1eed53f 100644 --- a/src/goto-instrument/goto_program2code.h +++ b/src/goto-instrument/goto_program2code.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Dump Goto-Program as C/C++ Source + #ifndef CPROVER_GOTO_INSTRUMENT_GOTO_PROGRAM2CODE_H #define CPROVER_GOTO_INSTRUMENT_GOTO_PROGRAM2CODE_H diff --git a/src/goto-instrument/havoc_loops.cpp b/src/goto-instrument/havoc_loops.cpp index 88cb37075ad..e1213ec1831 100644 --- a/src/goto-instrument/havoc_loops.cpp +++ b/src/goto-instrument/havoc_loops.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Havoc Loops + #include #include @@ -59,18 +62,6 @@ class havoc_loopst goto_programt::targett get_loop_exit(const loopt &); }; -/*******************************************************************\ - -Function: havoc_loopst::get_loop_exit - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - goto_programt::targett havoc_loopst::get_loop_exit(const loopt &loop) { assert(!loop.empty()); @@ -89,18 +80,6 @@ goto_programt::targett havoc_loopst::get_loop_exit(const loopt &loop) return ++last; } -/*******************************************************************\ - -Function: havoc_loopst::build_havoc_code - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void havoc_loopst::build_havoc_code( const goto_programt::targett loop_head, const modifiest &modifies, @@ -122,18 +101,6 @@ void havoc_loopst::build_havoc_code( } } -/*******************************************************************\ - -Function: havoc_loopst::havoc_loop - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void havoc_loopst::havoc_loop( const goto_programt::targett loop_head, const loopt &loop) @@ -178,18 +145,6 @@ void havoc_loopst::havoc_loop( remove_skip(goto_function.body); } -/*******************************************************************\ - -Function: havoc_loopst::get_modifies - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void havoc_loopst::get_modifies( const loopt &loop, modifiest &modifies) @@ -220,18 +175,6 @@ void havoc_loopst::get_modifies( } } -/*******************************************************************\ - -Function: havoc_loopst::havoc_loops - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void havoc_loopst::havoc_loops() { // iterate over the (natural) loops in the function @@ -240,18 +183,6 @@ void havoc_loopst::havoc_loops() havoc_loop(loop.first, loop.second); } -/*******************************************************************\ - -Function: havoc_loops - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void havoc_loops(goto_functionst &goto_functions) { function_modifiest function_modifies(goto_functions); diff --git a/src/goto-instrument/havoc_loops.h b/src/goto-instrument/havoc_loops.h index 901e75d4fe5..dc3245a1162 100644 --- a/src/goto-instrument/havoc_loops.h +++ b/src/goto-instrument/havoc_loops.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Havoc Loops + #ifndef CPROVER_GOTO_INSTRUMENT_HAVOC_LOOPS_H #define CPROVER_GOTO_INSTRUMENT_HAVOC_LOOPS_H diff --git a/src/goto-instrument/horn_encoding.cpp b/src/goto-instrument/horn_encoding.cpp index c72f5db9af8..a1842b28a92 100644 --- a/src/goto-instrument/horn_encoding.cpp +++ b/src/goto-instrument/horn_encoding.cpp @@ -8,22 +8,13 @@ Date: June 2015 \*******************************************************************/ +/// \file +/// Horn-clause Encoding + #include #include "horn_encoding.h" -/*******************************************************************\ - -Function: horn_encoding - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void horn_encoding( const goto_functionst &, const namespacet &, diff --git a/src/goto-instrument/horn_encoding.h b/src/goto-instrument/horn_encoding.h index e6db93159be..44160c35ceb 100644 --- a/src/goto-instrument/horn_encoding.h +++ b/src/goto-instrument/horn_encoding.h @@ -6,6 +6,9 @@ Module: Horn-clause Encoding \*******************************************************************/ +/// \file +/// Horn-clause Encoding + #ifndef CPROVER_GOTO_INSTRUMENT_HORN_ENCODING_H #define CPROVER_GOTO_INSTRUMENT_HORN_ENCODING_H diff --git a/src/goto-instrument/interrupt.cpp b/src/goto-instrument/interrupt.cpp index 8fa40380617..93b11352792 100644 --- a/src/goto-instrument/interrupt.cpp +++ b/src/goto-instrument/interrupt.cpp @@ -8,6 +8,9 @@ Date: September 2011 \*******************************************************************/ +/// \file +/// Interrupt Instrumentation + #include #include #include @@ -23,18 +26,6 @@ Date: September 2011 #include #endif -/*******************************************************************\ - -Function: poential_race_on_read - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool potential_race_on_read( const rw_set_baset &code_rw_set, const rw_set_baset &isr_rw_set) @@ -49,18 +40,6 @@ bool potential_race_on_read( return false; } -/*******************************************************************\ - -Function: poential_race_on_write - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool potential_race_on_write( const rw_set_baset &code_rw_set, const rw_set_baset &isr_rw_set) @@ -78,18 +57,6 @@ bool potential_race_on_write( return false; } -/*******************************************************************\ - -Function: interrupt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void interrupt( value_setst &value_sets, const symbol_tablet &symbol_table, @@ -185,18 +152,6 @@ void interrupt( } } -/*******************************************************************\ - -Function: get_isr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - symbol_exprt get_isr( const symbol_tablet &symbol_table, const irep_idt &interrupt_handler) @@ -231,18 +186,6 @@ symbol_exprt get_isr( return isr; } -/*******************************************************************\ - -Function: interrupt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void interrupt( value_setst &value_sets, const symbol_tablet &symbol_table, diff --git a/src/goto-instrument/interrupt.h b/src/goto-instrument/interrupt.h index b37cfcf8854..711c4fa32df 100644 --- a/src/goto-instrument/interrupt.h +++ b/src/goto-instrument/interrupt.h @@ -8,6 +8,9 @@ Date: September 2011 \*******************************************************************/ +/// \file +/// Interrupt Instrumentation for Goto Programs + #ifndef CPROVER_GOTO_INSTRUMENT_INTERRUPT_H #define CPROVER_GOTO_INSTRUMENT_INTERRUPT_H diff --git a/src/goto-instrument/k_induction.cpp b/src/goto-instrument/k_induction.cpp index 50abfe492f4..fcedf66e412 100644 --- a/src/goto-instrument/k_induction.cpp +++ b/src/goto-instrument/k_induction.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// k-induction + #include #include @@ -49,18 +52,6 @@ class k_inductiont const loopt &); }; -/*******************************************************************\ - -Function: k_inductiont::process_loop - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void k_inductiont::process_loop( const goto_programt::targett loop_head, const loopt &loop) @@ -146,18 +137,6 @@ void k_inductiont::process_loop( remove_skip(goto_function.body); } -/*******************************************************************\ - -Function: k_inductiont::k_induction - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void k_inductiont::k_induction() { // iterate over the (natural) loops in the function @@ -169,18 +148,6 @@ void k_inductiont::k_induction() process_loop(l_it->first, l_it->second); } -/*******************************************************************\ - -Function: k_induction - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void k_induction( goto_functionst &goto_functions, bool base_case, bool step_case, diff --git a/src/goto-instrument/k_induction.h b/src/goto-instrument/k_induction.h index 5c5918f923a..e5af8b0c43f 100644 --- a/src/goto-instrument/k_induction.h +++ b/src/goto-instrument/k_induction.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// k-induction + #ifndef CPROVER_GOTO_INSTRUMENT_K_INDUCTION_H #define CPROVER_GOTO_INSTRUMENT_K_INDUCTION_H diff --git a/src/goto-instrument/loop_utils.cpp b/src/goto-instrument/loop_utils.cpp index 90981198321..27e27979585 100644 --- a/src/goto-instrument/loop_utils.cpp +++ b/src/goto-instrument/loop_utils.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Helper functions for k-induction and loop invariants + #include #include @@ -13,18 +16,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "loop_utils.h" -/*******************************************************************\ - -Function: get_loop_exit - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - goto_programt::targett get_loop_exit(const loopt &loop) { assert(!loop.empty()); @@ -43,18 +34,6 @@ goto_programt::targett get_loop_exit(const loopt &loop) return ++last; } -/*******************************************************************\ - -Function: build_havoc_code - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void build_havoc_code( const goto_programt::targett loop_head, const modifiest &modifies, @@ -76,18 +55,6 @@ void build_havoc_code( } } -/*******************************************************************\ - -Function: get_modifies_lhs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static void get_modifies_lhs( const local_may_aliast &local_may_alias, goto_programt::const_targett t, @@ -118,18 +85,6 @@ static void get_modifies_lhs( } } -/*******************************************************************\ - -Function: get_modifies - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void get_modifies( const local_may_aliast &local_may_alias, const loopt &loop, diff --git a/src/goto-instrument/loop_utils.h b/src/goto-instrument/loop_utils.h index e6558291c4d..57407ecec1b 100644 --- a/src/goto-instrument/loop_utils.h +++ b/src/goto-instrument/loop_utils.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Helper functions for k-induction and loop invariants + #ifndef CPROVER_GOTO_INSTRUMENT_LOOP_UTILS_H #define CPROVER_GOTO_INSTRUMENT_LOOP_UTILS_H diff --git a/src/goto-instrument/mmio.cpp b/src/goto-instrument/mmio.cpp index b66633146a0..99112118d35 100644 --- a/src/goto-instrument/mmio.cpp +++ b/src/goto-instrument/mmio.cpp @@ -8,6 +8,9 @@ Date: September 2011 \*******************************************************************/ +/// \file +/// Memory-mapped I/O Instrumentation for Goto Programs + #include #include @@ -30,18 +33,6 @@ Date: September 2011 #include "mmio.h" -/*******************************************************************\ - -Function: mmio - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void mmio( value_setst &value_sets, const symbol_tablet &symbol_table, @@ -171,18 +162,6 @@ void mmio( } } -/*******************************************************************\ - -Function: mmio - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void mmio( value_setst &value_sets, class symbol_tablet &symbol_table, diff --git a/src/goto-instrument/mmio.h b/src/goto-instrument/mmio.h index bb3684c4a34..eab567f9873 100644 --- a/src/goto-instrument/mmio.h +++ b/src/goto-instrument/mmio.h @@ -8,6 +8,9 @@ Date: September 2011 \*******************************************************************/ +/// \file +/// Memory-mapped I/O Instrumentation for Goto Programs + #ifndef CPROVER_GOTO_INSTRUMENT_MMIO_H #define CPROVER_GOTO_INSTRUMENT_MMIO_H diff --git a/src/goto-instrument/model_argc_argv.cpp b/src/goto-instrument/model_argc_argv.cpp index 113c6d46a81..cc82ab8642a 100644 --- a/src/goto-instrument/model_argc_argv.cpp +++ b/src/goto-instrument/model_argc_argv.cpp @@ -8,6 +8,9 @@ Date: April 2016 \*******************************************************************/ +/// \file +/// Initialize command line arguments + #include #include @@ -26,18 +29,6 @@ Date: April 2016 #include "model_argc_argv.h" -/*******************************************************************\ - -Function: model_argc_argv - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool model_argc_argv( symbol_tablet &symbol_table, goto_functionst &goto_functions, diff --git a/src/goto-instrument/model_argc_argv.h b/src/goto-instrument/model_argc_argv.h index 0b47c68555e..08a214f6fd6 100644 --- a/src/goto-instrument/model_argc_argv.h +++ b/src/goto-instrument/model_argc_argv.h @@ -8,6 +8,9 @@ Date: April 2016 \*******************************************************************/ +/// \file +/// Initialize command line arguments + #ifndef CPROVER_GOTO_INSTRUMENT_MODEL_ARGC_ARGV_H #define CPROVER_GOTO_INSTRUMENT_MODEL_ARGC_ARGV_H diff --git a/src/goto-instrument/nondet_static.cpp b/src/goto-instrument/nondet_static.cpp index 90eb8ab3c08..db5aab9ef39 100644 --- a/src/goto-instrument/nondet_static.cpp +++ b/src/goto-instrument/nondet_static.cpp @@ -9,6 +9,9 @@ Date: November 2011 \*******************************************************************/ +/// \file +/// Nondeterministic initialization of certain global scope variables + #include #include #include @@ -18,18 +21,6 @@ Date: November 2011 #include "nondet_static.h" -/*******************************************************************\ - -Function: nondet_static - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void nondet_static( const namespacet &ns, goto_functionst &goto_functions, @@ -80,18 +71,6 @@ void nondet_static( } -/*******************************************************************\ - -Function: nondet_static - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void nondet_static( const namespacet &ns, goto_functionst &goto_functions) diff --git a/src/goto-instrument/nondet_static.h b/src/goto-instrument/nondet_static.h index 274b9cc5c91..97f3f0e683b 100644 --- a/src/goto-instrument/nondet_static.h +++ b/src/goto-instrument/nondet_static.h @@ -9,6 +9,9 @@ Date: November 2011 \*******************************************************************/ +/// \file +/// Nondeterministic initialization of certain global scope variables + #ifndef CPROVER_GOTO_INSTRUMENT_NONDET_STATIC_H #define CPROVER_GOTO_INSTRUMENT_NONDET_STATIC_H diff --git a/src/goto-instrument/nondet_volatile.cpp b/src/goto-instrument/nondet_volatile.cpp index 43969dfa9d2..d85868275d2 100644 --- a/src/goto-instrument/nondet_volatile.cpp +++ b/src/goto-instrument/nondet_volatile.cpp @@ -8,23 +8,14 @@ Date: September 2011 \*******************************************************************/ +/// \file +/// Volatile Variables + #include #include #include "nondet_volatile.h" -/*******************************************************************\ - -Function: is_volatile - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool is_volatile( const symbol_tablet &symbol_table, const typet &src) @@ -43,18 +34,6 @@ bool is_volatile( return false; } -/*******************************************************************\ - -Function: nondet_volatile_rhs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void nondet_volatile_rhs(const symbol_tablet &symbol_table, exprt &expr) { Forall_operands(it, expr) @@ -75,18 +54,6 @@ void nondet_volatile_rhs(const symbol_tablet &symbol_table, exprt &expr) } } -/*******************************************************************\ - -Function: nondet_volatile_lhs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void nondet_volatile_lhs(const symbol_tablet &symbol_table, exprt &expr) { if(expr.id()==ID_if) @@ -110,18 +77,6 @@ void nondet_volatile_lhs(const symbol_tablet &symbol_table, exprt &expr) } } -/*******************************************************************\ - -Function: nondet_volatile - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void nondet_volatile( symbol_tablet &symbol_table, goto_programt &goto_program) @@ -164,18 +119,6 @@ void nondet_volatile( } } -/*******************************************************************\ - -Function: nondet_volatile - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void nondet_volatile( symbol_tablet &symbol_table, goto_functionst &goto_functions) diff --git a/src/goto-instrument/nondet_volatile.h b/src/goto-instrument/nondet_volatile.h index 1a4457d6842..8cb3930fd56 100644 --- a/src/goto-instrument/nondet_volatile.h +++ b/src/goto-instrument/nondet_volatile.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Volatile Variables + #ifndef CPROVER_GOTO_INSTRUMENT_NONDET_VOLATILE_H #define CPROVER_GOTO_INSTRUMENT_NONDET_VOLATILE_H diff --git a/src/goto-instrument/object_id.cpp b/src/goto-instrument/object_id.cpp index 9df8b426df2..f63581bcd38 100644 --- a/src/goto-instrument/object_id.cpp +++ b/src/goto-instrument/object_id.cpp @@ -6,19 +6,10 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "object_id.h" - -/*******************************************************************\ - -Function: get_objects_rec - - Inputs: - - Outputs: - - Purpose: +/// \file +/// Object Identifiers -\*******************************************************************/ +#include "object_id.h" enum class get_modet { LHS_R, LHS_W, READ }; @@ -78,87 +69,27 @@ void get_objects_rec( } } -/*******************************************************************\ - -Function: get_objects - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void get_objects(const exprt &expr, object_id_sett &dest) { get_objects_rec(get_modet::READ, expr, dest, ""); } -/*******************************************************************\ - -Function: get_objects_r - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void get_objects_r(const code_assignt &assign, object_id_sett &dest) { get_objects_rec(get_modet::LHS_R, assign.lhs(), dest, ""); get_objects_rec(get_modet::READ, assign.rhs(), dest, ""); } -/*******************************************************************\ - -Function: get_objects_w - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void get_objects_w(const code_assignt &assign, object_id_sett &dest) { get_objects_rec(get_modet::LHS_W, assign.lhs(), dest, ""); } -/*******************************************************************\ - -Function: get_objects_w_lhs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void get_objects_w(const exprt &lhs, object_id_sett &dest) { get_objects_rec(get_modet::LHS_W, lhs, dest, ""); } -/*******************************************************************\ - -Function: get_objects_r_lhs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void get_objects_r_lhs(const exprt &lhs, object_id_sett &dest) { get_objects_rec(get_modet::LHS_R, lhs, dest, ""); diff --git a/src/goto-instrument/object_id.h b/src/goto-instrument/object_id.h index ac928e29b5f..f7c597a798b 100644 --- a/src/goto-instrument/object_id.h +++ b/src/goto-instrument/object_id.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Object Identifiers + #ifndef CPROVER_GOTO_INSTRUMENT_OBJECT_ID_H #define CPROVER_GOTO_INSTRUMENT_OBJECT_ID_H diff --git a/src/goto-instrument/points_to.cpp b/src/goto-instrument/points_to.cpp index da29e800292..843d5755aee 100644 --- a/src/goto-instrument/points_to.cpp +++ b/src/goto-instrument/points_to.cpp @@ -6,19 +6,10 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "points_to.h" - -/*******************************************************************\ - -Function: points_tot::fixedpoint - - Inputs: - - Outputs: - - Purpose: +/// \file +/// Field-sensitive, location-insensitive points-to analysis -\*******************************************************************/ +#include "points_to.h" void points_tot::fixedpoint() { @@ -42,18 +33,6 @@ void points_tot::fixedpoint() while(added); } -/*******************************************************************\ - -Function: points_tot::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void points_tot::output(std::ostream &out) const { for(value_mapt::const_iterator @@ -71,22 +50,10 @@ void points_tot::output(std::ostream &out) const out << " " << *o_it; } - out << std::endl; + out << '\n'; } } -/*******************************************************************\ - -Function: points_tot::transform - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool points_tot::transform(const cfgt::nodet &e) { bool result=false; diff --git a/src/goto-instrument/points_to.h b/src/goto-instrument/points_to.h index 4805de2343c..8b4a47d980a 100644 --- a/src/goto-instrument/points_to.h +++ b/src/goto-instrument/points_to.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Field-sensitive, location-insensitive points-to analysis + #ifndef CPROVER_GOTO_INSTRUMENT_POINTS_TO_H #define CPROVER_GOTO_INSTRUMENT_POINTS_TO_H @@ -16,14 +19,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "object_id.h" -/*******************************************************************\ - - Class: points_tot - - Purpose: - -\*******************************************************************/ - class points_tot { public: diff --git a/src/goto-instrument/race_check.cpp b/src/goto-instrument/race_check.cpp index 8f26d89bf56..952657ff0e9 100644 --- a/src/goto-instrument/race_check.cpp +++ b/src/goto-instrument/race_check.cpp @@ -8,6 +8,9 @@ Date: February 2006 \*******************************************************************/ +/// \file +/// Race Detection for Threaded Goto Programs + #include #include #include @@ -64,18 +67,6 @@ class w_guardst symbol_tablet &symbol_table; }; -/*******************************************************************\ - -Function: w_guardst::get_guard_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const symbolt &w_guardst::get_guard_symbol(const irep_idt &object) { const irep_idt identifier=id2string(object)+"$w_guard"; @@ -100,18 +91,6 @@ const symbolt &w_guardst::get_guard_symbol(const irep_idt &object) return *symbol_ptr; } -/*******************************************************************\ - -Function: w_guardst::add_initialization - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void w_guardst::add_initialization(goto_programt &goto_program) const { goto_programt::targett t=goto_program.instructions.begin(); @@ -132,18 +111,6 @@ void w_guardst::add_initialization(goto_programt &goto_program) const } } -/*******************************************************************\ - -Function: comment - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string comment(const rw_set_baset::entryt &entry, bool write) { std::string result; @@ -157,18 +124,6 @@ std::string comment(const rw_set_baset::entryt &entry, bool write) return result; } -/*******************************************************************\ - -Function: is_shared - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool is_shared( const namespacet &ns, const symbol_exprt &symbol_expr) @@ -189,18 +144,6 @@ bool is_shared( return symbol.is_shared(); } -/*******************************************************************\ - -Function: race_check - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool has_shared_entries( const namespacet &ns, const rw_set_baset &rw_set) @@ -222,18 +165,6 @@ bool has_shared_entries( return false; } -/*******************************************************************\ - -Function: race_check - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void race_check( value_setst &value_sets, symbol_tablet &symbol_table, @@ -339,18 +270,6 @@ void race_check( remove_skip(goto_program); } -/*******************************************************************\ - -Function: race_check - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void race_check( value_setst &value_sets, symbol_tablet &symbol_table, @@ -372,18 +291,6 @@ void race_check( goto_program.update(); } -/*******************************************************************\ - -Function: race_check - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void race_check( value_setst &value_sets, symbol_tablet &symbol_table, diff --git a/src/goto-instrument/race_check.h b/src/goto-instrument/race_check.h index 1c7cd3e5be8..442d142ddc0 100644 --- a/src/goto-instrument/race_check.h +++ b/src/goto-instrument/race_check.h @@ -8,6 +8,9 @@ Date: February 2006 \*******************************************************************/ +/// \file +/// Race Detection for Threaded Goto Programs + #ifndef CPROVER_GOTO_INSTRUMENT_RACE_CHECK_H #define CPROVER_GOTO_INSTRUMENT_RACE_CHECK_H diff --git a/src/goto-instrument/reachability_slicer.cpp b/src/goto-instrument/reachability_slicer.cpp index 073f9284add..72b63fa76c4 100644 --- a/src/goto-instrument/reachability_slicer.cpp +++ b/src/goto-instrument/reachability_slicer.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Slicer + #include @@ -17,18 +20,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "reachability_slicer.h" #include "reachability_slicer_class.h" -/*******************************************************************\ - -Function: reachability_slicert::fixedpoint_assertions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void reachability_slicert::fixedpoint_assertions( const is_threadedt &is_threaded, slicing_criteriont &criterion) @@ -64,18 +55,6 @@ void reachability_slicert::fixedpoint_assertions( } } -/*******************************************************************\ - -Function: reachability_slicert::slice - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void reachability_slicert::slice(goto_functionst &goto_functions) { // now replace those instructions that do not reach any assertions @@ -101,18 +80,6 @@ void reachability_slicert::slice(goto_functionst &goto_functions) goto_functions.update(); } -/*******************************************************************\ - -Function: reachability_slicer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void reachability_slicer(goto_functionst &goto_functions) { reachability_slicert s; @@ -120,18 +87,6 @@ void reachability_slicer(goto_functionst &goto_functions) s(goto_functions, a); } -/*******************************************************************\ - -Function: reachability_slicer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void reachability_slicer( goto_functionst &goto_functions, const std::list &properties) diff --git a/src/goto-instrument/reachability_slicer.h b/src/goto-instrument/reachability_slicer.h index e45aa81f27e..4d82e4b194e 100644 --- a/src/goto-instrument/reachability_slicer.h +++ b/src/goto-instrument/reachability_slicer.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Slicing + #ifndef CPROVER_GOTO_INSTRUMENT_REACHABILITY_SLICER_H #define CPROVER_GOTO_INSTRUMENT_REACHABILITY_SLICER_H diff --git a/src/goto-instrument/reachability_slicer_class.h b/src/goto-instrument/reachability_slicer_class.h index 224259b57cd..4f21049892e 100644 --- a/src/goto-instrument/reachability_slicer_class.h +++ b/src/goto-instrument/reachability_slicer_class.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Goto Program Slicing + #ifndef CPROVER_GOTO_INSTRUMENT_REACHABILITY_SLICER_CLASS_H #define CPROVER_GOTO_INSTRUMENT_REACHABILITY_SLICER_CLASS_H @@ -16,14 +19,6 @@ Author: Daniel Kroening, kroening@kroening.com class slicing_criteriont; -/*******************************************************************\ - - Class: reachability_slicert - - Purpose: - -\*******************************************************************/ - class reachability_slicert { public: diff --git a/src/goto-instrument/remove_function.cpp b/src/goto-instrument/remove_function.cpp new file mode 100644 index 00000000000..131438d1af6 --- /dev/null +++ b/src/goto-instrument/remove_function.cpp @@ -0,0 +1,74 @@ +/*******************************************************************\ + +Module: Remove function definition + +Author: Michael Tautschnig + +Date: April 2017 + +\*******************************************************************/ + +/// \file +/// Remove function definition + +#include "remove_function.h" + +#include + +#include + +/// Remove the body of function "identifier" such that an analysis will treat it +/// as a side-effect free function with non-deterministic return value. +/// \par parameters: symbol_table Input symbol table to be modified +/// goto_functions Input functions to be modified +/// identifier Function to be removed +/// message_handler Error/status output +void remove_function( + symbol_tablet &symbol_table, + goto_functionst &goto_functions, + const irep_idt &identifier, + message_handlert &message_handler) +{ + messaget message(message_handler); + + goto_functionst::function_mapt::iterator entry= + goto_functions.function_map.find(identifier); + + if(entry==goto_functions.function_map.end()) + { + message.error() << "No function " << identifier + << " in goto program" << messaget::eom; + return; + } + else if(entry->second.is_inlined()) + { + message.warning() << "Function " << identifier << " is inlined, " + << "instantiations will not be removed" + << messaget::eom; + } + + if(entry->second.body_available()) + { + message.status() << "Removing body of " << identifier + << messaget::eom; + entry->second.clear(); + symbol_table.lookup(identifier).value.make_nil(); + } +} + +/// Remove the body of all functions listed in "names" such that an analysis +/// will treat it as a side-effect free function with non-deterministic return +/// value. +/// \par parameters: symbol_table Input symbol table to be modified +/// goto_functions Input functions to be modified +/// names List of functions to be removed +/// message_handler Error/status output +void remove_functions( + symbol_tablet &symbol_table, + goto_functionst &goto_functions, + const std::list &names, + message_handlert &message_handler) +{ + for(const auto &f : names) + remove_function(symbol_table, goto_functions, f, message_handler); +} diff --git a/src/goto-instrument/remove_function.h b/src/goto-instrument/remove_function.h new file mode 100644 index 00000000000..e11db1757ba --- /dev/null +++ b/src/goto-instrument/remove_function.h @@ -0,0 +1,38 @@ +/*******************************************************************\ + +Module: Remove function definition + +Author: Michael Tautschnig + +Date: April 2017 + +\*******************************************************************/ + +/// \file +/// Remove function definition + +#ifndef CPROVER_GOTO_INSTRUMENT_REMOVE_FUNCTION_H +#define CPROVER_GOTO_INSTRUMENT_REMOVE_FUNCTION_H + +#include +#include + +#include + +class goto_functionst; +class message_handlert; +class symbol_tablet; + +void remove_function( + symbol_tablet &symbol_table, + goto_functionst &goto_functions, + const irep_idt &identifier, + message_handlert &message_handler); + +void remove_functions( + symbol_tablet &symbol_table, + goto_functionst &goto_functions, + const std::list &names, + message_handlert &message_handler); + +#endif // CPROVER_GOTO_INSTRUMENT_REMOVE_FUNCTION_H diff --git a/src/goto-instrument/rw_set.cpp b/src/goto-instrument/rw_set.cpp index 531a3ea70b4..1d6a4dfff3b 100644 --- a/src/goto-instrument/rw_set.cpp +++ b/src/goto-instrument/rw_set.cpp @@ -8,6 +8,9 @@ Date: February 2006 \*******************************************************************/ +/// \file +/// Race Detection for Threaded Goto Programs + #include #include #include @@ -18,53 +21,29 @@ Date: February 2006 #include "rw_set.h" -/*******************************************************************\ - -Function: rw_set_baset::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rw_set_baset::output(std::ostream &out) const { - out << "READ:" << std::endl; + out << "READ:\n"; for(entriest::const_iterator it=r_entries.begin(); it!=r_entries.end(); it++) { out << it->second.object << " if " - << from_expr(ns, "", it->second.guard) << std::endl; + << from_expr(ns, "", it->second.guard) << '\n'; } - out << std::endl; + out << '\n'; - out << "WRITE:" << std::endl; + out << "WRITE:\n"; for(entriest::const_iterator it=w_entries.begin(); it!=w_entries.end(); it++) { out << it->second.object << " if " - << from_expr(ns, "", it->second.guard) << std::endl; + << from_expr(ns, "", it->second.guard) << '\n'; } } -/*******************************************************************\ - -Function: rw_set_loct::compute - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void _rw_set_loct::compute() { if(target->is_assign()) @@ -97,36 +76,12 @@ void _rw_set_loct::compute() } } -/*******************************************************************\ - -Function: rw_set_loct::assign - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void _rw_set_loct::assign(const exprt &lhs, const exprt &rhs) { read(rhs); read_write_rec(lhs, false, true, "", guardt()); } -/*******************************************************************\ - -Function: rw_set_loct::read_write_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void _rw_set_loct::read_write_rec( const exprt &expr, bool r, bool w, @@ -190,7 +145,7 @@ void _rw_set_loct::read_write_rec( { /* as an under-approximation */ // std::cout << "Sorry, LOCAL_MAY too imprecise. " - // << Omitting some variables." << std::endl; + // << Omitting some variables.\n"; irep_idt object=ID_unknown; entryt &entry=r_entries[object]; @@ -240,18 +195,6 @@ void _rw_set_loct::read_write_rec( } } -/*******************************************************************\ - -Function: rw_set_functiont::compute_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rw_set_functiont::compute_rec(const exprt &function) { if(function.id()==ID_symbol) diff --git a/src/goto-instrument/rw_set.h b/src/goto-instrument/rw_set.h index 9322efbfc3e..eba731d705c 100644 --- a/src/goto-instrument/rw_set.h +++ b/src/goto-instrument/rw_set.h @@ -8,6 +8,9 @@ Date: February 2006 \*******************************************************************/ +/// \file +/// Race Detection for Threaded Goto Programs + #ifndef CPROVER_GOTO_INSTRUMENT_RW_SET_H #define CPROVER_GOTO_INSTRUMENT_RW_SET_H diff --git a/src/goto-instrument/show_locations.cpp b/src/goto-instrument/show_locations.cpp index 411422e07fd..31993269e69 100644 --- a/src/goto-instrument/show_locations.cpp +++ b/src/goto-instrument/show_locations.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Show program locations + #include #include @@ -15,18 +18,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "show_locations.h" -/*******************************************************************\ - -Function: show_locations - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void show_locations( ui_message_handlert::uit ui, const irep_idt function_id, @@ -55,14 +46,14 @@ void show_locations( l.new_element("function").data= id2string(source_location.get_function()); - std::cout << xml << std::endl; + std::cout << xml << '\n'; } break; case ui_message_handlert::uit::PLAIN: std::cout << function_id << " " << it->location_number << " " - << it->source_location << std::endl; + << it->source_location << '\n'; break; default: @@ -71,18 +62,6 @@ void show_locations( } } -/*******************************************************************\ - -Function: show_locations - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void show_locations( ui_message_handlert::uit ui, const goto_functionst &goto_functions) diff --git a/src/goto-instrument/show_locations.h b/src/goto-instrument/show_locations.h index 60861add675..3f71b19ca48 100644 --- a/src/goto-instrument/show_locations.h +++ b/src/goto-instrument/show_locations.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Show program locations + #ifndef CPROVER_GOTO_INSTRUMENT_SHOW_LOCATIONS_H #define CPROVER_GOTO_INSTRUMENT_SHOW_LOCATIONS_H diff --git a/src/goto-instrument/skip_loops.cpp b/src/goto-instrument/skip_loops.cpp index f79fae9d7b4..55a7e4cd3cc 100644 --- a/src/goto-instrument/skip_loops.cpp +++ b/src/goto-instrument/skip_loops.cpp @@ -8,6 +8,9 @@ Date: January 2016 \*******************************************************************/ +/// \file +/// Skip over selected loops by adding gotos + #include #include @@ -18,18 +21,6 @@ Date: January 2016 typedef std::set loop_idst; typedef std::map loop_mapt; -/*******************************************************************\ - -Function: skip_loops - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static bool skip_loops( goto_programt &goto_program, const loop_idst &loop_ids, @@ -71,18 +62,6 @@ static bool skip_loops( return false; } -/*******************************************************************\ - -Function: skip_loops - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static bool parse_loop_ids( const std::string &loop_ids, loop_mapt &loop_map) @@ -111,18 +90,6 @@ static bool parse_loop_ids( return false; } -/*******************************************************************\ - -Function: skip_loops - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool skip_loops( goto_functionst &goto_functions, const std::string &loop_ids, diff --git a/src/goto-instrument/skip_loops.h b/src/goto-instrument/skip_loops.h index d2c9af8996f..c5e84c6172c 100644 --- a/src/goto-instrument/skip_loops.h +++ b/src/goto-instrument/skip_loops.h @@ -8,6 +8,9 @@ Date: January 2016 \*******************************************************************/ +/// \file +/// Skip over selected loops by adding gotos + #ifndef CPROVER_GOTO_INSTRUMENT_SKIP_LOOPS_H #define CPROVER_GOTO_INSTRUMENT_SKIP_LOOPS_H diff --git a/src/goto-instrument/stack_depth.cpp b/src/goto-instrument/stack_depth.cpp index 0c5e0f81146..e422b54184d 100644 --- a/src/goto-instrument/stack_depth.cpp +++ b/src/goto-instrument/stack_depth.cpp @@ -8,6 +8,9 @@ Date: November 2011 \*******************************************************************/ +/// \file +/// Stack depth checks + #include #include #include @@ -18,18 +21,6 @@ Date: November 2011 #include "stack_depth.h" -/*******************************************************************\ - -Function: add_stack_depth_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - symbol_exprt add_stack_depth_symbol(symbol_tablet &symbol_table) { const irep_idt identifier="$stack_depth"; @@ -51,18 +42,6 @@ symbol_exprt add_stack_depth_symbol(symbol_tablet &symbol_table) return symbol_exprt(identifier, type); } -/*******************************************************************\ - -Function: stack_depth - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void stack_depth( goto_programt &goto_program, const symbol_exprt &symbol, @@ -103,18 +82,6 @@ void stack_depth( goto_program.insert_before_swap(last, minus_ins); } -/*******************************************************************\ - -Function: stack_depth - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void stack_depth( symbol_tablet &symbol_table, goto_functionst &goto_functions, diff --git a/src/goto-instrument/stack_depth.h b/src/goto-instrument/stack_depth.h index f24964ff611..8d0414121d7 100644 --- a/src/goto-instrument/stack_depth.h +++ b/src/goto-instrument/stack_depth.h @@ -8,6 +8,9 @@ Date: November 2011 \*******************************************************************/ +/// \file +/// Stack depth checks + #ifndef CPROVER_GOTO_INSTRUMENT_STACK_DEPTH_H #define CPROVER_GOTO_INSTRUMENT_STACK_DEPTH_H diff --git a/src/goto-instrument/thread_instrumentation.cpp b/src/goto-instrument/thread_instrumentation.cpp index 4c23234d051..1720beb9e15 100644 --- a/src/goto-instrument/thread_instrumentation.cpp +++ b/src/goto-instrument/thread_instrumentation.cpp @@ -6,22 +6,12 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + +#include #include #include "thread_instrumentation.h" -/*******************************************************************\ - -Function: has_start_thread - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static bool has_start_thread(const goto_programt &goto_program) { for(const auto &instruction : goto_program.instructions) @@ -31,18 +21,6 @@ static bool has_start_thread(const goto_programt &goto_program) return false; } -/*******************************************************************\ - -Function: thread_exit_instrumentation - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void thread_exit_instrumentation(goto_programt &goto_program) { if(goto_program.instructions.empty()) @@ -66,7 +44,7 @@ void thread_exit_instrumentation(goto_programt &goto_program) binary_exprt get_may("get_may"); // NULL is any - get_may.op0()=constant_exprt(ID_NULL, pointer_typet(empty_typet())); + get_may.op0()=null_pointer_exprt(to_pointer_type(pointer_type(empty_typet()))); get_may.op1()=address_of_exprt(mutex_locked_string); end->make_assertion(not_exprt(get_may)); @@ -76,18 +54,6 @@ void thread_exit_instrumentation(goto_programt &goto_program) end->function=function; } -/*******************************************************************\ - -Function: thread_exit_instrumentation - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void thread_exit_instrumentation(goto_functionst &goto_functions) { // we'll look for START THREAD @@ -117,18 +83,6 @@ void thread_exit_instrumentation(goto_functionst &goto_functions) } } -/*******************************************************************\ - -Function: mutex_init_instrumentation - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void mutex_init_instrumentation( const symbol_tablet &symbol_table, goto_programt &goto_program, @@ -165,18 +119,6 @@ void mutex_init_instrumentation( } } -/*******************************************************************\ - -Function: mutex_init_instrumentation - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void mutex_init_instrumentation( const symbol_tablet &symbol_table, goto_functionst &goto_functions) diff --git a/src/goto-instrument/thread_instrumentation.h b/src/goto-instrument/thread_instrumentation.h index eb9e159b206..c4c92394d72 100644 --- a/src/goto-instrument/thread_instrumentation.h +++ b/src/goto-instrument/thread_instrumentation.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_GOTO_INSTRUMENT_THREAD_INSTRUMENTATION_H #define CPROVER_GOTO_INSTRUMENT_THREAD_INSTRUMENTATION_H diff --git a/src/goto-instrument/undefined_functions.cpp b/src/goto-instrument/undefined_functions.cpp index 53fff3ff84b..cb4c854d8fc 100644 --- a/src/goto-instrument/undefined_functions.cpp +++ b/src/goto-instrument/undefined_functions.cpp @@ -8,24 +8,15 @@ Date: July 2016 \*******************************************************************/ +/// \file +/// Handling of functions without body + #include #include #include "undefined_functions.h" -/*******************************************************************\ - -Function: list_undefined_functions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void list_undefined_functions( const goto_functionst &goto_functions, const namespacet &ns, @@ -34,21 +25,9 @@ void list_undefined_functions( forall_goto_functions(it, goto_functions) if(!ns.lookup(it->first).is_macro && !it->second.body_available()) - os << it->first << std::endl; + os << it->first << '\n'; } -/*******************************************************************\ - -Function: undefined_function_abort_path - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void undefined_function_abort_path(goto_functionst &goto_functions) { Forall_goto_functions(it, goto_functions) diff --git a/src/goto-instrument/undefined_functions.h b/src/goto-instrument/undefined_functions.h index 7b700c839a0..85c6ba77552 100644 --- a/src/goto-instrument/undefined_functions.h +++ b/src/goto-instrument/undefined_functions.h @@ -8,6 +8,9 @@ Date: July 2016 \*******************************************************************/ +/// \file +/// Handling of functions without body + #ifndef CPROVER_UNDEFINED_FUNCTIONS_H #define CPROVER_UNDEFINED_FUNCTIONS_H diff --git a/src/goto-instrument/uninitialized.cpp b/src/goto-instrument/uninitialized.cpp index c048a518440..c4f0d588298 100644 --- a/src/goto-instrument/uninitialized.cpp +++ b/src/goto-instrument/uninitialized.cpp @@ -8,6 +8,9 @@ Date: January 2010 \*******************************************************************/ +/// \file +/// Detection for Uninitialized Local Variables + #include #include #include @@ -16,14 +19,6 @@ Date: January 2010 #include "uninitialized.h" -/*******************************************************************\ - - Class: uninitializedt - - Purpose: - -\*******************************************************************/ - class uninitializedt { public: @@ -47,19 +42,7 @@ class uninitializedt void get_tracking(goto_programt::const_targett i_it); }; -/*******************************************************************\ - -Function: uninitializedt::get_tracking - - Inputs: - - Outputs: - - Purpose: which variables need tracking, - i.e., are uninitialized and may be read? - -\*******************************************************************/ - +/// which variables need tracking, i.e., are uninitialized and may be read? void uninitializedt::get_tracking(goto_programt::const_targett i_it) { std::list objects=objects_read(*i_it); @@ -80,18 +63,6 @@ void uninitializedt::get_tracking(goto_programt::const_targett i_it) } } -/*******************************************************************\ - -Function: uninitializedt::add_assertions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void uninitializedt::add_assertions(goto_programt &goto_program) { uninitialized_analysis(goto_program, ns); @@ -223,18 +194,6 @@ void uninitializedt::add_assertions(goto_programt &goto_program) } } -/*******************************************************************\ - -Function: add_uninitialized_locals_assertions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void add_uninitialized_locals_assertions( symbol_tablet &symbol_table, goto_functionst &goto_functions) @@ -247,18 +206,6 @@ void add_uninitialized_locals_assertions( } } -/*******************************************************************\ - -Function: show_uninitialized - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void show_uninitialized( const class symbol_tablet &symbol_table, const goto_functionst &goto_functions, @@ -270,10 +217,9 @@ void show_uninitialized( { if(f_it->second.body_available()) { - out << "////" << std::endl; - out << "//// Function: " << f_it->first << std::endl; - out << "////" << std::endl; - out << std::endl; + out << "////\n"; + out << "//// Function: " << f_it->first << '\n'; + out << "////\n\n"; uninitialized_analysist uninitialized_analysis; uninitialized_analysis(f_it->second.body, ns); uninitialized_analysis.output(ns, f_it->second.body, out); diff --git a/src/goto-instrument/uninitialized.h b/src/goto-instrument/uninitialized.h index 1f4b27b5964..11437eee972 100644 --- a/src/goto-instrument/uninitialized.h +++ b/src/goto-instrument/uninitialized.h @@ -8,6 +8,9 @@ Date: January 2010 \*******************************************************************/ +/// \file +/// Detection for Uninitialized Local Variables + #ifndef CPROVER_GOTO_INSTRUMENT_UNINITIALIZED_H #define CPROVER_GOTO_INSTRUMENT_UNINITIALIZED_H diff --git a/src/goto-instrument/unwind.cpp b/src/goto-instrument/unwind.cpp index 1ae2451c3a6..f7e8c8d0888 100644 --- a/src/goto-instrument/unwind.cpp +++ b/src/goto-instrument/unwind.cpp @@ -7,6 +7,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Loop unwinding + #ifdef DEBUG #include #endif @@ -18,18 +21,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "unwind.h" #include "loop_utils.h" -/*******************************************************************\ - -Function: parse_unwindset - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void parse_unwindset(const std::string &us, unwind_sett &unwind_set) { assert(unwind_set.empty()); @@ -64,18 +55,6 @@ void parse_unwindset(const std::string &us, unwind_sett &unwind_set) } } -/*******************************************************************\ - -Function: copy_segment - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_unwindt::copy_segment( const goto_programt::const_targett start, const goto_programt::const_targett end, // exclusive @@ -130,18 +109,6 @@ void goto_unwindt::copy_segment( } } -/*******************************************************************\ - -Function: unwind - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_unwindt::unwind( goto_programt &goto_program, const goto_programt::const_targett loop_head, @@ -154,18 +121,6 @@ void goto_unwindt::unwind( iteration_points); } -/*******************************************************************\ - -Function: unwind - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_unwindt::unwind( goto_programt &goto_program, const goto_programt::const_targett loop_head, @@ -334,18 +289,6 @@ void goto_unwindt::unwind( goto_program.destructive_insert(loop_exit, copies); } -/*******************************************************************\ - -Function: get_k - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - int goto_unwindt::get_k( const irep_idt func, const unsigned loop_id, @@ -369,18 +312,6 @@ int goto_unwindt::get_k( return k; } -/*******************************************************************\ - -Function: unwind - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_unwindt::unwind( goto_programt &goto_program, const unwind_sett &unwind_set, @@ -430,18 +361,6 @@ void goto_unwindt::unwind( } } -/*******************************************************************\ - -Function: operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_unwindt::operator()( goto_functionst &goto_functions, const unwind_sett &unwind_set, @@ -458,7 +377,7 @@ void goto_unwindt::operator()( continue; #ifdef DEBUG - std::cout << "Function: " << it->first << std::endl; + std::cout << "Function: " << it->first << '\n'; #endif goto_programt &goto_program=goto_function.body; @@ -467,18 +386,6 @@ void goto_unwindt::operator()( } } -/*******************************************************************\ - -Function: show_log_json - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - // call after calling goto_functions.update()! jsont goto_unwindt::unwind_logt::output_log_json() const { diff --git a/src/goto-instrument/unwind.h b/src/goto-instrument/unwind.h index 99719f7ddf1..16ee2cf9455 100644 --- a/src/goto-instrument/unwind.h +++ b/src/goto-instrument/unwind.h @@ -7,6 +7,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Loop unwinding + #ifndef CPROVER_GOTO_INSTRUMENT_UNWIND_H #define CPROVER_GOTO_INSTRUMENT_UNWIND_H diff --git a/src/goto-instrument/wmm/abstract_event.cpp b/src/goto-instrument/wmm/abstract_event.cpp index e080ba3ef3c..41e8efb78f2 100644 --- a/src/goto-instrument/wmm/abstract_event.cpp +++ b/src/goto-instrument/wmm/abstract_event.cpp @@ -8,19 +8,10 @@ Date: 2012 \*******************************************************************/ -#include "abstract_event.h" - -/*******************************************************************\ - -Function: abstract_eventt::unsafe_pair_lwfence_param - - Inputs: +/// \file +/// abstract events - Outputs: - - Purpose: - -\*******************************************************************/ +#include "abstract_event.h" bool abstract_eventt::unsafe_pair_lwfence_param(const abstract_eventt &next, memory_modelt model, @@ -107,18 +98,6 @@ bool abstract_eventt::unsafe_pair_lwfence_param(const abstract_eventt &next, return true; } -/*******************************************************************\ - -Function: abstract_eventt::unsafe_pair_asm - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool abstract_eventt::unsafe_pair_asm(const abstract_eventt &next, memory_modelt model, unsigned char met) const diff --git a/src/goto-instrument/wmm/abstract_event.h b/src/goto-instrument/wmm/abstract_event.h index ba0c0f5f1ff..a271c709ea1 100644 --- a/src/goto-instrument/wmm/abstract_event.h +++ b/src/goto-instrument/wmm/abstract_event.h @@ -8,6 +8,9 @@ Date: 2012 \*******************************************************************/ +/// \file +/// abstract events + #ifndef CPROVER_GOTO_INSTRUMENT_WMM_ABSTRACT_EVENT_H #define CPROVER_GOTO_INSTRUMENT_WMM_ABSTRACT_EVENT_H @@ -16,10 +19,6 @@ Date: 2012 #include "wmm.h" -/*******************************************************************\ - abstract event -\*******************************************************************/ - class abstract_eventt:public graph_nodet { protected: diff --git a/src/goto-instrument/wmm/cycle_collection.cpp b/src/goto-instrument/wmm/cycle_collection.cpp index c8110665ead..1012ae40cdc 100644 --- a/src/goto-instrument/wmm/cycle_collection.cpp +++ b/src/goto-instrument/wmm/cycle_collection.cpp @@ -8,22 +8,15 @@ Date: 2012 \*******************************************************************/ +/// \file +/// collection of cycles in graph of abstract events + #include #include "event_graph.h" -/*******************************************************************\ - -Function: event_grapht::graph_explorert::filter_thin_air - - Inputs: - - Outputs: - - Purpose: after the collection, eliminates the executions forbidden - by an indirect thin-air - -\*******************************************************************/ +/// after the collection, eliminates the executions forbidden by an indirect +/// thin-air void event_grapht::graph_explorert::filter_thin_air( std::set &set_of_cycles) { @@ -54,18 +47,7 @@ void event_grapht::graph_explorert::filter_thin_air( #endif } -/*******************************************************************\ - -Function: event_grapht::graph_explorert::collect_cycles - - Inputs: - - Outputs: - - Purpose: Tarjan 1972 adapted and modified for events - -\*******************************************************************/ - +/// Tarjan 1972 adapted and modified for events void event_grapht::graph_explorert::collect_cycles( std::set &set_of_cycles, memory_modelt model) @@ -123,20 +105,8 @@ void event_grapht::graph_explorert::collect_cycles( filter_thin_air(set_of_cycles); } -/*******************************************************************\ - -Function: event_grapht::graph_explorert::extract_cycle - - Inputs: - - Outputs: - - Purpose: extracts a (whole, unreduced) cycle from the stack. - Note: it may not be a real cycle yet -- we cannot check - the size before a call to this function. - -\*******************************************************************/ - +/// extracts a (whole, unreduced) cycle from the stack. Note: it may not be a +/// real cycle yet -- we cannot check the size before a call to this function. event_grapht::critical_cyclet event_grapht::graph_explorert::extract_cycle( event_idt vertex, event_idt source, @@ -176,18 +146,8 @@ event_grapht::critical_cyclet event_grapht::graph_explorert::extract_cycle( return new_cycle; } -/*******************************************************************\ - -Function: event_grapht::graph_explorert::backtrack - - Inputs: get_po_only: used for po-transitivity - - Outputs: - - Purpose: see event_grapht::collect_cycles - -\*******************************************************************/ - +/// see event_grapht::collect_cycles +/// \param get_po_only: used for po-transitivity bool event_grapht::graph_explorert::backtrack( std::set &set_of_cycles, event_idt source, diff --git a/src/goto-instrument/wmm/data_dp.cpp b/src/goto-instrument/wmm/data_dp.cpp index ce700dc1f8a..d220174c422 100644 --- a/src/goto-instrument/wmm/data_dp.cpp +++ b/src/goto-instrument/wmm/data_dp.cpp @@ -8,23 +8,15 @@ Date: 2012 \*******************************************************************/ +/// \file +/// data dependencies + #include #include "data_dp.h" #include "abstract_event.h" -/*******************************************************************\ - -Function: data_dpt::dp_analysis - - Inputs: - - Outputs: - - Purpose: insertion - -\*******************************************************************/ - +/// insertion void data_dpt::dp_analysis( const datat &read, bool local_read, @@ -66,18 +58,6 @@ void data_dpt::dp_analysis( } } -/*******************************************************************\ - -Function: data_dpt::dp_analysis - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void data_dpt::dp_analysis( const abstract_eventt &read, const abstract_eventt &write) @@ -87,18 +67,7 @@ void data_dpt::dp_analysis( dp_analysis(d_read, read.local, d_write, write.local); } -/*******************************************************************\ - -Function: data_dpt::dp - - Inputs: - - Outputs: - - Purpose: search in N^2 - -\*******************************************************************/ - +/// search in N^2 bool data_dpt::dp(const abstract_eventt &e1, const abstract_eventt &e2) const { for(const_iterator it1=begin(); it1!=end(); ++it1) @@ -143,18 +112,7 @@ bool data_dpt::dp(const abstract_eventt &e1, const abstract_eventt &e2) const return false; } -/*******************************************************************\ - -Function: data_dpt::dp_merge - - Inputs: - - Outputs: - - Purpose: merge in N^3 - -\*******************************************************************/ - +/// merge in N^3 void data_dpt::dp_merge() { if(size()<2) @@ -198,18 +156,6 @@ void data_dpt::dp_merge() dp_merge(); } -/*******************************************************************\ - -Function: data_dpt::print - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void data_dpt::print(messaget &message) { #ifdef DEBUG diff --git a/src/goto-instrument/wmm/data_dp.h b/src/goto-instrument/wmm/data_dp.h index 6b352acccfd..abd7641fb9c 100644 --- a/src/goto-instrument/wmm/data_dp.h +++ b/src/goto-instrument/wmm/data_dp.h @@ -8,6 +8,9 @@ Date: 2012 \*******************************************************************/ +/// \file +/// data dependencies + #ifndef CPROVER_GOTO_INSTRUMENT_WMM_DATA_DP_H #define CPROVER_GOTO_INSTRUMENT_WMM_DATA_DP_H @@ -18,10 +21,6 @@ Date: 2012 class abstract_eventt; class messaget; -/*******************************************************************\ - data dependencies -\*******************************************************************/ - struct datat { irep_idt id; diff --git a/src/goto-instrument/wmm/event_graph.cpp b/src/goto-instrument/wmm/event_graph.cpp index dce7b3de474..9342a9268f8 100644 --- a/src/goto-instrument/wmm/event_graph.cpp +++ b/src/goto-instrument/wmm/event_graph.cpp @@ -8,6 +8,9 @@ Date: 2012 \*******************************************************************/ +/// \file +/// graph of abstract events + #include "event_graph.h" #include @@ -22,32 +25,20 @@ static const char *colour_map[NB_COLOURS]= "deeppink", "indigo", "olivedrab"}; #define print_colour(u) colour_map[u%NB_COLOURS] -/*******************************************************************\ - -Function: event_grapht::print_rec_graph - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void event_grapht::print_rec_graph(std::ofstream &file, event_idt node_id, std::set &visited) { const abstract_eventt &node=operator[](node_id); file << node_id << "[label=\"" << node << ", " << node.source_location << - "\"];" << std::endl; + "\"];\n"; visited.insert(node_id); for(wmm_grapht::edgest::const_iterator it=po_out(node_id).begin(); it!=po_out(node_id).end(); ++it) { - file << node_id << "->" << it->first << "[]" << std::endl; - file << "{rank=same; " << node_id << "; " << it->first << "}" << std::endl; + file << node_id << "->" << it->first << "[]\n"; + file << "{rank=same; " << node_id << "; " << it->first << "}\n"; if(visited.find(it->first)==visited.end()) print_rec_graph(file, it->first, visited); } @@ -56,24 +47,12 @@ void event_grapht::print_rec_graph(std::ofstream &file, event_idt node_id, it=com_out(node_id).begin(); it!=com_out(node_id).end(); ++it) { - file << node_id << "->" << it->first << "[style=\"dotted\"]" << std::endl; + file << node_id << "->" << it->first << "[style=\"dotted\"]\n"; if(visited.find(it->first)==visited.end()) print_rec_graph(file, it->first, visited); } } -/*******************************************************************\ - -Function: event_grapht::print_graph - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void event_grapht::print_graph() { assert(po_order.size()>0); @@ -81,29 +60,19 @@ void event_grapht::print_graph() event_idt root=po_order.front(); std::ofstream file; file.open("graph.dot"); - file << "digraph G {" << std::endl; - file << "rankdir=LR;" << std::endl; + file << "digraph G {\n"; + file << "rankdir=LR;\n"; print_rec_graph(file, root, visited); - file << "}" << std::endl; + file << "}\n"; } -/*******************************************************************\ - -Function: event_grapht::copy_segment - - Inputs: begin: top of the subgraph - end: bottom of the subgraph - - Outputs: - - Purpose: copies the segment - -\*******************************************************************/ - +/// copies the segment +/// \param begin: top of the subgraph +/// \param end: bottom of the subgraph void event_grapht::explore_copy_segment(std::set &explored, event_idt begin, event_idt end) const { - // std::cout << "explores " << begin << " against " << end << std::endl; + // std::cout << "explores " << begin << " against " << end << '\n'; if(explored.find(begin)!=explored.end()) return; @@ -149,7 +118,7 @@ event_idt event_grapht::copy_segment(event_idt begin, event_idt end) // for(std::set::const_iterator it=covered.begin(); // it!=covered.end(); ++it) -// std::cout << "covered: " << *it << std::endl; +// std::cout << "covered: " << *it << '\n'; std::map orig2copy; @@ -214,18 +183,6 @@ event_idt event_grapht::copy_segment(event_idt begin, event_idt end) return orig2copy[end]; } -/*******************************************************************\ - -Function: event_grapht::critical_cyclet::check_AC - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool event_grapht::critical_cyclet::check_AC( const_iterator s_it, const abstract_eventt &first, @@ -267,18 +224,6 @@ bool event_grapht::critical_cyclet::check_AC( return AC; } -/*******************************************************************\ - -Function: event_grapht::critical_cyclet::check_BC - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool event_grapht::critical_cyclet::check_BC( const_iterator it, const abstract_eventt &first, @@ -332,18 +277,6 @@ bool event_grapht::critical_cyclet::check_BC( return BC; } -/*******************************************************************\ - -Function: event_grapht::critical_cyclet::is_unsafe - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool event_grapht::critical_cyclet::is_unsafe(memory_modelt model, bool fast) { egraph.message.debug() << "cycle is safe?" << messaget::eom; @@ -625,18 +558,7 @@ bool event_grapht::critical_cyclet::is_unsafe(memory_modelt model, bool fast) return unsafe_met; } -/*******************************************************************\ - -Function: event_grapht::critical_cyclet::is_unsafe_asm - - Inputs: - - Outputs: - - Purpose: same as is_unsafe, but with ASM fences - -\*******************************************************************/ - +/// same as is_unsafe, but with ASM fences bool event_grapht::critical_cyclet::is_unsafe_asm( memory_modelt model, bool fast) @@ -970,18 +892,6 @@ bool event_grapht::critical_cyclet::is_unsafe_asm( return unsafe_met; } -/*******************************************************************\ - -Function: event_grapht::critical_cyclet::is_not_uniproc - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool event_grapht::critical_cyclet::is_not_uniproc() const { const_iterator it=begin(); @@ -1020,18 +930,6 @@ bool event_grapht::critical_cyclet::is_not_uniproc() const return (it!=end()); } -/*******************************************************************\ - -Function: event_grapht::critical_cyclet::is_not_weak_uniproc - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool event_grapht::critical_cyclet::is_not_weak_uniproc() const { const_iterator it=begin(); @@ -1069,18 +967,6 @@ bool event_grapht::critical_cyclet::is_not_weak_uniproc() const return (it!=end()); } -/*******************************************************************\ - -Function: event_grapht::critical_cyclet::is_not_thin_air - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool event_grapht::critical_cyclet::is_not_thin_air() const { // assert(size()>2); @@ -1129,18 +1015,6 @@ bool event_grapht::critical_cyclet::is_not_thin_air() const return true; } -/*******************************************************************\ - -Function: event_grapht::critical_cyclet::print - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string event_grapht::critical_cyclet::print() const { std::string cycle="Cycle: "; @@ -1149,18 +1023,6 @@ std::string event_grapht::critical_cyclet::print() const return cycle + " End of cycle."; } -/*******************************************************************\ - -Function: event_grapht::critical_cyclet::print_unsafes - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string event_grapht::critical_cyclet::print_unsafes() const { std::string name="Unsafe pairs: "; @@ -1208,18 +1070,6 @@ std::string event_grapht::critical_cyclet::print_unsafes() const return name; } -/*******************************************************************\ - -Function: event_grapht::critical_cyclet::print_events - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string event_grapht::critical_cyclet::print_events() const { std::string cycle="Cycle: "; @@ -1232,18 +1082,6 @@ std::string event_grapht::critical_cyclet::print_events() const return cycle+" End of cycle."; } -/*******************************************************************\ - -Function: event_grapht::critical_cyclet::print_output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string event_grapht::critical_cyclet::print_output() const { std::string cycle; @@ -1257,18 +1095,6 @@ std::string event_grapht::critical_cyclet::print_output() const return cycle; } -/*******************************************************************\ - -Function: event_grapht::critical_cyclet::print_detail - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string event_grapht::critical_cyclet::print_detail( const critical_cyclet &reduced, std::map &map_id2var, @@ -1298,18 +1124,6 @@ std::string event_grapht::critical_cyclet::print_detail( return cycle; } -/*******************************************************************\ - -Function: event_grapht::critical_cyclet::print_all - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string event_grapht::critical_cyclet::print_all( memory_modelt model, std::map &map_id2var, @@ -1340,18 +1154,6 @@ std::string event_grapht::critical_cyclet::print_all( return cycle; } -/*******************************************************************\ - -Function: event_grapht::critical_cyclet::hide_internals - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void event_grapht::critical_cyclet::hide_internals( critical_cyclet &reduced) const { @@ -1428,18 +1230,6 @@ void event_grapht::critical_cyclet::hide_internals( } } -/*******************************************************************\ - -Function: event_grapht::critical_cyclet::print_name - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string event_grapht::critical_cyclet::print_name( const critical_cyclet &reduced, memory_modelt model) const @@ -1745,18 +1535,6 @@ std::string event_grapht::critical_cyclet::print_name( return name; } -/*******************************************************************\ - -Function: event_grapht::critical_cyclet::print_dot - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void event_grapht::critical_cyclet::print_dot( std::ostream &str, unsigned colour, @@ -1768,12 +1546,11 @@ void event_grapht::critical_cyclet::print_dot( const abstract_eventt &ev=egraph[*it]; /* id of the cycle in comments */ - str << "/* " << id << " */" << std::endl; + str << "/* " << id << " */\n"; /* vertex */ str << ev.id << "[label=\"\\\\lb {" << ev.id << "}" << ev.get_operation(); - str << "{" << ev.variable << "} {} @thread" << ev.thread << "\"];"; - str << std::endl; + str << "{" << ev.variable << "} {} @thread" << ev.thread << "\"];\n"; } /* print edges */ @@ -1783,7 +1560,7 @@ void event_grapht::critical_cyclet::print_dot( const abstract_eventt &cur=egraph[*cur_it]; /* id of the cycle in comments */ - str << "/* " << id << " */" << std::endl; + str << "/* " << id << " */\n"; /* edge */ if(prev_it!=end()) @@ -1845,7 +1622,7 @@ void event_grapht::critical_cyclet::print_dot( else str << cur.id << "[label=\"?"; - str << "\",color=" << print_colour(colour) << "];" <"; @@ -1911,5 +1688,5 @@ void event_grapht::critical_cyclet::print_dot( else str << first.id << "[label=\"?"; - str << "\", color=" << print_colour(colour) << "];" < wmm_grapht; typedef wmm_grapht::node_indext event_idt; diff --git a/src/goto-instrument/wmm/fence.cpp b/src/goto-instrument/wmm/fence.cpp index 34c0c387ac5..7c820f238f9 100644 --- a/src/goto-instrument/wmm/fence.cpp +++ b/src/goto-instrument/wmm/fence.cpp @@ -8,6 +8,9 @@ Date: February 2012 \*******************************************************************/ +/// \file +/// Fences for instrumentation + #include #include "fence.h" diff --git a/src/goto-instrument/wmm/fence.h b/src/goto-instrument/wmm/fence.h index 5d14c2cc7a3..0e08d23be28 100644 --- a/src/goto-instrument/wmm/fence.h +++ b/src/goto-instrument/wmm/fence.h @@ -8,6 +8,9 @@ Date: February 2012 \*******************************************************************/ +/// \file +/// Fences for instrumentation + #ifndef CPROVER_GOTO_INSTRUMENT_WMM_FENCE_H #define CPROVER_GOTO_INSTRUMENT_WMM_FENCE_H diff --git a/src/goto-instrument/wmm/goto2graph.cpp b/src/goto-instrument/wmm/goto2graph.cpp index efcd626cb10..77338b3ead1 100644 --- a/src/goto-instrument/wmm/goto2graph.cpp +++ b/src/goto-instrument/wmm/goto2graph.cpp @@ -8,6 +8,9 @@ Date: 2012 \*******************************************************************/ +/// \file +/// Turns a goto-program into an abstract event graph + #include #include #include @@ -30,18 +33,7 @@ Date: 2012 // #define PRINT_UNSAFES -/*******************************************************************\ - -Function: instrumentert::local - - Inputs: - - Outputs: - - Purpose: is local variable? - -\*******************************************************************/ - +/// is local variable? bool inline instrumentert::local(const irep_idt &id) { std::string identifier=id2string(id); @@ -95,20 +87,8 @@ bool inline instrumentert::cfg_visitort::local(const irep_idt &i) return instrumenter.local(i); } -/*******************************************************************\ - -Function: instrumentert::goto2graph_cfg - - Inputs: - - Outputs: - - Purpose: goes through CFG and build a static abstract event - graph overapproximating the read/write relations for any - executions - -\*******************************************************************/ - +/// goes through CFG and build a static abstract event graph overapproximating +/// the read/write relations for any executions unsigned instrumentert::goto2graph_cfg( value_setst &value_sets, memory_modelt model, @@ -169,18 +149,6 @@ unsigned instrumentert::goto2graph_cfg( return visitor.max_thread; } -/*******************************************************************\ - -Function: instrumentert::cfg_visitort::visit_cfg_function - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void instrumentert::cfg_visitort::visit_cfg_function( /* value_sets and options */ value_setst &value_sets, @@ -319,18 +287,6 @@ void instrumentert::cfg_visitort::visit_cfg_function( } } -/*******************************************************************\ - -Function: instrumentert::visit_cfg_propagate - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void inline instrumentert::cfg_visitort::visit_cfg_propagate( goto_programt::instructionst::iterator i_it) { @@ -343,34 +299,11 @@ void inline instrumentert::cfg_visitort::visit_cfg_propagate( in_pos[i_it].insert(node); } -/*******************************************************************\ - -Function: instrumentert::visit_cfg_thread - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void instrumentert::cfg_visitort::visit_cfg_thread() const { } -/*******************************************************************\ - -Function: instrumentert::visit_cfg_reference_function - - Inputs: - - Outputs: - - Purpose: references the first and last edges of the function - -\*******************************************************************/ - +/// references the first and last edges of the function /* OBSOLETE */ /* Note: can be merged with visit_cfg_body */ /* Warning: we iterate here over the successive instructions of the @@ -459,18 +392,6 @@ void inline instrumentert::cfg_visitort::visit_cfg_reference_function( std::make_pair(in_nodes, out_nodes); } -/*******************************************************************\ - -Function: alt_copy_segment - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - event_idt alt_copy_segment(wmm_grapht &alt_egraph, event_idt begin, event_idt end) { @@ -480,18 +401,6 @@ event_idt alt_copy_segment(wmm_grapht &alt_egraph, return end; } -/*******************************************************************\ - -Function: instrumentert::visit_cfg_visitort::contains_shared_array - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool instrumentert::cfg_visitort::contains_shared_array( goto_programt::const_targett targ, goto_programt::const_targett i_it, @@ -540,18 +449,7 @@ bool instrumentert::cfg_visitort::contains_shared_array( } -/*******************************************************************\ - -Function: instrumentert::visit_cfg_visitort::visit_cfg_body - - Inputs: - - Outputs: - - Purpose: strategy: fwd/bwd alternation - -\*******************************************************************/ - +/// strategy: fwd/bwd alternation void inline instrumentert::cfg_visitort::visit_cfg_body( goto_programt::const_targett i_it, loop_strategyt replicate_body, @@ -597,18 +495,6 @@ void inline instrumentert::cfg_visitort::visit_cfg_body( } } -/*******************************************************************\ - -Function: instrumentert::visit_cfg_visitort::visit_cfg_duplicate - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void inline instrumentert::cfg_visitort::visit_cfg_duplicate( goto_programt::const_targett targ, goto_programt::const_targett i_it) @@ -672,18 +558,7 @@ void inline instrumentert::cfg_visitort::visit_cfg_duplicate( } } -/*******************************************************************\ - -Function: instrumentert::visit_cfg_visitort::visit_cfg_backedge - - Inputs: - - Outputs: - - Purpose: strategy: fwd/bwd alternation - -\*******************************************************************/ - +/// strategy: fwd/bwd alternation void inline instrumentert::cfg_visitort::visit_cfg_backedge( goto_programt::const_targett targ, goto_programt::const_targett i_it) @@ -750,18 +625,6 @@ void inline instrumentert::cfg_visitort::visit_cfg_backedge( } } -/*******************************************************************\ - -Function: instrumentert::visit_cfg_goto - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void instrumentert::cfg_visitort::visit_cfg_goto( goto_programt::instructionst::iterator i_it, loop_strategyt replicate_body, @@ -791,18 +654,6 @@ void instrumentert::cfg_visitort::visit_cfg_goto( } } -/*******************************************************************\ - -Function: intrumentert::visit_cfg_function_call - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void instrumentert::cfg_visitort::visit_cfg_function_call( value_setst &value_sets, goto_programt::instructionst::iterator i_it, @@ -870,18 +721,6 @@ void instrumentert::cfg_visitort::visit_cfg_function_call( } } -/*******************************************************************\ - -Function: instrumentert::visit_cfg_lwfence - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void instrumentert::cfg_visitort::visit_cfg_lwfence( goto_programt::instructionst::iterator i_it) { @@ -914,18 +753,6 @@ void instrumentert::cfg_visitort::visit_cfg_lwfence( updated.insert(i_it); } -/*******************************************************************\ - -Function: instrumentert::visit_cfg_lwfence - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void instrumentert::cfg_visitort::visit_cfg_asm_fence( goto_programt::instructionst::iterator i_it) { @@ -966,18 +793,6 @@ void instrumentert::cfg_visitort::visit_cfg_asm_fence( updated.insert(i_it); } -/*******************************************************************\ - -Function: instrumentert::visit_cfg_assign - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void instrumentert::cfg_visitort::visit_cfg_assign( value_setst &value_sets, namespacet &ns, @@ -1295,18 +1110,6 @@ void instrumentert::cfg_visitort::visit_cfg_assign( } } -/*******************************************************************\ - -Function: instrumentert::visit_cfg_fence - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void instrumentert::cfg_visitort::visit_cfg_fence( goto_programt::instructionst::iterator i_it) { @@ -1342,36 +1145,12 @@ void instrumentert::cfg_visitort::visit_cfg_fence( updated.insert(i_it); } -/*******************************************************************\ - -Function: intrumentert::visit_cfg_skip - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void instrumentert::cfg_visitort::visit_cfg_skip( goto_programt::instructionst::iterator i_it) { visit_cfg_propagate(i_it); } -/*******************************************************************\ - -Function: intrumentert::add_instr_to_interleaving - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void inline instrumentert::add_instr_to_interleaving( goto_programt::instructionst::iterator it, goto_programt &interleaving) @@ -1404,18 +1183,6 @@ void inline instrumentert::add_instr_to_interleaving( current_instruction->swap(new_instruction); } -/*******************************************************************\ - -Function: instrumentert::is_cfg_spurious - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool instrumentert::is_cfg_spurious(const event_grapht::critical_cyclet &cyc) { message.debug() << "spurious by CFG? " << messaget::eom; @@ -1557,18 +1324,6 @@ bool instrumentert::is_cfg_spurious(const event_grapht::critical_cyclet &cyc) #endif } -/*******************************************************************\ - -Function: instrumentert::cfg_cycles_filter - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void instrumentert::cfg_cycles_filter() { if(!set_of_cycles.empty()) @@ -1616,18 +1371,6 @@ void instrumentert::cfg_cycles_filter() message.status() << "No cycle to filter" << messaget::eom; } -/*******************************************************************\ - -Function: instrumentert::print_outputs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void inline instrumentert::print_outputs_local( const std::set &set, std::ofstream &dot, @@ -1657,10 +1400,10 @@ void inline instrumentert::print_outputs_local( message.debug() << it->print_unsafes() << messaget::eom; #endif it->print_dot(dot, colour++, model); - ref << it->print_name(model, hide_internals) << std::endl; - output << it->print_output() << std::endl; + ref << it->print_name(model, hide_internals) << '\n'; + output << it->print_output() << '\n'; all << it->print_all(model, map_id2var, map_var2id, hide_internals) - << std::endl; + << '\n'; /* emphasises instrumented events */ for(std::list::const_iterator it_e=it->begin(); @@ -1682,7 +1425,7 @@ void inline instrumentert::print_outputs_local( { dot << ev.id << "[label=\"\\\\lb {" << ev.id << "}"; dot << ev.get_operation() << "{" << ev.variable << "} {} @thread"; - dot << ev.thread << "\",color=red,shape=box];" << std::endl; + dot << ev.thread << "\",color=red,shape=box];\n"; } } } @@ -1698,7 +1441,7 @@ void inline instrumentert::print_outputs_local( for(std::set::iterator it=same_po[i].begin(); it!=same_po[i].end(); it++) dot << egraph[*it].id << ";"; - dot << "};" << std::endl; + dot << "};\n"; } } @@ -1709,15 +1452,14 @@ void inline instrumentert::print_outputs_local( same_file.begin(); it!=same_file.end(); it++) { - dot << "subgraph cluster_" << irep_id_hash()(it->first) << "{" - << std::endl; - dot << " label=\"" << it->first << "\";" << std::endl; + dot << "subgraph cluster_" << irep_id_hash()(it->first) << "{\n"; + dot << " label=\"" << it->first << "\";\n"; for(std::set::const_iterator ev_it=it->second.begin(); ev_it!=it->second.end(); ev_it++) { - dot << " " << egraph[*ev_it].id << ";" << std::endl; + dot << " " << egraph[*ev_it].id << ";\n"; } - dot << "};" << std::endl; + dot << "};\n"; } } @@ -1728,11 +1470,11 @@ void inline instrumentert::print_outputs_local( m_it!=map_id2var.end(); ++m_it) { - table << std::endl << "| " << m_it->first << " : " << m_it->second; + table << "\n| " << m_it->first << " : " << m_it->second; } - table << std::endl; + table << '\n'; table << std::string(80, '-'); - table << std::endl; + table << '\n'; } void instrumentert::print_outputs(memory_modelt model, bool hide_internals) @@ -1749,8 +1491,8 @@ void instrumentert::print_outputs(memory_modelt model, bool hide_internals) all.open("all.txt"); table.open("table.txt"); - dot << "digraph G {" << std::endl; - dot << "nodesep=1; ranksep=1;" << std::endl; + dot << "digraph G {\n"; + dot << "nodesep=1; ranksep=1;\n"; /* prints cycles in the different outputs */ if(!set_of_cycles.empty()) @@ -1764,21 +1506,21 @@ void instrumentert::print_outputs(memory_modelt model, bool hide_internals) std::string name="scc_" + std::to_string(i) + ".dot"; local_dot.open(name.c_str()); - local_dot << "digraph G {" << std::endl; - local_dot << "nodesep=1; ranksep=1;" << std::endl; + local_dot << "digraph G {\n"; + local_dot << "nodesep=1; ranksep=1;\n"; print_outputs_local(set_of_cycles_per_SCC[i], local_dot, ref, output, all, table, model, hide_internals); - local_dot << "}" << std::endl; + local_dot << "}\n"; local_dot.close(); dot << i << "[label=\"SCC " << i << "\",link=\"" << "scc_" << i; - dot << ".svg\"]" << std::endl; + dot << ".svg\"]\n"; } } else message.debug() << "no cycles to output" << messaget::eom; - dot << "}" << std::endl; + dot << "}\n"; dot.close(); ref.close(); @@ -1787,18 +1529,7 @@ void instrumentert::print_outputs(memory_modelt model, bool hide_internals) table.close(); } -/*******************************************************************\ - -Function: instrumentert::collect_cycles_by_SCCs - - Inputs: - - Outputs: - - Purpose: Note: can be distributed (#define DISTRIBUTED) - -\*******************************************************************/ - +/// Note: can be distributed (#define DISTRIBUTED) #if 1 // #ifdef _WIN32 void instrumentert::collect_cycles_by_SCCs(memory_modelt model) diff --git a/src/goto-instrument/wmm/goto2graph.h b/src/goto-instrument/wmm/goto2graph.h index 46193c5239a..49adbfdb640 100644 --- a/src/goto-instrument/wmm/goto2graph.h +++ b/src/goto-instrument/wmm/goto2graph.h @@ -8,6 +8,9 @@ Date: 2012 \*******************************************************************/ +/// \file +/// Instrumenter + #ifndef CPROVER_GOTO_INSTRUMENT_WMM_GOTO2GRAPH_H #define CPROVER_GOTO_INSTRUMENT_WMM_GOTO2GRAPH_H diff --git a/src/goto-instrument/wmm/instrumenter_pensieve.h b/src/goto-instrument/wmm/instrumenter_pensieve.h index 7a5210448fe..1e954344322 100644 --- a/src/goto-instrument/wmm/instrumenter_pensieve.h +++ b/src/goto-instrument/wmm/instrumenter_pensieve.h @@ -6,6 +6,9 @@ Module: Instrumenter \*******************************************************************/ +/// \file +/// Instrumenter + #ifndef CPROVER_GOTO_INSTRUMENT_WMM_INSTRUMENTER_PENSIEVE_H #define CPROVER_GOTO_INSTRUMENT_WMM_INSTRUMENTER_PENSIEVE_H diff --git a/src/goto-instrument/wmm/instrumenter_strategies.cpp b/src/goto-instrument/wmm/instrumenter_strategies.cpp index f06ed867ab5..258eec8df0b 100644 --- a/src/goto-instrument/wmm/instrumenter_strategies.cpp +++ b/src/goto-instrument/wmm/instrumenter_strategies.cpp @@ -8,6 +8,9 @@ Date: 2012 \*******************************************************************/ +/// \file +/// Strategies for picking the abstract events to instrument + #include #include @@ -19,18 +22,6 @@ Date: 2012 #include #endif -/*******************************************************************\ - -Function: instrumentert::instrument_with_strategy - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void instrumentert::instrument_with_strategy(instrumentation_strategyt strategy) { var_to_instr.clear(); @@ -90,18 +81,6 @@ void instrumentert::instrument_with_strategy(instrumentation_strategyt strategy) message.debug() << "no cycles to instrument" << messaget::eom; } -/*******************************************************************\ - -Function: instrumentert::instrument_all_inserter - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void inline instrumentert::instrument_all_inserter( const std::set &set_of_cycles) { @@ -130,18 +109,6 @@ void inline instrumentert::instrument_all_inserter( } } -/*******************************************************************\ - -Function: instrumentert::instrument_one_event_per_cycle - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void inline instrumentert::instrument_one_event_per_cycle_inserter( const std::set &set_of_cycles) { @@ -193,18 +160,6 @@ void inline instrumentert::instrument_one_event_per_cycle_inserter( } } -/*******************************************************************\ - -Function: instrumentert::instrument_one_read_per_cycle - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void inline instrumentert::instrument_one_read_per_cycle_inserter( const std::set &set_of_cycles) { @@ -212,18 +167,6 @@ void inline instrumentert::instrument_one_read_per_cycle_inserter( throw "read first strategy not implemented yet"; } -/*******************************************************************\ - -Function: instrumentert::instrument_one_write_per_cycle - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void inline instrumentert::instrument_one_write_per_cycle_inserter( const std::set &set_of_cycles) { @@ -231,18 +174,7 @@ void inline instrumentert::instrument_one_write_per_cycle_inserter( throw "write first strategy not implemented yet"; } -/*******************************************************************\ - -Function: instrumentert::cost - - Inputs: - - Outputs: - - Purpose: cost function - -\*******************************************************************/ - +/// cost function unsigned inline instrumentert::cost( const event_grapht::critical_cyclet::delayt &e) { @@ -258,18 +190,6 @@ unsigned inline instrumentert::cost( return 3; } -/*******************************************************************\ - -Function: instrumentert::instrument_minimum_interference - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void inline instrumentert::instrument_minimum_interference_inserter( const std::set &set_of_cycles) { @@ -434,18 +354,6 @@ void inline instrumentert::instrument_minimum_interference_inserter( #endif } -/*******************************************************************\ - -Function: instrumentert::instrument_my_events_inserter - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void inline instrumentert::instrument_my_events_inserter( const std::set &set, const std::set &my_events) @@ -478,18 +386,6 @@ void inline instrumentert::instrument_my_events_inserter( } } -/*******************************************************************\ - -Function: instrumentert::instrument_my_events - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void instrumentert::instrument_my_events( const std::set &my_events) { @@ -508,18 +404,6 @@ void instrumentert::instrument_my_events( message.debug() << "no cycles to instrument" << messaget::eom; } -/*******************************************************************\ - -Function: extract_my_events - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::set instrumentert::extract_my_events() { std::ifstream file; diff --git a/src/goto-instrument/wmm/pair_collection.cpp b/src/goto-instrument/wmm/pair_collection.cpp index 4748ac2d2e7..a2bd0880eb3 100644 --- a/src/goto-instrument/wmm/pair_collection.cpp +++ b/src/goto-instrument/wmm/pair_collection.cpp @@ -9,6 +9,10 @@ Date: 2013 \*******************************************************************/ +/// \file +/// collection of pairs (for Pensieve's static delay-set analysis) in graph of +/// abstract events + #include #include @@ -16,19 +20,7 @@ Date: 2013 #include "event_graph.h" #define OUTPUT(s, fence, file, line, id, type) \ - s< #include @@ -24,24 +27,12 @@ Author: Daniel Kroening, kroening@kroening.com #include -#include +#include #include #include "goto_convert_class.h" #include "format_strings.h" -/*******************************************************************\ - -Function: goto_convertt::do_prob_uniform - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::do_prob_uniform( const exprt &lhs, const exprt &function, @@ -120,18 +111,6 @@ void goto_convertt::do_prob_uniform( copy(assignment, ASSIGN, dest); } -/*******************************************************************\ - -Function: goto_convertt::do_prob_coin - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::do_prob_coin( const exprt &lhs, const exprt &function, @@ -209,18 +188,6 @@ void goto_convertt::do_prob_coin( copy(assignment, ASSIGN, dest); } -/*******************************************************************\ - -Function: goto_convertt::do_printf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::do_printf( const exprt &lhs, const exprt &function, @@ -256,18 +223,6 @@ void goto_convertt::do_printf( assert(false); } -/*******************************************************************\ - -Function: goto_convertt::do_scanf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::do_scanf( const exprt &lhs, const exprt &function, @@ -335,7 +290,9 @@ void goto_convertt::do_scanf( copy(array_copy_statement, OTHER, dest); #else - exprt lhs=dereference_exprt(ptr, type.subtype()); + exprt lhs= + index_exprt( + dereference_exprt(ptr, type), from_integer(0, index_type())); exprt rhs=side_effect_expr_nondett(type.subtype()); code_assignt assign(lhs, rhs); assign.add_source_location()=function.source_location(); @@ -371,18 +328,6 @@ void goto_convertt::do_scanf( assert(false); } -/*******************************************************************\ - -Function: goto_convertt::do_input - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::do_input( const exprt &lhs, const exprt &function, @@ -404,18 +349,6 @@ void goto_convertt::do_input( copy(input_code, OTHER, dest); } -/*******************************************************************\ - -Function: goto_convertt::do_output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::do_output( const exprt &lhs, const exprt &function, @@ -437,18 +370,6 @@ void goto_convertt::do_output( copy(output_code, OTHER, dest); } -/*******************************************************************\ - -Function: goto_convertt::do_atomic_begin - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::do_atomic_begin( const exprt &lhs, const exprt &function, @@ -473,18 +394,6 @@ void goto_convertt::do_atomic_begin( t->source_location=function.source_location(); } -/*******************************************************************\ - -Function: goto_convertt::do_atomic_end - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::do_atomic_end( const exprt &lhs, const exprt &function, @@ -509,18 +418,6 @@ void goto_convertt::do_atomic_end( t->source_location=function.source_location(); } -/*******************************************************************\ - -Function: goto_convertt::do_cpp_new - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::do_cpp_new( const exprt &lhs, const side_effect_exprt &rhs, @@ -641,18 +538,6 @@ void goto_convertt::do_cpp_new( dest.destructive_append(tmp_initializer); } -/*******************************************************************\ - -Function: set_class_identifier - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void set_class_identifier( struct_exprt &expr, const namespacet &ns, @@ -678,18 +563,6 @@ void set_class_identifier( } } -/*******************************************************************\ - -Function: goto_convertt::do_java_new - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::do_java_new( const exprt &lhs, const side_effect_exprt &rhs, @@ -745,18 +618,6 @@ void goto_convertt::do_java_new( t_i->source_location=location; } -/*******************************************************************\ - -Function: goto_convertt::do_java_new_array - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::do_java_new_array( const exprt &lhs, const side_effect_exprt &rhs, @@ -844,7 +705,17 @@ void goto_convertt::do_java_new_array( allocate_data_type=data.type(); side_effect_exprt data_cpp_new_expr(ID_cpp_new_array, allocate_data_type); - data_cpp_new_expr.set(ID_size, rhs.op0()); + + // The instruction may specify a (hopefully small) upper bound on the + // array size, in which case we allocate a fixed-length array that may + // be larger than the `length` member rather than use a true variable- + // length array, which produces a more complex formula in the current + // backend. + const irept size_bound=rhs.find(ID_length_upper_bound); + if(size_bound.is_nil()) + data_cpp_new_expr.set(ID_size, rhs.op0()); + else + data_cpp_new_expr.set(ID_size, size_bound); // Must directly assign the new array to a temporary // because goto-symex will notice `x=side_effect_exprt` but not @@ -936,19 +807,7 @@ void goto_convertt::do_java_new_array( } } -/*******************************************************************\ - -Function: goto_convertt::cpp_new_initializer - - Inputs: - - Outputs: - - Purpose: builds a goto program for object initialization - after new - -\*******************************************************************/ - +/// builds a goto program for object initialization after new void goto_convertt::cpp_new_initializer( const exprt &lhs, const side_effect_exprt &rhs, @@ -977,18 +836,6 @@ void goto_convertt::cpp_new_initializer( } } -/*******************************************************************\ - -Function: goto_convertt::get_array_argument - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt goto_convertt::get_array_argument(const exprt &src) { if(src.id()==ID_typecast) @@ -1025,51 +872,8 @@ exprt goto_convertt::get_array_argument(const exprt &src) return src.op0().op0(); } -/*******************************************************************\ - -Function: goto_convertt::do_array_set - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -void goto_convertt::do_array_set( - const exprt &lhs, - const exprt &function, - const exprt::operandst &arguments, - goto_programt &dest) -{ - if(arguments.size()!=2) - { - error().source_location=function.find_source_location(); - error() << "array_set expects two arguments" << eom; - throw 0; - } - - codet array_set_statement; - array_set_statement.set_statement(ID_array_set); - array_set_statement.operands()=arguments; - - copy(array_set_statement, OTHER, dest); -} - -/*******************************************************************\ - -Function: goto_convertt::do_array_copy - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -void goto_convertt::do_array_copy( +void goto_convertt::do_array_op( + const irep_idt &id, const exprt &lhs, const exprt &function, const exprt::operandst &arguments, @@ -1078,29 +882,18 @@ void goto_convertt::do_array_copy( if(arguments.size()!=2) { error().source_location=function.find_source_location(); - error() << "array_copy expects two arguments" << eom; + error() << id << " expects two arguments" << eom; throw 0; } - codet array_copy_statement; - array_copy_statement.set_statement(ID_array_copy); - array_copy_statement.operands()=arguments; + codet array_op_statement; + array_op_statement.set_statement(id); + array_op_statement.operands()=arguments; + array_op_statement.add_source_location()=function.source_location(); - copy(array_copy_statement, OTHER, dest); + copy(array_op_statement, OTHER, dest); } -/*******************************************************************\ - -Function: goto_convertt::do_array_equal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::do_array_equal( const exprt &lhs, const exprt &function, @@ -1139,23 +932,12 @@ void goto_convertt::do_array_equal( assignment.lhs()=lhs; assignment.rhs()=binary_exprt( lhs_array, ID_array_equal, rhs_array, lhs.type()); + assignment.add_source_location()=function.source_location(); convert(assignment, dest); } } -/*******************************************************************\ - -Function: is_lvalue - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool is_lvalue(const exprt &expr) { if(expr.id()==ID_index) @@ -1170,18 +952,6 @@ bool is_lvalue(const exprt &expr) return false; } -/*******************************************************************\ - -Function: make_va_list - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt make_va_list(const exprt &expr) { // we first strip any typecast @@ -1197,19 +967,7 @@ exprt make_va_list(const exprt &expr) return expr; } -/*******************************************************************\ - -Function: goto_convertt::do_function_call_symbol - - Inputs: - - Outputs: - - Purpose: add function calls to function queue for later - processing - -\*******************************************************************/ - +/// add function calls to function queue for later processing void goto_convertt::do_function_call_symbol( const exprt &lhs, const symbol_exprt &function, @@ -1470,19 +1228,21 @@ void goto_convertt::do_function_call_symbol( assignment.add_source_location()=function.source_location(); copy(assignment, ASSIGN, dest); } - else if(has_prefix(id2string(identifier), CPROVER_PREFIX "array_set")) + else if(identifier==CPROVER_PREFIX "array_equal") { - do_array_set(lhs, function, arguments, dest); + do_array_equal(lhs, function, arguments, dest); } - else if(identifier==CPROVER_PREFIX "array_equal" || - identifier=="__CPROVER::array_equal") + else if(identifier==CPROVER_PREFIX "array_set") { - do_array_equal(lhs, function, arguments, dest); + do_array_op(ID_array_set, lhs, function, arguments, dest); } - else if(identifier==CPROVER_PREFIX "array_copy" || - identifier=="__CPROVER::array_equal") + else if(identifier==CPROVER_PREFIX "array_copy") { - do_array_copy(lhs, function, arguments, dest); + do_array_op(ID_array_copy, lhs, function, arguments, dest); + } + else if(identifier==CPROVER_PREFIX "array_replace") + { + do_array_op(ID_array_replace, lhs, function, arguments, dest); } else if(identifier=="printf") /* @@ -1588,8 +1348,18 @@ void goto_convertt::do_function_call_symbol( throw 0; } - const irep_idt description= - "assertion "+id2string(get_string_constant(arguments[3])); + irep_idt description; + try + { + description="assertion "+id2string(get_string_constant(arguments[3])); + } + catch(int) + { + // we might be building newlib, where __assert_func is passed + // a pointer-typed symbol; the warning will still have been + // printed + description="assertion"; + } goto_programt::targett t=dest.add_instruction(ASSERT); t->guard=false_exprt(); diff --git a/src/goto-programs/cfg.h b/src/goto-programs/cfg.h index 2fc7522a67d..364e13b7b74 100644 --- a/src/goto-programs/cfg.h +++ b/src/goto-programs/cfg.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Control Flow Graph + #ifndef CPROVER_GOTO_PROGRAMS_CFG_H #define CPROVER_GOTO_PROGRAMS_CFG_H @@ -14,14 +17,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_functions.h" -/*******************************************************************\ - - Class: cfg_baset - - Purpose: - -\*******************************************************************/ - class empty_cfg_nodet { }; @@ -136,14 +131,6 @@ class cfg_baset:public grapht< cfg_base_nodet > bool nodes_empty(P &program) const { return program.instructions.empty(); } }; -/*******************************************************************\ - - Class: concurrent_cfg_baset - - Purpose: - -\*******************************************************************/ - template @@ -157,14 +144,6 @@ class concurrent_cfg_baset:public virtual cfg_baset typename cfg_baset::entryt &entry); }; -/*******************************************************************\ - - Class: procedure_local_cfg_baset - - Purpose: - -\*******************************************************************/ - template @@ -179,14 +158,6 @@ class procedure_local_cfg_baset:public virtual cfg_baset typename cfg_baset::entryt &entry); }; -/*******************************************************************\ - - Class: procedure_local_concurrent_cfg_baset - - Purpose: - -\*******************************************************************/ - template @@ -196,18 +167,6 @@ class procedure_local_concurrent_cfg_baset: { }; -/*******************************************************************\ - -Function: cfg_baset::compute_edges_goto - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void cfg_baset::compute_edges_goto( const goto_programt &goto_program, @@ -224,18 +183,6 @@ void cfg_baset::compute_edges_goto( this->add_edge(entry, entry_map[t]); } -/*******************************************************************\ - -Function: cfg_baset::compute_edges_catch - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void cfg_baset::compute_edges_catch( const goto_programt &goto_program, @@ -254,18 +201,6 @@ void cfg_baset::compute_edges_catch( this->add_edge(entry, entry_map[t]); } -/*******************************************************************\ - -Function: cfg_baset::compute_edges_throw - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void cfg_baset::compute_edges_throw( const goto_programt &goto_program, @@ -276,18 +211,6 @@ void cfg_baset::compute_edges_throw( // no (trivial) successors } -/*******************************************************************\ - -Function: cfg_baset::compute_edges_start_thread - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void cfg_baset::compute_edges_start_thread( const goto_programt &goto_program, @@ -299,18 +222,6 @@ void cfg_baset::compute_edges_start_thread( this->add_edge(entry, entry_map[next_PC]); } -/*******************************************************************\ - -Function: concurrent_cfg_baset::compute_edges_start_thread - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void concurrent_cfg_baset::compute_edges_start_thread( const goto_programt &goto_program, @@ -329,18 +240,6 @@ void concurrent_cfg_baset::compute_edges_start_thread( this->add_edge(entry, this->entry_map[t]); } -/*******************************************************************\ - -Function: cfg_baset::compute_edges_function_call - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void cfg_baset::compute_edges_function_call( const goto_functionst &goto_functions, @@ -392,18 +291,6 @@ void cfg_baset::compute_edges_function_call( this->add_edge(entry, entry_map[next_PC]); } -/*******************************************************************\ - -Function: procedure_local_cfg_baset::compute_edges_function_call - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void procedure_local_cfg_baset::compute_edges_function_call( const goto_functionst &goto_functions, @@ -422,18 +309,6 @@ void procedure_local_cfg_baset::compute_edges_function_call( this->add_edge(entry, this->entry_map[next_PC]); } -/*******************************************************************\ - -Function: cfg_baset::compute_edges - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void cfg_baset::compute_edges( const goto_functionst &goto_functions, @@ -508,18 +383,6 @@ void cfg_baset::compute_edges( } } -/*******************************************************************\ - -Function: cfg_baset::compute_edges - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void cfg_baset::compute_edges( const goto_functionst &goto_functions, @@ -531,18 +394,6 @@ void cfg_baset::compute_edges( compute_edges(goto_functions, goto_program, it); } -/*******************************************************************\ - -Function: cfg_baset::compute_edges - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void cfg_baset::compute_edges( const goto_functionst &goto_functions) diff --git a/src/goto-programs/class_hierarchy.cpp b/src/goto-programs/class_hierarchy.cpp index 1311a3e7fdc..10a16760b98 100644 --- a/src/goto-programs/class_hierarchy.cpp +++ b/src/goto-programs/class_hierarchy.cpp @@ -8,6 +8,9 @@ Date: April 2016 \*******************************************************************/ +/// \file +/// Class Hierarchy + #include #include @@ -15,18 +18,6 @@ Date: April 2016 #include "class_hierarchy.h" -/*******************************************************************\ - -Function: class_hierarchyt::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void class_hierarchyt::operator()(const symbol_tablet &symbol_table) { forall_symbols(it, symbol_table.symbols) @@ -52,18 +43,6 @@ void class_hierarchyt::operator()(const symbol_tablet &symbol_table) } } -/*******************************************************************\ - -Function: class_hierarchyt::get_children_trans_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void class_hierarchyt::get_children_trans_rec( const irep_idt &c, idst &dest) const @@ -81,18 +60,6 @@ void class_hierarchyt::get_children_trans_rec( get_children_trans_rec(child, dest); } -/*******************************************************************\ - -Function: class_hierarchyt::get_parents_trans_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void class_hierarchyt::get_parents_trans_rec( const irep_idt &c, idst &dest) const @@ -110,18 +77,6 @@ void class_hierarchyt::get_parents_trans_rec( get_parents_trans_rec(child, dest); } -/*******************************************************************\ - -Function: class_hierarchyt::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void class_hierarchyt::output(std::ostream &out) const { for(const auto &c : class_map) diff --git a/src/goto-programs/class_hierarchy.h b/src/goto-programs/class_hierarchy.h index bef2c7ec7eb..5cd33b4d864 100644 --- a/src/goto-programs/class_hierarchy.h +++ b/src/goto-programs/class_hierarchy.h @@ -8,6 +8,9 @@ Date: April 2016 \*******************************************************************/ +/// \file +/// Class Hierarchy + #ifndef CPROVER_GOTO_PROGRAMS_CLASS_HIERARCHY_H #define CPROVER_GOTO_PROGRAMS_CLASS_HIERARCHY_H diff --git a/src/goto-programs/class_identifier.cpp b/src/goto-programs/class_identifier.cpp index 6e814174e51..bbdc94c8533 100644 --- a/src/goto-programs/class_identifier.cpp +++ b/src/goto-programs/class_identifier.cpp @@ -6,24 +6,17 @@ Author: Chris Smowton, chris.smowton@diffblue.com \*******************************************************************/ +/// \file +/// Extract class identifier + #include "class_identifier.h" #include #include -/*******************************************************************\ - -Function: build_class_identifier - - Inputs: Struct expression - - Outputs: Member expression giving the clsid field of the input, - or its parent, grandparent, etc. - - Purpose: - -\*******************************************************************/ - +/// \par parameters: Struct expression +/// \return Member expression giving the clsid field of the input, or its +/// parent, grandparent, etc. static exprt build_class_identifier( const exprt &src, const namespacet &ns) @@ -56,19 +49,9 @@ static exprt build_class_identifier( } } -/*******************************************************************\ - -Function: get_class_identifier_field - - Inputs: Pointer expression of any pointer type, including void*, - and a recommended access type if the pointer is void-typed. - - Outputs: Member expression to access a class identifier, as above. - - Purpose: - -\*******************************************************************/ - +/// \par parameters: Pointer expression of any pointer type, including void*, +/// and a recommended access type if the pointer is void-typed. +/// \return Member expression to access a class identifier, as above. exprt get_class_identifier_field( const exprt &this_expr_in, const symbol_typet &suggested_type, diff --git a/src/goto-programs/class_identifier.h b/src/goto-programs/class_identifier.h index 8ae6dc4ce71..ccc679b8e1f 100644 --- a/src/goto-programs/class_identifier.h +++ b/src/goto-programs/class_identifier.h @@ -6,6 +6,9 @@ Author: Chris Smowton, chris.smowton@diffblue.com \*******************************************************************/ +/// \file +/// Extract class identifier + #ifndef CPROVER_GOTO_PROGRAMS_CLASS_IDENTIFIER_H #define CPROVER_GOTO_PROGRAMS_CLASS_IDENTIFIER_H diff --git a/src/goto-programs/compute_called_functions.cpp b/src/goto-programs/compute_called_functions.cpp index 0c1acc08d22..251a89c5054 100644 --- a/src/goto-programs/compute_called_functions.cpp +++ b/src/goto-programs/compute_called_functions.cpp @@ -6,22 +6,14 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Query Called Functions + #include #include "compute_called_functions.h" -/*******************************************************************\ - -Function: compute_address_taken_functions - - Inputs: - - Outputs: - - Purpose: get all functions whose address is taken - -\*******************************************************************/ - +/// get all functions whose address is taken void compute_address_taken_functions( const exprt &src, std::set &address_taken) @@ -40,18 +32,7 @@ void compute_address_taken_functions( } } -/*******************************************************************\ - -Function: compute_functions - - Inputs: - - Outputs: - - Purpose: get all functions in the expression - -\*******************************************************************/ - +/// get all functions in the expression void compute_functions( const exprt &src, std::set &address_taken) @@ -64,18 +45,7 @@ void compute_functions( address_taken.insert(to_symbol_expr(src).get_identifier()); } -/*******************************************************************\ - -Function: compute_address_taken_functions - - Inputs: - - Outputs: - - Purpose: get all functions whose address is taken - -\*******************************************************************/ - +/// get all functions whose address is taken void compute_address_taken_functions( const goto_programt &goto_program, std::set &address_taken) @@ -87,18 +57,7 @@ void compute_address_taken_functions( } } -/*******************************************************************\ - -Function: compute_address_taken_functions - - Inputs: - - Outputs: - - Purpose: get all functions whose address is taken - -\*******************************************************************/ - +/// get all functions whose address is taken void compute_address_taken_functions( const goto_functionst &goto_functions, std::set &address_taken) @@ -107,18 +66,7 @@ void compute_address_taken_functions( compute_address_taken_functions(it->second.body, address_taken); } -/*******************************************************************\ - -Function: compute_called_functions - - Inputs: - - Outputs: - - Purpose: computes the functions that are (potentially) called - -\*******************************************************************/ - +/// computes the functions that are (potentially) called void compute_called_functions( const goto_functionst &goto_functions, std::set &functions) @@ -163,18 +111,7 @@ void compute_called_functions( } } -/*******************************************************************\ - -Function: compute_called_functions - - Inputs: - - Outputs: - - Purpose: computes the functions that are (potentially) called - -\*******************************************************************/ - +/// computes the functions that are (potentially) called void compute_called_functions( const goto_modelt &goto_model, std::set &functions) diff --git a/src/goto-programs/compute_called_functions.h b/src/goto-programs/compute_called_functions.h index 40dba2b894e..6f92b420b37 100644 --- a/src/goto-programs/compute_called_functions.h +++ b/src/goto-programs/compute_called_functions.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Query Called Functions + #ifndef CPROVER_GOTO_PROGRAMS_COMPUTE_CALLED_FUNCTIONS_H #define CPROVER_GOTO_PROGRAMS_COMPUTE_CALLED_FUNCTIONS_H diff --git a/src/goto-programs/convert_nondet.cpp b/src/goto-programs/convert_nondet.cpp index 7762b13a9f3..9e1a6d388c5 100644 --- a/src/goto-programs/convert_nondet.cpp +++ b/src/goto-programs/convert_nondet.cpp @@ -6,6 +6,9 @@ Author: Reuben Thomas, reuben.thomas@diffblue.com \*******************************************************************/ +/// \file +/// Convert side_effect_expr_nondett expressions + #include "goto-programs/convert_nondet.h" #include "goto-programs/goto_convert.h" #include "goto-programs/goto_model.h" @@ -15,26 +18,15 @@ Author: Reuben Thomas, reuben.thomas@diffblue.com #include "util/irep_ids.h" -/*******************************************************************\ - -Function: insert_nondet_init_code - - Inputs: - goto_program: The goto program to modify. - target: One of the steps in that goto program. - symbol_table: The global symbol table. - message_handler: Handles logging. - max_nondet_array_length: Maximum size of new nondet arrays. - - Outputs: The next instruction to process with this function. - - Purpose: Checks an instruction to see whether it contains an assignment - from side_effect_expr_nondet. If so, replaces the instruction - with a range of instructions to properly nondet-initialize - the lhs. - -\*******************************************************************/ - +/// Checks an instruction to see whether it contains an assignment from +/// side_effect_expr_nondet. If so, replaces the instruction with a range of +/// instructions to properly nondet-initialize the lhs. +/// \param goto_program: The goto program to modify. +/// \param target: One of the steps in that goto program. +/// \param symbol_table: The global symbol table. +/// \param message_handler: Handles logging. +/// \param max_nondet_array_length: Maximum size of new nondet arrays. +/// \return The next instruction to process with this function. static goto_programt::targett insert_nondet_init_code( goto_programt &goto_program, const goto_programt::targett &target, @@ -108,22 +100,13 @@ static goto_programt::targett insert_nondet_init_code( return next_instr; } -/*******************************************************************\ - -Function: convert_nondet - - Inputs: - goto_program: The goto program to modify. - symbol_table: The global symbol table. - message_handler: Handles logging. - max_nondet_array_length: Maximum size of new nondet arrays. - - Purpose: For each instruction in the goto program, checks if it is - an assignment from nondet and replaces it with the appropriate - composite initialization code if so. - -\*******************************************************************/ - +/// For each instruction in the goto program, checks if it is an assignment from +/// nondet and replaces it with the appropriate composite initialization code if +/// so. +/// \param goto_program: The goto program to modify. +/// \param symbol_table: The global symbol table. +/// \param message_handler: Handles logging. +/// \param max_nondet_array_length: Maximum size of new nondet arrays. static void convert_nondet( goto_programt &goto_program, symbol_tablet &symbol_table, diff --git a/src/goto-programs/convert_nondet.h b/src/goto-programs/convert_nondet.h index 919d977a94e..2d083c58bf7 100644 --- a/src/goto-programs/convert_nondet.h +++ b/src/goto-programs/convert_nondet.h @@ -6,6 +6,9 @@ Author: Reuben Thomas, reuben.thomas@diffblue.com \*******************************************************************/ +/// \file +/// Convert side_effect_expr_nondett expressions + #ifndef CPROVER_GOTO_PROGRAMS_CONVERT_NONDET_H #define CPROVER_GOTO_PROGRAMS_CONVERT_NONDET_H @@ -15,21 +18,12 @@ class goto_functionst; class symbol_tablet; class message_handlert; -/*******************************************************************\ - -Function: convert_nondet - - Inputs: - goto_functions: The set of goto programs to modify. - symbol_table: The symbol table to query/update. - message_handler: For error logging. - max_nondet_array_length: The maximum length of any new arrays. - - Purpose: Replace calls to nondet library functions with an internal - nondet representation. - -\*******************************************************************/ - +/// Replace calls to nondet library functions with an internal nondet +/// representation. +/// \param goto_functions: The set of goto programs to modify. +/// \param symbol_table: The symbol table to query/update. +/// \param message_handler: For error logging. +/// \param max_nondet_array_length: The maximum length of any new arrays. void convert_nondet( goto_functionst &goto_functions, symbol_tablet &symbol_table, diff --git a/src/goto-programs/destructor.cpp b/src/goto-programs/destructor.cpp index ba1fe127a5f..956734ddee2 100644 --- a/src/goto-programs/destructor.cpp +++ b/src/goto-programs/destructor.cpp @@ -6,23 +6,14 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Destructor Calls + #include #include #include "destructor.h" -/*******************************************************************\ - -Function: get_destructor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - code_function_callt get_destructor( const namespacet &ns, const typet &type) diff --git a/src/goto-programs/destructor.h b/src/goto-programs/destructor.h index 2ea310361f3..3fd62efb0c4 100644 --- a/src/goto-programs/destructor.h +++ b/src/goto-programs/destructor.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Destructor Calls + #ifndef CPROVER_GOTO_PROGRAMS_DESTRUCTOR_H #define CPROVER_GOTO_PROGRAMS_DESTRUCTOR_H diff --git a/src/goto-programs/elf_reader.cpp b/src/goto-programs/elf_reader.cpp index 9a2212bfbfc..1668a88c8b5 100644 --- a/src/goto-programs/elf_reader.cpp +++ b/src/goto-programs/elf_reader.cpp @@ -6,22 +6,13 @@ Module: Read ELF \*******************************************************************/ +/// \file +/// Read ELF + #include #include "elf_reader.h" -/*******************************************************************\ - -Function: elf_readert::elf_readert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - elf_readert::elf_readert(std::istream &_in):in(_in) { // read 32-bit header @@ -130,18 +121,6 @@ elf_readert::elf_readert(std::istream &_in):in(_in) } } -/*******************************************************************\ - -Function: elf_readert::get_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string elf_readert::get_string(std::streampos index) const { in.seekg(string_table_offset+index); @@ -160,18 +139,6 @@ std::string elf_readert::get_string(std::streampos index) const return result; } -/*******************************************************************\ - -Function: elf_readert::has_section - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool elf_readert::has_section(const std::string &name) const { for(unsigned i=0; i #include -#include +#include #include #include "format_strings.h" -/*******************************************************************\ - -Function: parse_flags - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void parse_flags( std::string::const_iterator &it, format_tokent &curtok) @@ -52,18 +43,6 @@ void parse_flags( } } -/*******************************************************************\ - -Function: parse_field_width - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void parse_field_width( std::string::const_iterator &it, format_tokent &curtok) @@ -79,18 +58,6 @@ void parse_field_width( curtok.field_width=string2integer(tmp); } -/*******************************************************************\ - -Function: parse_precision - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void parse_precision( std::string::const_iterator &it, format_tokent &curtok) @@ -113,18 +80,6 @@ void parse_precision( } } -/*******************************************************************\ - -Function: parse_length_modifier - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void parse_length_modifier( std::string::const_iterator &it, format_tokent &curtok) @@ -160,18 +115,6 @@ void parse_length_modifier( } } -/*******************************************************************\ - -Function: parse_conversion_specifier - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void parse_conversion_specifier( const std::string &arg_string, std::string::const_iterator &it, @@ -237,18 +180,6 @@ void parse_conversion_specifier( it++; } -/*******************************************************************\ - -Function: parse_format_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - format_token_listt parse_format_string(const std::string &arg_string) { format_token_listt token_list; @@ -287,18 +218,6 @@ format_token_listt parse_format_string(const std::string &arg_string) return token_list; } -/*******************************************************************\ - -Function: get_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet get_type(const format_tokent &token) { switch(token.type) diff --git a/src/goto-programs/format_strings.h b/src/goto-programs/format_strings.h index 6283b77f19b..8c233324ecf 100644 --- a/src/goto-programs/format_strings.h +++ b/src/goto-programs/format_strings.h @@ -6,6 +6,9 @@ Author: CM Wintersteiger \*******************************************************************/ +/// \file +/// Format String Parser + #ifndef CPROVER_GOTO_PROGRAMS_FORMAT_STRINGS_H #define CPROVER_GOTO_PROGRAMS_FORMAT_STRINGS_H diff --git a/src/goto-programs/goto_asm.cpp b/src/goto-programs/goto_asm.cpp index 782d601a29e..63492b5d9ce 100644 --- a/src/goto-programs/goto_asm.cpp +++ b/src/goto-programs/goto_asm.cpp @@ -6,19 +6,10 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "goto_convert_class.h" - -/*******************************************************************\ - -Function: goto_convertt::convert_asm - - Inputs: +/// \file +/// Assembler -> Goto - Outputs: - - Purpose: - -\*******************************************************************/ +#include "goto_convert_class.h" void goto_convertt::convert_asm( const code_asmt &code, diff --git a/src/goto-programs/goto_clean_expr.cpp b/src/goto-programs/goto_clean_expr.cpp index c7fa8637194..6df78c5af9b 100644 --- a/src/goto-programs/goto_clean_expr.cpp +++ b/src/goto-programs/goto_clean_expr.cpp @@ -6,28 +6,19 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Program Transformation + #include #include #include #include #include -#include +#include #include "goto_convert_class.h" -/*******************************************************************\ - -Function: goto_convertt::make_compound_literal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - symbol_exprt goto_convertt::make_compound_literal( const exprt &expr, goto_programt &dest) @@ -69,18 +60,6 @@ symbol_exprt goto_convertt::make_compound_literal( return result; } -/*******************************************************************\ - -Function: goto_convertt::needs_cleaning - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool goto_convertt::needs_cleaning(const exprt &expr) { if(expr.id()==ID_dereference || @@ -125,18 +104,7 @@ bool goto_convertt::needs_cleaning(const exprt &expr) return false; } -/*******************************************************************\ - -Function: goto_convertt::rewrite_boolean - - Inputs: - - Outputs: - - Purpose: re-write boolean operators into ?: - -\*******************************************************************/ - +/// re-write boolean operators into ?: void goto_convertt::rewrite_boolean(exprt &expr) { assert(expr.id()==ID_and || expr.id()==ID_or); @@ -192,18 +160,6 @@ void goto_convertt::rewrite_boolean(exprt &expr) expr.swap(tmp); } -/*******************************************************************\ - -Function: goto_convertt::clean_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::clean_expr( exprt &expr, goto_programt &dest, @@ -481,18 +437,6 @@ void goto_convertt::clean_expr( } } -/*******************************************************************\ - -Function: goto_convertt::clean_expr_address_of - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::clean_expr_address_of( exprt &expr, goto_programt &dest) @@ -556,18 +500,6 @@ void goto_convertt::clean_expr_address_of( clean_expr_address_of(*it, dest); } -/*******************************************************************\ - -Function: goto_convertt::remove_gcc_conditional_expression - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::remove_gcc_conditional_expression( exprt &expr, goto_programt &dest) diff --git a/src/goto-programs/goto_convert.cpp b/src/goto-programs/goto_convert.cpp index 25118d0b223..6b3f5d68d66 100644 --- a/src/goto-programs/goto_convert.cpp +++ b/src/goto-programs/goto_convert.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Program Transformation + #include #include @@ -17,24 +20,12 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -#include +#include #include "goto_convert.h" #include "goto_convert_class.h" #include "destructor.h" -/*******************************************************************\ - -Function: is_empty - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static bool is_empty(const goto_programt &goto_program) { forall_goto_program_instructions(it, goto_program) @@ -46,19 +37,8 @@ static bool is_empty(const goto_programt &goto_program) return true; } -/*******************************************************************\ - -Function: finish_catch_push_targets - - Inputs: - - Outputs: - - Purpose: Populate the CATCH instructions with the targets - corresponding to their associated labels - -\*******************************************************************/ - +/// Populate the CATCH instructions with the targets corresponding to their +/// associated labels static void finish_catch_push_targets(goto_programt &dest) { std::map label_targets; @@ -215,17 +195,19 @@ void goto_convertt::finish_gotos(goto_programt &dest) if(!stack_is_prefix) { - warning() << "Encountered goto (" << goto_label << - ") that enters one or more lexical blocks;" << - "omitting constructors and destructors." << eom; + debug().source_location=i.code.find_source_location(); + debug() << "encountered goto `" << goto_label + << "' that enters one or more lexical blocks; " + << "omitting constructors and destructors" << eom; } else { auto unwind_to_size=label_stack.size(); if(unwind_to_sizesource_location=code.source_location(); } -/*******************************************************************\ - -Function: goto_convert::convert_label - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_label( const code_labelt &code, goto_programt &dest) @@ -454,18 +364,6 @@ void goto_convertt::convert_label( target->labels.push_front(label); } -/*******************************************************************\ - -Function: goto_convert::convert_gcc_local_label - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_gcc_local_label( const codet &code, goto_programt &dest) @@ -473,18 +371,6 @@ void goto_convertt::convert_gcc_local_label( // ignore for now } -/*******************************************************************\ - -Function: goto_convert::convert_switch_case - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_switch_case( const code_switch_caset &code, goto_programt &dest) @@ -524,18 +410,6 @@ void goto_convertt::convert_switch_case( } } -/*******************************************************************\ - -Function: goto_convert::convert_gcc_switch_case_range - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_gcc_switch_case_range( const codet &code, goto_programt &dest) @@ -569,18 +443,7 @@ void goto_convertt::convert_gcc_switch_case_range( #endif } -/*******************************************************************\ - -Function: goto_convertt::convert - - Inputs: - - Outputs: - - Purpose: converts 'code' and appends the result to 'dest' - -\*******************************************************************/ - +/// converts 'code' and appends the result to 'dest' void goto_convertt::convert( const codet &code, goto_programt &dest) @@ -714,18 +577,6 @@ void goto_convertt::convert( } } -/*******************************************************************\ - -Function: goto_convertt::convert_block - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_block( const code_blockt &code, goto_programt &dest) @@ -757,18 +608,6 @@ void goto_convertt::convert_block( targets.destructor_stack.resize(old_stack_size); } -/*******************************************************************\ - -Function: goto_convertt::convert_expression - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_expression( const code_expressiont &code, goto_programt &dest) @@ -812,18 +651,6 @@ void goto_convertt::convert_expression( } } -/*******************************************************************\ - -Function: goto_convertt::convert_decl - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_decl( const code_declt &code, goto_programt &dest) @@ -893,18 +720,6 @@ void goto_convertt::convert_decl( } } -/*******************************************************************\ - -Function: goto_convertt::convert_decl_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_decl_type( const codet &code, goto_programt &dest) @@ -912,18 +727,6 @@ void goto_convertt::convert_decl_type( // we remove these } -/*******************************************************************\ - -Function: goto_convertt::convert_assign - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_assign( const code_assignt &code, goto_programt &dest) @@ -1011,18 +814,6 @@ void goto_convertt::convert_assign( } } -/*******************************************************************\ - -Function: goto_convertt::convert_init - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_init( const codet &code, goto_programt &dest) @@ -1041,18 +832,6 @@ void goto_convertt::convert_init( convert(to_code_assign(assignment), dest); } -/*******************************************************************\ - -Function: goto_convertt::convert_cpp_delete - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_cpp_delete( const codet &code, goto_programt &dest) @@ -1118,18 +897,6 @@ void goto_convertt::convert_cpp_delete( convert(delete_call, dest); } -/*******************************************************************\ - -Function: goto_convertt::convert_assert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_assert( const code_assertt &code, goto_programt &dest) @@ -1145,18 +912,6 @@ void goto_convertt::convert_assert( t->source_location.set("user-provided", true); } -/*******************************************************************\ - -Function: goto_convertt::convert_skip - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_skip( const codet &code, goto_programt &dest) @@ -1166,18 +921,6 @@ void goto_convertt::convert_skip( t->code=code; } -/*******************************************************************\ - -Function: goto_convertt::convert_assume - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_assume( const code_assumet &code, goto_programt &dest) @@ -1191,18 +934,6 @@ void goto_convertt::convert_assume( t->source_location=code.source_location(); } -/*******************************************************************\ - -Function: goto_convertt::convert_loop_invariant - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_loop_invariant( const codet &code, goto_programt::targett loop) @@ -1226,18 +957,6 @@ void goto_convertt::convert_loop_invariant( loop->guard.add(ID_C_spec_loop_invariant).swap(invariant); } -/*******************************************************************\ - -Function: goto_convertt::convert_for - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_for( const code_fort &code, goto_programt &dest) @@ -1337,18 +1056,6 @@ void goto_convertt::convert_for( old_targets.restore(targets); } -/*******************************************************************\ - -Function: goto_convertt::convert_while - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_while( const code_whilet &code, goto_programt &dest) @@ -1409,18 +1116,6 @@ void goto_convertt::convert_while( old_targets.restore(targets); } -/*******************************************************************\ - -Function: goto_convertt::convert_dowhile - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_dowhile( const codet &code, goto_programt &dest) @@ -1493,18 +1188,6 @@ void goto_convertt::convert_dowhile( old_targets.restore(targets); } -/*******************************************************************\ - -Function: goto_convertt::case_guard - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt goto_convertt::case_guard( const exprt &value, const exprt::operandst &case_op) @@ -1532,18 +1215,6 @@ exprt goto_convertt::case_guard( return dest; } -/*******************************************************************\ - -Function: goto_convertt::convert_switch - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_switch( const code_switcht &code, goto_programt &dest) @@ -1627,18 +1298,6 @@ void goto_convertt::convert_switch( old_targets.restore(targets); } -/*******************************************************************\ - -Function: goto_convertt::convert_break - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_break( const code_breakt &code, goto_programt &dest) @@ -1660,18 +1319,6 @@ void goto_convertt::convert_break( t->source_location=code.source_location(); } -/*******************************************************************\ - -Function: goto_convertt::convert_return - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_return( const code_returnt &code, goto_programt &dest) @@ -1742,18 +1389,6 @@ void goto_convertt::convert_return( t->source_location=new_code.source_location(); } -/*******************************************************************\ - -Function: goto_convertt::convert_continue - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_continue( const code_continuet &code, goto_programt &dest) @@ -1775,18 +1410,6 @@ void goto_convertt::convert_continue( t->source_location=code.source_location(); } -/*******************************************************************\ - -Function: goto_convertt::convert_goto - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_goto( const codet &code, goto_programt &dest) @@ -1800,18 +1423,6 @@ void goto_convertt::convert_goto( targets.gotos.push_back(std::make_pair(t, targets.destructor_stack)); } -/*******************************************************************\ - -Function: goto_convertt::convert_gcc_computed_goto - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_gcc_computed_goto( const codet &code, goto_programt &dest) @@ -1825,18 +1436,6 @@ void goto_convertt::convert_gcc_computed_goto( targets.computed_gotos.push_back(t); } -/*******************************************************************\ - -Function: goto_convertt::convert_non_deterministic_goto - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_non_deterministic_goto( const codet &code, goto_programt &dest) @@ -1844,18 +1443,6 @@ void goto_convertt::convert_non_deterministic_goto( convert_goto(code, dest); } -/*******************************************************************\ - -Function: goto_convertt::convert_specc_notify - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_specc_notify( const codet &code, goto_programt &dest) @@ -1873,18 +1460,6 @@ void goto_convertt::convert_specc_notify( copy(code, OTHER, dest); } -/*******************************************************************\ - -Function: goto_convertt::convert_specc_event - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_specc_event( const exprt &op, std::set &events) @@ -1911,18 +1486,6 @@ void goto_convertt::convert_specc_event( } } -/*******************************************************************\ - -Function: goto_convertt::convert_specc_wait - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_specc_wait( const codet &code, goto_programt &dest) @@ -1951,18 +1514,6 @@ void goto_convertt::convert_specc_wait( copy(code, OTHER, dest); } -/*******************************************************************\ - -Function: goto_convertt::convert_specc_par - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_specc_par( const codet &code, goto_programt &dest) @@ -1970,18 +1521,6 @@ void goto_convertt::convert_specc_par( copy(code, OTHER, dest); } -/*******************************************************************\ - -Function: goto_convertt::convert_start_thread - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_start_thread( const codet &code, goto_programt &dest) @@ -2021,18 +1560,6 @@ void goto_convertt::convert_start_thread( } } -/*******************************************************************\ - -Function: goto_convertt::convert_end_thread - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_end_thread( const codet &code, goto_programt &dest) @@ -2047,18 +1574,6 @@ void goto_convertt::convert_end_thread( copy(code, END_THREAD, dest); } -/*******************************************************************\ - -Function: goto_convertt::convert_atomic_begin - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_atomic_begin( const codet &code, goto_programt &dest) @@ -2073,18 +1588,6 @@ void goto_convertt::convert_atomic_begin( copy(code, ATOMIC_BEGIN, dest); } -/*******************************************************************\ - -Function: goto_convertt::convert_atomic_end - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_atomic_end( const codet &code, goto_programt &dest) @@ -2099,18 +1602,6 @@ void goto_convertt::convert_atomic_end( copy(code, ATOMIC_END, dest); } -/*******************************************************************\ - -Function: goto_convertt::convert_bp_enforce - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_bp_enforce( const codet &code, goto_programt &dest) @@ -2170,18 +1661,6 @@ void goto_convertt::convert_bp_enforce( dest.destructive_append(tmp); } -/*******************************************************************\ - -Function: goto_convertt::convert_bp_abortif - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_bp_abortif( const codet &code, goto_programt &dest) @@ -2205,18 +1684,6 @@ void goto_convertt::convert_bp_abortif( t->source_location=code.source_location(); } -/*******************************************************************\ - -Function: goto_convertt::convert_ifthenelse - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_ifthenelse( const code_ifthenelset &code, goto_programt &dest) @@ -2268,18 +1735,6 @@ void goto_convertt::convert_ifthenelse( generate_ifthenelse(tmp_guard, tmp_then, tmp_else, source_location, dest); } -/*******************************************************************\ - -Function: goto_convertt::collect_operands - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::collect_operands( const exprt &expr, const irep_idt &id, @@ -2297,36 +1752,16 @@ void goto_convertt::collect_operands( } } -/*******************************************************************\ - -Function: is_size_one - - Inputs: Goto program 'g' - - Outputs: True if 'g' has one instruction - - Purpose: This is (believed to be) faster than using std::list.size - -\*******************************************************************/ - +/// This is (believed to be) faster than using std::list.size +/// \par parameters: Goto program 'g' +/// \return True if 'g' has one instruction static inline bool is_size_one(const goto_programt &g) { return (!g.instructions.empty()) && ++g.instructions.begin()==g.instructions.end(); } -/*******************************************************************\ - -Function: goto_convertt::generate_ifthenelse - - Inputs: - - Outputs: - - Purpose: if(guard) true_case; else false_case; - -\*******************************************************************/ - +/// if(guard) true_case; else false_case; void goto_convertt::generate_ifthenelse( const exprt &guard, goto_programt &true_case, @@ -2467,18 +1902,7 @@ void goto_convertt::generate_ifthenelse( dest.destructive_append(tmp_z); } -/*******************************************************************\ - -Function: goto_convertt::generate_conditional_branch - - Inputs: - - Outputs: - - Purpose: if(guard) goto target; - -\*******************************************************************/ - +/// if(guard) goto target; static bool has_and_or(const exprt &expr) { forall_operands(it, expr) @@ -2529,18 +1953,7 @@ void goto_convertt::generate_conditional_branch( } } -/*******************************************************************\ - -Function: goto_convertt::generate_conditional_branch - - Inputs: - - Outputs: - - Purpose: if(guard) goto target_true; else goto target_false; - -\*******************************************************************/ - +/// if(guard) goto target_true; else goto target_false; void goto_convertt::generate_conditional_branch( const exprt &guard, goto_programt::targett target_true, @@ -2618,18 +2031,6 @@ void goto_convertt::generate_conditional_branch( t_false->source_location=source_location; } -/*******************************************************************\ - -Function: goto_convertt::get_string_constant - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool goto_convertt::get_string_constant( const exprt &expr, irep_idt &value) @@ -2671,18 +2072,6 @@ bool goto_convertt::get_string_constant( return true; } -/*******************************************************************\ - -Function: goto_convertt::get_string_constant - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - irep_idt goto_convertt::get_string_constant(const exprt &expr) { irep_idt result; @@ -2699,18 +2088,6 @@ irep_idt goto_convertt::get_string_constant(const exprt &expr) return result; } -/*******************************************************************\ - -Function: goto_convertt::get_constant - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt goto_convertt::get_constant(const exprt &expr) { if(expr.id()==ID_symbol) @@ -2737,18 +2114,6 @@ exprt goto_convertt::get_constant(const exprt &expr) return expr; } -/*******************************************************************\ - -Function: goto_convertt::new_tmp_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - symbolt &goto_convertt::new_tmp_symbol( const typet &type, const std::string &suffix, @@ -2772,18 +2137,6 @@ symbolt &goto_convertt::new_tmp_symbol( return new_symbol; } -/*******************************************************************\ - -Function: goto_convertt::make_temp_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::make_temp_symbol( exprt &expr, const std::string &suffix, @@ -2804,18 +2157,6 @@ void goto_convertt::make_temp_symbol( expr=new_symbol.symbol_expr(); } -/*******************************************************************\ - -Function: goto_convertt::new_name - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::new_name(symbolt &symbol) { // rename it @@ -2825,18 +2166,6 @@ void goto_convertt::new_name(symbolt &symbol) symbol_table.add(symbol); } -/*******************************************************************\ - -Function: goto_convertt::lookup - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const symbolt &goto_convertt::lookup(const irep_idt &identifier) { const symbolt *symbol; @@ -2848,24 +2177,15 @@ const symbolt &goto_convertt::lookup(const irep_idt &identifier) return *symbol; } -/*******************************************************************\ - -Function: goto_convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convert( const codet &code, symbol_tablet &symbol_table, goto_programt &dest, message_handlert &message_handler) { + const unsigned errors_before= + message_handler.get_message_count(messaget::M_ERROR); + goto_convertt goto_convert(symbol_table, message_handler); try @@ -2876,33 +2196,21 @@ void goto_convert( catch(int) { goto_convert.error(); - throw 0; } catch(const char *e) { goto_convert.error() << e << messaget::eom; - throw 0; } catch(const std::string &e) { goto_convert.error() << e << messaget::eom; - throw 0; } -} -/*******************************************************************\ - -Function: goto_convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ + if(message_handler.get_message_count(messaget::M_ERROR)!=errors_before) + throw 0; +} void goto_convert( symbol_tablet &symbol_table, diff --git a/src/goto-programs/goto_convert.h b/src/goto-programs/goto_convert.h index 499c24aa572..c0196486ae4 100644 --- a/src/goto-programs/goto_convert.h +++ b/src/goto-programs/goto_convert.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Program Transformation + #ifndef CPROVER_GOTO_PROGRAMS_GOTO_CONVERT_H #define CPROVER_GOTO_PROGRAMS_GOTO_CONVERT_H diff --git a/src/goto-programs/goto_convert_class.h b/src/goto-programs/goto_convert_class.h index b018810e76e..8e6fe4da973 100644 --- a/src/goto-programs/goto_convert_class.h +++ b/src/goto-programs/goto_convert_class.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Program Transformation + #ifndef CPROVER_GOTO_PROGRAMS_GOTO_CONVERT_CLASS_H #define CPROVER_GOTO_PROGRAMS_GOTO_CONVERT_CLASS_H @@ -537,7 +540,8 @@ class goto_convertt:public messaget const exprt &rhs, const exprt::operandst &arguments, goto_programt &dest); - void do_array_copy( + void do_array_op( + const irep_idt &id, const exprt &lhs, const exprt &rhs, const exprt::operandst &arguments, diff --git a/src/goto-programs/goto_convert_exceptions.cpp b/src/goto-programs/goto_convert_exceptions.cpp index 63f503e8a0b..0f17c7c011c 100644 --- a/src/goto-programs/goto_convert_exceptions.cpp +++ b/src/goto-programs/goto_convert_exceptions.cpp @@ -6,22 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Program Transformation + #include #include "goto_convert_class.h" -/*******************************************************************\ - -Function: goto_convertt::convert_msc_try_finally - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_msc_try_finally( const codet &code, goto_programt &dest) @@ -60,18 +51,6 @@ void goto_convertt::convert_msc_try_finally( dest.destructive_append(tmp); } -/*******************************************************************\ - -Function: goto_convertt::convert_msc_try_except - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_msc_try_except( const codet &code, goto_programt &dest) @@ -88,18 +67,6 @@ void goto_convertt::convert_msc_try_except( // todo: generate exception tracking } -/*******************************************************************\ - -Function: goto_convertt::convert_msc_leave - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_msc_leave( const codet &code, goto_programt &dest) @@ -126,18 +93,6 @@ void goto_convertt::convert_msc_leave( t->source_location=code.source_location(); } -/*******************************************************************\ - -Function: goto_convertt::convert_java_try_catch - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_java_try_catch( const codet &code, goto_programt &dest) @@ -193,18 +148,6 @@ void goto_convertt::convert_java_try_catch( dest.destructive_append(end); } -/*******************************************************************\ - -Function: goto_convertt::convert_try_catch - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_try_catch( const codet &code, goto_programt &dest) @@ -258,18 +201,6 @@ void goto_convertt::convert_try_catch( dest.destructive_append(end); } -/*******************************************************************\ - -Function: goto_convertt::convert_CPROVER_try_catch - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_CPROVER_try_catch( const codet &code, goto_programt &dest) @@ -307,18 +238,6 @@ void goto_convertt::convert_CPROVER_try_catch( dest.destructive_append(tmp); } -/*******************************************************************\ - -Function: goto_convertt::convert_CPROVER_throw - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_CPROVER_throw( const codet &code, goto_programt &dest) @@ -356,18 +275,6 @@ void goto_convertt::convert_CPROVER_throw( } } -/*******************************************************************\ - -Function: goto_convertt::convert_CPROVER_try_finally - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_CPROVER_try_finally( const codet &code, goto_programt &dest) @@ -392,18 +299,6 @@ void goto_convertt::convert_CPROVER_try_finally( convert(to_code(code.op1()), dest); } -/*******************************************************************\ - -Function: goto_convertt::exception_flag - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - symbol_exprt goto_convertt::exception_flag() { irep_idt id="$exception_flag"; @@ -426,18 +321,6 @@ symbol_exprt goto_convertt::exception_flag() return symbol_exprt(id, bool_typet()); } -/*******************************************************************\ - -Function: goto_convertt::unwind_destructor_stack - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::unwind_destructor_stack( const source_locationt &source_location, std::size_t final_stack_size, diff --git a/src/goto-programs/goto_convert_function_call.cpp b/src/goto-programs/goto_convert_function_call.cpp index 6fe2b42bbc1..c8688cc6c7e 100644 --- a/src/goto-programs/goto_convert_function_call.cpp +++ b/src/goto-programs/goto_convert_function_call.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Program Transformation + #include #include @@ -14,22 +17,10 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -#include +#include #include "goto_convert_class.h" -/*******************************************************************\ - -Function: goto_convertt::convert_function_call - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_function_call( const code_function_callt &function_call, goto_programt &dest) @@ -41,18 +32,6 @@ void goto_convertt::convert_function_call( dest); } -/*******************************************************************\ - -Function: goto_convertt::do_function_call - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::do_function_call( const exprt &lhs, const exprt &function, @@ -109,18 +88,6 @@ void goto_convertt::do_function_call( } } -/*******************************************************************\ - -Function: goto_convertt::do_function_call_if - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::do_function_call_if( const exprt &lhs, const if_exprt &function, @@ -185,18 +152,6 @@ void goto_convertt::do_function_call_if( dest.destructive_append(tmp_z); } -/*******************************************************************\ - -Function: goto_convertt::do_function_call_other - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::do_function_call_other( const exprt &lhs, const exprt &function, diff --git a/src/goto-programs/goto_convert_functions.cpp b/src/goto-programs/goto_convert_functions.cpp index b25d8870f09..69f35bbdbea 100644 --- a/src/goto-programs/goto_convert_functions.cpp +++ b/src/goto-programs/goto_convert_functions.cpp @@ -18,18 +18,6 @@ Date: June 2003 #include "goto_convert_functions.h" #include "goto_inline.h" -/*******************************************************************\ - -Function: goto_convert_functionst::goto_convert_functionst - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - goto_convert_functionst::goto_convert_functionst( symbol_tablet &_symbol_table, goto_functionst &_functions, @@ -39,34 +27,10 @@ goto_convert_functionst::goto_convert_functionst( { } -/*******************************************************************\ - -Function: goto_convert_functionst::~goto_convert_functionst - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - goto_convert_functionst::~goto_convert_functionst() { } -/*******************************************************************\ - -Function: goto_convert_functionst::goto_convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convert_functionst::goto_convert() { // warning! hash-table iterators are not stable @@ -105,18 +69,6 @@ void goto_convert_functionst::goto_convert() #endif } -/*******************************************************************\ - -Function: goto_convert_functionst::hide - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool goto_convert_functionst::hide(const goto_programt &goto_program) { forall_goto_program_instructions(i_it, goto_program) @@ -129,18 +81,6 @@ bool goto_convert_functionst::hide(const goto_programt &goto_program) return false; } -/*******************************************************************\ - -Function: goto_convert_functionst::add_return - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convert_functionst::add_return( goto_functionst::goto_functiont &f, const source_locationt &source_location) @@ -194,18 +134,6 @@ void goto_convert_functionst::add_return( t->source_location=source_location; } -/*******************************************************************\ - -Function: goto_convert_functionst::convert_function - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convert_functionst::convert_function(const irep_idt &identifier) { const symbolt &symbol=ns.lookup(identifier); @@ -292,18 +220,6 @@ void goto_convert_functionst::convert_function(const irep_idt &identifier) f.make_hidden(); } -/*******************************************************************\ - -Function: goto_convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convert( symbol_tablet &symbol_table, goto_modelt &goto_model, @@ -313,23 +229,14 @@ void goto_convert( goto_model.symbol_table.swap(symbol_table); } -/*******************************************************************\ - -Function: goto_convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convert( symbol_tablet &symbol_table, goto_functionst &functions, message_handlert &message_handler) { + const unsigned errors_before= + message_handler.get_message_count(messaget::M_ERROR); + goto_convert_functionst goto_convert_functions( symbol_table, functions, message_handler); @@ -341,33 +248,21 @@ void goto_convert( catch(int) { goto_convert_functions.error(); - throw 0; } catch(const char *e) { goto_convert_functions.error() << e << messaget::eom; - throw 0; } catch(const std::string &e) { goto_convert_functions.error() << e << messaget::eom; - throw 0; } -} - -/*******************************************************************\ - -Function: goto_convert - - Inputs: - - Outputs: - - Purpose: -\*******************************************************************/ + if(message_handler.get_message_count(messaget::M_ERROR)!=errors_before) + throw 0; +} void goto_convert( const irep_idt &identifier, @@ -375,6 +270,9 @@ void goto_convert( goto_functionst &functions, message_handlert &message_handler) { + const unsigned errors_before= + message_handler.get_message_count(messaget::M_ERROR); + goto_convert_functionst goto_convert_functions( symbol_table, functions, message_handler); @@ -386,18 +284,18 @@ void goto_convert( catch(int) { goto_convert_functions.error(); - throw 0; } catch(const char *e) { goto_convert_functions.error() << e << messaget::eom; - throw 0; } catch(const std::string &e) { goto_convert_functions.error() << e << messaget::eom; - throw 0; } + + if(message_handler.get_message_count(messaget::M_ERROR)!=errors_before) + throw 0; } diff --git a/src/goto-programs/goto_convert_functions.h b/src/goto-programs/goto_convert_functions.h index 9678c928609..2b7b128eab6 100644 --- a/src/goto-programs/goto_convert_functions.h +++ b/src/goto-programs/goto_convert_functions.h @@ -8,6 +8,9 @@ Date: June 2003 \*******************************************************************/ +/// \file +/// Goto Programs with Functions + #ifndef CPROVER_GOTO_PROGRAMS_GOTO_CONVERT_FUNCTIONS_H #define CPROVER_GOTO_PROGRAMS_GOTO_CONVERT_FUNCTIONS_H diff --git a/src/goto-programs/goto_convert_new_switch_case.cpp b/src/goto-programs/goto_convert_new_switch_case.cpp index 4a81a4176a2..315d9ae810f 100644 --- a/src/goto-programs/goto_convert_new_switch_case.cpp +++ b/src/goto-programs/goto_convert_new_switch_case.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Program Transformation + #include #include @@ -15,24 +18,12 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -#include +#include #include "goto_convert.h" #include "goto_convert_class.h" #include "destructor.h" -/*******************************************************************\ - -Function: is_empty - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static bool is_empty(const goto_programt &goto_program) { forall_goto_program_instructions(it, goto_program) @@ -44,18 +35,6 @@ static bool is_empty(const goto_programt &goto_program) return true; } -/*******************************************************************\ - -Function: goto_convertt::finish_gotos - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::finish_gotos() { for(const auto &target : targets.gotos) @@ -129,18 +108,6 @@ void goto_convertt::finish_gotos() targets.gotos.clear(); } -/*******************************************************************\ - -Function: goto_convertt::finish_computed_gotos - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::finish_computed_gotos(goto_programt &goto_program) { for(const auto &target : targets.computed_gotos) @@ -180,35 +147,11 @@ void goto_convertt::finish_computed_gotos(goto_programt &goto_program) targets.computed_gotos.clear(); } -/*******************************************************************\ - -Function: goto_convertt::goto_convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::goto_convert(const codet &code, goto_programt &dest) { goto_convert_rec(code, dest); } -/*******************************************************************\ - -Function: goto_convertt::goto_convert_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::goto_convert_rec( const codet &code, goto_programt &dest) @@ -219,18 +162,6 @@ void goto_convertt::goto_convert_rec( finish_computed_gotos(dest); } -/*******************************************************************\ - -Function: goto_convertt::copy - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::copy( const codet &code, goto_program_instruction_typet type, @@ -241,18 +172,6 @@ void goto_convertt::copy( t->source_location=code.source_location(); } -/*******************************************************************\ - -Function: goto_convert::convert_label - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_label( const code_labelt &code, goto_programt &dest) @@ -289,18 +208,6 @@ void goto_convertt::convert_label( target->labels.push_front(label); } -/*******************************************************************\ - -Function: goto_convert::convert_gcc_local_label - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_gcc_local_label( const codet &code, goto_programt &dest) @@ -308,18 +215,6 @@ void goto_convertt::convert_gcc_local_label( // ignore for now } -/*******************************************************************\ - -Function: goto_convert::convert_switch_case - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_switch_case( const code_switch_caset &code, goto_programt &dest) @@ -365,18 +260,6 @@ void goto_convertt::convert_switch_case( } } -/*******************************************************************\ - -Function: goto_convert::convert_gcc_switch_case_range - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_gcc_switch_case_range( const codet &code, goto_programt &dest) @@ -410,18 +293,7 @@ void goto_convertt::convert_gcc_switch_case_range( #endif } -/*******************************************************************\ - -Function: goto_convertt::convert - - Inputs: - - Outputs: - - Purpose: converts 'code' and appends the result to 'dest' - -\*******************************************************************/ - +/// converts 'code' and appends the result to 'dest' void goto_convertt::convert( const codet &code, goto_programt &dest) @@ -556,18 +428,6 @@ void goto_convertt::convert( } } -/*******************************************************************\ - -Function: goto_convertt::convert_block - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_block( const code_blockt &code, goto_programt &dest) @@ -591,18 +451,6 @@ void goto_convertt::convert_block( targets.destructor_stack.resize(old_stack_size); } -/*******************************************************************\ - -Function: goto_convertt::convert_expression - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_expression( const code_expressiont &code, goto_programt &dest) @@ -646,18 +494,6 @@ void goto_convertt::convert_expression( } } -/*******************************************************************\ - -Function: goto_convertt::convert_decl - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_decl( const code_declt &code, goto_programt &dest) @@ -727,18 +563,6 @@ void goto_convertt::convert_decl( } } -/*******************************************************************\ - -Function: goto_convertt::convert_decl_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_decl_type( const codet &code, goto_programt &dest) @@ -746,18 +570,6 @@ void goto_convertt::convert_decl_type( // we remove these } -/*******************************************************************\ - -Function: goto_convertt::convert_assign - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_assign( const code_assignt &code, goto_programt &dest) @@ -845,18 +657,6 @@ void goto_convertt::convert_assign( } } -/*******************************************************************\ - -Function: goto_convertt::convert_init - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_init( const codet &code, goto_programt &dest) @@ -875,18 +675,6 @@ void goto_convertt::convert_init( convert(to_code_assign(assignment), dest); } -/*******************************************************************\ - -Function: goto_convertt::convert_cpp_delete - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_cpp_delete( const codet &code, goto_programt &dest) @@ -952,18 +740,6 @@ void goto_convertt::convert_cpp_delete( convert(delete_call, dest); } -/*******************************************************************\ - -Function: goto_convertt::convert_assert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_assert( const code_assertt &code, goto_programt &dest) @@ -979,18 +755,6 @@ void goto_convertt::convert_assert( t->source_location.set("user-provided", true); } -/*******************************************************************\ - -Function: goto_convertt::convert_skip - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_skip( const codet &code, goto_programt &dest) @@ -1000,18 +764,6 @@ void goto_convertt::convert_skip( t->code=code; } -/*******************************************************************\ - -Function: goto_convertt::convert_assert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_assume( const code_assumet &code, goto_programt &dest) @@ -1025,18 +777,6 @@ void goto_convertt::convert_assume( t->source_location=code.source_location(); } -/*******************************************************************\ - -Function: goto_convertt::convert_for - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_for( const code_fort &code, goto_programt &dest) @@ -1133,18 +873,6 @@ void goto_convertt::convert_for( old_targets.restore(targets); } -/*******************************************************************\ - -Function: goto_convertt::convert_while - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_while( const code_whilet &code, goto_programt &dest) @@ -1202,18 +930,6 @@ void goto_convertt::convert_while( old_targets.restore(targets); } -/*******************************************************************\ - -Function: goto_convertt::convert_dowhile - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_dowhile( const codet &code, goto_programt &dest) @@ -1283,18 +999,6 @@ void goto_convertt::convert_dowhile( old_targets.restore(targets); } -/*******************************************************************\ - -Function: goto_convertt::case_guard - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt goto_convertt::case_guard( const exprt &value, const exprt::operandst &case_op) @@ -1322,18 +1026,6 @@ exprt goto_convertt::case_guard( return dest; } -/*******************************************************************\ - -Function: goto_convertt::convert_switch - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_switch( const code_switcht &code, goto_programt &dest) @@ -1432,18 +1124,6 @@ void goto_convertt::convert_switch( old_targets.restore(targets); } -/*******************************************************************\ - -Function: goto_convertt::convert_break - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_break( const code_breakt &code, goto_programt &dest) @@ -1465,18 +1145,6 @@ void goto_convertt::convert_break( t->source_location=code.source_location(); } -/*******************************************************************\ - -Function: goto_convertt::convert_return - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_return( const code_returnt &code, goto_programt &dest) @@ -1547,18 +1215,6 @@ void goto_convertt::convert_return( t->source_location=new_code.source_location(); } -/*******************************************************************\ - -Function: goto_convertt::convert_continue - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_continue( const code_continuet &code, goto_programt &dest) @@ -1580,18 +1236,6 @@ void goto_convertt::convert_continue( t->source_location=code.source_location(); } -/*******************************************************************\ - -Function: goto_convertt::convert_goto - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_goto( const codet &code, goto_programt &dest) @@ -1605,18 +1249,6 @@ void goto_convertt::convert_goto( targets.gotos.push_back(t); } -/*******************************************************************\ - -Function: goto_convertt::convert_gcc_computed_goto - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_gcc_computed_goto( const codet &code, goto_programt &dest) @@ -1630,18 +1262,6 @@ void goto_convertt::convert_gcc_computed_goto( targets.computed_gotos.push_back(t); } -/*******************************************************************\ - -Function: goto_convertt::convert_non_deterministic_goto - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_non_deterministic_goto( const codet &code, goto_programt &dest) @@ -1649,18 +1269,6 @@ void goto_convertt::convert_non_deterministic_goto( convert_goto(code, dest); } -/*******************************************************************\ - -Function: goto_convertt::convert_specc_notify - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_specc_notify( const codet &code, goto_programt &dest) @@ -1678,18 +1286,6 @@ void goto_convertt::convert_specc_notify( copy(code, OTHER, dest); } -/*******************************************************************\ - -Function: goto_convertt::convert_specc_event - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_specc_event( const exprt &op, std::set &events) @@ -1716,18 +1312,6 @@ void goto_convertt::convert_specc_event( } } -/*******************************************************************\ - -Function: goto_convertt::convert_specc_wait - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_specc_wait( const codet &code, goto_programt &dest) @@ -1756,18 +1340,6 @@ void goto_convertt::convert_specc_wait( copy(code, OTHER, dest); } -/*******************************************************************\ - -Function: goto_convertt::convert_specc_par - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_specc_par( const codet &code, goto_programt &dest) @@ -1775,18 +1347,6 @@ void goto_convertt::convert_specc_par( copy(code, OTHER, dest); } -/*******************************************************************\ - -Function: goto_convertt::convert_start_thread - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_start_thread( const codet &code, goto_programt &dest) @@ -1826,18 +1386,6 @@ void goto_convertt::convert_start_thread( } } -/*******************************************************************\ - -Function: goto_convertt::convert_end_thread - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_end_thread( const codet &code, goto_programt &dest) @@ -1852,18 +1400,6 @@ void goto_convertt::convert_end_thread( copy(code, END_THREAD, dest); } -/*******************************************************************\ - -Function: goto_convertt::convert_atomic_begin - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_atomic_begin( const codet &code, goto_programt &dest) @@ -1878,18 +1414,6 @@ void goto_convertt::convert_atomic_begin( copy(code, ATOMIC_BEGIN, dest); } -/*******************************************************************\ - -Function: goto_convertt::convert_atomic_end - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_atomic_end( const codet &code, goto_programt &dest) @@ -1904,18 +1428,6 @@ void goto_convertt::convert_atomic_end( copy(code, ATOMIC_END, dest); } -/*******************************************************************\ - -Function: goto_convertt::convert_bp_enforce - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_bp_enforce( const codet &code, goto_programt &dest) @@ -1976,18 +1488,6 @@ void goto_convertt::convert_bp_enforce( dest.destructive_append(tmp); } -/*******************************************************************\ - -Function: goto_convertt::convert_bp_abortif - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_bp_abortif( const codet &code, goto_programt &dest) @@ -2011,18 +1511,6 @@ void goto_convertt::convert_bp_abortif( t->source_location=code.source_location(); } -/*******************************************************************\ - -Function: goto_convertt::convert_ifthenelse - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::convert_ifthenelse( const code_ifthenelset &code, goto_programt &dest) @@ -2074,18 +1562,6 @@ void goto_convertt::convert_ifthenelse( generate_ifthenelse(tmp_guard, tmp_then, tmp_else, source_location, dest); } -/*******************************************************************\ - -Function: goto_convertt::collect_operands - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::collect_operands( const exprt &expr, const irep_idt &id, @@ -2103,18 +1579,7 @@ void goto_convertt::collect_operands( } } -/*******************************************************************\ - -Function: goto_convertt::generate_ifthenelse - - Inputs: - - Outputs: - - Purpose: if(guard) true_case; else false_case; - -\*******************************************************************/ - +/// if(guard) true_case; else false_case; void goto_convertt::generate_ifthenelse( const exprt &guard, goto_programt &true_case, @@ -2234,18 +1699,7 @@ void goto_convertt::generate_ifthenelse( dest.destructive_append(tmp_z); } -/*******************************************************************\ - -Function: goto_convertt::generate_conditional_branch - - Inputs: - - Outputs: - - Purpose: if(guard) goto target; - -\*******************************************************************/ - +/// if(guard) goto target; static bool has_and_or(const exprt &expr) { forall_operands(it, expr) @@ -2296,18 +1750,7 @@ void goto_convertt::generate_conditional_branch( } } -/*******************************************************************\ - -Function: goto_convertt::generate_conditional_branch - - Inputs: - - Outputs: - - Purpose: if(guard) goto target_true; else goto target_false; - -\*******************************************************************/ - +/// if(guard) goto target_true; else goto target_false; void goto_convertt::generate_conditional_branch( const exprt &guard, goto_programt::targett target_true, @@ -2385,18 +1828,6 @@ void goto_convertt::generate_conditional_branch( t_false->source_location=source_location; } -/*******************************************************************\ - -Function: goto_convertt::get_string_constant - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const irep_idt goto_convertt::get_string_constant( const exprt &expr) { @@ -2442,18 +1873,6 @@ const irep_idt goto_convertt::get_string_constant( throw 0; } -/*******************************************************************\ - -Function: goto_convertt::get_constant - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt goto_convertt::get_constant(const exprt &expr) { if(expr.id()==ID_symbol) @@ -2480,18 +1899,6 @@ exprt goto_convertt::get_constant(const exprt &expr) return expr; } -/*******************************************************************\ - -Function: goto_convertt::new_tmp_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - symbolt &goto_convertt::new_tmp_symbol( const typet &type, const std::string &suffix, @@ -2519,18 +1926,6 @@ symbolt &goto_convertt::new_tmp_symbol( return *symbol_ptr; } -/*******************************************************************\ - -Function: goto_convertt::make_temp_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::make_temp_symbol( exprt &expr, const std::string &suffix, @@ -2551,18 +1946,6 @@ void goto_convertt::make_temp_symbol( expr=new_symbol.symbol_expr(); } -/*******************************************************************\ - -Function: goto_convertt::new_name - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::new_name(symbolt &symbol) { // rename it @@ -2572,18 +1955,6 @@ void goto_convertt::new_name(symbolt &symbol) symbol_table.add(symbol); } -/*******************************************************************\ - -Function: goto_convertt::lookup - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const symbolt &goto_convertt::lookup(const irep_idt &identifier) const { const symbolt *symbol; @@ -2595,18 +1966,6 @@ const symbolt &goto_convertt::lookup(const irep_idt &identifier) const return *symbol; } -/*******************************************************************\ - -Function: goto_convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convert( const codet &code, symbol_tablet &symbol_table, @@ -2641,18 +2000,6 @@ void goto_convert( throw 0; } -/*******************************************************************\ - -Function: goto_convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convert( symbol_tablet &symbol_table, goto_programt &dest, diff --git a/src/goto-programs/goto_convert_side_effect.cpp b/src/goto-programs/goto_convert_side_effect.cpp index dbebb856ec1..3119cc252d7 100644 --- a/src/goto-programs/goto_convert_side_effect.cpp +++ b/src/goto-programs/goto_convert_side_effect.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Program Transformation + #include #include #include @@ -13,22 +16,10 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -#include +#include #include "goto_convert_class.h" -/*******************************************************************\ - -Function: goto_convertt::has_function_call - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool goto_convertt::has_function_call(const exprt &expr) { forall_operands(it, expr) @@ -42,18 +33,6 @@ bool goto_convertt::has_function_call(const exprt &expr) return false; } -/*******************************************************************\ - -Function: goto_convertt::remove_assignment - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::remove_assignment( side_effect_exprt &expr, goto_programt &dest, @@ -157,18 +136,6 @@ void goto_convertt::remove_assignment( expr.make_nil(); } -/*******************************************************************\ - -Function: goto_convertt::remove_pre - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::remove_pre( side_effect_exprt &expr, goto_programt &dest, @@ -256,18 +223,6 @@ void goto_convertt::remove_pre( expr.make_nil(); } -/*******************************************************************\ - -Function: goto_convertt::remove_post - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::remove_post( side_effect_exprt &expr, goto_programt &dest, @@ -374,18 +329,6 @@ void goto_convertt::remove_post( dest.destructive_append(tmp2); } -/*******************************************************************\ - -Function: goto_convertt::remove_function_call - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::remove_function_call( side_effect_exprt &expr, goto_programt &dest, @@ -466,18 +409,6 @@ void goto_convertt::remove_function_call( static_cast(expr)=new_symbol.symbol_expr(); } -/*******************************************************************\ - -Function: goto_convertt::replace_new_object - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::replace_new_object( const exprt &object, exprt &dest) @@ -489,18 +420,6 @@ void goto_convertt::replace_new_object( replace_new_object(object, *it); } -/*******************************************************************\ - -Function: goto_convertt::remove_cpp_new - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::remove_cpp_new( side_effect_exprt &expr, goto_programt &dest, @@ -531,18 +450,6 @@ void goto_convertt::remove_cpp_new( convert(call, dest); } -/*******************************************************************\ - -Function: goto_convertt::remove_cpp_delete - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::remove_cpp_delete( side_effect_exprt &expr, goto_programt &dest, @@ -562,18 +469,6 @@ void goto_convertt::remove_cpp_delete( expr.make_nil(); } -/*******************************************************************\ - -Function: goto_convertt::remove_malloc - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::remove_malloc( side_effect_exprt &expr, goto_programt &dest, @@ -611,18 +506,6 @@ void goto_convertt::remove_malloc( convert(call, dest); } -/*******************************************************************\ - -Function: goto_convertt::remove_temporary_object - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::remove_temporary_object( side_effect_exprt &expr, goto_programt &dest, @@ -663,18 +546,6 @@ void goto_convertt::remove_temporary_object( static_cast(expr)=new_symbol.symbol_expr(); } -/*******************************************************************\ - -Function: goto_convertt::remove_statement_expression - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::remove_statement_expression( side_effect_exprt &expr, goto_programt &dest, @@ -765,18 +636,6 @@ void goto_convertt::remove_statement_expression( static_cast(expr)=tmp_symbol_expr; } -/*******************************************************************\ - -Function: goto_convertt::remove_push_catch - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::remove_push_catch( side_effect_exprt &expr, goto_programt &dest) @@ -788,18 +647,6 @@ void goto_convertt::remove_push_catch( expr.make_nil(); } -/*******************************************************************\ - -Function: goto_convertt::remove_side_effect - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_convertt::remove_side_effect( side_effect_exprt &expr, goto_programt &dest, diff --git a/src/goto-programs/goto_functions.cpp b/src/goto-programs/goto_functions.cpp index d11868339b3..9c14c8bc6bc 100644 --- a/src/goto-programs/goto_functions.cpp +++ b/src/goto-programs/goto_functions.cpp @@ -8,19 +8,10 @@ Date: June 2003 \*******************************************************************/ -#include "goto_functions.h" - -/*******************************************************************\ - -Function: get_local_identifiers - - Inputs: +/// \file +/// Goto Programs with Functions - Outputs: - - Purpose: - -\*******************************************************************/ +#include "goto_functions.h" void get_local_identifiers( const goto_function_templatet &goto_function, diff --git a/src/goto-programs/goto_functions.h b/src/goto-programs/goto_functions.h index 096fab391ec..7fc9f70628a 100644 --- a/src/goto-programs/goto_functions.h +++ b/src/goto-programs/goto_functions.h @@ -8,6 +8,9 @@ Date: June 2003 \*******************************************************************/ +/// \file +/// Goto Programs with Functions + #ifndef CPROVER_GOTO_PROGRAMS_GOTO_FUNCTIONS_H #define CPROVER_GOTO_PROGRAMS_GOTO_FUNCTIONS_H diff --git a/src/goto-programs/goto_functions_template.h b/src/goto-programs/goto_functions_template.h index 9333cce06b3..3ea7a7bad83 100644 --- a/src/goto-programs/goto_functions_template.h +++ b/src/goto-programs/goto_functions_template.h @@ -8,6 +8,9 @@ Date: June 2003 \*******************************************************************/ +/// \file +/// Goto Programs with Functions + #ifndef CPROVER_GOTO_PROGRAMS_GOTO_FUNCTIONS_TEMPLATE_H #define CPROVER_GOTO_PROGRAMS_GOTO_FUNCTIONS_TEMPLATE_H @@ -158,18 +161,6 @@ class goto_functions_templatet } }; -/*******************************************************************\ - -Function: goto_functions_templatet::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void goto_functions_templatet::output( const namespacet &ns, @@ -190,18 +181,6 @@ void goto_functions_templatet::output( } } -/*******************************************************************\ - -Function: goto_functions_templatet::compute_location_numbers - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void goto_functions_templatet::compute_location_numbers() { @@ -214,18 +193,6 @@ void goto_functions_templatet::compute_location_numbers() it->second.body.compute_location_numbers(nr); } -/*******************************************************************\ - -Function: goto_functions_templatet::compute_incoming_edges - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void goto_functions_templatet::compute_incoming_edges() { @@ -236,18 +203,6 @@ void goto_functions_templatet::compute_incoming_edges() it->second.body.compute_incoming_edges(); } -/*******************************************************************\ - -Function: goto_functions_templatet::compute_target_numbers - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void goto_functions_templatet::compute_target_numbers() { @@ -258,18 +213,6 @@ void goto_functions_templatet::compute_target_numbers() it->second.body.compute_target_numbers(); } -/*******************************************************************\ - -Function: goto_functions_templatet::compute_loop_numbers - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void goto_functions_templatet::compute_loop_numbers() { diff --git a/src/goto-programs/goto_inline.cpp b/src/goto-programs/goto_inline.cpp index 01c0f1bf392..58db12c1838 100644 --- a/src/goto-programs/goto_inline.cpp +++ b/src/goto-programs/goto_inline.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Function Inlining + #include #include @@ -18,18 +21,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_inline.h" #include "goto_inline_class.h" -/*******************************************************************\ - -Function: goto_inline - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_inline( goto_modelt &goto_model, message_handlert &message_handler, @@ -43,18 +34,6 @@ void goto_inline( adjust_function); } -/*******************************************************************\ - -Function: goto_inline - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_inline( goto_functionst &goto_functions, const namespacet &ns, @@ -118,28 +97,13 @@ void goto_inline( } } -/*******************************************************************\ - -Function: goto_partial_inline - - Inputs: - goto_model: - Source of the symbol table and function map to use. - message_handler: - Message handler used by goto_inlinet. - smallfunc_limit: - The maximum number of instructions in functions to be inlined. - adjust_function: - Tell goto_inlinet to adjust function. - - Outputs: - - Purpose: - Inline all function calls to functions either marked as "inlined" or - smaller than smallfunc_limit (by instruction count). - -\*******************************************************************/ - +/// Inline all function calls to functions either marked as "inlined" or +/// smaller than smallfunc_limit (by instruction count). +/// \param goto_model: Source of the symbol table and function map to use. +/// \param message_handler: Message handler used by goto_inlinet. +/// \param smallfunc_limit: The maximum number of instructions in functions to +/// be inlined. +/// \param adjust_function: Tell goto_inlinet to adjust function. void goto_partial_inline( goto_modelt &goto_model, message_handlert &message_handler, @@ -155,31 +119,15 @@ void goto_partial_inline( adjust_function); } -/*******************************************************************\ - -Function: goto_partial_inline - - Inputs: - goto_functions: - The function map to use to find functions containing calls and function - bodies. - ns: - Namespace used by goto_inlinet. - message_handler: - Message handler used by goto_inlinet. - smallfunc_limit: - The maximum number of instructions in functions to be inlined. - adjust_function: - Tell goto_inlinet to adjust function. - - Outputs: - - Purpose: - Inline all function calls to functions either marked as "inlined" or - smaller than smallfunc_limit (by instruction count). - -\*******************************************************************/ - +/// Inline all function calls to functions either marked as "inlined" or +/// smaller than smallfunc_limit (by instruction count). +/// \param goto_functions: The function map to use to find functions containing +/// calls and function bodies. +/// \param ns: Namespace used by goto_inlinet. +/// \param message_handler: Message handler used by goto_inlinet. +/// \param smallfunc_limit: The maximum number of instructions in functions to +/// be inlined. +/// \param adjust_function: Tell goto_inlinet to adjust function. void goto_partial_inline( goto_functionst &goto_functions, const namespacet &ns, @@ -259,24 +207,12 @@ void goto_partial_inline( goto_inline.goto_inline(inline_map, false); } -/*******************************************************************\ - -Function: goto_function_inline - - Inputs: - goto_model: Source of the symbol table and function map to use. - function: The function whose calls to inline. - message_handler: Message handler used by goto_inlinet. - adjust_function: Tell goto_inlinet to adjust function. - caching: Tell goto_inlinet to cache. - - Outputs: - - Purpose: - Inline all function calls made from a particular function - -\*******************************************************************/ - +/// Inline all function calls made from a particular function +/// \param goto_model: Source of the symbol table and function map to use. +/// \param function: The function whose calls to inline. +/// \param message_handler: Message handler used by goto_inlinet. +/// \param adjust_function: Tell goto_inlinet to adjust function. +/// \param caching: Tell goto_inlinet to cache. void goto_function_inline( goto_modelt &goto_model, const irep_idt function, @@ -294,25 +230,13 @@ void goto_function_inline( caching); } -/*******************************************************************\ - -Function: goto_function_inline - - Inputs: - goto_functions: The function map to use to find function bodies. - function: The function whose calls to inline. - ns: Namespace used by goto_inlinet. - message_handler: Message handler used by goto_inlinet. - adjust_function: Tell goto_inlinet to adjust function. - caching: Tell goto_inlinet to cache. - - Outputs: - - Purpose: - Inline all function calls made from a particular function - -\*******************************************************************/ - +/// Inline all function calls made from a particular function +/// \param goto_functions: The function map to use to find function bodies. +/// \param function: The function whose calls to inline. +/// \param ns: Namespace used by goto_inlinet. +/// \param message_handler: Message handler used by goto_inlinet. +/// \param adjust_function: Tell goto_inlinet to adjust function. +/// \param caching: Tell goto_inlinet to cache. void goto_function_inline( goto_functionst &goto_functions, const irep_idt function, @@ -357,18 +281,6 @@ void goto_function_inline( goto_inline.goto_inline(function, goto_function, inline_map, true); } -/*******************************************************************\ - -Function: goto_function_inline_and_log - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - jsont goto_function_inline_and_log( goto_functionst &goto_functions, const irep_idt function, diff --git a/src/goto-programs/goto_inline.h b/src/goto-programs/goto_inline.h index 5d3dd54fa6d..3319aa36172 100644 --- a/src/goto-programs/goto_inline.h +++ b/src/goto-programs/goto_inline.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Function Inlining + #ifndef CPROVER_GOTO_PROGRAMS_GOTO_INLINE_H #define CPROVER_GOTO_PROGRAMS_GOTO_INLINE_H diff --git a/src/goto-programs/goto_inline_class.cpp b/src/goto-programs/goto_inline_class.cpp index f7c8e4509af..592630f1443 100644 --- a/src/goto-programs/goto_inline_class.cpp +++ b/src/goto-programs/goto_inline_class.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Function Inlining + #ifdef DEBUG #include #endif @@ -23,18 +26,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_inline.h" #include "goto_inline_class.h" -/*******************************************************************\ - -Function: goto_inlinet::parameter_assignments - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_inlinet::parameter_assignments( const goto_programt::targett target, const irep_idt &function_name, // name of called function @@ -66,7 +57,7 @@ void goto_inlinet::parameter_assignments( const irep_idt &identifier=parameter.get_identifier(); - if(identifier==irep_idt()) + if(identifier.empty()) { error().source_location=source_location; error() << "no identifier for function parameter" << eom; @@ -167,18 +158,6 @@ void goto_inlinet::parameter_assignments( } } -/*******************************************************************\ - -Function: goto_inlinet::parameter_destruction - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_inlinet::parameter_destruction( const goto_programt::targett target, const irep_idt &function_name, // name of called function @@ -203,7 +182,7 @@ void goto_inlinet::parameter_destruction( const irep_idt &identifier=parameter.get_identifier(); - if(identifier==irep_idt()) + if(identifier.empty()) { error().source_location=source_location; error() << "no identifier for function parameter" << eom; @@ -223,18 +202,6 @@ void goto_inlinet::parameter_destruction( } } -/*******************************************************************\ - -Function: goto_inlinet::replace_return - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_inlinet::replace_return( goto_programt &dest, // inlining this const exprt &lhs, // lhs in caller @@ -348,18 +315,6 @@ void goto_inlinet::replace_return( } } -/*******************************************************************\ - -Function: replace_location - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void replace_location( source_locationt &dest, const source_locationt &new_location) @@ -373,28 +328,16 @@ void replace_location( dest=new_location; - if(comment!=irep_idt()) + if(!comment.empty()) dest.set_comment(comment); - if(property_class!=irep_idt()) + if(!property_class.empty()) dest.set_property_class(property_class); - if(property_id!=irep_idt()) + if(!property_id.empty()) dest.set_property_id(property_id); } -/*******************************************************************\ - -Function: replace_location - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void replace_location( exprt &dest, const source_locationt &new_location) @@ -406,18 +349,6 @@ void replace_location( replace_location(dest.add_source_location(), new_location); } -/*******************************************************************\ - -Function: goto_inlinet::insert_function_body - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_inlinet::insert_function_body( const goto_functiont &goto_function, goto_programt &dest, @@ -519,18 +450,6 @@ void goto_inlinet::insert_function_body( dest.destructive_insert(target, tmp); } -/*******************************************************************\ - -Function: goto_inlinet::insert_function_nobody - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_inlinet::insert_function_nobody( goto_programt &dest, const exprt &lhs, @@ -584,18 +503,6 @@ void goto_inlinet::insert_function_nobody( dest.destructive_insert(target, tmp); } -/*******************************************************************\ - -Function: goto_inlinet::expand_function_call - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_inlinet::expand_function_call( goto_programt &dest, const inline_mapt &inline_map, @@ -608,7 +515,7 @@ void goto_inlinet::expand_function_call( assert(!transitive || inline_map.empty()); #ifdef DEBUG - std::cout << "Expanding call:" << std::endl; + std::cout << "Expanding call:\n"; dest.output_instruction(ns, "", std::cout, target); #endif @@ -721,18 +628,6 @@ void goto_inlinet::expand_function_call( } } -/*******************************************************************\ - -Function: goto_inlinet::get_call - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_inlinet::get_call( goto_programt::const_targett it, exprt &lhs, @@ -762,35 +657,11 @@ void goto_inlinet::get_call( } } -/*******************************************************************\ - -Function: goto_inlinet::is_call - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool goto_inlinet::is_call(goto_programt::const_targett it) { return it->is_function_call() || is_bp_call(it); } -/*******************************************************************\ - -Function: goto_inlinet::is_bp_call - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool goto_inlinet::is_bp_call(goto_programt::const_targett it) { if(!it->is_other()) @@ -802,18 +673,6 @@ bool goto_inlinet::is_bp_call(goto_programt::const_targett it) it->code.op0().op1().get(ID_statement)==ID_function_call; } -/*******************************************************************\ - -Function: goto_inline - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_inlinet::goto_inline( const inline_mapt &inline_map, const bool force_full) @@ -833,18 +692,6 @@ void goto_inlinet::goto_inline( } } -/*******************************************************************\ - -Function: goto_inline - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_inlinet::goto_inline( const irep_idt identifier, goto_functiont &goto_function, @@ -860,18 +707,6 @@ void goto_inlinet::goto_inline( force_full); } -/*******************************************************************\ - -Function: goto_inline - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_inlinet::goto_inline_nontransitive( const irep_idt identifier, goto_functiont &goto_function, @@ -926,18 +761,6 @@ void goto_inlinet::goto_inline_nontransitive( finished_set.insert(identifier); } -/*******************************************************************\ - -Function: goto_inline_transitive - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const goto_inlinet::goto_functiont &goto_inlinet::goto_inline_transitive( const irep_idt identifier, const goto_functiont &goto_function, @@ -999,18 +822,6 @@ const goto_inlinet::goto_functiont &goto_inlinet::goto_inline_transitive( return cached; } -/*******************************************************************\ - -Function: is_ignored - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool goto_inlinet::is_ignored(const irep_idt id) const { return @@ -1022,18 +833,6 @@ bool goto_inlinet::is_ignored(const irep_idt id) const id=="__CPROVER_cover"; } -/*******************************************************************\ - -Function: check_inline_map - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool goto_inlinet::check_inline_map( const irep_idt identifier, const inline_mapt &inline_map) const @@ -1080,18 +879,6 @@ bool goto_inlinet::check_inline_map( return true; } -/*******************************************************************\ - -Function: check_inline_map - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool goto_inlinet::check_inline_map(const inline_mapt &inline_map) const { forall_goto_functions(f_it, goto_functions) @@ -1103,18 +890,6 @@ bool goto_inlinet::check_inline_map(const inline_mapt &inline_map) const return true; } -/*******************************************************************\ - -Function: output_inline_map - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_inlinet::output_inline_map( std::ostream &out, const inline_mapt &inline_map) @@ -1161,18 +936,6 @@ void goto_inlinet::output_inline_map( } } -/*******************************************************************\ - -Function: output_cache - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_inlinet::output_cache(std::ostream &out) const { for(auto it=cache.begin(); it!=cache.end(); it++) @@ -1184,18 +947,6 @@ void goto_inlinet::output_cache(std::ostream &out) const } } -/*******************************************************************\ - -Function: cleanup - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - // remove segment that refer to the given goto program void goto_inlinet::goto_inline_logt::cleanup( const goto_programt &goto_program) @@ -1204,18 +955,6 @@ void goto_inlinet::goto_inline_logt::cleanup( log_map.erase(it); } -/*******************************************************************\ - -Function: cleanup - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_inlinet::goto_inline_logt::cleanup( const goto_functionst::function_mapt &function_map) { @@ -1231,18 +970,6 @@ void goto_inlinet::goto_inline_logt::cleanup( } } -/*******************************************************************\ - -Function: add_segment - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_inlinet::goto_inline_logt::add_segment( const goto_programt &goto_program, const unsigned begin_location_number, @@ -1270,18 +997,6 @@ void goto_inlinet::goto_inline_logt::add_segment( log_map[start]=info; } -/*******************************************************************\ - -Function: copy_from - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_inlinet::goto_inline_logt::copy_from( const goto_programt &from, const goto_programt &to) @@ -1321,18 +1036,6 @@ void goto_inlinet::goto_inline_logt::copy_from( } } -/*******************************************************************\ - -Function: output_inline_log_json - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - // call after goto_functions.update()! jsont goto_inlinet::goto_inline_logt::output_inline_log_json() const { diff --git a/src/goto-programs/goto_inline_class.h b/src/goto-programs/goto_inline_class.h index e043bf48807..c2356759e40 100644 --- a/src/goto-programs/goto_inline_class.h +++ b/src/goto-programs/goto_inline_class.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_GOTO_PROGRAMS_GOTO_INLINE_CLASS_H #define CPROVER_GOTO_PROGRAMS_GOTO_INLINE_CLASS_H diff --git a/src/goto-programs/goto_model.h b/src/goto-programs/goto_model.h index 37b491dc996..6e9ebbc6f37 100644 --- a/src/goto-programs/goto_model.h +++ b/src/goto-programs/goto_model.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbol Table + CFG + #ifndef CPROVER_GOTO_PROGRAMS_GOTO_MODEL_H #define CPROVER_GOTO_PROGRAMS_GOTO_MODEL_H diff --git a/src/goto-programs/goto_program.cpp b/src/goto-programs/goto_program.cpp index c1b72dc7bbf..be564d3715d 100644 --- a/src/goto-programs/goto_program.cpp +++ b/src/goto-programs/goto_program.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Program Transformation + #include #include @@ -14,23 +17,13 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_program.h" -/*******************************************************************\ - -Function: goto_programt::output_instruction - - Inputs: - ns - the namespace to resolve the expressions in - identifier - the identifier used to find a symbol to identify the - source language - out - the stream to write the goto string to - it - an iterator pointing to the instruction to convert - - Outputs: See below. - - Purpose: See below. - -\*******************************************************************/ - +/// See below. +/// \param ns: the namespace to resolve the expressions in +/// \param identifier: the identifier used to find a symbol to identify the +/// source language +/// \param out: the stream to write the goto string to +/// \param it: an iterator pointing to the instruction to convert +/// \return See below. std::ostream &goto_programt::output_instruction( const class namespacet &ns, const irep_idt &identifier, @@ -40,26 +33,15 @@ std::ostream &goto_programt::output_instruction( return output_instruction(ns, identifier, out, *it); } -/*******************************************************************\ - -Function: goto_programt::output_instruction - - Inputs: - ns - the namespace to resolve the expressions in - identifier - the identifier used to find a symbol to identify the - source language - out - the stream to write the goto string to - instruction - the instruction to convert - - Outputs: Appends to out a two line representation of the instruction - - Purpose: Writes to out a two line string representation of the specific - instruction. It is of the format: - // {location} file {source file} line {line in source file} - {representation of the instruction} - -\*******************************************************************/ - +/// Writes to out a two line string representation of the specific instruction. +/// It is of the format: // {location} file {source file} line {line in source +/// file} {representation of the instruction} +/// \param ns: the namespace to resolve the expressions in +/// \param identifier: the identifier used to find a symbol to identify the +/// source language +/// \param out: the stream to write the goto string to +/// \param instruction: the instruction to convert +/// \return Appends to out a two line representation of the instruction std::ostream &goto_programt::output_instruction( const namespacet &ns, const irep_idt &identifier, @@ -229,18 +211,6 @@ std::ostream &goto_programt::output_instruction( return out; } -/*******************************************************************\ - -Function: goto_programt::get_decl_identifiers - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_programt::get_decl_identifiers( decl_identifierst &decl_identifiers) const { @@ -256,18 +226,6 @@ void goto_programt::get_decl_identifiers( } } -/*******************************************************************\ - -Function: parse_lhs_read - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void parse_lhs_read(const exprt &src, std::list &dest) { if(src.id()==ID_dereference) @@ -295,18 +253,6 @@ void parse_lhs_read(const exprt &src, std::list &dest) } } -/*******************************************************************\ - -Function: expressions_read - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::list expressions_read( const goto_programt::instructiont &instruction) { @@ -352,18 +298,6 @@ std::list expressions_read( return dest; } -/*******************************************************************\ - -Function: expressions_written - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::list expressions_written( const goto_programt::instructiont &instruction) { @@ -392,18 +326,6 @@ std::list expressions_written( return dest; } -/*******************************************************************\ - -Function: get_objects_read - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void objects_read( const exprt &src, std::list &dest) @@ -428,18 +350,6 @@ void objects_read( } } -/*******************************************************************\ - -Function: objects_read - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::list objects_read( const goto_programt::instructiont &instruction) { @@ -453,18 +363,6 @@ std::list objects_read( return dest; } -/*******************************************************************\ - -Function: objects_written - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void objects_written( const exprt &src, std::list &dest) @@ -479,18 +377,6 @@ void objects_written( dest.push_back(src); } -/*******************************************************************\ - -Function: objects_written - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::list objects_written( const goto_programt::instructiont &instruction) { @@ -504,18 +390,6 @@ std::list objects_written( return dest; } -/*******************************************************************\ - -Function: as_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string as_string( const class namespacet &ns, const goto_programt::instructiont &i) diff --git a/src/goto-programs/goto_program.h b/src/goto-programs/goto_program.h index 83fb020c096..8e966283953 100644 --- a/src/goto-programs/goto_program.h +++ b/src/goto-programs/goto_program.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Concrete Goto Program + #ifndef CPROVER_GOTO_PROGRAMS_GOTO_PROGRAM_H #define CPROVER_GOTO_PROGRAMS_GOTO_PROGRAM_H diff --git a/src/goto-programs/goto_program_irep.cpp b/src/goto-programs/goto_program_irep.cpp index 3ddc09e27a3..8e473a3341d 100644 --- a/src/goto-programs/goto_program_irep.cpp +++ b/src/goto-programs/goto_program_irep.cpp @@ -8,24 +8,15 @@ Date: May 2007 \*******************************************************************/ +/// \file +/// goto_programt -> irep conversion + #include #include #include "goto_program_irep.h" -/*******************************************************************\ - -Function: convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void convert(const goto_programt::instructiont &instruction, irept &irep) { irep.set(ID_code, instruction.code); @@ -62,18 +53,6 @@ void convert(const goto_programt::instructiont &instruction, irept &irep) } } -/*******************************************************************\ - -Function: convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void convert( const irept &irep, goto_programt::instructiont &instruction) @@ -94,18 +73,6 @@ void convert( instruction.labels.push_back(lsub.id()); } -/*******************************************************************\ - -Function: convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void convert(const goto_programt &program, irept &irep) { irep.id("goto-program"); @@ -117,18 +84,6 @@ void convert(const goto_programt &program, irept &irep) } } -/*******************************************************************\ - -Function: convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void convert(const irept &irep, goto_programt &program) { assert(irep.id()=="goto-program"); @@ -179,7 +134,7 @@ void convert(const irept &irep, goto_programt &program) if(fit==program.instructions.end()) { std::cout << "Warning: could not resolve target link " - << "during irep->goto_program translation." << std::endl; + << "during irep->goto_program translation.\n"; throw 0; } } diff --git a/src/goto-programs/goto_program_irep.h b/src/goto-programs/goto_program_irep.h index aef5c1f9f0a..4659e62f9d4 100644 --- a/src/goto-programs/goto_program_irep.h +++ b/src/goto-programs/goto_program_irep.h @@ -8,6 +8,9 @@ Date: May 2007 \*******************************************************************/ +/// \file +/// goto_programt -> irep conversion + #ifndef CPROVER_GOTO_PROGRAMS_GOTO_PROGRAM_IREP_H #define CPROVER_GOTO_PROGRAMS_GOTO_PROGRAM_IREP_H diff --git a/src/goto-programs/goto_program_template.cpp b/src/goto-programs/goto_program_template.cpp index 80fc9089c74..bc4522a6841 100644 --- a/src/goto-programs/goto_program_template.cpp +++ b/src/goto-programs/goto_program_template.cpp @@ -6,22 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Goto Program Template + #include #include "goto_program_template.h" -/*******************************************************************\ - -Function: operator<< - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::ostream &operator<<(std::ostream &out, goto_program_instruction_typet t) { switch(t) diff --git a/src/goto-programs/goto_program_template.h b/src/goto-programs/goto_program_template.h index fc36d573ef9..af121f78444 100644 --- a/src/goto-programs/goto_program_template.h +++ b/src/goto-programs/goto_program_template.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Goto Program Template + #ifndef CPROVER_GOTO_PROGRAMS_GOTO_PROGRAM_TEMPLATE_H #define CPROVER_GOTO_PROGRAMS_GOTO_PROGRAM_TEMPLATE_H diff --git a/src/goto-programs/goto_trace.cpp b/src/goto-programs/goto_trace.cpp index d3ddb767d0c..aa55b2643f4 100644 --- a/src/goto-programs/goto_trace.cpp +++ b/src/goto-programs/goto_trace.cpp @@ -8,6 +8,9 @@ Author: Daniel Kroening \*******************************************************************/ +/// \file +/// Traces of GOTO Programs + #include #include @@ -19,18 +22,6 @@ Author: Daniel Kroening #include "goto_trace.h" -/*******************************************************************\ - -Function: goto_tracet::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_tracet::output( const class namespacet &ns, std::ostream &out) const @@ -39,18 +30,6 @@ void goto_tracet::output( step.output(ns, out); } -/*******************************************************************\ - -Function: goto_tracet::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_trace_stept::output( const namespacet &ns, std::ostream &out) const @@ -137,18 +116,6 @@ void goto_trace_stept::output( out << "\n"; } -/*******************************************************************\ - -Function: trace_value_binary - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string trace_value_binary( const exprt &expr, const namespacet &ns) @@ -212,18 +179,6 @@ std::string trace_value_binary( return "?"; } -/*******************************************************************\ - -Function: trace_value - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void trace_value( std::ostream &out, const namespacet &ns, @@ -254,18 +209,6 @@ void trace_value( << "\n"; } -/*******************************************************************\ - -Function: show_state_header - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void show_state_header( std::ostream &out, const goto_trace_stept &state, @@ -284,18 +227,6 @@ void show_state_header( out << "----------------------------------------------------" << "\n"; } -/*******************************************************************\ - -Function: is_index_member_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool is_index_member_symbol(const exprt &src) { if(src.id()==ID_index) @@ -308,18 +239,6 @@ bool is_index_member_symbol(const exprt &src) return false; } -/*******************************************************************\ - -Function: show_goto_trace - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void show_goto_trace( std::ostream &out, const namespacet &ns, diff --git a/src/goto-programs/goto_trace.h b/src/goto-programs/goto_trace.h index 7bcbc1077b8..02f230e8943 100644 --- a/src/goto-programs/goto_trace.h +++ b/src/goto-programs/goto_trace.h @@ -8,6 +8,9 @@ Date: July 2005 \*******************************************************************/ +/// \file +/// Traces of GOTO Programs + #ifndef CPROVER_GOTO_PROGRAMS_GOTO_TRACE_H #define CPROVER_GOTO_PROGRAMS_GOTO_TRACE_H diff --git a/src/goto-programs/graphml_witness.cpp b/src/goto-programs/graphml_witness.cpp index ae10705e232..2362d8f1461 100644 --- a/src/goto-programs/graphml_witness.cpp +++ b/src/goto-programs/graphml_witness.cpp @@ -6,27 +6,18 @@ Author: Daniel Kroening \*******************************************************************/ +/// \file +/// Witnesses for Traces and Proofs + #include #include -#include +#include #include #include #include #include "graphml_witness.h" -/*******************************************************************\ - -Function: graphml_witnesst::remove_l0_l1 - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void graphml_witnesst::remove_l0_l1(exprt &expr) { if(expr.id()==ID_symbol) @@ -53,18 +44,6 @@ void graphml_witnesst::remove_l0_l1(exprt &expr) remove_l0_l1(*it); } -/*******************************************************************\ - -Function: graphml_witnesst::convert_assign_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string graphml_witnesst::convert_assign_rec( const irep_idt &identifier, const code_assignt &assign) @@ -81,7 +60,7 @@ std::string graphml_witnesst::convert_assign_rec( { index_exprt index( assign.lhs(), - from_integer(i++, signedbv_typet(config.ansi_c.pointer_width)), + from_integer(i++, index_type()), type.subtype()); if(!result.empty()) result+=' '; @@ -156,18 +135,6 @@ std::string graphml_witnesst::convert_assign_rec( return result; } -/*******************************************************************\ - -Function: filter_out - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static bool filter_out( const goto_tracet &goto_trace, const goto_tracet::stepst::const_iterator &prev_it, @@ -203,18 +170,7 @@ static bool filter_out( return false; } -/*******************************************************************\ - -Function: graphml_witnesst::operator() - - Inputs: - - Outputs: - - Purpose: counterexample witness - -\*******************************************************************/ - +/// counterexample witness void graphml_witnesst::operator()(const goto_tracet &goto_trace) { graphml.key_values["sourcecodelang"]="C"; @@ -398,18 +354,7 @@ void graphml_witnesst::operator()(const goto_tracet &goto_trace) } } -/*******************************************************************\ - -Function: graphml_witnesst::operator() - - Inputs: - - Outputs: - - Purpose: proof witness - -\*******************************************************************/ - +/// proof witness void graphml_witnesst::operator()(const symex_target_equationt &equation) { graphml.key_values["sourcecodelang"]="C"; diff --git a/src/goto-programs/graphml_witness.h b/src/goto-programs/graphml_witness.h index 65a6b8e5406..053eb801146 100644 --- a/src/goto-programs/graphml_witness.h +++ b/src/goto-programs/graphml_witness.h @@ -6,6 +6,9 @@ Author: Daniel Kroening \*******************************************************************/ +/// \file +/// Witnesses for Traces and Proofs + #ifndef CPROVER_GOTO_PROGRAMS_GRAPHML_WITNESS_H #define CPROVER_GOTO_PROGRAMS_GRAPHML_WITNESS_H diff --git a/src/goto-programs/initialize_goto_model.cpp b/src/goto-programs/initialize_goto_model.cpp index 52a6caeeba2..df678c522c4 100644 --- a/src/goto-programs/initialize_goto_model.cpp +++ b/src/goto-programs/initialize_goto_model.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Get a Goto Program + #include #include @@ -20,18 +23,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "read_goto_binary.h" #include "initialize_goto_model.h" -/*******************************************************************\ - -Function: initialize_goto_model - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool initialize_goto_model( goto_modelt &goto_model, const cmdlinet &cmdline, @@ -91,7 +82,10 @@ bool initialize_goto_model( if(lf.language==NULL) { - msg.error("failed to figure out type of file", filename); + source_locationt location; + location.set_file(filename); + msg.error().source_location=location; + msg.error() << "failed to figure out type of file" << messaget::eom; return true; } diff --git a/src/goto-programs/initialize_goto_model.h b/src/goto-programs/initialize_goto_model.h index 2b4b03615ca..9aa1c8ef126 100644 --- a/src/goto-programs/initialize_goto_model.h +++ b/src/goto-programs/initialize_goto_model.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Initialize a Goto Program + #ifndef CPROVER_GOTO_PROGRAMS_INITIALIZE_GOTO_MODEL_H #define CPROVER_GOTO_PROGRAMS_INITIALIZE_GOTO_MODEL_H diff --git a/src/goto-programs/interpreter.cpp b/src/goto-programs/interpreter.cpp index 149f4002651..7e0c74a0b6b 100644 --- a/src/goto-programs/interpreter.cpp +++ b/src/goto-programs/interpreter.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Interpreter for GOTO Programs + #include #include #include @@ -27,18 +30,6 @@ Author: Daniel Kroening, kroening@kroening.com const size_t interpretert::npos=std::numeric_limits::max(); -/*******************************************************************\ - -Function: interpretert::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void interpretert::operator()() { status() << "0- Initialize:" << eom; @@ -61,20 +52,8 @@ void interpretert::operator()() command(); } -/*******************************************************************\ - -Function: interpretert::initialize - - Inputs: - - Outputs: - - Purpose: Initializes the memory map of the interpreter and - [optionally] runs up to the entry point (thus doing - the cprover initialization) - -\*******************************************************************/ - +/// Initializes the memory map of the interpreter and [optionally] runs up to +/// the entry point (thus doing the cprover initialization) void interpretert::initialize(bool init) { build_memory_map(); @@ -115,19 +94,7 @@ void interpretert::initialize(bool init) } } -/*******************************************************************\ - -Function: interpretert::show_state - - Inputs: - - Outputs: - - Purpose: displays the current position of the pc and corresponding - code - -\*******************************************************************/ - +/// displays the current position of the pc and corresponding code void interpretert::show_state() { if(!show) @@ -150,18 +117,7 @@ void interpretert::show_state() status() << eom; } -/*******************************************************************\ - -Function: interpretert::command - - Inputs: - - Outputs: - - Purpose: reads a user command and executes it. - -\*******************************************************************/ - +/// reads a user command and executes it. void interpretert::command() { #define BUFSIZE 100 @@ -266,18 +222,7 @@ void interpretert::command() show_state(); } -/*******************************************************************\ - -Function: interpretert::step - - Inputs: - - Outputs: - - Purpose: executes a single step and updates the program counter - -\*******************************************************************/ - +/// executes a single step and updates the program counter void interpretert::step() { total_steps++; @@ -413,18 +358,7 @@ void interpretert::step() pc=next_pc; } -/*******************************************************************\ - -Function: interpretert::execute_goto - - Inputs: - - Outputs: - - Purpose: executes a goto instruction - -\*******************************************************************/ - +/// executes a goto instruction void interpretert::execute_goto() { if(evaluate_boolean(pc->guard)) @@ -439,18 +373,7 @@ void interpretert::execute_goto() } } -/*******************************************************************\ - -Function: interpretert::execute_other - - Inputs: - - Outputs: - - Purpose: executes side effects of 'other' instructions - -\*******************************************************************/ - +/// executes side effects of 'other' instructions void interpretert::execute_other() { const irep_idt &statement=pc->code.get_statement(); @@ -483,35 +406,13 @@ void interpretert::execute_other() throw "unexpected OTHER statement: "+id2string(statement); } -/*******************************************************************\ - -Function: interpretert::execute_decl - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void interpretert::execute_decl() { assert(pc->code.get_statement()==ID_decl); } -/*******************************************************************\ - -Function: interpretert::get_component_id - - Inputs: an object and a memory offset - - Outputs: - - Purpose: retrieves the member at offset - -\*******************************************************************/ - +/// retrieves the member at offset +/// \par parameters: an object and a memory offset irep_idt interpretert::get_component_id( const irep_idt &object, unsigned offset) @@ -534,18 +435,7 @@ irep_idt interpretert::get_component_id( return object; } -/*******************************************************************\ - -Function: interpretert::get_type - - Inputs: - - Outputs: - - Purpose: returns the type object corresponding to id - -\*******************************************************************/ - +/// returns the type object corresponding to id typet interpretert::get_type(const irep_idt &id) const { dynamic_typest::const_iterator it=dynamic_types.find(id); @@ -554,19 +444,8 @@ typet interpretert::get_type(const irep_idt &id) const return it->second; } -/*******************************************************************\ - -Function: interpretert::get_value - - Inputs: - - Outputs: - - Purpose: retrives the constant value at memory location offset - as an object of type type - -\*******************************************************************/ - +/// retrives the constant value at memory location offset as an object of type +/// type exprt interpretert::get_value( const typet &type, std::size_t offset, @@ -627,19 +506,8 @@ exprt interpretert::get_value( return get_value(type, rhs); } -/*******************************************************************\ - - Function: interpretert::get_value - - Inputs: - - Outputs: - - Purpose: returns the value at offset in the form of type given a - memory buffer rhs which is typically a structured type - -\*******************************************************************/ - +/// returns the value at offset in the form of type given a memory buffer rhs +/// which is typically a structured type exprt interpretert::get_value( const typet &type, mp_vectort &rhs, @@ -765,18 +633,7 @@ exprt interpretert::get_value( return from_integer(rhs[offset], type); } -/*******************************************************************\ - -Function: interpretert::execute_assign - - Inputs: - - Outputs: - - Purpose: executes the assign statement at the current pc value - -\*******************************************************************/ - +/// executes the assign statement at the current pc value void interpretert::execute_assign() { const code_assignt &code_assign= @@ -826,19 +683,7 @@ void interpretert::execute_assign() } } -/*******************************************************************\ - -Function: interpretert::assign - - Inputs: - - Outputs: - - Purpose: sets the memory at address with the given rhs value - (up to sizeof(rhs)) - -\*******************************************************************/ - +/// sets the memory at address with the given rhs value (up to sizeof(rhs)) void interpretert::assign( mp_integer address, const mp_vectort &rhs) @@ -863,36 +708,12 @@ void interpretert::assign( } } -/*******************************************************************\ - -Function: interpretert::execute_assume - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void interpretert::execute_assume() { if(!evaluate_boolean(pc->guard)) throw "assumption failed"; } -/*******************************************************************\ - -Function: interpretert::execute_assert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void interpretert::execute_assert() { if(!evaluate_boolean(pc->guard)) @@ -905,18 +726,6 @@ void interpretert::execute_assert() } } -/*******************************************************************\ - -Function: interpretert::execute_function_call - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void interpretert::execute_function_call() { const code_function_callt &function_call= @@ -1027,18 +836,7 @@ void interpretert::execute_function_call() } } -/*******************************************************************\ - -Function: interpretert::build_memory_map - - Inputs: - - Outputs: - - Purpose: Creates a memory map of all static symbols in the program - -\*******************************************************************/ - +/// Creates a memory map of all static symbols in the program void interpretert::build_memory_map() { // put in a dummy for NULL @@ -1056,18 +854,6 @@ void interpretert::build_memory_map() stack_pointer=memory.size(); } -/*******************************************************************\ - -Function: interpretert::build_memory_map - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void interpretert::build_memory_map(const symbolt &symbol) { size_t size=0; @@ -1090,18 +876,7 @@ void interpretert::build_memory_map(const symbolt &symbol) } } -/*******************************************************************\ - -Function: interpretert::concretize_type - - Inputs: - - Outputs: - - Purpose: turns a variable length array type into a fixed array type - -\*******************************************************************/ - +/// turns a variable length array type into a fixed array type typet interpretert::concretize_type(const typet &type) { if(type.id()==ID_array) @@ -1126,19 +901,8 @@ typet interpretert::concretize_type(const typet &type) return type; } -/*******************************************************************\ - -Function: interpretert::build_memory_map - - Inputs: - - Outputs: Updates the memory map to include variable id if it does - not exist - - Purpose: Populates dynamic entries of the memory map - -\*******************************************************************/ - +/// Populates dynamic entries of the memory map +/// \return Updates the memory map to include variable id if it does not exist mp_integer interpretert::build_memory_map( const irep_idt &id, const typet &type) @@ -1190,21 +954,10 @@ bool interpretert::unbounded_size(const typet &type) return false; } -/*******************************************************************\ - -Function: interpretert::get_size - - Inputs: - type - a structured type - - Outputs: Size of the given type - - Purpose: Retrieves the actual size of the provided structured type. - Unbounded objects get allocated 2^32 address space each - (of a 2^64 sized space). - -\*******************************************************************/ - +/// Retrieves the actual size of the provided structured type. Unbounded objects +/// get allocated 2^32 address space each (of a 2^64 sized space). +/// \param type: a structured type +/// \return Size of the given type size_t interpretert::get_size(const typet &type) { if(unbounded_size(type)) @@ -1270,18 +1023,6 @@ size_t interpretert::get_size(const typet &type) return 1; } -/******************************************************************* \ - -Function: interpretert::get_value - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt interpretert::get_value(const irep_idt &id) { // The dynamic type and the static symbol type may differ for VLAs, @@ -1300,18 +1041,6 @@ exprt interpretert::get_value(const irep_idt &id) return get_value(get_type, integer2size_t(whole_lhs_object_address)); } -/*******************************************************************\ - -Function: interpreter - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void interpreter( const symbol_tablet &symbol_table, const goto_functionst &goto_functions, @@ -1324,19 +1053,8 @@ void interpreter( interpreter(); } -/*******************************************************************\ - -Function: interpretert::print_memory - - Inputs: - - Outputs: - - Purpose: Prints the current state of the memory map - Since messaget mdofifies class members, print functions are nonconst - -\*******************************************************************/ - +/// Prints the current state of the memory map Since messaget mdofifies class +/// members, print functions are nonconst void interpretert::print_memory(bool input_flags) { for(const auto &cell_address : memory) diff --git a/src/goto-programs/interpreter.h b/src/goto-programs/interpreter.h index 1888a009969..8d598852b1a 100644 --- a/src/goto-programs/interpreter.h +++ b/src/goto-programs/interpreter.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Interpreter for GOTO Programs + #ifndef CPROVER_GOTO_PROGRAMS_INTERPRETER_H #define CPROVER_GOTO_PROGRAMS_INTERPRETER_H diff --git a/src/goto-programs/interpreter_class.h b/src/goto-programs/interpreter_class.h index d1051eeb93f..9456037a474 100644 --- a/src/goto-programs/interpreter_class.h +++ b/src/goto-programs/interpreter_class.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Interpreter for GOTO Programs + #ifndef CPROVER_GOTO_PROGRAMS_INTERPRETER_CLASS_H #define CPROVER_GOTO_PROGRAMS_INTERPRETER_CLASS_H diff --git a/src/goto-programs/interpreter_evaluate.cpp b/src/goto-programs/interpreter_evaluate.cpp index b711be84ba2..12aca4b57b5 100644 --- a/src/goto-programs/interpreter_evaluate.cpp +++ b/src/goto-programs/interpreter_evaluate.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Interpreter for GOTO Programs + #include #include #include @@ -18,19 +21,8 @@ Author: Daniel Kroening, kroening@kroening.com #include "interpreter_class.h" -/*******************************************************************\ - -Function: interpretert::read - - Inputs: - - Outputs: - - Purpose: reads a memory address and loads it into the dest variable - marks cell as read before written if cell has never been written - -\*******************************************************************/ - +/// reads a memory address and loads it into the dest variable marks cell as +/// read before written if cell has never been written void interpretert::read( mp_integer address, mp_vectort &dest) const @@ -82,18 +74,7 @@ void interpretert::read_unbounded( } } -/*******************************************************************\ - -Function: interpretert::allocate - - Inputs: - - Outputs: - - Purpose: reserves memory block of size at address - -\*******************************************************************/ - +/// reserves memory block of size at address void interpretert::allocate( mp_integer address, size_t size) @@ -110,18 +91,7 @@ void interpretert::allocate( } } -/*******************************************************************\ - -Function: interpretert::clear_input_flags - - Inputs: - - Outputs: - - Purpose: Clears memoy r/w flag initialization - -\*******************************************************************/ - +/// Clears memoy r/w flag initialization void interpretert::clear_input_flags() { for(auto &cell : memory) @@ -131,18 +101,7 @@ void interpretert::clear_input_flags() } } -/*******************************************************************\ - -Function: interpretert::count_type_leaves - - Inputs: Type - - Outputs: Number of leaf primitive types; returns true on error - - Purpose: - -\*******************************************************************/ - +/// \return Number of leaf primitive types; returns true on error bool interpretert::count_type_leaves(const typet &ty, mp_integer &result) { if(ty.id()==ID_struct) @@ -177,25 +136,15 @@ bool interpretert::count_type_leaves(const typet &ty, mp_integer &result) } } -/*******************************************************************\ - -Function: interpretert::byte_offset_to_memory_offset - - Inputs: 'source_type', 'offset' (unit: bytes), - - Outputs: Offset into a vector of interpreter values; returns true on error - - Purpose: Supposing the caller has an mp_vector representing - a value with type 'source_type', this yields the offset into that - vector at which to find a value at *byte* address 'offset'. - We need this because the interpreter's memory map uses unlabelled - variable-width values -- for example, a C value { { 1, 2 }, 3, 4 } - of type struct { int x[2]; char y; unsigned long z; } - would be represented [1,2,3,4], with the source type needed alongside - to figure out which member is targeted by a byte-extract operation. - -\*******************************************************************/ - +/// Supposing the caller has an mp_vector representing a value with type +/// 'source_type', this yields the offset into that vector at which to find a +/// value at *byte* address 'offset'. We need this because the interpreter's +/// memory map uses unlabelled variable-width values -- for example, a C value { +/// { 1, 2 }, 3, 4 } of type struct { int x[2]; char y; unsigned long z; } would +/// be represented [1,2,3,4], with the source type needed alongside to figure +/// out which member is targeted by a byte-extract operation. +/// \par parameters: 'source_type', 'offset' (unit: bytes), +/// \return Offset into a vector of interpreter values; returns true on error bool interpretert::byte_offset_to_memory_offset( const typet &source_type, mp_integer offset, @@ -270,21 +219,12 @@ bool interpretert::byte_offset_to_memory_offset( } } -/*******************************************************************\ - -Function: interpretert::memory_offset_to_byte_offset - - Inputs: An interpreter memory offset and the type to interpret that memory - - Outputs: The corresponding byte offset. Returns true on error - - Purpose: Similarly to the above, the interpreter's memory objects contain - mp_integers that represent variable-sized struct members. This - counts the size of type leaves to determine the byte offset - corresponding to a memory offset. - -\*******************************************************************/ - +/// Similarly to the above, the interpreter's memory objects contain mp_integers +/// that represent variable-sized struct members. This counts the size of type +/// leaves to determine the byte offset corresponding to a memory offset. +/// \par parameters: An interpreter memory offset and the type to interpret that +/// memory +/// \return The corresponding byte offset. Returns true on error bool interpretert::memory_offset_to_byte_offset( const typet &source_type, mp_integer cell_offset, @@ -356,18 +296,6 @@ bool interpretert::memory_offset_to_byte_offset( } } -/*******************************************************************\ - -Function: interpretert::evaluate - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void interpretert::evaluate( const exprt &expr, mp_vectort &dest) @@ -1136,18 +1064,6 @@ void interpretert::evaluate( << eom; } -/*******************************************************************\ - -Function: interpretert::evaluate_address - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - mp_integer interpretert::evaluate_address( const exprt &expr, bool fail_quietly) diff --git a/src/goto-programs/json_goto_trace.cpp b/src/goto-programs/json_goto_trace.cpp index 694466aec2b..eaa84f6654b 100644 --- a/src/goto-programs/json_goto_trace.cpp +++ b/src/goto-programs/json_goto_trace.cpp @@ -8,6 +8,9 @@ Author: Daniel Kroening \*******************************************************************/ +/// \file +/// Traces of GOTO Programs + #include #include @@ -16,18 +19,6 @@ Author: Daniel Kroening #include "json_goto_trace.h" -/*******************************************************************\ - -Function: convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void convert( const namespacet &ns, const goto_tracet &goto_trace, diff --git a/src/goto-programs/json_goto_trace.h b/src/goto-programs/json_goto_trace.h index a4a3f2757fe..102569b50e6 100644 --- a/src/goto-programs/json_goto_trace.h +++ b/src/goto-programs/json_goto_trace.h @@ -8,6 +8,9 @@ Date: November 2005 \*******************************************************************/ +/// \file +/// Traces of GOTO Programs + #ifndef CPROVER_GOTO_PROGRAMS_JSON_GOTO_TRACE_H #define CPROVER_GOTO_PROGRAMS_JSON_GOTO_TRACE_H diff --git a/src/goto-programs/link_to_library.cpp b/src/goto-programs/link_to_library.cpp index c3ead7e6ecb..f78abb5dc39 100644 --- a/src/goto-programs/link_to_library.cpp +++ b/src/goto-programs/link_to_library.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Library Linking + #include #include @@ -14,18 +17,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "compute_called_functions.h" #include "goto_convert_functions.h" -/*******************************************************************\ - -Function: link_to_library - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void link_to_library( goto_modelt &goto_model, message_handlert &message_handler) @@ -36,18 +27,6 @@ void link_to_library( message_handler); } -/*******************************************************************\ - -Function: link_to_library - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void link_to_library( symbol_tablet &symbol_table, goto_functionst &goto_functions, diff --git a/src/goto-programs/link_to_library.h b/src/goto-programs/link_to_library.h index cb266e5d8fa..c45c5efbfa2 100644 --- a/src/goto-programs/link_to_library.h +++ b/src/goto-programs/link_to_library.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Library Linking + #ifndef CPROVER_GOTO_PROGRAMS_LINK_TO_LIBRARY_H #define CPROVER_GOTO_PROGRAMS_LINK_TO_LIBRARY_H diff --git a/src/goto-programs/loop_ids.cpp b/src/goto-programs/loop_ids.cpp index 723ffe329aa..46ca3ad3e8e 100644 --- a/src/goto-programs/loop_ids.cpp +++ b/src/goto-programs/loop_ids.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Loop IDs + #include #include @@ -15,18 +18,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "loop_ids.h" -/*******************************************************************\ - -Function: show_loop_ids - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void show_loop_ids( ui_message_handlert::uit ui, const goto_modelt &goto_model) @@ -34,18 +25,6 @@ void show_loop_ids( show_loop_ids(ui, goto_model.goto_functions); } -/*******************************************************************\ - -Function: show_loop_ids - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void show_loop_ids( ui_message_handlert::uit ui, const goto_programt &goto_program) @@ -113,18 +92,6 @@ void show_loop_ids_json( } } -/*******************************************************************\ - -Function: show_loop_ids - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void show_loop_ids( ui_message_handlert::uit ui, const goto_functionst &goto_functions) diff --git a/src/goto-programs/loop_ids.h b/src/goto-programs/loop_ids.h index da17118698c..a9f439286d7 100644 --- a/src/goto-programs/loop_ids.h +++ b/src/goto-programs/loop_ids.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Loop IDs + #ifndef CPROVER_GOTO_PROGRAMS_LOOP_IDS_H #define CPROVER_GOTO_PROGRAMS_LOOP_IDS_H diff --git a/src/goto-programs/mm_io.cpp b/src/goto-programs/mm_io.cpp new file mode 100644 index 00000000000..a8378fc200d --- /dev/null +++ b/src/goto-programs/mm_io.cpp @@ -0,0 +1,129 @@ +/*******************************************************************\ + +Module: Perform Memory-mapped I/O instrumentation + +Author: Daniel Kroening + +Date: April 2017 + +\*******************************************************************/ + +/// \file +/// Perform Memory-mapped I/O instrumentation + +#include +#include +#include + +#include "remove_returns.h" +#include "mm_io.h" + +void collect_deref_expr( + const exprt &src, + std::set &dest) +{ + if(src.id()==ID_dereference) + dest.insert(to_dereference_expr(src)); + + for(const auto & op : src.operands()) + collect_deref_expr(op, dest); // recursive call +} + +void mm_io( + const exprt &mm_io_r, + const exprt &mm_io_w, + goto_functionst::goto_functiont &goto_function, + const namespacet &ns) +{ + for(goto_programt::instructionst::iterator it= + goto_function.body.instructions.begin(); + it!=goto_function.body.instructions.end(); + it++) + { + std::set deref_expr_w, deref_expr_r; + + if(it->is_assign()) + { + auto &a=to_code_assign(it->code); + collect_deref_expr(a.rhs(), deref_expr_r); + + if(mm_io_r.is_not_nil()) + { + if(deref_expr_r.size()==1) + { + const dereference_exprt &d=*deref_expr_r.begin(); + source_locationt source_location=it->source_location; + code_function_callt fc; + const code_typet &ct=to_code_type(mm_io_r.type()); + + irep_idt identifier=to_symbol_expr(mm_io_r).get_identifier(); + irep_idt r_identifier=id2string(identifier)+RETURN_VALUE_SUFFIX; + symbol_exprt return_value(r_identifier, ct.return_type()); + if_exprt if_expr(integer_address(d.pointer()), return_value, d); + replace_expr(d, if_expr, a.rhs()); + + const typet &pt=ct.parameters()[0].type(); + const typet &st=ct.parameters()[1].type(); + exprt size=size_of_expr(d.type(), ns); + fc.arguments().resize(2); + fc.arguments()[0]=typecast_exprt(d.pointer(), pt); + fc.arguments()[1]=typecast_exprt(size, st); + fc.function()=mm_io_r; + goto_function.body.insert_before_swap(it); + it->make_function_call(fc); + it->source_location=source_location; + it++; + } + } + + if(mm_io_w.is_not_nil()) + { + if(a.lhs().id()==ID_dereference) + { + const dereference_exprt &d=to_dereference_expr(a.lhs()); + source_locationt source_location=it->source_location; + code_function_callt fc; + const code_typet &ct=to_code_type(mm_io_w.type()); + const typet &pt=ct.parameters()[0].type(); + const typet &st=ct.parameters()[1].type(); + const typet &vt=ct.parameters()[2].type(); + exprt size=size_of_expr(d.type(), ns); + fc.arguments().resize(3); + fc.arguments()[0]=typecast_exprt(d.pointer(), pt); + fc.arguments()[1]=typecast_exprt(size, st); + fc.arguments()[2]=typecast_exprt(a.rhs(), vt); + fc.function()=mm_io_w; + goto_function.body.insert_before_swap(it); + it->make_function_call(fc); + it->source_location=source_location; + it++; + } + } + } + } +} + +void mm_io( + const symbol_tablet &symbol_table, + goto_functionst &goto_functions) +{ + const namespacet ns(symbol_table); + exprt mm_io_r=nil_exprt(), mm_io_w=nil_exprt(); + + irep_idt id_r=CPROVER_PREFIX "mm_io_r"; + irep_idt id_w=CPROVER_PREFIX "mm_io_w"; + + if(symbol_table.has_symbol(id_r)) + mm_io_r=symbol_table.lookup(id_r).symbol_expr(); + + if(symbol_table.has_symbol(id_w)) + mm_io_w=symbol_table.lookup(id_w).symbol_expr(); + + for(auto & f : goto_functions.function_map) + mm_io(mm_io_r, mm_io_w, f.second, ns); +} + +void mm_io(goto_modelt &model) +{ + mm_io(model.symbol_table, model.goto_functions); +} diff --git a/src/goto-programs/mm_io.h b/src/goto-programs/mm_io.h new file mode 100644 index 00000000000..dd9058b63c5 --- /dev/null +++ b/src/goto-programs/mm_io.h @@ -0,0 +1,22 @@ +/*******************************************************************\ + +Module: Perform Memory-mapped I/O instrumentation + +Author: Daniel Kroening + +Date: April 2017 + +\*******************************************************************/ + +/// \file +/// Perform Memory-mapped I/O instrumentation + +#ifndef CPROVER_GOTO_PROGRAMS_MM_IO_H +#define CPROVER_GOTO_PROGRAMS_MM_IO_H + +#include + +void mm_io(const symbol_tablet &, goto_functionst &); +void mm_io(goto_modelt &); + +#endif // CPROVER_GOTO_PROGRAMS_MM_IO_H diff --git a/src/goto-programs/osx_fat_reader.cpp b/src/goto-programs/osx_fat_reader.cpp index aa9594ec203..93bc0f93dbc 100644 --- a/src/goto-programs/osx_fat_reader.cpp +++ b/src/goto-programs/osx_fat_reader.cpp @@ -6,6 +6,9 @@ Module: Read Mach-O \*******************************************************************/ +/// \file +/// Read Mach-O + #include #include @@ -15,18 +18,6 @@ Module: Read Mach-O #include #endif -/*******************************************************************\ - -Function: is_osx_fat_magic - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool is_osx_fat_magic(char hdr[4]) { #ifdef __APPLE__ @@ -43,18 +34,6 @@ bool is_osx_fat_magic(char hdr[4]) return false; } -/*******************************************************************\ - -Function: osx_fat_readert::osx_fat_readert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - osx_fat_readert::osx_fat_readert(std::ifstream &in) : has_gb_arch(false) { @@ -94,18 +73,6 @@ osx_fat_readert::osx_fat_readert(std::ifstream &in) : #endif } -/*******************************************************************\ - -Function: osx_fat_readert::extract_gb - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool osx_fat_readert::extract_gb( const std::string &source, const std::string &dest) const diff --git a/src/goto-programs/osx_fat_reader.h b/src/goto-programs/osx_fat_reader.h index e164548607b..715fc9f1eec 100644 --- a/src/goto-programs/osx_fat_reader.h +++ b/src/goto-programs/osx_fat_reader.h @@ -6,6 +6,9 @@ Module: Read OS X Fat Binaries \*******************************************************************/ +/// \file +/// Read OS X Fat Binaries + #ifndef CPROVER_GOTO_PROGRAMS_OSX_FAT_READER_H #define CPROVER_GOTO_PROGRAMS_OSX_FAT_READER_H diff --git a/src/goto-programs/parameter_assignments.cpp b/src/goto-programs/parameter_assignments.cpp index 2052bdb09d8..98d9f80a1c3 100644 --- a/src/goto-programs/parameter_assignments.cpp +++ b/src/goto-programs/parameter_assignments.cpp @@ -8,6 +8,9 @@ Date: September 2015 \*******************************************************************/ +/// \file +/// Add parameter assignments + #include #include @@ -32,18 +35,7 @@ class parameter_assignmentst goto_programt &goto_program); }; -/*******************************************************************\ - -Function: parameter_assignmentst::do_function_calls - -Inputs: - -Outputs: - -Purpose: turns x=f(...) into f(...); lhs=f#return_value; - -\*******************************************************************/ - +/// turns x=f(...) into f(...); lhs=f#return_value; void parameter_assignmentst::do_function_calls( goto_functionst &goto_functions, goto_programt &goto_program) @@ -98,36 +90,13 @@ void parameter_assignmentst::do_function_calls( } } -/*******************************************************************\ - -Function: parameter_assignmentst::operator() - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void parameter_assignmentst::operator()(goto_functionst &goto_functions) { Forall_goto_functions(it, goto_functions) do_function_calls(goto_functions, it->second.body); } -/*******************************************************************\ - -Function: parameter_assignments - -Inputs: - -Outputs: - -Purpose: removes returns - -\*******************************************************************/ - +/// removes returns void parameter_assignments( symbol_tablet &symbol_table, goto_functionst &goto_functions) @@ -136,18 +105,7 @@ void parameter_assignments( rr(goto_functions); } -/*******************************************************************\ - -Function: parameter_assignments - -Inputs: - -Outputs: - -Purpose: removes returns - -\*******************************************************************/ - +/// removes returns void parameter_assignments(goto_modelt &goto_model) { parameter_assignmentst rr(goto_model.symbol_table); diff --git a/src/goto-programs/parameter_assignments.h b/src/goto-programs/parameter_assignments.h index b9cafe8f932..61eb180d7cd 100644 --- a/src/goto-programs/parameter_assignments.h +++ b/src/goto-programs/parameter_assignments.h @@ -8,6 +8,9 @@ Date: September 2015 \*******************************************************************/ +/// \file +/// Add parameter assignments + #ifndef CPROVER_GOTO_PROGRAMS_PARAMETER_ASSIGNMENTS_H #define CPROVER_GOTO_PROGRAMS_PARAMETER_ASSIGNMENTS_H diff --git a/src/goto-programs/pointer_arithmetic.cpp b/src/goto-programs/pointer_arithmetic.cpp index 0639a0dbca4..9911e3432c9 100644 --- a/src/goto-programs/pointer_arithmetic.cpp +++ b/src/goto-programs/pointer_arithmetic.cpp @@ -6,23 +6,12 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include "pointer_arithmetic.h" -/*******************************************************************\ - -Function: pointer_arithmetict::pointer_arithmetict - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - pointer_arithmetict::pointer_arithmetict(const exprt &src) { pointer.make_nil(); @@ -30,18 +19,6 @@ pointer_arithmetict::pointer_arithmetict(const exprt &src) read(src); } -/*******************************************************************\ - -Function: pointer_arithmetict::read - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void pointer_arithmetict::read(const exprt &src) { if(src.id()==ID_plus) @@ -87,18 +64,6 @@ void pointer_arithmetict::read(const exprt &src) make_pointer(src); } -/*******************************************************************\ - -Function: pointer_arithmetict::add_to_offset - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void pointer_arithmetict::add_to_offset(const exprt &src) { if(offset.is_nil()) @@ -116,18 +81,6 @@ void pointer_arithmetict::add_to_offset(const exprt &src) } } -/*******************************************************************\ - -Function: pointer_arithmetict::make_pointer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void pointer_arithmetict::make_pointer(const exprt &src) { if(pointer.is_nil()) diff --git a/src/goto-programs/pointer_arithmetic.h b/src/goto-programs/pointer_arithmetic.h index 4e59e78ff52..7aafa7e233c 100644 --- a/src/goto-programs/pointer_arithmetic.h +++ b/src/goto-programs/pointer_arithmetic.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_GOTO_PROGRAMS_POINTER_ARITHMETIC_H #define CPROVER_GOTO_PROGRAMS_POINTER_ARITHMETIC_H diff --git a/src/goto-programs/property_checker.cpp b/src/goto-programs/property_checker.cpp index de790db2dd4..7c39bc34e06 100644 --- a/src/goto-programs/property_checker.cpp +++ b/src/goto-programs/property_checker.cpp @@ -6,19 +6,10 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "property_checker.h" - -/*******************************************************************\ - -Function: property_checkert::as_string - - Inputs: - - Outputs: - - Purpose: +/// \file +/// Property Checker Interface -\*******************************************************************/ +#include "property_checker.h" std::string property_checkert::as_string(resultt result) { @@ -33,36 +24,12 @@ std::string property_checkert::as_string(resultt result) return ""; } -/*******************************************************************\ - -Function: property_checkert::property_checkert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - property_checkert::property_checkert( message_handlert &_message_handler): messaget(_message_handler) { } -/*******************************************************************\ - -Function: property_checkert::initialize_property_map - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void property_checkert::initialize_property_map( const goto_functionst &goto_functions) { diff --git a/src/goto-programs/property_checker.h b/src/goto-programs/property_checker.h index c6a4dbe40b5..fd89606a752 100644 --- a/src/goto-programs/property_checker.h +++ b/src/goto-programs/property_checker.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Property Checker Interface + #ifndef CPROVER_GOTO_PROGRAMS_PROPERTY_CHECKER_H #define CPROVER_GOTO_PROGRAMS_PROPERTY_CHECKER_H diff --git a/src/goto-programs/read_bin_goto_object.cpp b/src/goto-programs/read_bin_goto_object.cpp index 9c92b403cf1..faad12665ae 100644 --- a/src/goto-programs/read_bin_goto_object.cpp +++ b/src/goto-programs/read_bin_goto_object.cpp @@ -8,6 +8,9 @@ Date: June 2006 \*******************************************************************/ +/// \file +/// Read goto object files. + #include #include #include @@ -16,18 +19,9 @@ Date: June 2006 #include "goto_functions.h" #include "read_bin_goto_object.h" -/*******************************************************************\ - -Function: read_goto_object_v3 - - Inputs: input stream, symbol_table, functions - - Outputs: true on error, false otherwise - - Purpose: read goto binary format v3 - -\*******************************************************************/ - +/// read goto binary format v3 +/// \par parameters: input stream, symbol_table, functions +/// \return true on error, false otherwise bool read_bin_goto_object_v3( std::istream &in, const std::string &filename, @@ -168,18 +162,9 @@ bool read_bin_goto_object_v3( return false; } -/*******************************************************************\ - -Function: read_goto_object - - Inputs: input stream, symbol table, functions - - Outputs: true on error, false otherwise - - Purpose: reads a goto binary file back into a symbol and a function table - -\*******************************************************************/ - +/// reads a goto binary file back into a symbol and a function table +/// \par parameters: input stream, symbol table, functions +/// \return true on error, false otherwise bool read_bin_goto_object( std::istream &in, const std::string &filename, diff --git a/src/goto-programs/read_bin_goto_object.h b/src/goto-programs/read_bin_goto_object.h index a4b679427d7..e7b684b3cc4 100644 --- a/src/goto-programs/read_bin_goto_object.h +++ b/src/goto-programs/read_bin_goto_object.h @@ -8,6 +8,9 @@ Date: May 2007 \*******************************************************************/ +/// \file +/// Read goto object files. + #ifndef CPROVER_GOTO_PROGRAMS_READ_BIN_GOTO_OBJECT_H #define CPROVER_GOTO_PROGRAMS_READ_BIN_GOTO_OBJECT_H diff --git a/src/goto-programs/read_goto_binary.cpp b/src/goto-programs/read_goto_binary.cpp index b5919d93eee..717da589d2f 100644 --- a/src/goto-programs/read_goto_binary.cpp +++ b/src/goto-programs/read_goto_binary.cpp @@ -6,6 +6,9 @@ Module: Read Goto Programs \*******************************************************************/ +/// \file +/// Read Goto Programs + #if defined(__linux__) || \ defined(__FreeBSD_kernel__) || \ defined(__GNU__) || \ @@ -34,18 +37,6 @@ Module: Read Goto Programs #include "elf_reader.h" #include "osx_fat_reader.h" -/*******************************************************************\ - -Function: read_goto_binary - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool read_goto_binary( const std::string &filename, goto_modelt &dest, @@ -55,18 +46,6 @@ bool read_goto_binary( filename, dest.symbol_table, dest.goto_functions, message_handler); } -/*******************************************************************\ - -Function: read_goto_binary - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool read_goto_binary( const std::string &filename, symbol_tablet &symbol_table, @@ -172,18 +151,6 @@ bool read_goto_binary( return true; } -/*******************************************************************\ - -Function: is_goto_binary - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool is_goto_binary(const std::string &filename) { #ifdef _MSC_VER @@ -245,18 +212,6 @@ bool is_goto_binary(const std::string &filename) return false; } -/*******************************************************************\ - -Function: rename_symbols_in_function - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static void rename_symbols_in_function( goto_functionst::goto_functiont &function, const rename_symbolt &rename_symbol) @@ -271,25 +226,14 @@ static void rename_symbols_in_function( } } -/*******************************************************************\ - -Function: link_functions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static bool link_functions( symbol_tablet &dest_symbol_table, goto_functionst &dest_functions, const symbol_tablet &src_symbol_table, goto_functionst &src_functions, const rename_symbolt &rename_symbol, - const std::unordered_set &weak_symbols) + const std::unordered_set &weak_symbols, + const replace_symbolt &object_type_updates) { namespacet ns(dest_symbol_table); namespacet src_ns(src_symbol_table); @@ -368,8 +312,8 @@ static bool link_functions( #if 0 if(!base_type_eq(symbol.type, ns.lookup(id).type, ns)) { - std::cerr << symbol << std::endl; - std::cerr << ns.lookup(id) << std::endl; + std::cerr << symbol << '\n'; + std::cerr << ns.lookup(id) << '\n'; } assert(base_type_eq(symbol.type, ns.lookup(id).type, ns)); #endif @@ -381,21 +325,22 @@ static bool link_functions( Forall_goto_functions(dest_it, dest_functions) rename_symbols_in_function(dest_it->second, macro_application); + if(!object_type_updates.expr_map.empty()) + { + Forall_goto_functions(dest_it, dest_functions) + Forall_goto_program_instructions(iit, dest_it->second.body) + { + object_type_updates(iit->code); + object_type_updates(iit->guard); + } + } + return false; } -/*******************************************************************\ - -Function: read_object_and_link - - Inputs: a file_name - - Outputs: true on error, false otherwise - - Purpose: reads an object file - -\*******************************************************************/ - +/// reads an object file +/// \par parameters: a file_name +/// \return true on error, false otherwise bool read_object_and_link( const std::string &file_name, symbol_tablet &symbol_table, @@ -427,26 +372,22 @@ bool read_object_and_link( if(linking.typecheck_main()) return true; - if(link_functions(symbol_table, functions, - temp_model.symbol_table, temp_model.goto_functions, - linking.rename_symbol, weak_symbols)) + if(link_functions( + symbol_table, + functions, + temp_model.symbol_table, + temp_model.goto_functions, + linking.rename_symbol, + weak_symbols, + linking.object_type_updates)) return true; return false; } -/*******************************************************************\ - -Function: read_object_and_link - - Inputs: a file_name - - Outputs: true on error, false otherwise - - Purpose: reads an object file - -\*******************************************************************/ - +/// reads an object file +/// \par parameters: a file_name +/// \return true on error, false otherwise bool read_object_and_link( const std::string &file_name, goto_modelt &goto_model, diff --git a/src/goto-programs/read_goto_binary.h b/src/goto-programs/read_goto_binary.h index f926179b134..bbaba7a5c11 100644 --- a/src/goto-programs/read_goto_binary.h +++ b/src/goto-programs/read_goto_binary.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Read Goto Programs + #ifndef CPROVER_GOTO_PROGRAMS_READ_GOTO_BINARY_H #define CPROVER_GOTO_PROGRAMS_READ_GOTO_BINARY_H diff --git a/src/goto-programs/remove_asm.cpp b/src/goto-programs/remove_asm.cpp index a77d1e0e418..c40fbb8334c 100644 --- a/src/goto-programs/remove_asm.cpp +++ b/src/goto-programs/remove_asm.cpp @@ -9,6 +9,9 @@ Date: December 2014 \*******************************************************************/ +/// \file +/// Remove 'asm' statements by compiling into suitable standard code + #include #include @@ -48,18 +51,6 @@ class remove_asmt goto_programt &dest); }; -/*******************************************************************\ - -Function: remove_asmt::gcc_asm_function_call - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void remove_asmt::gcc_asm_function_call( const irep_idt &function_base_name, const codet &code, @@ -118,18 +109,7 @@ void remove_asmt::gcc_asm_function_call( } } -/*******************************************************************\ - -Function: remove_asmt::process_instruction - -Inputs: - -Outputs: - -Purpose: removes assembler - -\*******************************************************************/ - +/// removes assembler void remove_asmt::process_instruction( goto_programt::instructiont &instruction, goto_programt &dest) @@ -143,7 +123,7 @@ void remove_asmt::process_instruction( const irep_idt &i_str= to_string_constant(code.op0()).get_value(); - // std::cout << "DOING " << i_str << std::endl; + // std::cout << "DOING " << i_str << '\n'; std::istringstream str(id2string(i_str)); assembler_parser.clear(); @@ -163,7 +143,7 @@ void remove_asmt::process_instruction( std::cout << "A ********************\n"; for(const auto &ins : instruction) { - std::cout << "XX: " << ins.pretty() << std::endl; + std::cout << "XX: " << ins.pretty() << '\n'; } std::cout << "B ********************\n"; @@ -302,18 +282,7 @@ void remove_asmt::process_instruction( } } -/*******************************************************************\ - -Function: remove_asmt::process_function - -Inputs: - -Outputs: - -Purpose: removes assembler - -\*******************************************************************/ - +/// removes assembler void remove_asmt::process_function( goto_functionst::goto_functiont &goto_function) { @@ -333,18 +302,7 @@ void remove_asmt::process_function( } } -/*******************************************************************\ - -Function: remove_asmt:operator() - -Inputs: - -Outputs: - -Purpose: removes assembler - -\*******************************************************************/ - +/// removes assembler void remove_asmt::operator()() { Forall_goto_functions(it, goto_functions) @@ -353,18 +311,7 @@ void remove_asmt::operator()() } } -/*******************************************************************\ - -Function: remove_asm - -Inputs: - -Outputs: - -Purpose: removes assembler - -\*******************************************************************/ - +/// removes assembler void remove_asm( symbol_tablet &symbol_table, goto_functionst &goto_functions) @@ -372,18 +319,7 @@ void remove_asm( remove_asmt(symbol_table, goto_functions)(); } -/*******************************************************************\ - -Function: remove_asm - -Inputs: - -Outputs: - -Purpose: removes assembler - -\*******************************************************************/ - +/// removes assembler void remove_asm(goto_modelt &goto_model) { remove_asmt(goto_model.symbol_table, goto_model.goto_functions)(); diff --git a/src/goto-programs/remove_asm.h b/src/goto-programs/remove_asm.h index a0de50fc699..7717ba59ca0 100644 --- a/src/goto-programs/remove_asm.h +++ b/src/goto-programs/remove_asm.h @@ -9,6 +9,9 @@ Date: December 2014 \*******************************************************************/ +/// \file +/// Remove 'asm' statements by compiling into suitable standard code + #ifndef CPROVER_GOTO_PROGRAMS_REMOVE_ASM_H #define CPROVER_GOTO_PROGRAMS_REMOVE_ASM_H diff --git a/src/goto-programs/remove_complex.cpp b/src/goto-programs/remove_complex.cpp index 44539fb5f1e..bb031082bd0 100644 --- a/src/goto-programs/remove_complex.cpp +++ b/src/goto-programs/remove_complex.cpp @@ -8,22 +8,13 @@ Date: September 2014 \*******************************************************************/ +/// \file +/// Remove 'complex' data type + #include #include "remove_complex.h" -/*******************************************************************\ - -Function: complex_member - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - static exprt complex_member(const exprt &expr, irep_idt id) { if(expr.id()==ID_struct && expr.operands().size()==2) @@ -45,18 +36,6 @@ static exprt complex_member(const exprt &expr, irep_idt id) } } -/*******************************************************************\ - -Function: have_to_remove_complex - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static bool have_to_remove_complex(const typet &type); static bool have_to_remove_complex(const exprt &expr) @@ -94,18 +73,6 @@ static bool have_to_remove_complex(const exprt &expr) return false; } -/*******************************************************************\ - -Function: have_to_remove_complex - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static bool have_to_remove_complex(const typet &type) { if(type.id()==ID_struct || type.id()==ID_union) @@ -129,18 +96,7 @@ static bool have_to_remove_complex(const typet &type) return false; } -/*******************************************************************\ - -Function: remove_complex - -Inputs: - -Outputs: - -Purpose: removes complex data type - -\*******************************************************************/ - +/// removes complex data type static void remove_complex(typet &); static void remove_complex(exprt &expr) @@ -274,18 +230,7 @@ static void remove_complex(exprt &expr) remove_complex(expr.type()); } -/*******************************************************************\ - -Function: remove_complex - -Inputs: - -Outputs: - -Purpose: removes complex data type - -\*******************************************************************/ - +/// removes complex data type static void remove_complex(typet &type) { if(!have_to_remove_complex(type)) @@ -327,54 +272,21 @@ static void remove_complex(typet &type) } } -/*******************************************************************\ - -Function: remove_complex - -Inputs: - -Outputs: - -Purpose: removes complex data type - -\*******************************************************************/ - +/// removes complex data type static void remove_complex(symbolt &symbol) { remove_complex(symbol.value); remove_complex(symbol.type); } -/*******************************************************************\ - -Function: remove_complex - -Inputs: - -Outputs: - -Purpose: removes complex data type - -\*******************************************************************/ - +/// removes complex data type void remove_complex(symbol_tablet &symbol_table) { Forall_symbols(it, symbol_table.symbols) remove_complex(it->second); } -/*******************************************************************\ - -Function: remove_complex - -Inputs: - -Outputs: - -Purpose: removes complex data type - -\*******************************************************************/ - +/// removes complex data type static void remove_complex( goto_functionst::goto_functiont &goto_function) { @@ -387,36 +299,14 @@ static void remove_complex( } } -/*******************************************************************\ - -Function: remove_complex - -Inputs: - -Outputs: - -Purpose: removes complex data type - -\*******************************************************************/ - +/// removes complex data type static void remove_complex(goto_functionst &goto_functions) { Forall_goto_functions(it, goto_functions) remove_complex(it->second); } -/*******************************************************************\ - -Function: remove_complex - -Inputs: - -Outputs: - -Purpose: removes complex data type - -\*******************************************************************/ - +/// removes complex data type void remove_complex( symbol_tablet &symbol_table, goto_functionst &goto_functions) @@ -425,18 +315,7 @@ void remove_complex( remove_complex(goto_functions); } -/*******************************************************************\ - -Function: remove_complex - -Inputs: - -Outputs: - -Purpose: removes complex data type - -\*******************************************************************/ - +/// removes complex data type void remove_complex(goto_modelt &goto_model) { remove_complex(goto_model.symbol_table, goto_model.goto_functions); diff --git a/src/goto-programs/remove_complex.h b/src/goto-programs/remove_complex.h index c42784318cf..098470ecc1a 100644 --- a/src/goto-programs/remove_complex.h +++ b/src/goto-programs/remove_complex.h @@ -8,6 +8,9 @@ Date: September 2014 \*******************************************************************/ +/// \file +/// Remove the 'complex' data type by compilation into structs + #ifndef CPROVER_GOTO_PROGRAMS_REMOVE_COMPLEX_H #define CPROVER_GOTO_PROGRAMS_REMOVE_COMPLEX_H diff --git a/src/goto-programs/remove_const_function_pointers.cpp b/src/goto-programs/remove_const_function_pointers.cpp index c0a7d8d5380..3e9824cad30 100644 --- a/src/goto-programs/remove_const_function_pointers.cpp +++ b/src/goto-programs/remove_const_function_pointers.cpp @@ -6,6 +6,9 @@ Author: Thomas Kiley, thomas.kiley@diffblue.com \*******************************************************************/ +/// \file +/// Goto Programs + #include #include #include @@ -16,23 +19,12 @@ 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. - -\*******************************************************************/ - +/// To take a function call on a function pointer, and if possible resolve it to +/// a small collection of possible values. +/// \param message_handler: The message handler for messaget +/// \param base_expression: The function call through a function pointer +/// \param ns: The namespace to use to resolve types +/// \param symbol_table: The symbol table to look up symbols in remove_const_function_pointerst::remove_const_function_pointerst( message_handlert &message_handler, const exprt &base_expression, @@ -44,28 +36,16 @@ 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. - -\*******************************************************************/ - +/// To take a function call on a function pointer, and if possible resolve it to +/// a small collection of possible values. It will resolve function pointers +/// that are const and: - assigned directly to a function - assigned to a value +/// in an array of functions - assigned to a const struct component Or +/// variations within. +/// \param out_functions: The functions that (symbols of type ID_code) the base +/// expression could take. +/// \return Returns true if it was able to resolve the call, false if not. If it +/// returns true, out_functions will be populated by all the possible values +/// the function pointer could be. bool remove_const_function_pointerst::operator()( functionst &out_functions) { @@ -74,23 +54,13 @@ bool remove_const_function_pointerst::operator()( 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. - -\*******************************************************************/ - +/// To collapse the symbols down to their values where possible This takes a +/// very general approach, recreating the expr tree exactly as it was and +/// ignoring what type of expressions are found and instead recurses over all +/// the operands. +/// \param expression: The expression to resolve symbols in +/// \return Returns a modified version of the expression, with all const symbols +/// resolved to their actual values. exprt remove_const_function_pointerst::replace_const_symbols( const exprt &expression) const { @@ -129,19 +99,9 @@ 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 - -\*******************************************************************/ - +/// Look up a symbol in the symbol table and return its value +/// \param symbol_expr: The symbol expression +/// \return The expression value of the symbol. exprt remove_const_function_pointerst::resolve_symbol( const symbol_exprt &symbol_expr) const { @@ -150,25 +110,14 @@ 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. - -\*******************************************************************/ - +/// To resolve an expression to the specific function calls it can be. This is +/// different to try_resolve_expression which isn't explicitly looking for +/// functions and is instead just trying to squash particular exprt structures. +/// \param expr: The expression to get the possible function calls +/// \param out_functions: The functions this expression could be resolved to +/// \return Returns true if it was able to resolve the expression to some +/// specific functions. If this is the case, out_functions will contain the +/// possible functions. bool remove_const_function_pointerst::try_resolve_function_call( const exprt &expr, functionst &out_functions) { @@ -233,23 +182,12 @@ 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. - -\*******************************************************************/ - +/// To resolve a collection of expressions to the specific function calls they +/// can be. Returns a collection if and only if all of them can be resolved. +/// \param exprs: The expressions to evaluate +/// \param out_functions: The functions these expressions resolve to +/// \return Returns true if able to resolve each of the expressions down to one +/// or more functions. bool remove_const_function_pointerst::try_resolve_function_calls( const expressionst &exprs, functionst &out_functions) { @@ -274,27 +212,17 @@ bool remove_const_function_pointerst::try_resolve_function_calls( return true; } -/*******************************************************************\ - -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 - -\*******************************************************************/ - +/// To resolve an expression to the specific function calls it can be. +/// Specifically, this function deals with index expressions where it squashes +/// its array and squash its index If we can get a precise number for the index, +/// we try_resolve_function_call on its value otherwise +/// try_resolve_function_call on each and return the union of them all +/// \param index_expr: The index expression to resolve to possible function +/// calls +/// \param out_functions: The functions this expression could be +/// \return Returns true if it was able to resolve the index expression to some +/// specific functions. If this is the case, out_functions will contain the +/// possible functions. bool remove_const_function_pointerst::try_resolve_index_of_function_call( const index_exprt &index_expr, functionst &out_functions) { @@ -318,24 +246,15 @@ bool remove_const_function_pointerst::try_resolve_index_of_function_call( return try_resolve_function_calls(potential_array_values, out_functions); } -/*******************************************************************\ - -Function: remove_const_function_pointerst::try_resolve_member_function_call - - Inputs: - member_expr - The member expression to resolve to possible function calls - out_functions - The functions this expression could be - - Outputs: Returns true if it was able to resolve the member expression to some - specific functions. If this is the case, out_functions will contain - the possible functions. - - Purpose: To resolve an expression to the specific function calls it can - be. Specifically, this function deals with member expressions - by using try_resolve_member and then recursing on its value. - -\*******************************************************************/ - +/// To resolve an expression to the specific function calls it can be. +/// Specifically, this function deals with member expressions by using +/// try_resolve_member and then recursing on its value. +/// \param member_expr: The member expression to resolve to possible function +/// calls +/// \param out_functions: The functions this expression could be +/// \return Returns true if it was able to resolve the member expression to some +/// specific functions. If this is the case, out_functions will contain the +/// possible functions. bool remove_const_function_pointerst::try_resolve_member_function_call( const member_exprt &member_expr, functionst &out_functions) { @@ -359,24 +278,14 @@ bool remove_const_function_pointerst::try_resolve_member_function_call( return try_resolve_function_calls(potential_component_values, out_functions); } -/*******************************************************************\ - -Function: remove_const_function_pointerst::try_resolve_address_of_function_call - - Inputs: - address_expr - The address_of expression to resolve to possible function - calls - out_functions - The functions this expression could be - - Outputs: Returns true if it was able to resolve the address_of expression to - some specific functions. If this is the case, out_functions will - contain the possible functions. - - Purpose: To resolve an expression to the specific function calls it can - be. Specifically, this function deals with address_of expressions. - -\*******************************************************************/ - +/// To resolve an expression to the specific function calls it can be. +/// Specifically, this function deals with address_of expressions. +/// \param address_expr: The address_of expression to resolve to possible +/// function calls +/// \param out_functions: The functions this expression could be +/// \return Returns true if it was able to resolve the address_of expression to +/// some specific functions. If this is the case, out_functions will contain +/// the possible functions. bool remove_const_function_pointerst::try_resolve_address_of_function_call( const address_of_exprt &address_expr, functionst &out_functions) { @@ -389,24 +298,15 @@ bool remove_const_function_pointerst::try_resolve_address_of_function_call( 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. - -\*******************************************************************/ - +/// To resolve an expression to the specific function calls it can be. +/// Specifically, this function deals with dereference expressions by using +/// try_resolve_dereferebce and then recursing on its value. +/// \param deref_expr: The dereference expression to resolve to possible +/// function calls +/// \param out_functions: The functions this expression could be +/// \return Returns true if it was able to resolve the dereference expression to +/// some specific functions. If this is the case, out_functions will contain +/// the possible functions. bool remove_const_function_pointerst::try_resolve_dereference_function_call( const dereference_exprt &deref_expr, functionst &out_functions) { @@ -430,24 +330,15 @@ bool remove_const_function_pointerst::try_resolve_dereference_function_call( return try_resolve_function_calls(potential_deref_values, out_functions); } -/*******************************************************************\ - -Function: remove_const_function_pointerst::try_resolve_typecast_function_call - - Inputs: - typecast_expr - The typecast expression to resolve to possible function calls - out_functions - The functions this expression could be - - Outputs: Returns true if it was able to resolve the typecast expression to - some specific functions. If this is the case, out_functions will - contain the possible functions. - - Purpose: To resolve an expression to the specific function calls it can - be. Specifically, this function deals with typecast expressions - by looking at the type cast values. - -\*******************************************************************/ - +/// To resolve an expression to the specific function calls it can be. +/// Specifically, this function deals with typecast expressions by looking at +/// the type cast values. +/// \param typecast_expr: The typecast expression to resolve to possible +/// function calls +/// \param out_functions: The functions this expression could be +/// \return Returns true if it was able to resolve the typecast expression to +/// some specific functions. If this is the case, out_functions will contain +/// the possible functions. bool remove_const_function_pointerst::try_resolve_typecast_function_call( const typecast_exprt &typecast_expr, functionst &out_functions) { @@ -471,33 +362,20 @@ bool remove_const_function_pointerst::try_resolve_typecast_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 - -\*******************************************************************/ - +/// To squash various expr types to simplify the expression. ID_index -> dig to +/// find ID_array and get the values out of it ID_member -> dig to find +/// ID_struct and extract the component value ID_dereference -> dig to find +/// ID_address_of and extract the value ID_typecast -> return the value +/// ID_symbol -> return false, const symbols are squashed first and non const +/// symbols cannot be squashed Everything else -> unchanged +/// \param expr: The expression to try and squash +/// \param out_resolved_expression: The squashed version of this expression +/// \param out_is_const: Is the squashed expression constant +/// \return Returns true providing the squashing went OK (note it may not have +/// squashed anything). The out_resolved_expression will in this case be all +/// the possible squashed versions of the supplied expression. The +/// out_is_const will return whether the squashed value is suitably const +/// (e.g. if we squashed a struct access, was the struct const). bool remove_const_function_pointerst::try_resolve_expression( const exprt &expr, expressionst &out_resolved_expression, bool &out_is_const) { @@ -559,25 +437,14 @@ 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. - -\*******************************************************************/ - +/// Given an index into an array, resolve, if possible, the index that is being +/// accessed. This deals with symbols and typecasts to constant values. +/// \param expr: The expression of the index of the index expression (e.g. +/// index_exprt::index()) +/// \param out_array_index: The constant value the index takes +/// \return Returns true if was able to find a constant value for the index +/// expression. If true, then out_array_index will be the index within the +/// array that the function pointer is pointing to. bool remove_const_function_pointerst::try_resolve_index_value( const exprt &expr, mp_integer &out_array_index) { @@ -610,28 +477,16 @@ 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 - out_expressions - The expressions this expression could be - out_is_const - Is the squashed expression constant - - Outputs: Returns true if it was able to squash the index expression - If this is the case, out_expressions will contain - the possible values this index_of could return - The out_is_const will return whether either the array itself - is const, or the values of the array are const. - - Purpose: To squash an index access by first finding the array it is accessing - Then if the index can be resolved, return the squashed value. If - the index can't be determined then squash each value in the array - and return them all. - -\*******************************************************************/ - +/// To squash an index access by first finding the array it is accessing Then if +/// the index can be resolved, return the squashed value. If the index can't be +/// determined then squash each value in the array and return them all. +/// \param index_expr: The index expression to to resolve +/// \param out_expressions: The expressions this expression could be +/// \param out_is_const: Is the squashed expression constant +/// \return Returns true if it was able to squash the index expression If this +/// is the case, out_expressions will contain the possible values this +/// index_of could return The out_is_const will return whether either the +/// array itself is const, or the values of the array are const. bool remove_const_function_pointerst::try_resolve_index_of( const index_exprt &index_expr, expressionst &out_expressions, @@ -728,26 +583,14 @@ 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. - -\*******************************************************************/ - +/// To squash an member access by first finding the struct it is accessing Then +/// return the squashed value of the relevant component. +/// \param member_expr: The member expression to resolve. +/// \param out_expressions: The expressions this component could be +/// \param out_is_const: Is the squashed expression constant +/// \return Returns true if it was able to squash the member expression If this +/// is the case, out_expressions will contain the possible values this member +/// could return The out_is_const will return whether the struct is const. bool remove_const_function_pointerst::try_resolve_member( const member_exprt &member_expr, expressionst &out_expressions, @@ -805,27 +648,16 @@ bool remove_const_function_pointerst::try_resolve_member( } } -/*******************************************************************\ - -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. - -\*******************************************************************/ - +/// To squash a dereference access by first finding the address_of the +/// dereference is dereferencing. Then return the squashed value of the relevant +/// component. +/// \param deref_expr: The dereference expression to resolve. +/// \param out_expressions: The expressions this dereference could be +/// \param out_is_const: Is the squashed expression constant +/// \return Returns true if it was able to squash the dereference expression If +/// this is the case, out_expressions will contain the possible values this +/// dereference could return The out_is_const will return whether the object +/// that gets dereferenced is constant. bool remove_const_function_pointerst::try_resolve_dereference( const dereference_exprt &deref_expr, expressionst &out_expressions, @@ -890,23 +722,13 @@ bool remove_const_function_pointerst::try_resolve_dereference( } } -/*******************************************************************\ - -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. - -\*******************************************************************/ - +/// To squash a typecast access. +/// \param typecast_expr: The typecast expression to resolve. +/// \param out_expressions: The expressions this typecast could be +/// \param out_is_const: Is the squashed expression constant +/// \return Returns true if it was able to squash the typecast expression If +/// this is the case, out_expressions will contain the possible values after +/// removing the typecast. bool remove_const_function_pointerst::try_resolve_typecast( const typecast_exprt &typecast_expr, expressionst &out_expressions, @@ -934,39 +756,19 @@ bool remove_const_function_pointerst::try_resolve_typecast( } } -/*******************************************************************\ - -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. - -\*******************************************************************/ - +/// To evaluate the const-ness of the expression type. +/// \param expression: The expression to check +/// \return Returns true if the type of the expression is constant. bool remove_const_function_pointerst::is_const_expression( const exprt &expression) const { return is_const_type(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. - -\*******************************************************************/ - +/// To evaluate the const-ness of the type. +/// \param type: The type to check +/// \return Returns true if the type has ID_C_constant or is an array since +/// arrays are implicitly const in C. bool remove_const_function_pointerst::is_const_type(const typet &type) const { c_qualifierst qualifers(type); @@ -981,21 +783,11 @@ bool remove_const_function_pointerst::is_const_type(const typet &type) const } } -/*******************************************************************\ - -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 - -\*******************************************************************/ - +/// To extract the value of the specific component within a struct +/// \param struct_expr: The expression of the structure being accessed +/// \param member_expr: The expression saying which component is being accessed +/// \return Returns the value of a specific component for a given struct +/// expression. exprt remove_const_function_pointerst::get_component_value( const struct_exprt &struct_expr, const member_exprt &member_expr) { diff --git a/src/goto-programs/remove_const_function_pointers.h b/src/goto-programs/remove_const_function_pointers.h index 6516fb6ec64..45ed1c16fba 100644 --- a/src/goto-programs/remove_const_function_pointers.h +++ b/src/goto-programs/remove_const_function_pointers.h @@ -6,6 +6,9 @@ Author: Thomas Kiley, thomas.kiley@diffblue.com \*******************************************************************/ +/// \file +/// Goto Programs + #ifndef CPROVER_GOTO_PROGRAMS_REMOVE_CONST_FUNCTION_POINTERS_H #define CPROVER_GOTO_PROGRAMS_REMOVE_CONST_FUNCTION_POINTERS_H diff --git a/src/goto-programs/remove_exceptions.cpp b/src/goto-programs/remove_exceptions.cpp index ee7e467d3ff..23624eb1686 100644 --- a/src/goto-programs/remove_exceptions.cpp +++ b/src/goto-programs/remove_exceptions.cpp @@ -8,6 +8,9 @@ Date: December 2016 \*******************************************************************/ +/// \file +/// Remove exception handling + #ifdef DEBUG #include #endif @@ -66,19 +69,8 @@ class remove_exceptionst const goto_functionst::function_mapt::iterator &); }; -/*******************************************************************\ - -Function: remove_exceptionst::add_exceptional_returns - -Inputs: - -Outputs: - -Purpose: adds exceptional return variables for every function that - may escape exceptions - -\*******************************************************************/ - +/// adds exceptional return variables for every function that may escape +/// exceptions void remove_exceptionst::add_exceptional_returns( const goto_functionst::function_mapt::iterator &func_it) { @@ -179,19 +171,8 @@ void remove_exceptionst::add_exceptional_returns( } } -/*******************************************************************\ - -Function: remove_exceptionst::instrument_exception_handler - -Inputs: - -Outputs: - -Purpose: at the beginning of each handler in function f - adds exc=f#exception_value; f#exception_value=NULL; - -\*******************************************************************/ - +/// at the beginning of each handler in function f adds exc=f#exception_value; +/// f#exception_value=NULL; void remove_exceptionst::instrument_exception_handler( const goto_functionst::function_mapt::iterator &func_it, const goto_programt::instructionst::iterator &instr_it) @@ -235,19 +216,8 @@ void remove_exceptionst::instrument_exception_handler( instr_it->make_skip(); } -/*******************************************************************\ - -Function: get_exceptional_output - -Inputs: - -Outputs: - -Purpose: finds the instruction where the exceptional output is set - or the end of the function if no such output exists - -\*******************************************************************/ - +/// finds the instruction where the exceptional output is set or the end of the +/// function if no such output exists static goto_programt::targett get_exceptional_output( goto_programt &goto_program) { @@ -268,19 +238,8 @@ static goto_programt::targett get_exceptional_output( return goto_program.get_end_function(); } -/*******************************************************************\ - -Function: remove_exceptionst::instrument_throw - -Inputs: - -Outputs: - -Purpose: instruments each throw with conditional GOTOS to the - corresponding exception handlers - -\*******************************************************************/ - +/// instruments each throw with conditional GOTOS to the corresponding +/// exception handlers void remove_exceptionst::instrument_throw( const goto_functionst::function_mapt::iterator &func_it, const goto_programt::instructionst::iterator &instr_it, @@ -367,19 +326,8 @@ void remove_exceptionst::instrument_throw( instr_it->code=assignment; } -/*******************************************************************\ - -Function: remove_exceptionst::instrument_function_call - -Inputs: - -Outputs: - -Purpose: instruments each function call that may escape exceptions - with conditional GOTOS to the corresponding exception handlers - -\*******************************************************************/ - +/// instruments each function call that may escape exceptions with conditional +/// GOTOS to the corresponding exception handlers void remove_exceptionst::instrument_function_call( const goto_functionst::function_mapt::iterator &func_it, const goto_programt::instructionst::iterator &instr_it, @@ -476,20 +424,9 @@ void remove_exceptionst::instrument_function_call( } } -/*******************************************************************\ - -Function: remove_exceptionst::instrument_exceptions - -Inputs: - -Outputs: - -Purpose: instruments throws, function calls that may escape exceptions - and exception handlers. Additionally, it re-computes - the live-range of local variables in order to add DEAD instructions. - -\*******************************************************************/ - +/// instruments throws, function calls that may escape exceptions and exception +/// handlers. Additionally, it re-computes the live-range of local variables in +/// order to add DEAD instructions. void remove_exceptionst::instrument_exceptions( const goto_functionst::function_mapt::iterator &func_it) { @@ -526,7 +463,7 @@ void remove_exceptionst::instrument_exceptions( else { #ifdef DEBUG - std::cout << "Remove exceptions: empty stack" << std::endl; + std::cout << "Remove exceptions: empty stack\n"; #endif } } @@ -572,18 +509,6 @@ void remove_exceptionst::instrument_exceptions( } } -/*******************************************************************\ - -Function: remove_exceptionst::operator() - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void remove_exceptionst::operator()(goto_functionst &goto_functions) { Forall_goto_functions(it, goto_functions) @@ -592,18 +517,7 @@ void remove_exceptionst::operator()(goto_functionst &goto_functions) instrument_exceptions(it); } -/*******************************************************************\ - -Function: remove_exceptions - -Inputs: - -Outputs: - -Purpose: removes throws/CATCH-POP/CATCH-PUSH - -\*******************************************************************/ - +/// removes throws/CATCH-POP/CATCH-PUSH void remove_exceptions( symbol_tablet &symbol_table, goto_functionst &goto_functions) @@ -615,18 +529,7 @@ void remove_exceptions( remove_exceptions(goto_functions); } -/*******************************************************************\ - -Function: remove_exceptions - -Inputs: - -Outputs: - -Purpose: removes throws/CATCH-POP/CATCH-PUSH - -\*******************************************************************/ - +/// removes throws/CATCH-POP/CATCH-PUSH void remove_exceptions(goto_modelt &goto_model) { std::map> exceptions_map; diff --git a/src/goto-programs/remove_exceptions.h b/src/goto-programs/remove_exceptions.h index 89162b5833d..47cf349cf13 100644 --- a/src/goto-programs/remove_exceptions.h +++ b/src/goto-programs/remove_exceptions.h @@ -8,6 +8,9 @@ Date: December 2016 \*******************************************************************/ +/// \file +/// Remove function exceptional returns + #ifndef CPROVER_GOTO_PROGRAMS_REMOVE_EXCEPTIONS_H #define CPROVER_GOTO_PROGRAMS_REMOVE_EXCEPTIONS_H diff --git a/src/goto-programs/remove_function_pointers.cpp b/src/goto-programs/remove_function_pointers.cpp index 2d5be9c0ab2..d62d1b62c87 100644 --- a/src/goto-programs/remove_function_pointers.cpp +++ b/src/goto-programs/remove_function_pointers.cpp @@ -6,34 +6,28 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Program Transformation + #include #include #include #include #include -#include #include #include #include #include #include -#include +#include #include "remove_skip.h" #include "remove_function_pointers.h" #include "compute_called_functions.h" #include "remove_const_function_pointers.h" -/*******************************************************************\ - - Class: remove_function_pointerst - - Purpose: - -\*******************************************************************/ - class remove_function_pointerst:public messaget { public: @@ -94,18 +88,6 @@ class remove_function_pointerst:public messaget } }; -/*******************************************************************\ - -Function: remove_function_pointerst::remove_function_pointerst - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - remove_function_pointerst::remove_function_pointerst( message_handlert &_message_handler, symbol_tablet &_symbol_table, @@ -125,18 +107,6 @@ remove_function_pointerst::remove_function_pointerst( type_map[f_it->first]=f_it->second.type; } -/*******************************************************************\ - -Function: remove_function_pointerst::arg_is_type_compatible - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool remove_function_pointerst::arg_is_type_compatible( const typet &call_type, const typet &function_type) @@ -169,18 +139,6 @@ bool remove_function_pointerst::arg_is_type_compatible( return false; } -/*******************************************************************\ - -Function: remove_function_pointerst::is_type_compatible - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool remove_function_pointerst::is_type_compatible( bool return_value_used, const code_typet &call_type, @@ -231,18 +189,6 @@ bool remove_function_pointerst::is_type_compatible( return true; } -/*******************************************************************\ - -Function: remove_function_pointerst::fix_argument_types - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void remove_function_pointerst::fix_argument_types( code_function_callt &function_call) { @@ -268,18 +214,6 @@ void remove_function_pointerst::fix_argument_types( } } -/*******************************************************************\ - -Function: remove_function_pointerst::fix_return_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void remove_function_pointerst::fix_return_type( code_function_callt &function_call, goto_programt &dest) @@ -319,18 +253,6 @@ void remove_function_pointerst::fix_return_type( old_lhs, typecast_exprt(tmp_symbol_expr, old_lhs.type())); } -/*******************************************************************\ - -Function: remove_function_pointerst::remove_function_pointer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void remove_function_pointerst::remove_function_pointer( goto_programt &goto_program, goto_programt::targett target) @@ -510,18 +432,6 @@ void remove_function_pointerst::remove_function_pointer( << functions.size() << " possible targets" << eom; } -/*******************************************************************\ - -Function: remove_function_pointerst::remove_function_pointers - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool remove_function_pointerst::remove_function_pointers( goto_programt &goto_program) { @@ -549,18 +459,6 @@ bool remove_function_pointerst::remove_function_pointers( return did_something; } -/*******************************************************************\ - -Function: remove_function_pointerst::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void remove_function_pointerst::operator()(goto_functionst &functions) { bool did_something=false; @@ -580,18 +478,6 @@ void remove_function_pointerst::operator()(goto_functionst &functions) functions.compute_location_numbers(); } -/*******************************************************************\ - -Function: remove_function_pointers - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool remove_function_pointers(message_handlert &_message_handler, symbol_tablet &symbol_table, const goto_functionst &goto_functions, @@ -610,18 +496,6 @@ bool remove_function_pointers(message_handlert &_message_handler, return rfp.remove_function_pointers(goto_program); } -/*******************************************************************\ - -Function: remove_function_pointers - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void remove_function_pointers( message_handlert &_message_handler, symbol_tablet &symbol_table, @@ -640,18 +514,6 @@ void remove_function_pointers( rfp(goto_functions); } -/*******************************************************************\ - -Function: remove_function_pointers - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void remove_function_pointers(message_handlert &_message_handler, goto_modelt &goto_model, bool add_safety_assertion, diff --git a/src/goto-programs/remove_function_pointers.h b/src/goto-programs/remove_function_pointers.h index e8eea37ea75..3038a940637 100644 --- a/src/goto-programs/remove_function_pointers.h +++ b/src/goto-programs/remove_function_pointers.h @@ -8,6 +8,9 @@ Date: June 2003 \*******************************************************************/ +/// \file +/// Remove Indirect Function Calls + #ifndef CPROVER_GOTO_PROGRAMS_REMOVE_FUNCTION_POINTERS_H #define CPROVER_GOTO_PROGRAMS_REMOVE_FUNCTION_POINTERS_H diff --git a/src/goto-programs/remove_instanceof.cpp b/src/goto-programs/remove_instanceof.cpp index 8e6c9f5de20..8a033668f6a 100644 --- a/src/goto-programs/remove_instanceof.cpp +++ b/src/goto-programs/remove_instanceof.cpp @@ -6,6 +6,9 @@ Author: Chris Smowton, chris.smowton@diffblue.com \*******************************************************************/ +/// \file +/// Remove Instance-of Operators + #include "class_hierarchy.h" #include "class_identifier.h" #include "remove_instanceof.h" @@ -54,19 +57,10 @@ class remove_instanceoft bool contains_instanceof(const exprt &); }; -/*******************************************************************\ - -Function: remove_instanceoft::contains_instanceof - - Inputs: Expression `expr` - - Outputs: Returns true if `expr` contains any instanceof ops - - Purpose: Avoid breaking sharing by checking for instanceof - before calling lower_instanceof. - -\*******************************************************************/ - +/// Avoid breaking sharing by checking for instanceof before calling +/// lower_instanceof. +/// \par parameters: Expression `expr` +/// \return Returns true if `expr` contains any instanceof ops bool remove_instanceoft::contains_instanceof( const exprt &expr) { @@ -78,24 +72,12 @@ bool remove_instanceoft::contains_instanceof( return false; } -/*******************************************************************\ - -Function: remove_instanceoft::lower_instanceof - - Inputs: Expression to lower `expr` and the `goto_program` and - instruction `this_inst` it belongs to. - - Outputs: Side-effect on `expr` replacing it with an explicit clsid test - - Purpose: Replaces an expression like - e instanceof A - with - e.@class_identifier == "A" - Or a big-or of similar expressions if we know of subtypes - that also satisfy the given test. - -\*******************************************************************/ - +/// Replaces an expression like e instanceof A with e.@class_identifier == "A" +/// Or a big-or of similar expressions if we know of subtypes that also satisfy +/// the given test. +/// \par parameters: Expression to lower `expr` and the `goto_program` and +/// instruction `this_inst` it belongs to. +/// \return Side-effect on `expr` replacing it with an explicit clsid test void remove_instanceoft::lower_instanceof( exprt &expr, goto_programt &goto_program, @@ -164,20 +146,12 @@ void remove_instanceoft::lower_instanceof( } } -/*******************************************************************\ - -Function: remove_instanceoft::lower_instanceof - - Inputs: GOTO program instruction `target` whose instanceof expressions, - if any, should be replaced with explicit tests, and the - `goto_program` it is part of. - - Outputs: Side-effect on `target` as above. - - Purpose: See function above - -\*******************************************************************/ - +/// See function above +/// \par parameters: GOTO program instruction `target` whose instanceof +/// expressions, +/// if any, should be replaced with explicit tests, and the +/// `goto_program` it is part of. +/// \return Side-effect on `target` as above. void remove_instanceoft::lower_instanceof( goto_programt &goto_program, goto_programt::targett target, @@ -198,18 +172,10 @@ void remove_instanceoft::lower_instanceof( lower_instanceof(target->guard, goto_program, target, inst_switch); } -/*******************************************************************\ - -Function: remove_instanceoft::lower_instanceof - - Inputs: `goto_program`, all of whose instanceof expressions will - be replaced by explicit class-identifier tests. - - Outputs: Side-effect on `goto_program` as above. - - Purpose: See function above - -\*******************************************************************/ +/// See function above +/// \par parameters: `goto_program`, all of whose instanceof expressions will +/// be replaced by explicit class-identifier tests. +/// \return Side-effect on `goto_program` as above. bool remove_instanceoft::lower_instanceof(goto_programt &goto_program) { instanceof_instt inst_switch; @@ -230,19 +196,9 @@ bool remove_instanceoft::lower_instanceof(goto_programt &goto_program) return false; } -/*******************************************************************\ - -Function: remove_instanceoft::lower_instanceof - - Inputs: None - - Outputs: Side-effects on this->goto_functions, replacing every - instanceof in every function with an explicit test. - - Purpose: See function above - -\*******************************************************************/ - +/// See function above +/// \return Side-effects on this->goto_functions, replacing every instanceof in +/// every function with an explicit test. void remove_instanceoft::lower_instanceof() { bool changed=false; @@ -252,22 +208,12 @@ void remove_instanceoft::lower_instanceof() goto_functions.compute_location_numbers(); } -/*******************************************************************\ - -Function: remove_instanceof - - Inputs: `goto_functions`, a function map, and the corresponding - `symbol_table`. - - Outputs: Side-effects on goto_functions, replacing every - instanceof in every function with an explicit test. - Extra auxiliary variables may be introduced into - `symbol_table`. - - Purpose: See function above - -\*******************************************************************/ - +/// See function above +/// \par parameters: `goto_functions`, a function map, and the corresponding +/// `symbol_table`. +/// \return Side-effects on goto_functions, replacing every instanceof in every +/// function with an explicit test. Extra auxiliary variables may be +/// introduced into `symbol_table`. void remove_instanceof( symbol_tablet &symbol_table, goto_functionst &goto_functions) diff --git a/src/goto-programs/remove_instanceof.h b/src/goto-programs/remove_instanceof.h index 7b4682ba9bf..15a02bf35b2 100644 --- a/src/goto-programs/remove_instanceof.h +++ b/src/goto-programs/remove_instanceof.h @@ -6,6 +6,9 @@ Author: Chris Smowton, chris.smowton@diffblue.com \*******************************************************************/ +/// \file +/// Remove Instance-of Operators + #ifndef CPROVER_GOTO_PROGRAMS_REMOVE_INSTANCEOF_H #define CPROVER_GOTO_PROGRAMS_REMOVE_INSTANCEOF_H diff --git a/src/goto-programs/remove_returns.cpp b/src/goto-programs/remove_returns.cpp index 9ca6554275c..fd8f49df4bc 100644 --- a/src/goto-programs/remove_returns.cpp +++ b/src/goto-programs/remove_returns.cpp @@ -8,6 +8,9 @@ Date: September 2009 \*******************************************************************/ +/// \file +/// Remove function return values + #include #include @@ -45,18 +48,7 @@ class remove_returnst goto_programt &goto_program); }; -/*******************************************************************\ - -Function: remove_returnst::replace_returns - -Inputs: - -Outputs: - -Purpose: turns 'return x' into an assignment to fkt#return_value - -\*******************************************************************/ - +/// turns 'return x' into an assignment to fkt#return_value void remove_returnst::replace_returns( goto_functionst::function_mapt::iterator f_it) { @@ -121,18 +113,7 @@ void remove_returnst::replace_returns( } } -/*******************************************************************\ - -Function: remove_returnst::do_function_calls - -Inputs: - -Outputs: - -Purpose: turns x=f(...) into f(...); lhs=f#return_value; - -\*******************************************************************/ - +/// turns x=f(...) into f(...); lhs=f#return_value; void remove_returnst::do_function_calls( goto_functionst &goto_functions, goto_programt &goto_program) @@ -208,18 +189,6 @@ void remove_returnst::do_function_calls( } } -/*******************************************************************\ - -Function: remove_returnst::operator() - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void remove_returnst::operator()(goto_functionst &goto_functions) { Forall_goto_functions(it, goto_functions) @@ -229,18 +198,7 @@ void remove_returnst::operator()(goto_functionst &goto_functions) } } -/*******************************************************************\ - -Function: remove_returns - -Inputs: - -Outputs: - -Purpose: removes returns - -\*******************************************************************/ - +/// removes returns void remove_returns( symbol_tablet &symbol_table, goto_functionst &goto_functions) @@ -249,36 +207,13 @@ void remove_returns( rr(goto_functions); } -/*******************************************************************\ - -Function: remove_returns - -Inputs: - -Outputs: - -Purpose: removes returns - -\*******************************************************************/ - +/// removes returns void remove_returns(goto_modelt &goto_model) { remove_returnst rr(goto_model.symbol_table); rr(goto_model.goto_functions); } -/*******************************************************************\ - -Function: original_return_type - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - code_typet original_return_type( const symbol_tablet &symbol_table, const irep_idt &function_id) @@ -307,18 +242,7 @@ code_typet original_return_type( return type; } -/*******************************************************************\ - -Function: remove_returnst::restore_returns - -Inputs: - -Outputs: - -Purpose: turns 'return x' into an assignment to fkt#return_value - -\*******************************************************************/ - +/// turns 'return x' into an assignment to fkt#return_value bool remove_returnst::restore_returns( goto_functionst::function_mapt::iterator f_it) { @@ -391,18 +315,7 @@ bool remove_returnst::restore_returns( return false; } -/*******************************************************************\ - -Function: remove_returnst::undo_function_calls - -Inputs: - -Outputs: - -Purpose: turns f(...); lhs=f#return_value; into x=f(...) - -\*******************************************************************/ - +/// turns f(...); lhs=f#return_value; into x=f(...) void remove_returnst::undo_function_calls( goto_functionst &goto_functions, goto_programt &goto_program) @@ -461,18 +374,6 @@ void remove_returnst::undo_function_calls( } } -/*******************************************************************\ - -Function: remove_returnst::restore() - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void remove_returnst::restore(goto_functionst &goto_functions) { // restore all types first @@ -487,18 +388,7 @@ void remove_returnst::restore(goto_functionst &goto_functions) } } -/*******************************************************************\ - -Function: restore_returns - -Inputs: - -Outputs: - -Purpose: restores return statements - -\*******************************************************************/ - +/// restores return statements void restore_returns( symbol_tablet &symbol_table, goto_functionst &goto_functions) diff --git a/src/goto-programs/remove_returns.h b/src/goto-programs/remove_returns.h index 453d8a7be7f..d4e50cae57b 100644 --- a/src/goto-programs/remove_returns.h +++ b/src/goto-programs/remove_returns.h @@ -8,6 +8,9 @@ Date: September 2009 \*******************************************************************/ +/// \file +/// Remove function returns + #ifndef CPROVER_GOTO_PROGRAMS_REMOVE_RETURNS_H #define CPROVER_GOTO_PROGRAMS_REMOVE_RETURNS_H diff --git a/src/goto-programs/remove_skip.cpp b/src/goto-programs/remove_skip.cpp index dedeb8aca2a..816960b1ea0 100644 --- a/src/goto-programs/remove_skip.cpp +++ b/src/goto-programs/remove_skip.cpp @@ -6,19 +6,10 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "remove_skip.h" - -/*******************************************************************\ - -Function: is_skip - - Inputs: - - Outputs: - - Purpose: +/// \file +/// Program Transformation -\*******************************************************************/ +#include "remove_skip.h" static bool is_skip(goto_programt::instructionst::iterator it) { @@ -76,18 +67,7 @@ static bool is_skip(goto_programt::instructionst::iterator it) return false; } -/*******************************************************************\ - -Function: remove_skip - - Inputs: - - Outputs: - - Purpose: remove unnecessary skip statements - -\*******************************************************************/ - +/// remove unnecessary skip statements void remove_skip(goto_programt &goto_program) { // This needs to be a fixed-point, as @@ -174,18 +154,7 @@ void remove_skip(goto_programt &goto_program) while(goto_program.instructions.size() #include @@ -29,19 +32,10 @@ class remove_static_init_loopst const symbol_tablet &symbol_table; }; -/*******************************************************************\ - -Function: unwind_enum_static - - Inputs: goto_functions and options - - Outputs: side effect is adding loops to unwindset - - Purpose: unwind static initialization loops of Java enums as far as - the enum has elements, thus flattening them completely - -\*******************************************************************/ - +/// unwind static initialization loops of Java enums as far as the enum has +/// elements, thus flattening them completely +/// \par parameters: goto_functions and options +/// \return side effect is adding loops to unwindset void remove_static_init_loopst::unwind_enum_static( const goto_functionst &goto_functions, optionst &options) @@ -95,19 +89,10 @@ void remove_static_init_loopst::unwind_enum_static( } } -/*******************************************************************\ - -Function: remove_static_init_loops - - Inputs: symbol table, goto_functions and options - - Outputs: side effect is adding loops to unwindset - - Purpose: this is the entry point for the removal of loops in static - initialization code of Java enums - -\*******************************************************************/ - +/// this is the entry point for the removal of loops in static initialization +/// code of Java enums +/// \par parameters: symbol table, goto_functions and options +/// \return side effect is adding loops to unwindset void remove_static_init_loops( const symbol_tablet &symbol_table, const goto_functionst &goto_functions, diff --git a/src/goto-programs/remove_static_init_loops.h b/src/goto-programs/remove_static_init_loops.h index dd07ec6a670..eee270215a2 100644 --- a/src/goto-programs/remove_static_init_loops.h +++ b/src/goto-programs/remove_static_init_loops.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Unwind loops in static initializers + #include #include diff --git a/src/goto-programs/remove_unreachable.cpp b/src/goto-programs/remove_unreachable.cpp index 14f92e97be1..1e34355ab99 100644 --- a/src/goto-programs/remove_unreachable.cpp +++ b/src/goto-programs/remove_unreachable.cpp @@ -6,23 +6,15 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Program Transformation + #include #include #include "remove_unreachable.h" -/*******************************************************************\ - -Function: remove_unreachable - - Inputs: - - Outputs: - - Purpose: remove unreachable code - -\*******************************************************************/ - +/// remove unreachable code void remove_unreachable(goto_programt &goto_program) { std::set reachable; @@ -55,3 +47,13 @@ void remove_unreachable(goto_programt &goto_program) it->make_skip(); } } + +/// Removes unreachable instructions from all functions. +/// \par parameters: The goto functions from which the unreachable functions are +/// to be removed. +/// \return None. +void remove_unreachable(goto_functionst &goto_functions) +{ + Forall_goto_functions(f_it, goto_functions) + remove_unreachable(f_it->second.body); +} diff --git a/src/goto-programs/remove_unreachable.h b/src/goto-programs/remove_unreachable.h index 694cd8c0af8..5267529d364 100644 --- a/src/goto-programs/remove_unreachable.h +++ b/src/goto-programs/remove_unreachable.h @@ -6,11 +6,15 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Program Transformation + #ifndef CPROVER_GOTO_PROGRAMS_REMOVE_UNREACHABLE_H #define CPROVER_GOTO_PROGRAMS_REMOVE_UNREACHABLE_H #include "goto_functions.h" void remove_unreachable(goto_programt &goto_program); +void remove_unreachable(goto_functionst &goto_functions); #endif // CPROVER_GOTO_PROGRAMS_REMOVE_UNREACHABLE_H diff --git a/src/goto-programs/remove_unused_functions.cpp b/src/goto-programs/remove_unused_functions.cpp index 860af2e1d73..986f615ba6b 100644 --- a/src/goto-programs/remove_unused_functions.cpp +++ b/src/goto-programs/remove_unused_functions.cpp @@ -6,22 +6,13 @@ Author: CM Wintersteiger \*******************************************************************/ +/// \file +/// Unused function removal + #include #include "remove_unused_functions.h" -/*******************************************************************\ - -Function: remove_unused_functions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void remove_unused_functions( goto_functionst &functions, message_handlert &message_handler) @@ -54,18 +45,6 @@ void remove_unused_functions( functions.function_map.erase(f); } -/*******************************************************************\ - -Function: find_used_functions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void find_used_functions( const irep_idt &start, goto_functionst &functions, diff --git a/src/goto-programs/remove_unused_functions.h b/src/goto-programs/remove_unused_functions.h index b571de4e059..550d657f299 100644 --- a/src/goto-programs/remove_unused_functions.h +++ b/src/goto-programs/remove_unused_functions.h @@ -6,6 +6,9 @@ Author: CM Wintersteiger \*******************************************************************/ +/// \file +/// Unused function removal + #ifndef CPROVER_GOTO_PROGRAMS_REMOVE_UNUSED_FUNCTIONS_H #define CPROVER_GOTO_PROGRAMS_REMOVE_UNUSED_FUNCTIONS_H diff --git a/src/goto-programs/remove_vector.cpp b/src/goto-programs/remove_vector.cpp index f7b63e42d4f..827bbb322dd 100644 --- a/src/goto-programs/remove_vector.cpp +++ b/src/goto-programs/remove_vector.cpp @@ -8,22 +8,13 @@ Date: September 2014 \*******************************************************************/ +/// \file +/// Remove 'vector' data type + #include #include "remove_vector.h" -/*******************************************************************\ - -Function: have_to_remove_vector - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - static bool have_to_remove_vector(const typet &type); static bool have_to_remove_vector(const exprt &expr) @@ -51,18 +42,6 @@ static bool have_to_remove_vector(const exprt &expr) return false; } -/*******************************************************************\ - -Function: have_to_remove_vector - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - static bool have_to_remove_vector(const typet &type) { if(type.id()==ID_struct || type.id()==ID_union) @@ -87,18 +66,7 @@ static bool have_to_remove_vector(const typet &type) return false; } -/*******************************************************************\ - -Function: remove_vector - -Inputs: - -Outputs: - -Purpose: removes vector data type - -\*******************************************************************/ - +/// removes vector data type static void remove_vector(typet &); static void remove_vector(exprt &expr) @@ -174,18 +142,7 @@ static void remove_vector(exprt &expr) remove_vector(expr.type()); } -/*******************************************************************\ - -Function: remove_vector - -Inputs: - -Outputs: - -Purpose: removes vector data type - -\*******************************************************************/ - +/// removes vector data type static void remove_vector(typet &type) { if(!have_to_remove_vector(type)) @@ -223,54 +180,21 @@ static void remove_vector(typet &type) } } -/*******************************************************************\ - -Function: remove_vector - -Inputs: - -Outputs: - -Purpose: removes vector data type - -\*******************************************************************/ - +/// removes vector data type static void remove_vector(symbolt &symbol) { remove_vector(symbol.value); remove_vector(symbol.type); } -/*******************************************************************\ - -Function: remove_vector - -Inputs: - -Outputs: - -Purpose: removes vector data type - -\*******************************************************************/ - +/// removes vector data type static void remove_vector(symbol_tablet &symbol_table) { Forall_symbols(it, symbol_table.symbols) remove_vector(it->second); } -/*******************************************************************\ - -Function: remove_vector - -Inputs: - -Outputs: - -Purpose: removes vector data type - -\*******************************************************************/ - +/// removes vector data type void remove_vector(goto_functionst::goto_functiont &goto_function) { remove_vector(goto_function.type); @@ -282,36 +206,14 @@ void remove_vector(goto_functionst::goto_functiont &goto_function) } } -/*******************************************************************\ - -Function: remove_vector - -Inputs: - -Outputs: - -Purpose: removes vector data type - -\*******************************************************************/ - +/// removes vector data type static void remove_vector(goto_functionst &goto_functions) { Forall_goto_functions(it, goto_functions) remove_vector(it->second); } -/*******************************************************************\ - -Function: remove_vector - -Inputs: - -Outputs: - -Purpose: removes vector data type - -\*******************************************************************/ - +/// removes vector data type void remove_vector( symbol_tablet &symbol_table, goto_functionst &goto_functions) @@ -320,18 +222,7 @@ void remove_vector( remove_vector(goto_functions); } -/*******************************************************************\ - -Function: remove_vector - -Inputs: - -Outputs: - -Purpose: removes vector data type - -\*******************************************************************/ - +/// removes vector data type void remove_vector(goto_modelt &goto_model) { remove_vector(goto_model.symbol_table, goto_model.goto_functions); diff --git a/src/goto-programs/remove_vector.h b/src/goto-programs/remove_vector.h index ffcb58421b4..960d75953a8 100644 --- a/src/goto-programs/remove_vector.h +++ b/src/goto-programs/remove_vector.h @@ -8,6 +8,9 @@ Date: September 2014 \*******************************************************************/ +/// \file +/// Remove the 'vector' data type by compilation into arrays + #ifndef CPROVER_GOTO_PROGRAMS_REMOVE_VECTOR_H #define CPROVER_GOTO_PROGRAMS_REMOVE_VECTOR_H diff --git a/src/goto-programs/remove_virtual_functions.cpp b/src/goto-programs/remove_virtual_functions.cpp index fde2f5f8405..e766b089274 100644 --- a/src/goto-programs/remove_virtual_functions.cpp +++ b/src/goto-programs/remove_virtual_functions.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Remove Virtual Function (Method) Calls + #include #include @@ -13,14 +16,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "class_identifier.h" #include "remove_virtual_functions.h" -/*******************************************************************\ - - Class: remove_virtual_functionst - - Purpose: - -\*******************************************************************/ - class remove_virtual_functionst { public: @@ -67,18 +62,6 @@ class remove_virtual_functionst const irep_idt &component_name) const; }; -/*******************************************************************\ - -Function: remove_virtual_functionst::remove_virtual_functionst - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - remove_virtual_functionst::remove_virtual_functionst( const symbol_tablet &_symbol_table, const goto_functionst &goto_functions): @@ -88,18 +71,6 @@ remove_virtual_functionst::remove_virtual_functionst( class_hierarchy(symbol_table); } -/*******************************************************************\ - -Function: remove_virtual_functionst::remove_virtual_function - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void remove_virtual_functionst::remove_virtual_function( goto_programt &goto_program, goto_programt::targett target) @@ -231,28 +202,17 @@ void remove_virtual_functionst::remove_virtual_function( target->make_skip(); } -/*******************************************************************\ - -Function: remove_virtual_functionst::get_child_functions_rec - - Inputs: `this_id`: class name - `last_method_defn`: the most-derived parent of `this_id` - to define the requested function - `component_name`: name of the function searched for - - Outputs: `functions` is assigned a list of {class name, function symbol} - pairs indicating that if `this` is of the given class, then the - call will target the given function. Thus if A <: B <: C and A - and C provide overrides of `f` (but B does not), - get_child_functions_rec("C", C.f, "f") -> [{"C", C.f}, - {"B", C.f}, - {"A", A.f}] - - Purpose: Used by get_functions to track the most-derived parent that - provides an override of a given function. - -\*******************************************************************/ - +/// Used by get_functions to track the most-derived parent that provides an +/// override of a given function. +/// \par parameters: `this_id`: class name +/// `last_method_defn`: the most-derived parent of `this_id` to define the +/// requested function +/// `component_name`: name of the function searched for +/// \return `functions` is assigned a list of {class name, function symbol} +/// pairs indicating that if `this` is of the given class, then the call will +/// target the given function. Thus if A <: B <: C and A and C provide +/// overrides of `f` (but B does not), get_child_functions_rec("C", C.f, "f") +/// -> [{"C", C.f}, {"B", C.f}, {"A", A.f}] void remove_virtual_functionst::get_child_functions_rec( const irep_idt &this_id, const symbol_exprt &last_method_defn, @@ -290,18 +250,6 @@ void remove_virtual_functionst::get_child_functions_rec( } } -/*******************************************************************\ - -Function: remove_virtual_functionst::get_functions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void remove_virtual_functionst::get_functions( const exprt &function, functionst &functions) @@ -352,18 +300,6 @@ void remove_virtual_functionst::get_functions( functions.push_back(root_function); } -/*******************************************************************\ - -Function: remove_virtual_functionst::get_method - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt remove_virtual_functionst::get_method( const irep_idt &class_id, const irep_idt &component_name) const @@ -378,18 +314,6 @@ exprt remove_virtual_functionst::get_method( return symbol->symbol_expr(); } -/*******************************************************************\ - -Function: remove_virtual_functionst::remove_virtual_functions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool remove_virtual_functionst::remove_virtual_functions( goto_programt &goto_program) { @@ -416,18 +340,6 @@ bool remove_virtual_functionst::remove_virtual_functions( return did_something; } -/*******************************************************************\ - -Function: remove_virtual_functionst::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void remove_virtual_functionst::operator()(goto_functionst &functions) { bool did_something=false; @@ -447,18 +359,6 @@ void remove_virtual_functionst::operator()(goto_functionst &functions) functions.compute_location_numbers(); } -/*******************************************************************\ - -Function: remove_virtual_functions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void remove_virtual_functions( const symbol_tablet &symbol_table, goto_functionst &goto_functions) @@ -469,18 +369,6 @@ void remove_virtual_functions( rvf(goto_functions); } -/*******************************************************************\ - -Function: remove_virtual_functions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void remove_virtual_functions(goto_modelt &goto_model) { remove_virtual_functions( diff --git a/src/goto-programs/remove_virtual_functions.h b/src/goto-programs/remove_virtual_functions.h index 0fec71a318f..af83cf57e4d 100644 --- a/src/goto-programs/remove_virtual_functions.h +++ b/src/goto-programs/remove_virtual_functions.h @@ -8,6 +8,9 @@ Date: April 2016 \*******************************************************************/ +/// \file +/// Remove Virtual Function (Method) Calls + #ifndef CPROVER_GOTO_PROGRAMS_REMOVE_VIRTUAL_FUNCTIONS_H #define CPROVER_GOTO_PROGRAMS_REMOVE_VIRTUAL_FUNCTIONS_H diff --git a/src/goto-programs/replace_java_nondet.cpp b/src/goto-programs/replace_java_nondet.cpp index b0514d60a7b..02a989d307a 100644 --- a/src/goto-programs/replace_java_nondet.cpp +++ b/src/goto-programs/replace_java_nondet.cpp @@ -6,6 +6,9 @@ Author: Reuben Thomas, reuben.thomas@diffblue.com \*******************************************************************/ +/// \file +/// Replace Java Nondet expressions + #include "goto-programs/replace_java_nondet.h" #include "goto-programs/goto_convert.h" #include "goto-programs/goto_model.h" @@ -16,15 +19,8 @@ Author: Reuben Thomas, reuben.thomas@diffblue.com #include #include -/*******************************************************************\ - - Class: nondet_instruction_infot - - Purpose: Holds information about any discovered nondet methods, - with extreme type-safety. - -\*******************************************************************/ - +/// Holds information about any discovered nondet methods, with extreme type- +/// safety. class nondet_instruction_infot final { public: @@ -51,22 +47,11 @@ class nondet_instruction_infot final is_nullablet is_nullable; }; -/*******************************************************************\ - -Function: is_nondet_returning_object - - Inputs: - function_call: The function call declaration to check. - - Outputs: A structure detailing whether the function call appears to - be one of our nondet library methods, and if so, whether - or not it allows null results. - - Purpose: Checks whether the function call is one of our nondet - library functions. - -\*******************************************************************/ - +/// Checks whether the function call is one of our nondet library functions. +/// \param function_call: The function call declaration to check. +/// \return A structure detailing whether the function call appears to be one of +/// our nondet library methods, and if so, whether or not it allows null +/// results. static nondet_instruction_infot is_nondet_returning_object( const code_function_callt &function_call) { @@ -85,21 +70,10 @@ static nondet_instruction_infot is_nondet_returning_object( nondet_instruction_infot::is_nullablet(!match_results[1].matched)); } -/*******************************************************************\ - -Function: get_nondet_instruction_info - - Inputs: - instr: A goto-program instruction to check. - - Outputs: A structure detailing the properties of the nondet method. - - Purpose: Check whether the instruction is a function call which - matches one of the recognised nondet library methods, and - return some information about it. - -\*******************************************************************/ - +/// Check whether the instruction is a function call which matches one of the +/// recognised nondet library methods, and return some information about it. +/// \param instr: A goto-program instruction to check. +/// \return A structure detailing the properties of the nondet method. static nondet_instruction_infot get_nondet_instruction_info( const goto_programt::const_targett &instr) { @@ -116,43 +90,21 @@ static nondet_instruction_infot get_nondet_instruction_info( return is_nondet_returning_object(function_call); } -/*******************************************************************\ - -Function: is_symbol_with_id - - Inputs: - expr: The expression which may be a symbol. - identifier: Some identifier. - - Outputs: True if the expression is a symbol with the specified identifier. - - Purpose: Return whether the expression is a symbol with the specified - identifier. - -\*******************************************************************/ - +/// Return whether the expression is a symbol with the specified identifier. +/// \param expr: The expression which may be a symbol. +/// \param identifier: Some identifier. +/// \return True if the expression is a symbol with the specified identifier. static bool is_symbol_with_id(const exprt& expr, const irep_idt& identifier) { return expr.id()==ID_symbol && to_symbol_expr(expr).get_identifier()==identifier; } -/*******************************************************************\ - -Function: is_typecast_with_id - - Inputs: - expr: The expression which may be a typecast. - identifier: Some identifier. - - Outputs: True if the expression is a typecast with one operand, and the - typecast's identifier matches the specified identifier. - - Purpose: Return whether the expression is a typecast with the specified - identifier. - -\*******************************************************************/ - +/// Return whether the expression is a typecast with the specified identifier. +/// \param expr: The expression which may be a typecast. +/// \param identifier: Some identifier. +/// \return True if the expression is a typecast with one operand, and the +/// typecast's identifier matches the specified identifier. static bool is_typecast_with_id(const exprt& expr, const irep_idt& identifier) { if(!(expr.id()==ID_typecast && expr.operands().size()==1)) @@ -169,22 +121,12 @@ static bool is_typecast_with_id(const exprt& expr, const irep_idt& identifier) return op_symbol.get_identifier()==identifier; } -/*******************************************************************\ - -Function: is_assignment_from - - Inputs: - instr: A goto program instruction. - identifier: Some identifier. - - Outputs: True if the expression is a typecast with one operand, and the - typecast's identifier matches the specified identifier. - - Purpose: Return whether the instruction is an assignment, and the rhs is a - symbol or typecast expression with the specified identifier. - -\*******************************************************************/ - +/// Return whether the instruction is an assignment, and the rhs is a symbol or +/// typecast expression with the specified identifier. +/// \param instr: A goto program instruction. +/// \param identifier: Some identifier. +/// \return True if the expression is a typecast with one operand, and the +/// typecast's identifier matches the specified identifier. static bool is_assignment_from( const goto_programt::instructiont &instr, const irep_idt &identifier) @@ -199,23 +141,13 @@ static bool is_assignment_from( is_typecast_with_id(rhs, identifier); } -/*******************************************************************\ - -Function: check_and_replace_target - - Inputs: - goto_program: The goto program to modify. - target: A single step of the goto program which may be erased and - replaced. - - Outputs: The next instruction to process, probably with this function. - - Purpose: Given an iterator into a list of instructions, modify the list to - replace 'nondet' library functions with CBMC-native nondet - expressions, and return an iterator to the next instruction to check. - -\*******************************************************************/ - +/// Given an iterator into a list of instructions, modify the list to replace +/// 'nondet' library functions with CBMC-native nondet expressions, and return +/// an iterator to the next instruction to check. +/// \param goto_program: The goto program to modify. +/// \param target: A single step of the goto program which may be erased and +/// replaced. +/// \return The next instruction to process, probably with this function. static goto_programt::targett check_and_replace_target( goto_programt &goto_program, const goto_programt::targett &target) @@ -287,20 +219,10 @@ static goto_programt::targett check_and_replace_target( return after_matching_assignment; } -/*******************************************************************\ - -Function: replace_java_nondet - - Inputs: - goto_program: The goto program to modify. - - Purpose: Checks each instruction in the goto program to see whether - it is a method returning nondet. If it is, replaces the - function call with an irep representing a nondet side - effect with an appropriate type. - -\*******************************************************************/ - +/// Checks each instruction in the goto program to see whether it is a method +/// returning nondet. If it is, replaces the function call with an irep +/// representing a nondet side effect with an appropriate type. +/// \param goto_program: The goto program to modify. static void replace_java_nondet(goto_programt &goto_program) { for(auto instruction_iterator=goto_program.instructions.begin(), diff --git a/src/goto-programs/replace_java_nondet.h b/src/goto-programs/replace_java_nondet.h index 077f95ab84c..cc924e9e974 100644 --- a/src/goto-programs/replace_java_nondet.h +++ b/src/goto-programs/replace_java_nondet.h @@ -6,23 +6,17 @@ Author: Reuben Thomas, reuben.thomas@diffblue.com \*******************************************************************/ +/// \file +/// Replace Java Nondet expressions + #ifndef CPROVER_GOTO_PROGRAMS_REPLACE_JAVA_NONDET_H #define CPROVER_GOTO_PROGRAMS_REPLACE_JAVA_NONDET_H class goto_functionst; -/*******************************************************************\ - -Function: replace_java_nondet - - Inputs: - goto_functions: The set of goto programs to modify. - - Purpose: Replace calls to nondet library functions with an internal - nondet representation. - -\*******************************************************************/ - +/// Replace calls to nondet library functions with an internal nondet +/// representation. +/// \param goto_functions: The set of goto programs to modify. void replace_java_nondet(goto_functionst &goto_functions); #endif diff --git a/src/goto-programs/safety_checker.cpp b/src/goto-programs/safety_checker.cpp index 275cffbbe09..b1236c08dc7 100644 --- a/src/goto-programs/safety_checker.cpp +++ b/src/goto-programs/safety_checker.cpp @@ -6,37 +6,16 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "safety_checker.h" - -/*******************************************************************\ - -Function: safety_checkert::safety_checkert - - Inputs: +/// \file +/// Safety Checker Interface - Outputs: - - Purpose: - -\*******************************************************************/ +#include "safety_checker.h" safety_checkert::safety_checkert(const namespacet &_ns): ns(_ns) { } -/*******************************************************************\ - -Function: safety_checkert::safety_checkert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - safety_checkert::safety_checkert( const namespacet &_ns, message_handlert &_message_handler): diff --git a/src/goto-programs/safety_checker.h b/src/goto-programs/safety_checker.h index e7f5e0b81ea..bb1492d6f53 100644 --- a/src/goto-programs/safety_checker.h +++ b/src/goto-programs/safety_checker.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Safety Checker Interface + #ifndef CPROVER_GOTO_PROGRAMS_SAFETY_CHECKER_H #define CPROVER_GOTO_PROGRAMS_SAFETY_CHECKER_H diff --git a/src/goto-programs/set_properties.cpp b/src/goto-programs/set_properties.cpp index fc79d4dcfe7..303d8a9367d 100644 --- a/src/goto-programs/set_properties.cpp +++ b/src/goto-programs/set_properties.cpp @@ -6,24 +6,15 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Set Properties + #include #include #include "set_properties.h" -/*******************************************************************\ - -Function: set_properties - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void set_properties( goto_programt &goto_program, std::unordered_set &property_set) @@ -48,35 +39,11 @@ void set_properties( } } -/*******************************************************************\ - -Function: label_properties - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void label_properties(goto_modelt &goto_model) { label_properties(goto_model.goto_functions); } -/*******************************************************************\ - -Function: label_properties - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void label_properties( goto_programt &goto_program, std::map &property_counters) @@ -119,36 +86,12 @@ void label_properties( } } -/*******************************************************************\ - -Function: label_properties - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void label_properties(goto_programt &goto_program) { std::map property_counters; label_properties(goto_program, property_counters); } -/*******************************************************************\ - -Function: set_properties - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void set_properties( goto_modelt &goto_model, const std::list &properties) @@ -156,18 +99,6 @@ void set_properties( set_properties(goto_model.goto_functions, properties); } -/*******************************************************************\ - -Function: set_properties - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void set_properties( goto_functionst &goto_functions, const std::list &properties) @@ -184,18 +115,6 @@ void set_properties( throw "property "+id2string(*property_set.begin())+" not found"; } -/*******************************************************************\ - -Function: label_properties - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void label_properties(goto_functionst &goto_functions) { std::map property_counters; @@ -208,35 +127,11 @@ void label_properties(goto_functionst &goto_functions) label_properties(it->second.body, property_counters); } -/*******************************************************************\ - -Function: make_assertions_false - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void make_assertions_false(goto_modelt &goto_model) { make_assertions_false(goto_model.goto_functions); } -/*******************************************************************\ - -Function: make_assertions_false - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void make_assertions_false( goto_functionst &goto_functions) { diff --git a/src/goto-programs/set_properties.h b/src/goto-programs/set_properties.h index 8f302b79bee..53d1bee93d7 100644 --- a/src/goto-programs/set_properties.h +++ b/src/goto-programs/set_properties.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Set the properties to check + #ifndef CPROVER_GOTO_PROGRAMS_SET_PROPERTIES_H #define CPROVER_GOTO_PROGRAMS_SET_PROPERTIES_H diff --git a/src/goto-programs/show_goto_functions.cpp b/src/goto-programs/show_goto_functions.cpp index 2b07d6d6db8..516d2e6a3d2 100644 --- a/src/goto-programs/show_goto_functions.cpp +++ b/src/goto-programs/show_goto_functions.cpp @@ -6,6 +6,9 @@ Author: Peter Schrammel \*******************************************************************/ +/// \file +/// Show goto functions + #include #include @@ -23,18 +26,6 @@ Author: Peter Schrammel #include "goto_functions.h" #include "goto_model.h" -/*******************************************************************\ - -Function: cbmc_parseoptionst::show_goto_functions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void show_goto_functions( const namespacet &ns, ui_message_handlert::uit ui, @@ -62,18 +53,6 @@ void show_goto_functions( } } -/*******************************************************************\ - -Function: show_goto_functions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void show_goto_functions( const goto_modelt &goto_model, ui_message_handlert::uit ui) diff --git a/src/goto-programs/show_goto_functions.h b/src/goto-programs/show_goto_functions.h index a496682961e..4f63fde97a6 100644 --- a/src/goto-programs/show_goto_functions.h +++ b/src/goto-programs/show_goto_functions.h @@ -6,6 +6,9 @@ Author: Peter Schrammel \*******************************************************************/ +/// \file +/// Show the goto functions + #ifndef CPROVER_GOTO_PROGRAMS_SHOW_GOTO_FUNCTIONS_H #define CPROVER_GOTO_PROGRAMS_SHOW_GOTO_FUNCTIONS_H diff --git a/src/goto-programs/show_goto_functions_json.cpp b/src/goto-programs/show_goto_functions_json.cpp index 47a19e0662a..da9c2424322 100644 --- a/src/goto-programs/show_goto_functions_json.cpp +++ b/src/goto-programs/show_goto_functions_json.cpp @@ -6,6 +6,9 @@ Author: Thomas Kiley \*******************************************************************/ +/// \file +/// Goto Program + #include #include @@ -20,37 +23,15 @@ Author: Thomas Kiley #include "goto_model.h" #include "show_goto_functions_json.h" -/*******************************************************************\ - -Function: show_goto_functions_jsont::show_goto_functions_jsont - - Inputs: - ns - the namespace to use to resolve names with - - Outputs: - - Purpose: For outputing the GOTO program in a readable JSON format. - -\*******************************************************************/ - +/// For outputing the GOTO program in a readable JSON format. +/// \param ns: the namespace to use to resolve names with show_goto_functions_jsont::show_goto_functions_jsont(const namespacet &ns): ns(ns) {} -/*******************************************************************\ - -Function: show_goto_functions_jsont::convert - - Inputs: - goto_functions - the goto functions that make up the program - - Outputs: - - Purpose: Walks through all of the functions in the program and returns - a JSON object representing all their functions - -\*******************************************************************/ - +/// Walks through all of the functions in the program and returns a JSON object +/// representing all their functions +/// \param goto_functions: the goto functions that make up the program json_objectt show_goto_functions_jsont::convert( const goto_functionst &goto_functions) { @@ -129,24 +110,13 @@ json_objectt show_goto_functions_jsont::convert( return json_result; } -/*******************************************************************\ - -Function: show_goto_functions_jsont::operator() - - Inputs: - goto_functions - the goto functions that make up the program - out - the stream to write the object to - append - should a command and newline be appended to the stream - before writing the JSON object. Defaults to true - - Outputs: - - Purpose: Print the json object generated by - show_goto_functions_jsont::show_goto_functions to the provided - stream (e.g. std::cout) - -\*******************************************************************/ - +/// Print the json object generated by +/// show_goto_functions_jsont::show_goto_functions to the provided stream (e.g. +/// std::cout) +/// \param goto_functions: the goto functions that make up the program +/// \param out: the stream to write the object to +/// \param append: should a command and newline be appended to the stream before +/// writing the JSON object. Defaults to true void show_goto_functions_jsont::operator()( const goto_functionst &goto_functions, std::ostream &out, diff --git a/src/goto-programs/show_goto_functions_json.h b/src/goto-programs/show_goto_functions_json.h index b6313247f43..0f2c7a9e8e5 100644 --- a/src/goto-programs/show_goto_functions_json.h +++ b/src/goto-programs/show_goto_functions_json.h @@ -6,6 +6,9 @@ Author: Thomas Kiley \*******************************************************************/ +/// \file +/// Goto Program + #ifndef CPROVER_GOTO_PROGRAMS_SHOW_GOTO_FUNCTIONS_JSON_H #define CPROVER_GOTO_PROGRAMS_SHOW_GOTO_FUNCTIONS_JSON_H diff --git a/src/goto-programs/show_goto_functions_xml.cpp b/src/goto-programs/show_goto_functions_xml.cpp index 7ccdd71a4ff..cce37c8d2c4 100644 --- a/src/goto-programs/show_goto_functions_xml.cpp +++ b/src/goto-programs/show_goto_functions_xml.cpp @@ -6,6 +6,9 @@ Author: Thomas Kiley \*******************************************************************/ +/// \file +/// Goto Program + #include #include @@ -21,51 +24,19 @@ Author: Thomas Kiley #include "show_goto_functions_xml.h" -/*******************************************************************\ - -Function: show_goto_functions_xmlt::show_goto_functions_xmlt - - Inputs: - ns - the namespace to use to resolve names with - - Outputs: - - Purpose: For outputing the GOTO program in a readable xml format. - -\*******************************************************************/ - +/// For outputing the GOTO program in a readable xml format. +/// \param ns: the namespace to use to resolve names with show_goto_functions_xmlt::show_goto_functions_xmlt(const namespacet &ns): ns(ns) {} -/*******************************************************************\ - -Function: show_goto_functions_xmlt::convert - - Inputs: - goto_functions - the goto functions that make up the program - - Outputs: - - Purpose: Walks through all of the functions in the program and returns - an xml object representing all their functions. Produces output - like this: - - - - - - - // 34 file main.c line 1 - s = { 'a', 'b', 'c', 0 }; - - - - - - -\*******************************************************************/ - +/// Walks through all of the functions in the program and returns an xml object +/// representing all their functions. Produces output like this: +/// +/// +/// // 34 file main.c line 1 s = { 'a', 'b', 'c', 0 }; +/// +/// \param goto_functions: the goto functions that make up the program xmlt show_goto_functions_xmlt::convert( const goto_functionst &goto_functions) { @@ -114,24 +85,13 @@ xmlt show_goto_functions_xmlt::convert( return xml_functions; } -/*******************************************************************\ - -Function: show_goto_functions_xmlt::operator() - - Inputs: - goto_functions - the goto functions that make up the program - out - the stream to write the object to - append - should a command and newline be appended to the stream - before writing the xml object. Defaults to true - - Outputs: - - Purpose: Print the xml object generated by - show_goto_functions_xmlt::show_goto_functions to the provided - stream (e.g. std::cout) - -\*******************************************************************/ - +/// Print the xml object generated by +/// show_goto_functions_xmlt::show_goto_functions to the provided stream (e.g. +/// std::cout) +/// \param goto_functions: the goto functions that make up the program +/// \param out: the stream to write the object to +/// \param append: should a command and newline be appended to the stream before +/// writing the xml object. Defaults to true void show_goto_functions_xmlt::operator()( const goto_functionst &goto_functions, std::ostream &out, diff --git a/src/goto-programs/show_goto_functions_xml.h b/src/goto-programs/show_goto_functions_xml.h index 6e170b5f32d..1d47bba0b55 100644 --- a/src/goto-programs/show_goto_functions_xml.h +++ b/src/goto-programs/show_goto_functions_xml.h @@ -6,6 +6,9 @@ Author: Thomas Kiley \*******************************************************************/ +/// \file +/// Goto Program + #ifndef CPROVER_GOTO_PROGRAMS_SHOW_GOTO_FUNCTIONS_XML_H #define CPROVER_GOTO_PROGRAMS_SHOW_GOTO_FUNCTIONS_XML_H diff --git a/src/goto-programs/show_properties.cpp b/src/goto-programs/show_properties.cpp index b6b03d1a7a4..9afa3f99eba 100644 --- a/src/goto-programs/show_properties.cpp +++ b/src/goto-programs/show_properties.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Show Claims + #include #include @@ -19,18 +22,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_functions.h" #include "goto_model.h" -/*******************************************************************\ - -Function: cbmc_parseoptionst::show_properties - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void show_properties( const namespacet &ns, const irep_idt &identifier, @@ -67,7 +58,7 @@ void show_properties( xml_property.new_element("expression").data= from_expr(ns, identifier, ins.guard); - std::cout << xml_property << std::endl; + std::cout << xml_property << '\n'; } break; @@ -76,14 +67,14 @@ void show_properties( break; case ui_message_handlert::uit::PLAIN: - std::cout << "Property " << property_id << ":" << std::endl; + std::cout << "Property " << property_id << ":\n"; - std::cout << " " << ins.source_location << std::endl - << " " << description << std::endl + std::cout << " " << ins.source_location << '\n' + << " " << description << '\n' << " " << from_expr(ns, identifier, ins.guard) - << std::endl; + << '\n'; - std::cout << std::endl; + std::cout << '\n'; break; default: @@ -93,18 +84,6 @@ void show_properties( } -/*******************************************************************\ - -Function: cbmc_parseoptionst::show_properties_json - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void show_properties_json( json_arrayt &json_properties, const namespacet &ns, @@ -141,18 +120,6 @@ void show_properties_json( } } -/*******************************************************************\ - -Function: show_properties_json - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void show_properties_json( const namespacet &ns, const goto_functionst &goto_functions) @@ -172,18 +139,6 @@ void show_properties_json( std::cout << ",\n" << json_result; } -/*******************************************************************\ - -Function: show_properties - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void show_properties( const namespacet &ns, ui_message_handlert::uit ui, @@ -197,18 +152,6 @@ void show_properties( show_properties(ns, fct.first, ui, fct.second.body); } -/*******************************************************************\ - -Function: show_properties - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void show_properties( const goto_modelt &goto_model, ui_message_handlert::uit ui) diff --git a/src/goto-programs/show_properties.h b/src/goto-programs/show_properties.h index 0feff5f6a3d..b5564818195 100644 --- a/src/goto-programs/show_properties.h +++ b/src/goto-programs/show_properties.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Show the properties + #ifndef CPROVER_GOTO_PROGRAMS_SHOW_PROPERTIES_H #define CPROVER_GOTO_PROGRAMS_SHOW_PROPERTIES_H diff --git a/src/goto-programs/show_symbol_table.cpp b/src/goto-programs/show_symbol_table.cpp index cf24e4677ca..60460147e52 100644 --- a/src/goto-programs/show_symbol_table.cpp +++ b/src/goto-programs/show_symbol_table.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Show the symbol table + #include #include @@ -15,34 +18,10 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_model.h" #include "show_symbol_table.h" -/*******************************************************************\ - -Function: show_symbol_table_xml_ui - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void show_symbol_table_xml_ui() { } -/*******************************************************************\ - -Function: show_symbol_table_plain - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void show_symbol_table_plain( const goto_modelt &goto_model, std::ostream &out) @@ -130,18 +109,6 @@ void show_symbol_table_plain( } } -/*******************************************************************\ - -Function: show_symbol_table - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void show_symbol_table( const goto_modelt &goto_model, ui_message_handlert::uit ui) diff --git a/src/goto-programs/show_symbol_table.h b/src/goto-programs/show_symbol_table.h index 6e3b387f863..5ad717e7049 100644 --- a/src/goto-programs/show_symbol_table.h +++ b/src/goto-programs/show_symbol_table.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Show the symbol table + #ifndef CPROVER_GOTO_PROGRAMS_SHOW_SYMBOL_TABLE_H #define CPROVER_GOTO_PROGRAMS_SHOW_SYMBOL_TABLE_H diff --git a/src/goto-programs/slice_global_inits.cpp b/src/goto-programs/slice_global_inits.cpp index 5e58888d366..5496a8266a3 100644 --- a/src/goto-programs/slice_global_inits.cpp +++ b/src/goto-programs/slice_global_inits.cpp @@ -8,6 +8,9 @@ Date: December 2016 \*******************************************************************/ +/// \file +/// Remove initializations of unused global variables + #include #include @@ -22,18 +25,6 @@ Date: December 2016 #include "slice_global_inits.h" -/*******************************************************************\ - -Function: slice_global_inits - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void slice_global_inits( const namespacet &ns, goto_functionst &goto_functions) diff --git a/src/goto-programs/slice_global_inits.h b/src/goto-programs/slice_global_inits.h index 7907c31c49b..25a96121961 100644 --- a/src/goto-programs/slice_global_inits.h +++ b/src/goto-programs/slice_global_inits.h @@ -8,6 +8,9 @@ Date: December 2016 \*******************************************************************/ +/// \file +/// Remove initializations of unused global variables + #ifndef CPROVER_GOTO_PROGRAMS_SLICE_GLOBAL_INITS_H #define CPROVER_GOTO_PROGRAMS_SLICE_GLOBAL_INITS_H diff --git a/src/goto-programs/string_abstraction.cpp b/src/goto-programs/string_abstraction.cpp index 5c7a1868578..1e4f110a1f6 100644 --- a/src/goto-programs/string_abstraction.cpp +++ b/src/goto-programs/string_abstraction.cpp @@ -6,31 +6,23 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// String Abstraction + #include +#include #include #include #include #include #include -#include +#include #include "pointer_arithmetic.h" #include "string_abstraction.h" -/*******************************************************************\ - -Function: string_abstractiont::build_wrap - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool string_abstractiont::build_wrap( const exprt &object, exprt &dest, bool write) @@ -60,18 +52,6 @@ bool string_abstractiont::build_wrap( return false; } -/*******************************************************************\ - -Function: string_abstractiont::is_ptr_string_struct - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool string_abstractiont::is_ptr_string_struct(const typet &type) const { return type.id()==ID_pointer && @@ -83,18 +63,6 @@ static inline bool is_ptr_argument(const typet &type) return type.id()==ID_pointer; } -/*******************************************************************\ - -Function: string_abstraction - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_abstraction( symbol_tablet &symbol_table, message_handlert &message_handler, @@ -104,18 +72,6 @@ void string_abstraction( string_abstraction(dest); } -/*******************************************************************\ - -Function: string_abstraction - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_abstraction( symbol_tablet &symbol_table, message_handlert &message_handler, @@ -125,18 +81,6 @@ void string_abstraction( string_abstraction(dest); } -/*******************************************************************\ - -Function: string_abstractiont::string_abstractiont - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - string_abstractiont::string_abstractiont( symbol_tablet &_symbol_table, message_handlert &_message_handler): @@ -166,18 +110,6 @@ string_abstractiont::string_abstractiont( string_struct=s; } -/*******************************************************************\ - -Function: string_abstractiont::build_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet string_abstractiont::build_type(whatt what) { typet type; @@ -192,18 +124,6 @@ typet string_abstractiont::build_type(whatt what) return type; } -/*******************************************************************\ - -Function: string_abstractiont::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_abstractiont::operator()(goto_functionst &dest) { Forall_goto_functions(it, dest) @@ -229,18 +149,6 @@ void string_abstractiont::operator()(goto_functionst &dest) } } -/*******************************************************************\ - -Function: string_abstractiont::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_abstractiont::operator()(goto_programt &dest) { abstract(dest); @@ -251,18 +159,6 @@ void string_abstractiont::operator()(goto_programt &dest) initialization.clear(); } -/*******************************************************************\ - -Function: string_abstractiont::add_str_arguments - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_abstractiont::add_str_arguments( const irep_idt &name, goto_functionst::goto_functiont &fct) @@ -302,18 +198,6 @@ void string_abstractiont::add_str_arguments( symb_parameters.end(), str_args.begin(), str_args.end()); } -/*******************************************************************\ - -Function: string_abstractiont::add_argument - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_abstractiont::add_argument( code_typet::parameterst &str_args, const symbolt &fct_symbol, @@ -342,18 +226,6 @@ void string_abstractiont::add_argument( symbol_table.move(new_symbol); } -/*******************************************************************\ - -Function: string_abstractiont::abstract - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_abstractiont::abstract(goto_programt &dest) { locals.clear(); @@ -369,18 +241,6 @@ void string_abstractiont::abstract(goto_programt &dest) locals.clear(); } -/*******************************************************************\ - -Function: string_abstractiont::declare_define_locals - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_abstractiont::declare_define_locals(goto_programt &dest) { typedef std::unordered_map @@ -417,18 +277,6 @@ void string_abstractiont::declare_define_locals(goto_programt &dest) } } -/*******************************************************************\ - -Function: string_abstractiont::make_decl_and_def - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_abstractiont::make_decl_and_def(goto_programt &dest, goto_programt::targett ref_instr, const irep_idt &identifier, @@ -464,18 +312,6 @@ void string_abstractiont::make_decl_and_def(goto_programt &dest, } } -/*******************************************************************\ - -Function: string_abstractiont::make_val_or_dummy_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt string_abstractiont::make_val_or_dummy_rec(goto_programt &dest, goto_programt::targett ref_instr, const symbolt &symbol, const typet &source_type) @@ -545,18 +381,6 @@ exprt string_abstractiont::make_val_or_dummy_rec(goto_programt &dest, return nil_exprt(); } -/*******************************************************************\ - -Function: string_abstractiont::add_dummy_symbol_and_value - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - symbol_exprt string_abstractiont::add_dummy_symbol_and_value( goto_programt &dest, goto_programt::targett ref_instr, @@ -623,18 +447,6 @@ symbol_exprt string_abstractiont::add_dummy_symbol_and_value( return sym_expr; } -/*******************************************************************\ - -Function: string_abstractiont::abstract - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - goto_programt::targett string_abstractiont::abstract( goto_programt &dest, goto_programt::targett it) @@ -682,18 +494,6 @@ goto_programt::targett string_abstractiont::abstract( return it; } -/*******************************************************************\ - -Function: string_abstractiont::abstract_assign - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - goto_programt::targett string_abstractiont::abstract_assign( goto_programt &dest, goto_programt::targett target) @@ -721,18 +521,6 @@ goto_programt::targett string_abstractiont::abstract_assign( return target; } -/*******************************************************************\ - -Function: string_abstractiont::abstract_function_call - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_abstractiont::abstract_function_call( goto_programt &dest, goto_programt::targett target) @@ -786,18 +574,6 @@ void string_abstractiont::abstract_function_call( arguments.insert(arguments.end(), str_args.begin(), str_args.end()); } -/*******************************************************************\ - -Function: string_abstractiont::has_string_macros - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool string_abstractiont::has_string_macros(const exprt &expr) { if(expr.id()=="is_zero_string" || @@ -812,18 +588,6 @@ bool string_abstractiont::has_string_macros(const exprt &expr) return false; } -/*******************************************************************\ - -Function: string_abstractiont::replace_string_macros - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_abstractiont::replace_string_macros( exprt &expr, bool lhs, @@ -852,18 +616,6 @@ void string_abstractiont::replace_string_macros( replace_string_macros(*it, lhs, source_location); } -/*******************************************************************\ - -Function: string_abstractiont::build - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt string_abstractiont::build( const exprt &pointer, whatt what, @@ -891,28 +643,13 @@ exprt string_abstractiont::build( if(what==whatt::LENGTH || what==whatt::SIZE) { // adjust for offset - exprt pointer_offset(ID_pointer_offset, size_type()); - pointer_offset.copy_to_operands(pointer); - if(pointer_offset.is_not_nil() && - !pointer_offset.is_zero()) - result=minus_exprt(result, pointer_offset); + result=minus_exprt(result, pointer_offset(pointer)); + result.op0().make_typecast(result.op1().type()); } return result; } -/*******************************************************************\ - -Function: string_abstractiont::build_abstraction_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const typet &string_abstractiont::build_abstraction_type(const typet &type) { const typet &eff_type=ns.follow(type); @@ -932,18 +669,6 @@ const typet &string_abstractiont::build_abstraction_type(const typet &type) std::make_pair(eff_type, map_entry->second)).first->second; } -/*******************************************************************\ - -Function: string_abstractiont::build_abstraction_type_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const typet &string_abstractiont::build_abstraction_type_rec(const typet &type, const abstraction_types_mapt &known) { @@ -1008,18 +733,6 @@ const typet &string_abstractiont::build_abstraction_type_rec(const typet &type, return map_entry.first->second; } -/*******************************************************************\ - -Function: string_abstractiont::build - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool string_abstractiont::build(const exprt &object, exprt &dest, bool write) { const typet &abstract_type=build_abstraction_type(object.type()); @@ -1084,18 +797,6 @@ bool string_abstractiont::build(const exprt &object, exprt &dest, bool write) return true; } -/*******************************************************************\ - -Function: string_abstractiont::build_if - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool string_abstractiont::build_if(const if_exprt &o_if, exprt &dest, bool write) { @@ -1124,18 +825,6 @@ bool string_abstractiont::build_if(const if_exprt &o_if, return false; } -/*******************************************************************\ - -Function: string_abstractiont::build_array - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool string_abstractiont::build_array(const array_exprt &object, exprt &dest, bool write) { @@ -1160,18 +849,6 @@ bool string_abstractiont::build_array(const array_exprt &object, return true; } -/*******************************************************************\ - -Function: string_abstractiont::build_pointer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool string_abstractiont::build_pointer(const exprt &object, exprt &dest, bool write) { @@ -1204,18 +881,6 @@ bool string_abstractiont::build_pointer(const exprt &object, return true; } -/*******************************************************************\ - -Function: string_abstractiont::build_unknown - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt string_abstractiont::build_unknown(whatt what, bool write) { typet type=build_type(what); @@ -1240,18 +905,6 @@ exprt string_abstractiont::build_unknown(whatt what, bool write) return result; } -/*******************************************************************\ - -Function: string_abstractiont::build_unknown - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt string_abstractiont::build_unknown(const typet &type, bool write) { if(write) @@ -1279,18 +932,6 @@ exprt string_abstractiont::build_unknown(const typet &type, bool write) return ns.lookup(identifier).symbol_expr(); } -/*******************************************************************\ - -Function: string_abstractiont::build_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool string_abstractiont::build_symbol(const symbol_exprt &sym, exprt &dest) { const symbolt &symbol=ns.lookup(sym.get_identifier()); @@ -1318,18 +959,6 @@ bool string_abstractiont::build_symbol(const symbol_exprt &sym, exprt &dest) return false; } -/*******************************************************************\ - -Function: string_abstractiont::build_new_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_abstractiont::build_new_symbol(const symbolt &symbol, const irep_idt &identifier, const typet &type) { @@ -1361,18 +990,6 @@ void string_abstractiont::build_new_symbol(const symbolt &symbol, } } -/*******************************************************************\ - -Function: string_abstractiont::build_symbol_constant - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool string_abstractiont::build_symbol_constant( const mp_integer &zero_length, const mp_integer &buf_size, @@ -1418,18 +1035,6 @@ bool string_abstractiont::build_symbol_constant( return false; } -/*******************************************************************\ - -Function: string_abstractiont::move_lhs_arithmetic - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_abstractiont::move_lhs_arithmetic(exprt &lhs, exprt &rhs) { if(lhs.id()==ID_minus) @@ -1442,18 +1047,6 @@ void string_abstractiont::move_lhs_arithmetic(exprt &lhs, exprt &rhs) } } -/*******************************************************************\ - -Function: string_abstractiont::abstract_pointer_assign - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - goto_programt::targett string_abstractiont::abstract_pointer_assign( goto_programt &dest, goto_programt::targett target) @@ -1499,18 +1092,6 @@ goto_programt::targett string_abstractiont::abstract_pointer_assign( } } -/*******************************************************************\ - -Function: string_abstractiont::abstract_char_assign - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - goto_programt::targett string_abstractiont::abstract_char_assign( goto_programt &dest, goto_programt::targett target) @@ -1572,18 +1153,6 @@ goto_programt::targett string_abstractiont::abstract_char_assign( return target; } -/*******************************************************************\ - -Function: string_abstractiont::char_assign - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - goto_programt::targett string_abstractiont::char_assign( goto_programt &dest, goto_programt::targett target, @@ -1621,18 +1190,6 @@ goto_programt::targett string_abstractiont::char_assign( return target; } -/*******************************************************************\ - -Function: string_abstractiont::value_assignments - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - goto_programt::targett string_abstractiont::value_assignments( goto_programt &dest, goto_programt::targett target, @@ -1680,18 +1237,6 @@ goto_programt::targett string_abstractiont::value_assignments( return target; } -/*******************************************************************\ - -Function: string_abstractiont::value_assignments_if - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - goto_programt::targett string_abstractiont::value_assignments_if( goto_programt &dest, goto_programt::targett target, @@ -1730,18 +1275,6 @@ goto_programt::targett string_abstractiont::value_assignments_if( return last; } -/*******************************************************************\ - -Function: string_abstractiont::value_assignments_string_struct - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - goto_programt::targett string_abstractiont::value_assignments_string_struct( goto_programt &dest, goto_programt::targett target, @@ -1788,18 +1321,6 @@ goto_programt::targett string_abstractiont::value_assignments_string_struct( return last; } -/*******************************************************************\ - -Function: string_abstractiont::member - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt string_abstractiont::member(const exprt &a, whatt what) { if(a.is_nil()) diff --git a/src/goto-programs/string_abstraction.h b/src/goto-programs/string_abstraction.h index ebc716accc3..9443b09d68b 100644 --- a/src/goto-programs/string_abstraction.h +++ b/src/goto-programs/string_abstraction.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// String Abstraction + #ifndef CPROVER_GOTO_PROGRAMS_STRING_ABSTRACTION_H #define CPROVER_GOTO_PROGRAMS_STRING_ABSTRACTION_H @@ -16,14 +19,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_functions.h" -/*******************************************************************\ - - Class: string_abstractiont - - Purpose: - -\*******************************************************************/ - class string_abstractiont:public messaget { public: diff --git a/src/goto-programs/string_instrumentation.cpp b/src/goto-programs/string_instrumentation.cpp index 5a6596a97cd..a1147303308 100644 --- a/src/goto-programs/string_instrumentation.cpp +++ b/src/goto-programs/string_instrumentation.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// String Abstraction + #include #include @@ -16,22 +19,10 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -#include +#include #include "string_instrumentation.h" -/*******************************************************************\ - -Function: is_zero_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt is_zero_string( const exprt &what, bool write) @@ -42,18 +33,6 @@ exprt is_zero_string( return result; } -/*******************************************************************\ - -Function: zero_string_length - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt zero_string_length( const exprt &what, bool write) @@ -64,18 +43,6 @@ exprt zero_string_length( return result; } -/*******************************************************************\ - -Function: buffer_size - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt buffer_size(const exprt &what) { exprt result("buffer_size", size_type()); @@ -83,18 +50,6 @@ exprt buffer_size(const exprt &what) return result; } -/*******************************************************************\ - - Class: string_instrumentationt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - class string_instrumentationt:public messaget { public: @@ -197,18 +152,6 @@ class string_instrumentationt:public messaget const mp_integer &limit); }; -/*******************************************************************\ - -Function: string_instrumentation - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_instrumentation( symbol_tablet &symbol_table, message_handlert &message_handler, @@ -218,18 +161,6 @@ void string_instrumentation( string_instrumentation(dest); } -/*******************************************************************\ - -Function: string_instrumentation - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_instrumentation( symbol_tablet &symbol_table, message_handlert &message_handler, @@ -239,18 +170,6 @@ void string_instrumentation( string_instrumentation(dest); } -/*******************************************************************\ - -Function: string_instrumentationt::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_instrumentationt::operator()(goto_functionst &dest) { for(goto_functionst::function_mapt::iterator @@ -262,36 +181,12 @@ void string_instrumentationt::operator()(goto_functionst &dest) } } -/*******************************************************************\ - -Function: string_instrumentationt::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_instrumentationt::operator()(goto_programt &dest) { Forall_goto_program_instructions(it, dest) instrument(dest, it); } -/*******************************************************************\ - -Function: string_instrumentationt::instrument - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_instrumentationt::instrument( goto_programt &dest, goto_programt::targett it) @@ -311,18 +206,6 @@ void string_instrumentationt::instrument( } } -/*******************************************************************\ - -Function: string_instrumentationt::do_function_call - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_instrumentationt::do_function_call( goto_programt &dest, goto_programt::targett target) @@ -375,18 +258,6 @@ void string_instrumentationt::do_function_call( } } -/*******************************************************************\ - -Function: string_instrumentationt::do_sprintf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_instrumentationt::do_sprintf( goto_programt &dest, goto_programt::targett target, @@ -429,18 +300,6 @@ void string_instrumentationt::do_sprintf( dest.insert_before_swap(target, tmp); } -/*******************************************************************\ - -Function: string_instrumentationt::do_snprintf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_instrumentationt::do_snprintf( goto_programt &dest, goto_programt::targett target, @@ -484,18 +343,6 @@ void string_instrumentationt::do_snprintf( dest.insert_before_swap(target, tmp); } -/*******************************************************************\ - -Function: string_instrumentationt::do_fscanf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_instrumentationt::do_fscanf( goto_programt &dest, goto_programt::targett target, @@ -529,18 +376,6 @@ void string_instrumentationt::do_fscanf( dest.insert_before_swap(target, tmp); } -/*******************************************************************\ - -Function: string_instrumentationt::do_format_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_instrumentationt::do_format_string_read( goto_programt &dest, goto_programt::const_targett target, @@ -644,18 +479,6 @@ void string_instrumentationt::do_format_string_read( } } -/*******************************************************************\ - -Function: string_instrumentationt::do_format_string_write - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_instrumentationt::do_format_string_write( goto_programt &dest, goto_programt::const_targett target, @@ -806,18 +629,6 @@ void string_instrumentationt::do_format_string_write( } } -/*******************************************************************\ - -Function: string_instrumentationt::do_strncmp - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_instrumentationt::do_strncmp( goto_programt &dest, goto_programt::targett target, @@ -825,18 +636,6 @@ void string_instrumentationt::do_strncmp( { } -/*******************************************************************\ - -Function: string_instrumentationt::do_strchr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_instrumentationt::do_strchr( goto_programt &dest, goto_programt::targett target, @@ -864,18 +663,6 @@ void string_instrumentationt::do_strchr( dest.insert_before_swap(target, tmp); } -/*******************************************************************\ - -Function: string_instrumentationt::do_strrchr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_instrumentationt::do_strrchr( goto_programt &dest, goto_programt::targett target, @@ -903,18 +690,6 @@ void string_instrumentationt::do_strrchr( dest.insert_before_swap(target, tmp); } -/*******************************************************************\ - -Function: string_instrumentationt::do_strstr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_instrumentationt::do_strstr( goto_programt &dest, goto_programt::targett target, @@ -949,18 +724,6 @@ void string_instrumentationt::do_strstr( dest.insert_before_swap(target, tmp); } -/*******************************************************************\ - -Function: string_instrumentationt::do_strtok - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_instrumentationt::do_strtok( goto_programt &dest, goto_programt::targett target, @@ -995,18 +758,6 @@ void string_instrumentationt::do_strtok( dest.insert_before_swap(target, tmp); } -/*******************************************************************\ - -Function: string_instrumentationt::do_strerror - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_instrumentationt::do_strerror( goto_programt &dest, goto_programt::targett it, @@ -1103,18 +854,6 @@ void string_instrumentationt::do_strerror( dest.insert_before_swap(it, tmp); } -/*******************************************************************\ - -Function: string_instrumentationt::invalidate_buffer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void string_instrumentationt::invalidate_buffer( goto_programt &dest, goto_programt::const_targett target, diff --git a/src/goto-programs/string_instrumentation.h b/src/goto-programs/string_instrumentation.h index cd52bb54a84..261b8dcdb1f 100644 --- a/src/goto-programs/string_instrumentation.h +++ b/src/goto-programs/string_instrumentation.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// String Abstraction + #ifndef CPROVER_GOTO_PROGRAMS_STRING_INSTRUMENTATION_H #define CPROVER_GOTO_PROGRAMS_STRING_INSTRUMENTATION_H diff --git a/src/goto-programs/system_library_symbols.cpp b/src/goto-programs/system_library_symbols.cpp index 250eb3b1cdb..91e099b170d 100644 --- a/src/goto-programs/system_library_symbols.cpp +++ b/src/goto-programs/system_library_symbols.cpp @@ -6,6 +6,9 @@ Author: Thomas Kiley \*******************************************************************/ +/// \file +/// Goto Programs + #include "system_library_symbols.h" #include #include @@ -17,20 +20,9 @@ system_library_symbolst::system_library_symbolst() init_system_library_map(); } -/*******************************************************************\ - -Function: system_library_symbolst::init_system_library_map - -Inputs: - -Outputs: - -Purpose: To generate a map of header file names -> list of symbols - The symbol names are reserved as the header and source files - will be compiled in to the goto program. - -\*******************************************************************/ - +/// To generate a map of header file names -> list of symbols The symbol names +/// are reserved as the header and source files will be compiled in to the goto +/// program. void system_library_symbolst::init_system_library_map() { // ctype.h @@ -240,22 +232,10 @@ void system_library_symbolst::init_system_library_map() add_to_system_library("sys/wait.h", sys_wait_syms); } -/*******************************************************************\ - -Function: system_library_symbolst::add_to_system_library - -Inputs: - header_file - the name of the header file the symbol came from - symbols - a list of the names of the symbols in the header file - -Outputs: - -Purpose: To add the symbols from a specific header file to the - system library map. The symbol is used as the key so that - we can easily look up symbols. - -\*******************************************************************/ - +/// To add the symbols from a specific header file to the system library map. +/// The symbol is used as the key so that we can easily look up symbols. +/// \param header_file: the name of the header file the symbol came from +/// \param symbols: a list of the names of the symbols in the header file void system_library_symbolst::add_to_system_library( irep_idt header_file, std::list symbols) @@ -267,21 +247,10 @@ void system_library_symbolst::add_to_system_library( } -/*******************************************************************\ - -Function: system_library_symbolst::is_symbol_internal_symbol - -Inputs: - symbol - the symbol to check - -Outputs: True if the symbol is an internal symbol. If specific system - headers need to be included, the out_system_headers will contain - the headers. - -Purpose: To find out if a symbol is an internal symbol. - -\*******************************************************************/ - +/// To find out if a symbol is an internal symbol. +/// \param symbol: the symbol to check +/// \return True if the symbol is an internal symbol. If specific system headers +/// need to be included, the out_system_headers will contain the headers. bool system_library_symbolst::is_symbol_internal_symbol( const symbolt &symbol, std::set &out_system_headers) const diff --git a/src/goto-programs/system_library_symbols.h b/src/goto-programs/system_library_symbols.h index 9438e052a76..f5236314f21 100644 --- a/src/goto-programs/system_library_symbols.h +++ b/src/goto-programs/system_library_symbols.h @@ -6,6 +6,9 @@ Author: Thomas Kiley \*******************************************************************/ +/// \file +/// Goto Programs + #ifndef CPROVER_GOTO_PROGRAMS_SYSTEM_LIBRARY_SYMBOLS_H #define CPROVER_GOTO_PROGRAMS_SYSTEM_LIBRARY_SYMBOLS_H diff --git a/src/goto-programs/vcd_goto_trace.cpp b/src/goto-programs/vcd_goto_trace.cpp index 9a3bbf443f7..d6c39603cc4 100644 --- a/src/goto-programs/vcd_goto_trace.cpp +++ b/src/goto-programs/vcd_goto_trace.cpp @@ -8,6 +8,9 @@ Date: June 2011 \*******************************************************************/ +/// \file +/// Traces of GOTO Programs in VCD (Value Change Dump) Format + #include #include #include @@ -18,18 +21,6 @@ Date: June 2011 #include "vcd_goto_trace.h" -/*******************************************************************\ - -Function: output_vcd - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string as_vcd_binary( const exprt &expr, const namespacet &ns) @@ -90,18 +81,6 @@ std::string as_vcd_binary( return ""; } -/*******************************************************************\ - -Function: output_vcd - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void output_vcd( const namespacet &ns, const goto_tracet &goto_trace, diff --git a/src/goto-programs/vcd_goto_trace.h b/src/goto-programs/vcd_goto_trace.h index 5b9a3680cb6..0f7990b92bd 100644 --- a/src/goto-programs/vcd_goto_trace.h +++ b/src/goto-programs/vcd_goto_trace.h @@ -8,6 +8,9 @@ Date: June 2011 \*******************************************************************/ +/// \file +/// Traces of GOTO Programs in VCD (Value Change Dump) Format + #ifndef CPROVER_GOTO_PROGRAMS_VCD_GOTO_TRACE_H #define CPROVER_GOTO_PROGRAMS_VCD_GOTO_TRACE_H diff --git a/src/goto-programs/wp.cpp b/src/goto-programs/wp.cpp index 4290734e2f5..ea6ddd6a286 100644 --- a/src/goto-programs/wp.cpp +++ b/src/goto-programs/wp.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Weakest Preconditions + // #include #include @@ -14,18 +17,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "wp.h" -/*******************************************************************\ - -Function: has_nondet - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool has_nondet(const exprt &dest) { forall_operands(it, dest) @@ -44,18 +35,6 @@ bool has_nondet(const exprt &dest) return false; } -/*******************************************************************\ - -Function: approximate_nondet_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void approximate_nondet_rec(exprt &dest, unsigned &count) { if(dest.id()==ID_side_effect && @@ -71,36 +50,13 @@ void approximate_nondet_rec(exprt &dest, unsigned &count) approximate_nondet_rec(*it, count); } -/*******************************************************************\ - -Function: approximate_nondet - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void approximate_nondet(exprt &dest) { static unsigned count=0; // not proper, should be quantified approximate_nondet_rec(dest, count); } -/*******************************************************************\ - -Function: aliasing - - Inputs: - - Outputs: - - Purpose: consider possible aliasing - -\*******************************************************************/ - +/// consider possible aliasing enum class aliasingt { A_MAY, A_MUST, A_MUSTNOT }; aliasingt aliasing( @@ -155,19 +111,7 @@ aliasingt aliasing( return aliasingt::A_MAY; } -/*******************************************************************\ - -Function: substitute_rec - - Inputs: - - Outputs: - - Purpose: replace 'what' by 'by' in 'dest', - considering possible aliasing - -\*******************************************************************/ - +/// replace 'what' by 'by' in 'dest', considering possible aliasing void substitute_rec( exprt &dest, const exprt &what, @@ -217,18 +161,6 @@ void substitute_rec( } } -/*******************************************************************\ - -Function: rewrite_assignment - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rewrite_assignment(exprt &lhs, exprt &rhs) { if(lhs.id()==ID_member) // turn s.x:=e into s:=(s with .x=e) @@ -267,18 +199,6 @@ void rewrite_assignment(exprt &lhs, exprt &rhs) } } -/*******************************************************************\ - -Function: wp_assign - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt wp_assign( const code_assignt &code, const exprt &post, @@ -300,18 +220,6 @@ exprt wp_assign( return pre; } -/*******************************************************************\ - -Function: wp_assume - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt wp_assume( const code_assumet &code, const exprt &post, @@ -320,18 +228,6 @@ exprt wp_assume( return implies_exprt(code.assumption(), post); } -/*******************************************************************\ - -Function: wp_decl - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt wp_decl( const code_declt &code, const exprt &post, @@ -345,18 +241,6 @@ exprt wp_decl( return wp_assign(assignment, post, ns); } -/*******************************************************************\ - -Function: wp - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt wp( const codet &code, const exprt &post, diff --git a/src/goto-programs/wp.h b/src/goto-programs/wp.h index 741298b9507..836832efbc1 100644 --- a/src/goto-programs/wp.h +++ b/src/goto-programs/wp.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Weakest Preconditions + #ifndef CPROVER_GOTO_PROGRAMS_WP_H #define CPROVER_GOTO_PROGRAMS_WP_H diff --git a/src/goto-programs/write_goto_binary.cpp b/src/goto-programs/write_goto_binary.cpp index f5649e992d3..045aa9984fa 100644 --- a/src/goto-programs/write_goto_binary.cpp +++ b/src/goto-programs/write_goto_binary.cpp @@ -6,6 +6,9 @@ Author: CM Wintersteiger \*******************************************************************/ +/// \file +/// Write GOTO binaries + #include #include @@ -14,18 +17,7 @@ Author: CM Wintersteiger #include "write_goto_binary.h" -/*******************************************************************\ - -Function: goto_programt::write_goto_binary_v3 - - Inputs: - - Outputs: - - Purpose: Writes a goto program to disc, using goto binary format ver 2 - -\*******************************************************************/ - +/// Writes a goto program to disc, using goto binary format ver 2 bool write_goto_binary_v3( std::ostream &out, const symbol_tablet &lsymbol_table, @@ -127,18 +119,7 @@ bool write_goto_binary_v3( return false; } -/*******************************************************************\ - -Function: goto_programt::write_goto_binary - - Inputs: - - Outputs: - - Purpose: Writes a goto program to disc - -\*******************************************************************/ - +/// Writes a goto program to disc bool write_goto_binary( std::ostream &out, const symbol_tablet &lsymbol_table, @@ -172,18 +153,7 @@ bool write_goto_binary( return false; } -/*******************************************************************\ - -Function: goto_programt::write_goto_binary - - Inputs: - - Outputs: - - Purpose: Writes a goto program to disc - -\*******************************************************************/ - +/// Writes a goto program to disc bool write_goto_binary( const std::string &filename, const symbol_tablet &symbol_table, diff --git a/src/goto-programs/write_goto_binary.h b/src/goto-programs/write_goto_binary.h index 5b5f0aef18c..fd3acd9cb77 100644 --- a/src/goto-programs/write_goto_binary.h +++ b/src/goto-programs/write_goto_binary.h @@ -6,6 +6,9 @@ Author: CM Wintersteiger \*******************************************************************/ +/// \file +/// Write GOTO binaries + #ifndef CPROVER_GOTO_PROGRAMS_WRITE_GOTO_BINARY_H #define CPROVER_GOTO_PROGRAMS_WRITE_GOTO_BINARY_H diff --git a/src/goto-programs/xml_goto_trace.cpp b/src/goto-programs/xml_goto_trace.cpp index 8b1bdb0e885..25e61157e9d 100644 --- a/src/goto-programs/xml_goto_trace.cpp +++ b/src/goto-programs/xml_goto_trace.cpp @@ -8,6 +8,9 @@ Author: Daniel Kroening \*******************************************************************/ +/// \file +/// Traces of GOTO Programs + #include #include @@ -18,18 +21,6 @@ Author: Daniel Kroening #include "xml_goto_trace.h" -/*******************************************************************\ - -Function: convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void convert( const namespacet &ns, const goto_tracet &goto_trace, diff --git a/src/goto-programs/xml_goto_trace.h b/src/goto-programs/xml_goto_trace.h index 123e0d69877..ce77b09c450 100644 --- a/src/goto-programs/xml_goto_trace.h +++ b/src/goto-programs/xml_goto_trace.h @@ -8,6 +8,9 @@ Date: November 2005 \*******************************************************************/ +/// \file +/// Traces of GOTO Programs + #ifndef CPROVER_GOTO_PROGRAMS_XML_GOTO_TRACE_H #define CPROVER_GOTO_PROGRAMS_XML_GOTO_TRACE_H diff --git a/src/goto-symex/adjust_float_expressions.cpp b/src/goto-symex/adjust_float_expressions.cpp index 46dee137447..67eb4a06b56 100644 --- a/src/goto-symex/adjust_float_expressions.cpp +++ b/src/goto-symex/adjust_float_expressions.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbolic Execution + #include #include #include @@ -17,18 +20,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "adjust_float_expressions.h" -/*******************************************************************\ - -Function: have_to_adjust_float_expressions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static bool have_to_adjust_float_expressions( const exprt &expr, const namespacet &ns) @@ -84,19 +75,8 @@ static bool have_to_adjust_float_expressions( return false; } -/*******************************************************************\ - -Function: adjust_float_expressions - - Inputs: - - Outputs: - - Purpose: This adds the rounding mode to floating-point operations, - including those in vectors and complex numbers. - -\*******************************************************************/ - +/// This adds the rounding mode to floating-point operations, including those in +/// vectors and complex numbers. void adjust_float_expressions( exprt &expr, const namespacet &ns) @@ -199,18 +179,6 @@ void adjust_float_expressions( } } -/*******************************************************************\ - -Function: adjust_float_expressions - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - static void adjust_float_expressions( goto_functionst::goto_functiont &goto_function, const namespacet &ns) @@ -222,18 +190,6 @@ static void adjust_float_expressions( } } -/*******************************************************************\ - -Function: adjust_float_expressions - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void adjust_float_expressions( goto_functionst &goto_functions, const namespacet &ns) @@ -242,18 +198,6 @@ void adjust_float_expressions( adjust_float_expressions(it->second, ns); } -/*******************************************************************\ - -Function: adjust_float_expressions - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void adjust_float_expressions(goto_modelt &goto_model) { namespacet ns(goto_model.symbol_table); diff --git a/src/goto-symex/adjust_float_expressions.h b/src/goto-symex/adjust_float_expressions.h index f8547c59fa8..5cfd01d740f 100644 --- a/src/goto-symex/adjust_float_expressions.h +++ b/src/goto-symex/adjust_float_expressions.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbolic Execution + #ifndef CPROVER_GOTO_SYMEX_ADJUST_FLOAT_EXPRESSIONS_H #define CPROVER_GOTO_SYMEX_ADJUST_FLOAT_EXPRESSIONS_H diff --git a/src/goto-symex/auto_objects.cpp b/src/goto-symex/auto_objects.cpp index 1b3e6f2d636..dab9cdfa9b3 100644 --- a/src/goto-symex/auto_objects.cpp +++ b/src/goto-symex/auto_objects.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbolic Execution of ANSI-C + #include #include #include @@ -13,18 +16,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_symex.h" -/*******************************************************************\ - -Function: goto_symext::make_auto_object - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt goto_symext::make_auto_object(const typet &type) { dynamic_counter++; @@ -43,18 +34,6 @@ exprt goto_symext::make_auto_object(const typet &type) return symbol_exprt(symbol.name, symbol.type); } -/*******************************************************************\ - -Function: goto_symext::initialize_auto_object - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::initialize_auto_object( const exprt &expr, statet &state) @@ -101,18 +80,6 @@ void goto_symext::initialize_auto_object( } } -/*******************************************************************\ - -Function: goto_symext::trigger_auto_object - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::trigger_auto_object( const exprt &expr, statet &state) diff --git a/src/goto-symex/build_goto_trace.cpp b/src/goto-symex/build_goto_trace.cpp index d5c7b62c60a..6139c4dcdab 100644 --- a/src/goto-symex/build_goto_trace.cpp +++ b/src/goto-symex/build_goto_trace.cpp @@ -8,6 +8,9 @@ Author: Daniel Kroening \*******************************************************************/ +/// \file +/// Traces of GOTO Programs + #include #include @@ -21,18 +24,6 @@ Author: Daniel Kroening #include "build_goto_trace.h" -/*******************************************************************\ - -Function: build_full_lhs_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt build_full_lhs_rec( const prop_convt &prop_conv, const namespacet &ns, @@ -110,18 +101,6 @@ exprt build_full_lhs_rec( return src_original; } -/*******************************************************************\ - -Function: adjust_lhs_object - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt adjust_lhs_object( const prop_convt &prop_conv, const namespacet &ns, @@ -130,19 +109,8 @@ exprt adjust_lhs_object( return nil_exprt(); } -/*******************************************************************\ - -Function: set_internal_dynamic_object - - Inputs: - - Outputs: - - Purpose: set internal field for variable assignment related to - dynamic_object[0-9] and dynamic_[0-9]_array. - -\*******************************************************************/ - +/// set internal field for variable assignment related to dynamic_object[0-9] +/// and dynamic_[0-9]_array. void set_internal_dynamic_object( const exprt &expr, goto_trace_stept &goto_trace_step, @@ -166,20 +134,8 @@ void set_internal_dynamic_object( } } -/*******************************************************************\ - -Function: update_internal_field - - Inputs: - - Outputs: - - Purpose: set internal for variables assignments related to - dynamic_object and CPROVER internal functions - (e.g., __CPROVER_initialize) - -\*******************************************************************/ - +/// set internal for variables assignments related to dynamic_object and CPROVER +/// internal functions (e.g., __CPROVER_initialize) void update_internal_field( const symex_target_equationt::SSA_stept &SSA_step, goto_trace_stept &goto_trace_step, @@ -214,18 +170,6 @@ void update_internal_field( } } -/*******************************************************************\ - -Function: build_goto_trace - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void build_goto_trace( const symex_target_equationt &target, symex_target_equationt::SSA_stepst::const_iterator end_step, @@ -403,18 +347,6 @@ void build_goto_trace( s_it.step_nr=++step_nr; } -/*******************************************************************\ - -Function: build_goto_trace - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void build_goto_trace( const symex_target_equationt &target, const prop_convt &prop_conv, diff --git a/src/goto-symex/build_goto_trace.h b/src/goto-symex/build_goto_trace.h index f7350d41ffe..16df35f7e7e 100644 --- a/src/goto-symex/build_goto_trace.h +++ b/src/goto-symex/build_goto_trace.h @@ -8,6 +8,9 @@ Date: July 2005 \*******************************************************************/ +/// \file +/// Traces of GOTO Programs + #ifndef CPROVER_GOTO_SYMEX_BUILD_GOTO_TRACE_H #define CPROVER_GOTO_SYMEX_BUILD_GOTO_TRACE_H diff --git a/src/goto-symex/goto_symex.cpp b/src/goto-symex/goto_symex.cpp index a3d55220e8d..0ed472967c1 100644 --- a/src/goto-symex/goto_symex.cpp +++ b/src/goto-symex/goto_symex.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbolic Execution + #include #include "goto_symex.h" @@ -13,36 +16,12 @@ Author: Daniel Kroening, kroening@kroening.com unsigned goto_symext::nondet_count=0; unsigned goto_symext::dynamic_counter=0; -/*******************************************************************\ - -Function: goto_symext::do_simplify - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::do_simplify(exprt &expr) { if(options.get_bool_option("simplify")) simplify(expr, ns); } -/*******************************************************************\ - -Function: goto_symext::replace_nondet - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::replace_nondet(exprt &expr) { if(expr.id()==ID_side_effect && diff --git a/src/goto-symex/goto_symex.h b/src/goto-symex/goto_symex.h index f8c2cda0bf9..f45d722ebf7 100644 --- a/src/goto-symex/goto_symex.h +++ b/src/goto-symex/goto_symex.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbolic Execution + #ifndef CPROVER_GOTO_SYMEX_GOTO_SYMEX_H #define CPROVER_GOTO_SYMEX_GOTO_SYMEX_H diff --git a/src/goto-symex/goto_symex_state.cpp b/src/goto-symex/goto_symex_state.cpp index 7b9b206902b..d88e9c68bac 100644 --- a/src/goto-symex/goto_symex_state.cpp +++ b/src/goto-symex/goto_symex_state.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbolic Execution + #include #include #include @@ -17,18 +20,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_symex_state.h" -/*******************************************************************\ - -Function: goto_symex_statet::goto_symex_statet - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - goto_symex_statet::goto_symex_statet(): depth(0), symex_target(NULL), @@ -40,18 +31,6 @@ goto_symex_statet::goto_symex_statet(): new_frame(); } -/*******************************************************************\ - -Function: goto_symex_statet::initialize - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symex_statet::initialize(const goto_functionst &goto_functions) { goto_functionst::function_mapt::const_iterator it= @@ -67,18 +46,6 @@ void goto_symex_statet::initialize(const goto_functionst &goto_functions) top().calling_location.pc=top().end_of_function; } -/*******************************************************************\ - -Function: goto_symex_statet::level0t::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symex_statet::level0t::operator()( ssa_exprt &ssa_expr, const namespacet &ns, @@ -98,7 +65,7 @@ void goto_symex_statet::level0t::operator()( if(ns.lookup(obj_identifier, s)) { - std::cerr << "level0: failed to find " << obj_identifier << std::endl; + std::cerr << "level0: failed to find " << obj_identifier << '\n'; abort(); } @@ -111,18 +78,6 @@ void goto_symex_statet::level0t::operator()( ssa_expr.set_level_0(thread_nr); } -/*******************************************************************\ - -Function: goto_symex_statet::level1t::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symex_statet::level1t::operator()(ssa_exprt &ssa_expr) { // already renamed? @@ -139,19 +94,8 @@ void goto_symex_statet::level1t::operator()(ssa_exprt &ssa_expr) ssa_expr.set_level_1(it->second.second); } -/*******************************************************************\ - -Function: goto_symex_statet::constant_propagation - - Inputs: - - Outputs: - - Purpose: This function determines what expressions are to - be propagated as "constants" - -\*******************************************************************/ - +/// This function determines what expressions are to be propagated as +/// "constants" bool goto_symex_statet::constant_propagation(const exprt &expr) const { if(expr.is_constant()) @@ -240,19 +184,7 @@ bool goto_symex_statet::constant_propagation(const exprt &expr) const return false; } -/*******************************************************************\ - -Function: goto_symex_statet::constant_propagation_reference - - Inputs: - - Outputs: - - Purpose: this function determines which reference-typed - expressions are constant - -\*******************************************************************/ - +/// this function determines which reference-typed expressions are constant bool goto_symex_statet::constant_propagation_reference(const exprt &expr) const { if(expr.id()==ID_symbol) @@ -277,18 +209,7 @@ bool goto_symex_statet::constant_propagation_reference(const exprt &expr) const return false; } -/*******************************************************************\ - -Function: goto_symex_statet::assignment - - Inputs: - - Outputs: - - Purpose: write to a variable - -\*******************************************************************/ - +/// write to a variable static bool check_renaming(const exprt &expr); static bool check_renaming(const typet &type) @@ -375,7 +296,7 @@ static void assert_l1_renaming(const exprt &expr) #if 1 if(check_renaming_l1(expr)) { - std::cerr << expr.pretty() << std::endl; + std::cerr << expr.pretty() << '\n'; assert(false); } #else @@ -388,7 +309,7 @@ static void assert_l2_renaming(const exprt &expr) #if 1 if(check_renaming(expr)) { - std::cerr << expr.pretty() << std::endl; + std::cerr << expr.pretty() << '\n'; assert(false); } #else @@ -455,24 +376,12 @@ void goto_symex_statet::assignment( } #if 0 - std::cout << "Assigning " << l1_identifier << std::endl; + std::cout << "Assigning " << l1_identifier << '\n'; value_set.output(ns, std::cout); - std::cout << "**********************" << std::endl; + std::cout << "**********************\n"; #endif } -/*******************************************************************\ - -Function: goto_symex_statet::propagationt::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symex_statet::propagationt::operator()(exprt &expr) { if(expr.id()==ID_symbol) @@ -494,18 +403,6 @@ void goto_symex_statet::propagationt::operator()(exprt &expr) } } -/*******************************************************************\ - -Function: goto_symex_statet::set_ssa_indices - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symex_statet::set_ssa_indices( ssa_exprt &ssa_expr, const namespacet &ns, @@ -539,18 +436,6 @@ void goto_symex_statet::set_ssa_indices( } } -/*******************************************************************\ - -Function: goto_symex_statet::rename - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symex_statet::rename( exprt &expr, const namespacet &ns, @@ -642,18 +527,7 @@ void goto_symex_statet::rename( } } -/*******************************************************************\ - -Function: goto_symex_statet::l2_thread_read_encoding - - Inputs: - - Outputs: - - Purpose: thread encoding - -\*******************************************************************/ - +/// thread encoding bool goto_symex_statet::l2_thread_read_encoding( ssa_exprt &expr, const namespacet &ns) @@ -798,18 +672,7 @@ bool goto_symex_statet::l2_thread_read_encoding( return true; } -/*******************************************************************\ - -Function: goto_symex_statet::l2_thread_write_encoding - - Inputs: - - Outputs: - - Purpose: thread encoding - -\*******************************************************************/ - +/// thread encoding bool goto_symex_statet::l2_thread_write_encoding( const ssa_exprt &expr, const namespacet &ns) @@ -846,18 +709,6 @@ bool goto_symex_statet::l2_thread_write_encoding( return threads.size()>1; } -/*******************************************************************\ - -Function: goto_symex_statet::rename_address - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symex_statet::rename_address( exprt &expr, const namespacet &ns, @@ -935,18 +786,6 @@ void goto_symex_statet::rename_address( } } -/*******************************************************************\ - -Function: goto_symex_statet::rename - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symex_statet::rename( typet &type, const irep_idt &l1_identifier, @@ -1018,18 +857,6 @@ void goto_symex_statet::rename( l1_type_entry.first->second=type; } -/*******************************************************************\ - -Function: goto_symex_statet::get_original_name - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symex_statet::get_original_name(exprt &expr) const { get_original_name(expr.type()); @@ -1042,18 +869,6 @@ void goto_symex_statet::get_original_name(exprt &expr) const get_original_name(*it); } -/*******************************************************************\ - -Function: goto_symex_statet::get_original_name - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symex_statet::get_original_name(typet &type) const { // rename all the symbols with their last known value @@ -1082,18 +897,6 @@ void goto_symex_statet::get_original_name(typet &type) const } } -/*******************************************************************\ - -Function: goto_symex_statet::get_l1_name - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symex_statet::get_l1_name(exprt &expr) const { // do not reset the type ! @@ -1106,18 +909,6 @@ void goto_symex_statet::get_l1_name(exprt &expr) const get_l1_name(*it); } -/*******************************************************************\ - -Function: goto_symex_statet::switch_to_thread - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symex_statet::switch_to_thread(unsigned t) { assert(source.thread_nr #include "memory_model.h" -/*******************************************************************\ - -Function: memory_model_baset::memory_model_baset - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - memory_model_baset::memory_model_baset(const namespacet &_ns): partial_order_concurrencyt(_ns), var_cnt(0) { } -/*******************************************************************\ - -Function: memory_model_baset::~memory_model_baset - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - memory_model_baset::~memory_model_baset() { } -/*******************************************************************\ - -Function: memory_model_baset::nondet_bool_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - symbol_exprt memory_model_baset::nondet_bool_symbol( const std::string &prefix) { @@ -64,18 +31,6 @@ symbol_exprt memory_model_baset::nondet_bool_symbol( bool_typet()); } -/*******************************************************************\ - -Function: memory_model_baset::po - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool memory_model_baset::po(event_it e1, event_it e2) { // within same thread @@ -88,18 +43,6 @@ bool memory_model_baset::po(event_it e1, event_it e2) } } -/*******************************************************************\ - -Function: memory_model_baset::read_from - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void memory_model_baset::read_from(symex_target_equationt &equation) { // We iterate over all the reads, and diff --git a/src/goto-symex/memory_model.h b/src/goto-symex/memory_model.h index b72c3672613..083a75efa5b 100644 --- a/src/goto-symex/memory_model.h +++ b/src/goto-symex/memory_model.h @@ -6,6 +6,9 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk \*******************************************************************/ +/// \file +/// Memory models for partial order concurrency + #ifndef CPROVER_GOTO_SYMEX_MEMORY_MODEL_H #define CPROVER_GOTO_SYMEX_MEMORY_MODEL_H diff --git a/src/goto-symex/memory_model_pso.cpp b/src/goto-symex/memory_model_pso.cpp index 629451fc80b..2ef634e208c 100644 --- a/src/goto-symex/memory_model_pso.cpp +++ b/src/goto-symex/memory_model_pso.cpp @@ -6,23 +6,14 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk \*******************************************************************/ -#include "memory_model_pso.h" - -/*******************************************************************\ - -Function: memory_model_psot::operator() - - Inputs: +/// \file +/// Memory model for partial order concurrency - Outputs: - - Purpose: - -\*******************************************************************/ +#include "memory_model_pso.h" void memory_model_psot::operator()(symex_target_equationt &equation) { - print(8, "Adding PSO constraints"); + statistics() << "Adding PSO constraints" << eom; build_event_lists(equation); build_clock_type(equation); @@ -35,18 +26,6 @@ void memory_model_psot::operator()(symex_target_equationt &equation) #endif } -/*******************************************************************\ - -Function: memory_model_psot::program_order_is_relaxed - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool memory_model_psot::program_order_is_relaxed( partial_order_concurrencyt::event_it e1, partial_order_concurrencyt::event_it e2) const diff --git a/src/goto-symex/memory_model_pso.h b/src/goto-symex/memory_model_pso.h index 386a035bdcb..ca3cab0cd14 100644 --- a/src/goto-symex/memory_model_pso.h +++ b/src/goto-symex/memory_model_pso.h @@ -6,6 +6,9 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk \*******************************************************************/ +/// \file +/// Memory models for partial order concurrency + #ifndef CPROVER_GOTO_SYMEX_MEMORY_MODEL_PSO_H #define CPROVER_GOTO_SYMEX_MEMORY_MODEL_PSO_H diff --git a/src/goto-symex/memory_model_sc.cpp b/src/goto-symex/memory_model_sc.cpp index 7c131269802..d034711aa54 100644 --- a/src/goto-symex/memory_model_sc.cpp +++ b/src/goto-symex/memory_model_sc.cpp @@ -6,25 +6,16 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk \*******************************************************************/ +/// \file +/// Memory model for partial order concurrency + #include #include "memory_model_sc.h" -/*******************************************************************\ - -Function: memory_model_sct::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void memory_model_sct::operator()(symex_target_equationt &equation) { - print(8, "Adding SC constraints"); + statistics() << "Adding SC constraints" << eom; build_event_lists(equation); build_clock_type(equation); @@ -35,36 +26,12 @@ void memory_model_sct::operator()(symex_target_equationt &equation) from_read(equation); } -/*******************************************************************\ - -Function: memory_model_sct::before - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt memory_model_sct::before(event_it e1, event_it e2) { return partial_order_concurrencyt::before( e1, e2, AX_PROPAGATION); } -/*******************************************************************\ - -Function: memory_model_sct::program_order_is_relaxed - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool memory_model_sct::program_order_is_relaxed( partial_order_concurrencyt::event_it e1, partial_order_concurrencyt::event_it e2) const @@ -75,18 +42,6 @@ bool memory_model_sct::program_order_is_relaxed( return false; } -/*******************************************************************\ - -Function: memory_model_sct::build_per_thread_map - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void memory_model_sct::build_per_thread_map( const symex_target_equationt &equation, per_thread_mapt &dest) const @@ -108,18 +63,6 @@ void memory_model_sct::build_per_thread_map( } } -/*******************************************************************\ - -Function: memory_model_sct::thread_spawn - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void memory_model_sct::thread_spawn( symex_target_equationt &equation, const per_thread_mapt &per_thread_map) @@ -203,18 +146,6 @@ void memory_model_sct::thread_spawn( } #endif -/*******************************************************************\ - -Function: memory_model_sct::program_order - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void memory_model_sct::program_order( symex_target_equationt &equation) { @@ -262,18 +193,6 @@ void memory_model_sct::program_order( } } -/*******************************************************************\ - -Function: memory_model_sct::write_serialization_external - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void memory_model_sct::write_serialization_external( symex_target_equationt &equation) { @@ -326,18 +245,6 @@ void memory_model_sct::write_serialization_external( } } -/*******************************************************************\ - -Function: memory_model_sct::from_read - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void memory_model_sct::from_read(symex_target_equationt &equation) { // from-read: (w', w) in ws and (w', r) in rf -> (r, w) in fr diff --git a/src/goto-symex/memory_model_sc.h b/src/goto-symex/memory_model_sc.h index 66709ae22be..33e2edcb461 100644 --- a/src/goto-symex/memory_model_sc.h +++ b/src/goto-symex/memory_model_sc.h @@ -6,6 +6,9 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk \*******************************************************************/ +/// \file +/// Memory models for partial order concurrency + #ifndef CPROVER_GOTO_SYMEX_MEMORY_MODEL_SC_H #define CPROVER_GOTO_SYMEX_MEMORY_MODEL_SC_H diff --git a/src/goto-symex/memory_model_tso.cpp b/src/goto-symex/memory_model_tso.cpp index 1fec15c9bdd..f45d3db9d91 100644 --- a/src/goto-symex/memory_model_tso.cpp +++ b/src/goto-symex/memory_model_tso.cpp @@ -6,26 +6,17 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk \*******************************************************************/ +/// \file +/// Memory model for partial order concurrency + #include #include #include "memory_model_tso.h" -/*******************************************************************\ - -Function: memory_model_tsot::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void memory_model_tsot::operator()(symex_target_equationt &equation) { - print(8, "Adding TSO constraints"); + statistics() << "Adding TSO constraints" << eom; build_event_lists(equation); build_clock_type(equation); @@ -38,36 +29,12 @@ void memory_model_tsot::operator()(symex_target_equationt &equation) #endif } -/*******************************************************************\ - -Function: memory_model_tsot::before - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt memory_model_tsot::before(event_it e1, event_it e2) { return partial_order_concurrencyt::before( e1, e2, AX_SC_PER_LOCATION | AX_PROPAGATION); } -/*******************************************************************\ - -Function: memory_model_tsot::program_order_is_relaxed - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool memory_model_tsot::program_order_is_relaxed( partial_order_concurrencyt::event_it e1, partial_order_concurrencyt::event_it e2) const @@ -84,18 +51,6 @@ bool memory_model_tsot::program_order_is_relaxed( return e1->is_shared_write() && e2->is_shared_read(); } -/*******************************************************************\ - -Function: memory_model_tsot::program_order - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void memory_model_tsot::program_order( symex_target_equationt &equation) { diff --git a/src/goto-symex/memory_model_tso.h b/src/goto-symex/memory_model_tso.h index 11de873e02a..87592e471f6 100644 --- a/src/goto-symex/memory_model_tso.h +++ b/src/goto-symex/memory_model_tso.h @@ -6,6 +6,9 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk \*******************************************************************/ +/// \file +/// Memory models for partial order concurrency + #ifndef CPROVER_GOTO_SYMEX_MEMORY_MODEL_TSO_H #define CPROVER_GOTO_SYMEX_MEMORY_MODEL_TSO_H diff --git a/src/goto-symex/partial_order_concurrency.cpp b/src/goto-symex/partial_order_concurrency.cpp index 568a799b098..8cb323fec37 100644 --- a/src/goto-symex/partial_order_concurrency.cpp +++ b/src/goto-symex/partial_order_concurrency.cpp @@ -6,6 +6,9 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk \*******************************************************************/ +/// \file +/// Add constraints to equation encoding partial orders on events + #include #include @@ -13,51 +16,15 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk #include "partial_order_concurrency.h" -/*******************************************************************\ - -Function: partial_order_concurrencyt::~partial_order_concurrencyt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - partial_order_concurrencyt::partial_order_concurrencyt( const namespacet &_ns):ns(_ns) { } -/*******************************************************************\ - -Function: partial_order_concurrencyt::~partial_order_concurrencyt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - partial_order_concurrencyt::~partial_order_concurrencyt() { } -/*******************************************************************\ - -Function: partial_order_concurrencyt::add_init_writes - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void partial_order_concurrencyt::add_init_writes( symex_target_equationt &equation) { @@ -107,18 +74,6 @@ void partial_order_concurrencyt::add_init_writes( equation.SSA_steps.splice(equation.SSA_steps.begin(), init_steps); } -/*******************************************************************\ - -Function: partial_order_concurrencyt::build_event_lists - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void partial_order_concurrencyt::build_event_lists( symex_target_equationt &equation) { @@ -169,18 +124,6 @@ void partial_order_concurrencyt::build_event_lists( } } -/*******************************************************************\ - -Function: partial_order_concurrencyt::rw_clock_id - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - irep_idt partial_order_concurrencyt::rw_clock_id( event_it event, axiomt axiom) @@ -195,18 +138,6 @@ irep_idt partial_order_concurrencyt::rw_clock_id( return ""; } -/*******************************************************************\ - -Function: partial_order_concurrencyt::clock - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - symbol_exprt partial_order_concurrencyt::clock( event_it event, axiomt axiom) @@ -230,18 +161,6 @@ symbol_exprt partial_order_concurrencyt::clock( return symbol_exprt(identifier, clock_type); } -/*******************************************************************\ - -Function: partial_order_concurrencyt::build_clock_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void partial_order_concurrencyt::build_clock_type( const symex_target_equationt &equation) { @@ -252,18 +171,6 @@ void partial_order_concurrencyt::build_clock_type( clock_type=unsignedbv_typet(integer2unsigned(width)); } -/*******************************************************************\ - -Function: partial_order_concurrencyt::before - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt partial_order_concurrencyt::before( event_it e1, event_it e2, unsigned axioms) { @@ -298,18 +205,6 @@ exprt partial_order_concurrencyt::before( return conjunction(ops); } -/*******************************************************************\ - -Function: partial_order_concurrencyt::add_constraint - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void partial_order_concurrencyt::add_constraint( symex_target_equationt &equation, const exprt &cond, diff --git a/src/goto-symex/partial_order_concurrency.h b/src/goto-symex/partial_order_concurrency.h index 86817ba5360..5163451e210 100644 --- a/src/goto-symex/partial_order_concurrency.h +++ b/src/goto-symex/partial_order_concurrency.h @@ -6,6 +6,9 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk \*******************************************************************/ +/// \file +/// Add constraints to equation encoding partial orders on events + #ifndef CPROVER_GOTO_SYMEX_PARTIAL_ORDER_CONCURRENCY_H #define CPROVER_GOTO_SYMEX_PARTIAL_ORDER_CONCURRENCY_H diff --git a/src/goto-symex/postcondition.cpp b/src/goto-symex/postcondition.cpp index c93aa52a407..43aa79f6aa5 100644 --- a/src/goto-symex/postcondition.cpp +++ b/src/goto-symex/postcondition.cpp @@ -6,24 +6,15 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbolic Execution + #include #include #include "goto_symex_state.h" #include "postcondition.h" -/*******************************************************************\ - - Class: postconditiont - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - class postconditiont { public: @@ -55,18 +46,6 @@ class postconditiont bool is_used(const exprt &expr, const irep_idt &identifier); }; -/*******************************************************************\ - -Function: postcondition - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void postcondition( const namespacet &ns, const value_sett &value_set, @@ -86,18 +65,6 @@ void postcondition( } } -/*******************************************************************\ - -Function: postconditiont::is_used_address_of - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool postconditiont::is_used_address_of( const exprt &expr, const irep_idt &identifier) @@ -128,18 +95,6 @@ bool postconditiont::is_used_address_of( return false; } -/*******************************************************************\ - -Function: postconditiont::compute - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void postconditiont::compute(exprt &dest) { // weaken due to assignment @@ -149,18 +104,6 @@ void postconditiont::compute(exprt &dest) strengthen(dest); } -/*******************************************************************\ - -Function: postconditiont::strengthen - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void postconditiont::weaken(exprt &dest) { if(dest.id()==ID_and && @@ -183,18 +126,6 @@ void postconditiont::weaken(exprt &dest) // otherwise, no weakening needed } -/*******************************************************************\ - -Function: postconditiont::strengthen - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void postconditiont::strengthen(exprt &dest) { const irep_idt &lhs_identifier=SSA_step.ssa_lhs.get_object_name(); @@ -216,18 +147,6 @@ void postconditiont::strengthen(exprt &dest) } } -/*******************************************************************\ - -Function: postconditiont::is_used - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool postconditiont::is_used( const exprt &expr, const irep_idt &identifier) diff --git a/src/goto-symex/postcondition.h b/src/goto-symex/postcondition.h index 3e84235da47..4f154a572cf 100644 --- a/src/goto-symex/postcondition.h +++ b/src/goto-symex/postcondition.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Generate Equation using Symbolic Execution + #ifndef CPROVER_GOTO_SYMEX_POSTCONDITION_H #define CPROVER_GOTO_SYMEX_POSTCONDITION_H diff --git a/src/goto-symex/precondition.cpp b/src/goto-symex/precondition.cpp index 15cc3e180a2..091408f0afc 100644 --- a/src/goto-symex/precondition.cpp +++ b/src/goto-symex/precondition.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbolic Execution + #include #include @@ -13,18 +16,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_symex_state.h" #include "precondition.h" -/*******************************************************************\ - - Class: preconditiont - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - class preconditiont { public: @@ -57,18 +48,6 @@ class preconditiont void compute_address_of(exprt &dest); }; -/*******************************************************************\ - -Function: precondition - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void precondition( const namespacet &ns, value_setst &value_sets, @@ -89,18 +68,6 @@ void precondition( } } -/*******************************************************************\ - -Function: preconditiont::compute_address_of - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void preconditiont::compute_address_of(exprt &dest) { if(dest.id()==ID_symbol) @@ -125,35 +92,11 @@ void preconditiont::compute_address_of(exprt &dest) } } -/*******************************************************************\ - -Function: preconditiont::compute - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void preconditiont::compute(exprt &dest) { compute_rec(dest); } -/*******************************************************************\ - -Function: preconditiont::compute_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void preconditiont::compute_rec(exprt &dest) { if(dest.id()==ID_address_of) diff --git a/src/goto-symex/precondition.h b/src/goto-symex/precondition.h index 0d8b0caa23d..8adebcbd8c3 100644 --- a/src/goto-symex/precondition.h +++ b/src/goto-symex/precondition.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Generate Equation using Symbolic Execution + #ifndef CPROVER_GOTO_SYMEX_PRECONDITION_H #define CPROVER_GOTO_SYMEX_PRECONDITION_H diff --git a/src/goto-symex/rewrite_union.cpp b/src/goto-symex/rewrite_union.cpp index f0a329af5ae..2ecf09bed67 100644 --- a/src/goto-symex/rewrite_union.cpp +++ b/src/goto-symex/rewrite_union.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbolic Execution of ANSI-C + #include #include #include @@ -13,22 +16,10 @@ Author: Daniel Kroening, kroening@kroening.com #include -#include +#include #include "rewrite_union.h" -/*******************************************************************\ - -Function: have_to_rewrite_union - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static bool have_to_rewrite_union( const exprt &expr, const namespacet &ns) @@ -51,19 +42,8 @@ static bool have_to_rewrite_union( return false; } -/*******************************************************************\ - -Function: rewrite_union - - Inputs: - - Outputs: - - Purpose: We rewrite u.c for unions u into byte_extract(u, 0), - and { .c = v } into byte_update(NIL, 0, v) - -\*******************************************************************/ - +/// We rewrite u.c for unions u into byte_extract(u, 0), and { .c = v } into +/// byte_update(NIL, 0, v) void rewrite_union( exprt &expr, const namespacet &ns) @@ -97,18 +77,6 @@ void rewrite_union( } } -/*******************************************************************\ - -Function: rewrite_union - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - static void rewrite_union( goto_functionst::goto_functiont &goto_function, const namespacet &ns) @@ -120,18 +88,6 @@ static void rewrite_union( } } -/*******************************************************************\ - -Function: rewrite_union - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void rewrite_union( goto_functionst &goto_functions, const namespacet &ns) @@ -140,18 +96,6 @@ void rewrite_union( rewrite_union(it->second, ns); } -/*******************************************************************\ - -Function: rewrite_union - -Inputs: - -Outputs: - -Purpose: - -\*******************************************************************/ - void rewrite_union(goto_modelt &goto_model) { namespacet ns(goto_model.symbol_table); diff --git a/src/goto-symex/rewrite_union.h b/src/goto-symex/rewrite_union.h index 7215e0bf0a4..d2c9b1772b4 100644 --- a/src/goto-symex/rewrite_union.h +++ b/src/goto-symex/rewrite_union.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbolic Execution + #ifndef CPROVER_GOTO_SYMEX_REWRITE_UNION_H #define CPROVER_GOTO_SYMEX_REWRITE_UNION_H diff --git a/src/goto-symex/slice.cpp b/src/goto-symex/slice.cpp index 483e76211bc..a398264963e 100644 --- a/src/goto-symex/slice.cpp +++ b/src/goto-symex/slice.cpp @@ -6,23 +6,14 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Slicer for symex traces + #include #include "slice.h" #include "symex_slice_class.h" -/*******************************************************************\ - -Function: symex_slicet::get_symbols - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_slicet::get_symbols(const exprt &expr) { get_symbols(expr.type()); @@ -34,35 +25,11 @@ void symex_slicet::get_symbols(const exprt &expr) depends.insert(to_symbol_expr(expr).get_identifier()); } -/*******************************************************************\ - -Function: symex_slicet::get_symbols - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_slicet::get_symbols(const typet &type) { // TODO } -/*******************************************************************\ - -Function: symex_slicet::slice - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_slicet::slice( symex_target_equationt &equation, const expr_listt &exprs) @@ -74,18 +41,6 @@ void symex_slicet::slice( slice(equation); } -/*******************************************************************\ - -Function: symex_slicet::slice - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_slicet::slice(symex_target_equationt &equation) { for(symex_target_equationt::SSA_stepst::reverse_iterator @@ -95,18 +50,6 @@ void symex_slicet::slice(symex_target_equationt &equation) slice(*it); } -/*******************************************************************\ - -Function: symex_slicet::slice - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_slicet::slice(symex_target_equationt::SSA_stept &SSA_step) { get_symbols(SSA_step.guard); @@ -165,18 +108,6 @@ void symex_slicet::slice(symex_target_equationt::SSA_stept &SSA_step) } } -/*******************************************************************\ - -Function: symex_slicet::slice_assignment - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_slicet::slice_assignment( symex_target_equationt::SSA_stept &SSA_step) { @@ -192,18 +123,6 @@ void symex_slicet::slice_assignment( get_symbols(SSA_step.ssa_rhs); } -/*******************************************************************\ - -Function: symex_slicet::slice_decl - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_slicet::slice_decl( symex_target_equationt::SSA_stept &SSA_step) { @@ -217,20 +136,11 @@ void symex_slicet::slice_decl( } } -/*******************************************************************\ - -Function: symex_slice_classt::collect_open_variables - - Inputs: equation - symex trace - open_variables - target set - - Outputs: None. But open_variables is modified as a side-effect. - - Purpose: Collect the open variables, i.e., variables that are used - in RHS but never written in LHS - -\*******************************************************************/ - +/// Collect the open variables, i.e., variables that are used in RHS but never +/// written in LHS +/// \param equation: symex trace +/// \param open_variables: target set +/// \return None. But open_variables is modified as a side-effect. void symex_slicet::collect_open_variables( const symex_target_equationt &equation, symbol_sett &open_variables) @@ -295,38 +205,17 @@ void symex_slicet::collect_open_variables( open_variables.erase(lhs.begin(), lhs.end()); } -/*******************************************************************\ - -Function: slice - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void slice(symex_target_equationt &equation) { symex_slicet symex_slice; symex_slice.slice(equation); } -/*******************************************************************\ - -Function: collect_open_variables - - Inputs: equation - symex trace - open_variables - target set - - Outputs: None. But open_variables is modified as a side-effect. - - Purpose: Collect the open variables, i.e. variables that are used - in RHS but never written in LHS - -\*******************************************************************/ - +/// Collect the open variables, i.e. variables that are used in RHS but never +/// written in LHS +/// \param equation: symex trace +/// \param open_variables: target set +/// \return None. But open_variables is modified as a side-effect. void collect_open_variables( const symex_target_equationt &equation, symbol_sett &open_variables) @@ -335,19 +224,10 @@ void collect_open_variables( symex_slice.collect_open_variables(equation, open_variables); } -/*******************************************************************\ - -Function: slice - - Inputs: equation - symex trace to be sliced - expression - list of expressions, targets for slicing - - Outputs: None. But equation is modified as a side-effect. - - Purpose: Slice the symex trace with respect to a list of expressions - -\*******************************************************************/ - +/// Slice the symex trace with respect to a list of expressions +/// \param equation: symex trace to be sliced +/// \param expression: list of expressions, targets for slicing +/// \return None. But equation is modified as a side-effect. void slice(symex_target_equationt &equation, const expr_listt &expressions) { @@ -355,18 +235,6 @@ void slice(symex_target_equationt &equation, symex_slice.slice(equation, expressions); } -/*******************************************************************\ - -Function: simple_slice - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void simple_slice(symex_target_equationt &equation) { // just find the last assertion diff --git a/src/goto-symex/slice.h b/src/goto-symex/slice.h index 1fd15969274..2bc887a0c9f 100644 --- a/src/goto-symex/slice.h +++ b/src/goto-symex/slice.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Slicer for symex traces + #ifndef CPROVER_GOTO_SYMEX_SLICE_H #define CPROVER_GOTO_SYMEX_SLICE_H diff --git a/src/goto-symex/slice_by_trace.cpp b/src/goto-symex/slice_by_trace.cpp index 07a4f81b96a..f0dfccba4f5 100644 --- a/src/goto-symex/slice_by_trace.cpp +++ b/src/goto-symex/slice_by_trace.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Slicer for symex traces + #include #include #include @@ -21,23 +24,11 @@ Author: Daniel Kroening, kroening@kroening.com #include "slice_by_trace.h" -/*******************************************************************\ - -Function: slice_by_trace - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_slice_by_tracet::slice_by_trace( std::string trace_files, symex_target_equationt &equation) { - std::cout << "Slicing by trace..." << std::endl; + std::cout << "Slicing by trace...\n"; merge_identifier="goto_symex::\\merge"; merge_symbol=symbol_exprt(typet(ID_bool)); @@ -124,24 +115,12 @@ void symex_slice_by_tracet::slice_by_trace( assign_merges(equation); // Now add the merge variable assignments to eqn - std::cout << "Finished slicing by trace..." << std::endl; + std::cout << "Finished slicing by trace...\n"; } -/*******************************************************************\ - -Function: read_trace - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_slice_by_tracet::read_trace(std::string filename) { - std::cout << "Reading trace from file " << filename << std::endl; + std::cout << "Reading trace from file " << filename << '\n'; std::ifstream file(filename); if(file.fail()) throw "failed to read from trace file"; @@ -184,18 +163,6 @@ void symex_slice_by_tracet::read_trace(std::string filename) t.push_back(t_e); } -/*******************************************************************\ - -Function: parse_alphabet - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool symex_slice_by_tracet::parse_alphabet(std::string read_line) { if((read_line==":") || (read_line == ":exact") || @@ -210,24 +177,12 @@ bool symex_slice_by_tracet::parse_alphabet(std::string read_line) std::cout << "Alphabet: "; if(!alphabet_parity) std::cout << "!"; - std::cout << read_line << std::endl; + std::cout << read_line << '\n'; alphabet.insert(read_line); } return false; } -/*******************************************************************\ - -Function: parse_events - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_slice_by_tracet::parse_events(std::string read_line) { if(read_line=="") @@ -235,7 +190,7 @@ void symex_slice_by_tracet::parse_events(std::string read_line) bool parity=strstr(read_line.c_str(), "!")==NULL; bool universe=strstr(read_line.c_str(), "?")!=NULL; bool has_values=strstr(read_line.c_str(), " ")!=NULL; - std::cout << "Trace: " << read_line << std::endl; + std::cout << "Trace: " << read_line << '\n'; std::vector value_v; if(has_values) { @@ -276,18 +231,6 @@ void symex_slice_by_tracet::parse_events(std::string read_line) sigma.push_back(es); } -/*******************************************************************\ - -Function: compute_ts_back - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_slice_by_tracet::compute_ts_back( symex_target_equationt &equation) { @@ -314,12 +257,12 @@ void symex_slice_by_tracet::compute_ts_back( exprt guard=i->guard; #if 0 - std::cout << "EVENT: " << event << std::endl; - std::cout << "GUARD: " << from_expr(ns, "", guard) << std::endl; + std::cout << "EVENT: " << event << '\n'; + std::cout << "GUARD: " << from_expr(ns, "", guard) << '\n'; for(size_t j=0; j < t.size(); j++) { std::cout << "t[" << j << "]=" << from_expr(ns, "", t[j]) << - std::endl; + '\n'; } #endif @@ -430,35 +373,11 @@ void symex_slice_by_tracet::compute_ts_back( } } -/*******************************************************************\ - -Function: compute_ts_fd - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_slice_by_tracet::compute_ts_fd( symex_target_equationt &equation) { } -/*******************************************************************\ - -Function: slice_SSA_steps - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_slice_by_tracet::slice_SSA_steps( symex_target_equationt &equation, std::set implications) @@ -489,7 +408,7 @@ void symex_slice_by_tracet::slice_SSA_steps( if(!guard.is_true()) potential_SSA_steps++; // it->output(ns,std::cout); - // std::cout << "-----------------" << std::endl; + // std::cout << "-----------------\n"; if((guard.id()==ID_symbol) || (guard.id() == ID_not)) { @@ -529,7 +448,7 @@ void symex_slice_by_tracet::slice_SSA_steps( } else if(guard.id()==ID_or) { - std::cout << "Guarded by an OR." << std::endl; + std::cout << "Guarded by an OR.\n"; } } @@ -568,26 +487,14 @@ void symex_slice_by_tracet::slice_SSA_steps( std::cout << "Trace slicing effectively removed " << (sliced_SSA_steps + sliced_conds) << " out of " - << equation.SSA_steps.size() << " SSA_steps." << std::endl; + << equation.SSA_steps.size() << " SSA_steps.\n"; std::cout << " (" << ((sliced_SSA_steps + sliced_conds) - trace_loc_sliced) << " out of " << (equation.SSA_steps.size()-trace_SSA_steps-location_SSA_steps) - << " non-trace, non-location SSA_steps)" << std::endl; + << " non-trace, non-location SSA_steps)\n"; } -/*******************************************************************\ - -Function: matches - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool symex_slice_by_tracet::matches( event_sett s, irep_idt event) @@ -596,18 +503,6 @@ bool symex_slice_by_tracet::matches( return ((s.second && present) || (!s.second && !present)); } -/*******************************************************************\ - -Function: assign_merges - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_slice_by_tracet::assign_merges( symex_target_equationt &equation) { @@ -638,18 +533,6 @@ void symex_slice_by_tracet::assign_merges( } } -/*******************************************************************\ - -Function: implied_guards - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::set symex_slice_by_tracet::implied_guards(exprt e) { std::set s; @@ -732,18 +615,6 @@ std::set symex_slice_by_tracet::implied_guards(exprt e) return s; } -/*******************************************************************\ - -Function: symex_slice_by_tracet::implies_false - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool symex_slice_by_tracet::implies_false(const exprt e) { std::set imps=implied_guards(e); diff --git a/src/goto-symex/slice_by_trace.h b/src/goto-symex/slice_by_trace.h index 8223e6589e1..eb5f706694c 100644 --- a/src/goto-symex/slice_by_trace.h +++ b/src/goto-symex/slice_by_trace.h @@ -6,6 +6,9 @@ Author: Alex Groce (agroce@gmail.com) \*******************************************************************/ +/// \file +/// Slicer for matching with trace files + #ifndef CPROVER_GOTO_SYMEX_SLICE_BY_TRACE_H #define CPROVER_GOTO_SYMEX_SLICE_BY_TRACE_H diff --git a/src/goto-symex/symex_assign.cpp b/src/goto-symex/symex_assign.cpp index 61b6ad28488..047f3be8325 100644 --- a/src/goto-symex/symex_assign.cpp +++ b/src/goto-symex/symex_assign.cpp @@ -6,28 +6,19 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbolic Execution + #include #include -#include +#include #include "goto_symex.h" #include "goto_symex_state.h" // #define USE_UPDATE -/*******************************************************************\ - -Function: goto_symext::symex_assign_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::symex_assign_rec( statet &state, const code_assignt &code) @@ -40,18 +31,6 @@ void goto_symext::symex_assign_rec( symex_assign(state, deref_code); } -/*******************************************************************\ - -Function: goto_symext::symex_assign - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::symex_assign( statet &state, const code_assignt &code) @@ -114,18 +93,6 @@ void goto_symext::symex_assign( } } -/*******************************************************************\ - -Function: goto_symext::add_to_lhs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt goto_symext::add_to_lhs( const exprt &lhs, const exprt &what) @@ -156,18 +123,6 @@ exprt goto_symext::add_to_lhs( return new_lhs; } -/*******************************************************************\ - -Function: goto_symext::symex_assign_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::symex_assign_rec( statet &state, const exprt &lhs, @@ -246,18 +201,6 @@ void goto_symext::symex_assign_rec( throw "assignment to `"+lhs.id_string()+"' not handled"; } -/*******************************************************************\ - -Function: goto_symext::symex_assign_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::symex_assign_symbol( statet &state, const ssa_exprt &lhs, // L1 @@ -314,18 +257,6 @@ void goto_symext::symex_assign_symbol( assignment_type); } -/*******************************************************************\ - -Function: goto_symext::symex_assign_typecast - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::symex_assign_typecast( statet &state, const typecast_exprt &lhs, @@ -347,18 +278,6 @@ void goto_symext::symex_assign_typecast( state, lhs.op0(), new_full_lhs, rhs_typecasted, guard, assignment_type); } -/*******************************************************************\ - -Function: goto_symext::symex_assign_array - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::symex_assign_array( statet &state, const index_exprt &lhs, @@ -415,18 +334,6 @@ void goto_symext::symex_assign_array( #endif } -/*******************************************************************\ - -Function: goto_symext::symex_assign_struct_member - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::symex_assign_struct_member( statet &state, const member_exprt &lhs, @@ -501,18 +408,6 @@ void goto_symext::symex_assign_struct_member( #endif } -/*******************************************************************\ - -Function: goto_symext::symex_assign_if - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::symex_assign_if( statet &state, const if_exprt &lhs, @@ -546,18 +441,6 @@ void goto_symext::symex_assign_if( } } -/*******************************************************************\ - -Function: goto_symext::symex_assign_byte_extract - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::symex_assign_byte_extract( statet &state, const byte_extract_exprt &lhs, diff --git a/src/goto-symex/symex_atomic_section.cpp b/src/goto-symex/symex_atomic_section.cpp index 7f4e239f676..c243cafbcd4 100644 --- a/src/goto-symex/symex_atomic_section.cpp +++ b/src/goto-symex/symex_atomic_section.cpp @@ -6,19 +6,10 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "goto_symex.h" - -/*******************************************************************\ - -Function: goto_symext::symex_atomic_begin - - Inputs: +/// \file +/// Symbolic Execution - Outputs: - - Purpose: - -\*******************************************************************/ +#include "goto_symex.h" void goto_symext::symex_atomic_begin(statet &state) { @@ -40,18 +31,6 @@ void goto_symext::symex_atomic_begin(statet &state) state.source); } -/*******************************************************************\ - -Function: goto_symext::symex_atomic_end - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::symex_atomic_end(statet &state) { if(state.guard.is_false()) diff --git a/src/goto-symex/symex_builtin_functions.cpp b/src/goto-symex/symex_builtin_functions.cpp index c5bdd32d0f2..a85d6e5b18d 100644 --- a/src/goto-symex/symex_builtin_functions.cpp +++ b/src/goto-symex/symex_builtin_functions.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbolic Execution of ANSI-C + #include #include @@ -19,25 +22,13 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -#include +#include #include #include "goto_symex.h" #include "goto_symex_state.h" -/*******************************************************************\ - -Function: goto_symext::symex_malloc - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - inline static typet c_sizeof_type_rec(const exprt &expr) { const irept &sizeof_type=expr.find(ID_C_c_sizeof_type); @@ -195,18 +186,6 @@ void goto_symext::symex_malloc( symex_assign_rec(state, code_assignt(lhs, rhs)); } -/*******************************************************************\ - -Function: goto_symext::symex_gcc_builtin_va_arg_next - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - irep_idt get_symbol(const exprt &src) { if(src.id()==ID_typecast) @@ -242,7 +221,7 @@ void goto_symext::symex_gcc_builtin_va_arg_next( exprt rhs=zero_initializer(lhs.type(), code.source_location(), ns); - if(id!=irep_idt()) + if(!id.empty()) { // strip last name off id to get function name std::size_t pos=id2string(id).rfind("::"); @@ -271,18 +250,6 @@ void goto_symext::symex_gcc_builtin_va_arg_next( symex_assign_rec(state, code_assignt(lhs, rhs)); } -/*******************************************************************\ - -Function: goto_symext::get_string_argument_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - irep_idt get_string_argument_rec(const exprt &src) { if(src.id()==ID_typecast) @@ -309,18 +276,6 @@ irep_idt get_string_argument_rec(const exprt &src) return ""; } -/*******************************************************************\ - -Function: goto_symext::get_string_argument - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - irep_idt get_string_argument(const exprt &src, const namespacet &ns) { exprt tmp=src; @@ -328,18 +283,6 @@ irep_idt get_string_argument(const exprt &src, const namespacet &ns) return get_string_argument_rec(tmp); } -/*******************************************************************\ - -Function: goto_symext::symex_printf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::symex_printf( statet &state, const exprt &lhs, @@ -367,18 +310,6 @@ void goto_symext::symex_printf( state.source, "printf", format_string, args); } -/*******************************************************************\ - -Function: goto_symext::symex_input - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::symex_input( statet &state, const codet &code) @@ -404,18 +335,6 @@ void goto_symext::symex_input( target.input(state.guard.as_expr(), state.source, input_id, args); } -/*******************************************************************\ - -Function: goto_symext::symex_output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::symex_output( statet &state, const codet &code) @@ -441,18 +360,6 @@ void goto_symext::symex_output( target.output(state.guard.as_expr(), state.source, output_id, args); } -/*******************************************************************\ - -Function: goto_symext::symex_cpp_new - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::symex_cpp_new( statet &state, const exprt &lhs, @@ -513,18 +420,6 @@ void goto_symext::symex_cpp_new( symex_assign_rec(state, code_assignt(lhs, rhs)); } -/*******************************************************************\ - -Function: goto_symext::symex_cpp_delete - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::symex_cpp_delete( statet &state, const codet &code) @@ -532,18 +427,6 @@ void goto_symext::symex_cpp_delete( // bool do_array=code.get(ID_statement)==ID_cpp_delete_array; } -/*******************************************************************\ - -Function: goto_symext::symex_trace - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::symex_trace( statet &state, const code_function_callt &code) @@ -583,18 +466,6 @@ void goto_symext::symex_trace( } } -/*******************************************************************\ - -Function: goto_symext::symex_fkt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::symex_fkt( statet &state, const code_function_callt &code) @@ -618,18 +489,6 @@ void goto_symext::symex_fkt( #endif } -/*******************************************************************\ - -Function: goto_symext::symex_macro - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::symex_macro( statet &state, const code_function_callt &code) diff --git a/src/goto-symex/symex_catch.cpp b/src/goto-symex/symex_catch.cpp index ffddd6314e8..c36deb71645 100644 --- a/src/goto-symex/symex_catch.cpp +++ b/src/goto-symex/symex_catch.cpp @@ -6,19 +6,10 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "goto_symex.h" - -/*******************************************************************\ - -Function: goto_symext::symex_catch - - Inputs: +/// \file +/// Symbolic Execution - Outputs: - - Purpose: - -\*******************************************************************/ +#include "goto_symex.h" void goto_symext::symex_catch(statet &state) { diff --git a/src/goto-symex/symex_clean_expr.cpp b/src/goto-symex/symex_clean_expr.cpp index e3e650d7b99..ed455757bf8 100644 --- a/src/goto-symex/symex_clean_expr.cpp +++ b/src/goto-symex/symex_clean_expr.cpp @@ -6,27 +6,18 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbolic Execution of ANSI-C + #include #include #include #include -#include +#include #include "goto_symex.h" -/*******************************************************************\ - -Function: goto_symext::process_array_expr_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::process_array_expr_rec( exprt &expr, const typet &type) const @@ -58,6 +49,14 @@ void goto_symext::process_array_expr_rec( expr.swap(tmp); process_array_expr_rec(expr, type); } + else if(expr.id()==ID_byte_extract_little_endian || + expr.id()==ID_byte_extract_big_endian) + { + // pick the root object + exprt tmp=to_byte_extract_expr(expr).op(); + expr.swap(tmp); + process_array_expr_rec(expr, type); + } else if(expr.id()==ID_symbol && expr.get_bool(ID_C_SSA_symbol) && to_ssa_expr(expr).get_original_expr().id()==ID_index) @@ -69,7 +68,10 @@ void goto_symext::process_array_expr_rec( } else Forall_operands(it, expr) - process_array_expr_rec(*it, it->type()); + { + typet t=it->type(); + process_array_expr_rec(*it, t); + } if(!base_type_eq(expr.type(), type, ns)) { @@ -82,18 +84,6 @@ void goto_symext::process_array_expr_rec( } } -/*******************************************************************\ - -Function: goto_symext::process_array_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::process_array_expr(exprt &expr) { // This may change the type of the expression! @@ -129,6 +119,14 @@ void goto_symext::process_array_expr(exprt &expr) expr.swap(tmp); process_array_expr(expr); } + else if(expr.id()==ID_byte_extract_little_endian || + expr.id()==ID_byte_extract_big_endian) + { + // pick the root object + exprt tmp=to_byte_extract_expr(expr).op(); + expr.swap(tmp); + process_array_expr(expr); + } else if(expr.id()==ID_symbol && expr.get_bool(ID_C_SSA_symbol) && to_ssa_expr(expr).get_original_expr().id()==ID_index) @@ -143,18 +141,6 @@ void goto_symext::process_array_expr(exprt &expr) process_array_expr(*it); } -/*******************************************************************\ - -Function: goto_symext::replace_array_equal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::replace_array_equal(exprt &expr) { if(expr.id()==ID_array_equal) @@ -180,18 +166,6 @@ void goto_symext::replace_array_equal(exprt &expr) replace_array_equal(*it); } -/*******************************************************************\ - -Function: goto_symext::clean_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::clean_expr( exprt &expr, statet &state, diff --git a/src/goto-symex/symex_dead.cpp b/src/goto-symex/symex_dead.cpp index ec9440bc5e8..11bcadcfbd7 100644 --- a/src/goto-symex/symex_dead.cpp +++ b/src/goto-symex/symex_dead.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbolic Execution + #include #include @@ -15,18 +18,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_symex.h" -/*******************************************************************\ - -Function: goto_symext::symex_dead - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::symex_dead(statet &state) { const goto_programt::instructiont &instruction=*state.source.pc; diff --git a/src/goto-symex/symex_decl.cpp b/src/goto-symex/symex_decl.cpp index 4d5e162a4d9..436a2d6e55c 100644 --- a/src/goto-symex/symex_decl.cpp +++ b/src/goto-symex/symex_decl.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbolic Execution + #include #include @@ -17,18 +20,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_symex.h" -/*******************************************************************\ - -Function: goto_symext::symex_decl - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::symex_decl(statet &state) { const goto_programt::instructiont &instruction=*state.source.pc; @@ -47,18 +38,6 @@ void goto_symext::symex_decl(statet &state) symex_decl(state, to_symbol_expr(code.op0())); } -/*******************************************************************\ - -Function: goto_symext::symex_decl - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::symex_decl(statet &state, const symbol_exprt &expr) { // We increase the L2 renaming to make these non-deterministic. diff --git a/src/goto-symex/symex_dereference.cpp b/src/goto-symex/symex_dereference.cpp index 513655f44b9..6b28ec35adf 100644 --- a/src/goto-symex/symex_dereference.cpp +++ b/src/goto-symex/symex_dereference.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbolic Execution of ANSI-C + #include #include #include @@ -15,23 +18,11 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -#include +#include #include "goto_symex.h" #include "symex_dereference_state.h" -/*******************************************************************\ - -Function: goto_symext::dereference_rec_address_of - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::dereference_rec_address_of( exprt &expr, statet &state, @@ -72,18 +63,6 @@ void goto_symext::dereference_rec_address_of( } } -/*******************************************************************\ - -Function: goto_symext::is_index_member_symbol_if - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool goto_symext::is_index_member_symbol_if(const exprt &expr) { // Could be member, could be if, could be index. @@ -109,18 +88,7 @@ bool goto_symext::is_index_member_symbol_if(const exprt &expr) return false; } -/*******************************************************************\ - -Function: goto_symext::address_arithmetic - - Inputs: - - Outputs: - - Purpose: Evaluate an ID_address_of expression - -\*******************************************************************/ - +/// Evaluate an ID_address_of expression exprt goto_symext::address_arithmetic( const exprt &expr, statet &state, @@ -258,18 +226,6 @@ exprt goto_symext::address_arithmetic( return result; } -/*******************************************************************\ - -Function: goto_symext::dereference_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::dereference_rec( exprt &expr, statet &state, @@ -297,7 +253,7 @@ void goto_symext::dereference_rec( symex_dereference_state, language_mode); - // std::cout << "**** " << from_expr(ns, "", tmp1) << std::endl; + // std::cout << "**** " << from_expr(ns, "", tmp1) << '\n'; exprt tmp2= dereference.dereference( tmp1, @@ -305,7 +261,7 @@ void goto_symext::dereference_rec( write? value_set_dereferencet::modet::WRITE: value_set_dereferencet::modet::READ); - // std::cout << "**** " << from_expr(ns, "", tmp2) << std::endl; + // std::cout << "**** " << from_expr(ns, "", tmp2) << '\n'; expr.swap(tmp2); @@ -384,18 +340,6 @@ void goto_symext::dereference_rec( } } -/*******************************************************************\ - -Function: goto_symext::dereference - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::dereference( exprt &expr, statet &state, diff --git a/src/goto-symex/symex_dereference_state.cpp b/src/goto-symex/symex_dereference_state.cpp index cd69913e6a2..1e75222786f 100644 --- a/src/goto-symex/symex_dereference_state.cpp +++ b/src/goto-symex/symex_dereference_state.cpp @@ -6,22 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbolic Execution of ANSI-C + #include #include "symex_dereference_state.h" -/*******************************************************************\ - -Function: symex_dereference_statet::dereference_failure - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_dereference_statet::dereference_failure( const std::string &property, const std::string &msg, @@ -29,18 +20,6 @@ void symex_dereference_statet::dereference_failure( { } -/*******************************************************************\ - -Function: symex_dereference_statet::has_failed_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool symex_dereference_statet::has_failed_symbol( const exprt &expr, const symbolt *&symbol) @@ -98,18 +77,6 @@ bool symex_dereference_statet::has_failed_symbol( return false; } -/*******************************************************************\ - -Function: symex_dereference_statet::get_value_set - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_dereference_statet::get_value_set( const exprt &expr, value_setst::valuest &value_set) @@ -123,7 +90,7 @@ void symex_dereference_statet::get_value_set( #endif #if 0 - std::cout << "E: " << from_expr(goto_symex.ns, "", expr) << std::endl; + std::cout << "E: " << from_expr(goto_symex.ns, "", expr) << '\n'; #endif #if 0 @@ -131,7 +98,7 @@ void symex_dereference_statet::get_value_set( for(value_setst::valuest::const_iterator it=value_set.begin(); it!=value_set.end(); it++) - std::cout << from_expr(goto_symex.ns, "", *it) << std::endl; + std::cout << from_expr(goto_symex.ns, "", *it) << '\n'; std::cout << "**************************\n"; #endif } diff --git a/src/goto-symex/symex_dereference_state.h b/src/goto-symex/symex_dereference_state.h index 0afaf8a696f..315afb00a70 100644 --- a/src/goto-symex/symex_dereference_state.h +++ b/src/goto-symex/symex_dereference_state.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbolic Execution of ANSI-C + #ifndef CPROVER_GOTO_SYMEX_SYMEX_DEREFERENCE_STATE_H #define CPROVER_GOTO_SYMEX_SYMEX_DEREFERENCE_STATE_H @@ -13,18 +16,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_symex.h" -/*******************************************************************\ - - Class: symex_dereference_statet - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - class symex_dereference_statet: public dereference_callbackt { diff --git a/src/goto-symex/symex_function_call.cpp b/src/goto-symex/symex_function_call.cpp index 00636ae339b..e50d1c8ea7f 100644 --- a/src/goto-symex/symex_function_call.cpp +++ b/src/goto-symex/symex_function_call.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbolic Execution of ANSI-C + #include #include #include @@ -17,24 +20,12 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -#include +#include #include #include "goto_symex.h" -/*******************************************************************\ - -Function: goto_symext::get_unwind_recursion - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool goto_symext::get_unwind_recursion( const irep_idt &identifier, const unsigned thread_nr, @@ -43,18 +34,6 @@ bool goto_symext::get_unwind_recursion( return false; } -/*******************************************************************\ - -Function: goto_symext::parameter_assignments - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::parameter_assignments( const irep_idt function_identifier, const goto_functionst::goto_functiont &goto_function, @@ -83,7 +62,7 @@ void goto_symext::parameter_assignments( const irep_idt &identifier=parameter.get_identifier(); - if(identifier==irep_idt()) + if(identifier.empty()) throw "no identifier for function parameter"; const symbolt &symbol=ns.lookup(identifier); @@ -190,18 +169,6 @@ void goto_symext::parameter_assignments( } } -/*******************************************************************\ - -Function: goto_symext::symex_function_call - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::symex_function_call( const goto_functionst &goto_functions, statet &state, @@ -219,18 +186,6 @@ void goto_symext::symex_function_call( throw "unexpected function for symex_function_call: "+function.id_string(); } -/*******************************************************************\ - -Function: goto_symext::symex_function_call_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::symex_function_call_symbol( const goto_functionst &goto_functions, statet &state, @@ -259,18 +214,7 @@ void goto_symext::symex_function_call_symbol( symex_function_call_code(goto_functions, state, code); } -/*******************************************************************\ - -Function: goto_symext::symex_function_call_code - - Inputs: - - Outputs: - - Purpose: do function call by inlining - -\*******************************************************************/ - +/// do function call by inlining void goto_symext::symex_function_call_code( const goto_functionst &goto_functions, statet &state, @@ -373,18 +317,7 @@ void goto_symext::symex_function_call_code( state.source.pc=goto_function.body.instructions.begin(); } -/*******************************************************************\ - -Function: goto_symext::pop_frame - - Inputs: - - Outputs: - - Purpose: pop one call frame - -\*******************************************************************/ - +/// pop one call frame void goto_symext::pop_frame(statet &state) { assert(!state.call_stack().empty()); @@ -424,18 +357,7 @@ void goto_symext::pop_frame(statet &state) state.pop_frame(); } -/*******************************************************************\ - -Function: goto_symext::symex_end_of_function - - Inputs: - - Outputs: - - Purpose: do function call by inlining - -\*******************************************************************/ - +/// do function call by inlining void goto_symext::symex_end_of_function(statet &state) { // first record the return @@ -446,20 +368,8 @@ void goto_symext::symex_end_of_function(statet &state) pop_frame(state); } -/*******************************************************************\ - -Function: goto_symext::locality - - Inputs: - - Outputs: - - Purpose: preserves locality of local variables of a given - function by applying L1 renaming to the local - identifiers - -\*******************************************************************/ - +/// preserves locality of local variables of a given function by applying L1 +/// renaming to the local identifiers void goto_symext::locality( const irep_idt function_identifier, statet &state, @@ -517,18 +427,6 @@ void goto_symext::locality( } } -/*******************************************************************\ - -Function: goto_symext::return_assignment - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::return_assignment(statet &state) { statet::framet &frame=state.top(); diff --git a/src/goto-symex/symex_goto.cpp b/src/goto-symex/symex_goto.cpp index 0f6328bdc44..03186a129b3 100644 --- a/src/goto-symex/symex_goto.cpp +++ b/src/goto-symex/symex_goto.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbolic Execution + #include #include @@ -15,18 +18,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_symex.h" -/*******************************************************************\ - -Function: goto_symext::symex_goto - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::symex_goto(statet &state) { const goto_programt::instructiont &instruction=*state.source.pc; @@ -206,18 +197,6 @@ void goto_symext::symex_goto(statet &state) } } -/*******************************************************************\ - -Function: goto_symext::symex_step_goto - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::symex_step_goto(statet &state, bool taken) { const goto_programt::instructiont &instruction=*state.source.pc; @@ -235,18 +214,6 @@ void goto_symext::symex_step_goto(statet &state, bool taken) target.assumption(state.guard.as_expr(), guard, state.source); } -/*******************************************************************\ - -Function: goto_symext::merge_gotos - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::merge_gotos(statet &state) { statet::framet &frame=state.top(); @@ -271,18 +238,6 @@ void goto_symext::merge_gotos(statet &state) frame.goto_state_map.erase(state_map_it); } -/*******************************************************************\ - -Function: goto_symext::merge_goto - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::merge_goto( const statet::goto_statet &goto_state, statet &state) @@ -303,18 +258,6 @@ void goto_symext::merge_goto( state.depth=std::min(state.depth, goto_state.depth); } -/*******************************************************************\ - -Function: goto_symext::merge_value_sets - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::merge_value_sets( const statet::goto_statet &src, statet &dest) @@ -328,18 +271,6 @@ void goto_symext::merge_value_sets( dest.value_set.make_union(src.value_set); } -/*******************************************************************\ - -Function: goto_symext::phi_function - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::phi_function( const statet::goto_statet &goto_state, statet &dest_state) @@ -350,6 +281,16 @@ void goto_symext::phi_function( goto_state.level2_get_variables(variables); dest_state.level2.get_variables(variables); + guardt diff_guard; + + if(!variables.empty()) + { + diff_guard=goto_state.guard; + + // this gets the diff between the guards + diff_guard-=dest_state.guard; + } + for(std::unordered_set::const_iterator it=variables.begin(); it!=variables.end(); @@ -417,12 +358,7 @@ void goto_symext::phi_function( rhs=dest_state_rhs; else { - guardt tmp_guard(goto_state.guard); - - // this gets the diff between the guards - tmp_guard-=dest_state.guard; - - rhs=if_exprt(tmp_guard.as_expr(), goto_state_rhs, dest_state_rhs); + rhs=if_exprt(diff_guard.as_expr(), goto_state_rhs, dest_state_rhs); do_simplify(rhs); } @@ -441,18 +377,6 @@ void goto_symext::phi_function( } } -/*******************************************************************\ - -Function: goto_symext::loop_bound_exceeded - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::loop_bound_exceeded( statet &state, const exprt &guard) @@ -492,18 +416,6 @@ void goto_symext::loop_bound_exceeded( } } -/*******************************************************************\ - -Function: goto_symext::get_unwind - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool goto_symext::get_unwind( const symex_targett::sourcet &source, unsigned unwind) diff --git a/src/goto-symex/symex_main.cpp b/src/goto-symex/symex_main.cpp index 2cb7ac09290..501fdabea70 100644 --- a/src/goto-symex/symex_main.cpp +++ b/src/goto-symex/symex_main.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbolic Execution + #include #include @@ -17,36 +20,12 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_symex.h" -/*******************************************************************\ - -Function: goto_symext::new_name - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::new_name(symbolt &symbol) { get_new_name(symbol, ns); new_symbol_table.add(symbol); } -/*******************************************************************\ - -Function: goto_symext::vcc - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::vcc( const exprt &vcc_expr, const std::string &msg, @@ -74,18 +53,6 @@ void goto_symext::vcc( target.assertion(state.guard.as_expr(), expr, msg, state.source); } -/*******************************************************************\ - -Function: goto_symext::symex_assume - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::symex_assume(statet &state, const exprt &cond) { exprt simplified_cond=cond; @@ -115,18 +82,6 @@ void goto_symext::symex_assume(statet &state, const exprt &cond) symex_atomic_end(state); } -/*******************************************************************\ - -Function: goto_symext::rewrite_quantifiers - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::rewrite_quantifiers(exprt &expr, statet &state) { if(expr.id()==ID_forall) @@ -143,18 +98,7 @@ void goto_symext::rewrite_quantifiers(exprt &expr, statet &state) } } -/*******************************************************************\ - -Function: goto_symext::operator() - - Inputs: - - Outputs: - - Purpose: symex from given state - -\*******************************************************************/ - +/// symex from given state void goto_symext::operator()( statet &state, const goto_functionst &goto_functions, @@ -181,7 +125,7 @@ void goto_symext::operator()( state.source.thread_nr+1 #include @@ -14,22 +17,10 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -#include +#include #include "goto_symex.h" -/*******************************************************************\ - -Function: goto_symext::symex_other - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::symex_other( const goto_functionst &goto_functions, statet &state) @@ -85,7 +76,8 @@ void goto_symext::symex_other( { // we ignore this for now } - else if(statement==ID_array_copy) + else if(statement==ID_array_copy || + statement==ID_array_replace) { assert(code.operands().size()==2); @@ -94,15 +86,21 @@ void goto_symext::symex_other( // we need to add dereferencing for both operands dereference_exprt d0, d1; d0.op0()=code.op0(); - d0.type()=code.op0().type().subtype(); + d0.type()=empty_typet(); d1.op0()=code.op1(); - d1.type()=code.op1().type().subtype(); + d1.type()=empty_typet(); clean_code.op0()=d0; clean_code.op1()=d1; clean_expr(clean_code.op0(), state, true); + if(clean_code.op0().id()==byte_extract_id() && + clean_code.op0().type().id()==ID_empty) + clean_code.op0()=clean_code.op0().op0(); clean_expr(clean_code.op1(), state, false); + if(clean_code.op1().id()==byte_extract_id() && + clean_code.op1().type().id()==ID_empty) + clean_code.op1()=clean_code.op1().op0(); process_array_expr(clean_code.op0()); clean_expr(clean_code.op0(), state, true); @@ -114,11 +112,21 @@ void goto_symext::symex_other( clean_code.op1().type(), ns)) { byte_extract_exprt be(byte_extract_id()); - be.type()=clean_code.op0().type(); - be.op()=clean_code.op1(); be.offset()=from_integer(0, index_type()); - clean_code.op1()=be; + if(statement==ID_array_copy) + { + be.op()=clean_code.op1(); + be.type()=clean_code.op0().type(); + clean_code.op1()=be; + } + else + { + // ID_array_replace + be.op()=clean_code.op0(); + be.type()=clean_code.op1().type(); + clean_code.op0()=be; + } } code_assignt assignment; @@ -135,11 +143,14 @@ void goto_symext::symex_other( // we need to add dereferencing for the first operand dereference_exprt d0; d0.op0()=code.op0(); - d0.type()=code.op0().type().subtype(); + d0.type()=empty_typet(); clean_code.op0()=d0; clean_expr(clean_code.op0(), state, true); + if(clean_code.op0().id()==byte_extract_id() && + clean_code.op0().type().id()==ID_empty) + clean_code.op0()=clean_code.op0().op0(); clean_expr(clean_code.op1(), state, false); process_array_expr(clean_code.op0()); diff --git a/src/goto-symex/symex_slice_class.h b/src/goto-symex/symex_slice_class.h index c669ded9ed2..413a0bdc472 100644 --- a/src/goto-symex/symex_slice_class.h +++ b/src/goto-symex/symex_slice_class.h @@ -6,20 +6,15 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Slicer for symex traces + #ifndef CPROVER_GOTO_SYMEX_SYMEX_SLICE_CLASS_H #define CPROVER_GOTO_SYMEX_SYMEX_SLICE_CLASS_H #include "symex_target_equation.h" #include "slice.h" -/*******************************************************************\ - - Class: symex_slicet - - Purpose: - -\*******************************************************************/ - class symex_slicet { public: diff --git a/src/goto-symex/symex_start_thread.cpp b/src/goto-symex/symex_start_thread.cpp index 67cb147964c..e5891d79242 100644 --- a/src/goto-symex/symex_start_thread.cpp +++ b/src/goto-symex/symex_start_thread.cpp @@ -6,22 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbolic Execution + #include #include "goto_symex.h" -/*******************************************************************\ - -Function: goto_symext::symex_start_thread - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_symext::symex_start_thread(statet &state) { if(state.guard.is_false()) diff --git a/src/goto-symex/symex_target.cpp b/src/goto-symex/symex_target.cpp index 808ec3d2004..cc03c29eaad 100644 --- a/src/goto-symex/symex_target.cpp +++ b/src/goto-symex/symex_target.cpp @@ -6,19 +6,10 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "symex_target.h" - -/*******************************************************************\ - -Function: operator < - - Inputs: +/// \file +/// Symbolic Execution - Outputs: - - Purpose: - -\*******************************************************************/ +#include "symex_target.h" bool operator<( const symex_targett::sourcet &a, diff --git a/src/goto-symex/symex_target.h b/src/goto-symex/symex_target.h index 2aae977f71f..24a8daee0e2 100644 --- a/src/goto-symex/symex_target.h +++ b/src/goto-symex/symex_target.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Generate Equation using Symbolic Execution + #ifndef CPROVER_GOTO_SYMEX_SYMEX_TARGET_H #define CPROVER_GOTO_SYMEX_SYMEX_TARGET_H diff --git a/src/goto-symex/symex_target_equation.cpp b/src/goto-symex/symex_target_equation.cpp index e522affb3ac..e0c8e86a42f 100644 --- a/src/goto-symex/symex_target_equation.cpp +++ b/src/goto-symex/symex_target_equation.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbolic Execution + #include #include @@ -18,51 +21,16 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_symex_state.h" #include "symex_target_equation.h" -/*******************************************************************\ - -Function: symex_target_equationt::symex_target_equationt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - symex_target_equationt::symex_target_equationt( const namespacet &_ns):ns(_ns) { } -/*******************************************************************\ - -Function: symex_target_equationt::~symex_target_equationt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - symex_target_equationt::~symex_target_equationt() { } -/*******************************************************************\ - -Function: symex_target_equationt::shared_read - - Inputs: - - Outputs: - - Purpose: read from a shared variable - -\*******************************************************************/ - +/// read from a shared variable void symex_target_equationt::shared_read( const exprt &guard, const ssa_exprt &ssa_object, @@ -81,18 +49,7 @@ void symex_target_equationt::shared_read( merge_ireps(SSA_step); } -/*******************************************************************\ - -Function: symex_target_equationt::shared_write - - Inputs: - - Outputs: - - Purpose: write to a sharedvariable - -\*******************************************************************/ - +/// write to a sharedvariable void symex_target_equationt::shared_write( const exprt &guard, const ssa_exprt &ssa_object, @@ -111,18 +68,7 @@ void symex_target_equationt::shared_write( merge_ireps(SSA_step); } -/*******************************************************************\ - -Function: symex_target_equationt::spawn - - Inputs: - - Outputs: - - Purpose: spawn a new thread - -\*******************************************************************/ - +/// spawn a new thread void symex_target_equationt::spawn( const exprt &guard, const sourcet &source) @@ -136,18 +82,6 @@ void symex_target_equationt::spawn( merge_ireps(SSA_step); } -/*******************************************************************\ - -Function: symex_target_equationt::memory_barrier - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_target_equationt::memory_barrier( const exprt &guard, const sourcet &source) @@ -161,18 +95,7 @@ void symex_target_equationt::memory_barrier( merge_ireps(SSA_step); } -/*******************************************************************\ - -Function: symex_target_equationt::atomic_begin - - Inputs: - - Outputs: - - Purpose: start an atomic section - -\*******************************************************************/ - +/// start an atomic section void symex_target_equationt::atomic_begin( const exprt &guard, unsigned atomic_section_id, @@ -188,18 +111,7 @@ void symex_target_equationt::atomic_begin( merge_ireps(SSA_step); } -/*******************************************************************\ - -Function: symex_target_equationt::atomic_end - - Inputs: - - Outputs: - - Purpose: end an atomic section - -\*******************************************************************/ - +/// end an atomic section void symex_target_equationt::atomic_end( const exprt &guard, unsigned atomic_section_id, @@ -215,18 +127,7 @@ void symex_target_equationt::atomic_end( merge_ireps(SSA_step); } -/*******************************************************************\ - -Function: symex_target_equationt::assignment - - Inputs: - - Outputs: - - Purpose: write to a variable - -\*******************************************************************/ - +/// write to a variable void symex_target_equationt::assignment( const exprt &guard, const ssa_exprt &ssa_lhs, @@ -257,18 +158,7 @@ void symex_target_equationt::assignment( merge_ireps(SSA_step); } -/*******************************************************************\ - -Function: symex_target_equationt::decl - - Inputs: - - Outputs: - - Purpose: declare a fresh variable - -\*******************************************************************/ - +/// declare a fresh variable void symex_target_equationt::decl( const exprt &guard, const ssa_exprt &ssa_lhs, @@ -295,18 +185,7 @@ void symex_target_equationt::decl( merge_ireps(SSA_step); } -/*******************************************************************\ - -Function: symex_target_equationt::dead - - Inputs: - - Outputs: - - Purpose: declare a fresh variable - -\*******************************************************************/ - +/// declare a fresh variable void symex_target_equationt::dead( const exprt &guard, const ssa_exprt &ssa_lhs, @@ -315,18 +194,7 @@ void symex_target_equationt::dead( // we currently don't record these } -/*******************************************************************\ - -Function: symex_target_equationt::location - - Inputs: - - Outputs: - - Purpose: just record a location - -\*******************************************************************/ - +/// just record a location void symex_target_equationt::location( const exprt &guard, const sourcet &source) @@ -341,18 +209,7 @@ void symex_target_equationt::location( merge_ireps(SSA_step); } -/*******************************************************************\ - -Function: symex_target_equationt::function_call - - Inputs: - - Outputs: - - Purpose: just record a location - -\*******************************************************************/ - +/// just record a location void symex_target_equationt::function_call( const exprt &guard, const irep_idt &identifier, @@ -369,18 +226,7 @@ void symex_target_equationt::function_call( merge_ireps(SSA_step); } -/*******************************************************************\ - -Function: symex_target_equationt::function_return - - Inputs: - - Outputs: - - Purpose: just record a location - -\*******************************************************************/ - +/// just record a location void symex_target_equationt::function_return( const exprt &guard, const irep_idt &identifier, @@ -397,18 +243,7 @@ void symex_target_equationt::function_return( merge_ireps(SSA_step); } -/*******************************************************************\ - -Function: symex_target_equationt::output - - Inputs: - - Outputs: - - Purpose: just record output - -\*******************************************************************/ - +/// just record output void symex_target_equationt::output( const exprt &guard, const sourcet &source, @@ -427,18 +262,7 @@ void symex_target_equationt::output( merge_ireps(SSA_step); } -/*******************************************************************\ - -Function: symex_target_equationt::output_fmt - - Inputs: - - Outputs: - - Purpose: just record formatted output - -\*******************************************************************/ - +/// just record formatted output void symex_target_equationt::output_fmt( const exprt &guard, const sourcet &source, @@ -460,18 +284,7 @@ void symex_target_equationt::output_fmt( merge_ireps(SSA_step); } -/*******************************************************************\ - -Function: symex_target_equationt::input - - Inputs: - - Outputs: - - Purpose: just record input - -\*******************************************************************/ - +/// just record input void symex_target_equationt::input( const exprt &guard, const sourcet &source, @@ -490,18 +303,7 @@ void symex_target_equationt::input( merge_ireps(SSA_step); } -/*******************************************************************\ - -Function: symex_target_equationt::assumption - - Inputs: - - Outputs: - - Purpose: record an assumption - -\*******************************************************************/ - +/// record an assumption void symex_target_equationt::assumption( const exprt &guard, const exprt &cond, @@ -518,18 +320,7 @@ void symex_target_equationt::assumption( merge_ireps(SSA_step); } -/*******************************************************************\ - -Function: symex_target_equationt::assertion - - Inputs: - - Outputs: - - Purpose: record an assertion - -\*******************************************************************/ - +/// record an assertion void symex_target_equationt::assertion( const exprt &guard, const exprt &cond, @@ -548,18 +339,7 @@ void symex_target_equationt::assertion( merge_ireps(SSA_step); } -/*******************************************************************\ - -Function: symex_target_equationt::goto_instruction - - Inputs: - - Outputs: - - Purpose: record a goto instruction - -\*******************************************************************/ - +/// record a goto instruction void symex_target_equationt::goto_instruction( const exprt &guard, const exprt &cond, @@ -576,18 +356,7 @@ void symex_target_equationt::goto_instruction( merge_ireps(SSA_step); } -/*******************************************************************\ - -Function: symex_target_equationt::constraint - - Inputs: - - Outputs: - - Purpose: record a constraint - -\*******************************************************************/ - +/// record a constraint void symex_target_equationt::constraint( const exprt &cond, const std::string &msg, @@ -606,18 +375,6 @@ void symex_target_equationt::constraint( merge_ireps(SSA_step); } -/*******************************************************************\ - -Function: symex_target_equationt::convert - - Inputs: converter - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_target_equationt::convert( prop_convt &prop_conv) { @@ -631,18 +388,9 @@ void symex_target_equationt::convert( convert_constraints(prop_conv); } -/*******************************************************************\ - -Function: symex_target_equationt::convert_assignments - - Inputs: decision procedure - - Outputs: - - - Purpose: converts assignments - -\*******************************************************************/ - +/// converts assignments +/// \par parameters: decision procedure +/// \return - void symex_target_equationt::convert_assignments( decision_proceduret &decision_procedure) const { @@ -653,18 +401,8 @@ void symex_target_equationt::convert_assignments( } } -/*******************************************************************\ - -Function: symex_target_equationt::convert_decls - - Inputs: converter - - Outputs: - - - Purpose: converts declarations - -\*******************************************************************/ - +/// converts declarations +/// \return - void symex_target_equationt::convert_decls( prop_convt &prop_conv) const { @@ -679,18 +417,8 @@ void symex_target_equationt::convert_decls( } } -/*******************************************************************\ - -Function: symex_target_equationt::convert_guards - - Inputs: converter - - Outputs: - - - Purpose: converts guards - -\*******************************************************************/ - +/// converts guards +/// \return - void symex_target_equationt::convert_guards( prop_convt &prop_conv) { @@ -703,18 +431,8 @@ void symex_target_equationt::convert_guards( } } -/*******************************************************************\ - -Function: symex_target_equationt::convert_assumptions - - Inputs: converter - - Outputs: - - - Purpose: converts assumptions - -\*******************************************************************/ - +/// converts assumptions +/// \return - void symex_target_equationt::convert_assumptions( prop_convt &prop_conv) { @@ -730,18 +448,8 @@ void symex_target_equationt::convert_assumptions( } } -/*******************************************************************\ - -Function: symex_target_equationt::convert_goto_instructions - - Inputs: converter - - Outputs: - - - Purpose: converts goto instructions - -\*******************************************************************/ - +/// converts goto instructions +/// \return - void symex_target_equationt::convert_goto_instructions( prop_convt &prop_conv) { @@ -757,18 +465,9 @@ void symex_target_equationt::convert_goto_instructions( } } -/*******************************************************************\ - -Function: symex_target_equationt::convert_constraints - - Inputs: decision procedure - - Outputs: - - - Purpose: converts constraints - -\*******************************************************************/ - +/// converts constraints +/// \par parameters: decision procedure +/// \return - void symex_target_equationt::convert_constraints( decision_proceduret &decision_procedure) const { @@ -784,18 +483,8 @@ void symex_target_equationt::convert_constraints( } } -/*******************************************************************\ - -Function: symex_target_equationt::convert_assertions - - Inputs: converter - - Outputs: - - - Purpose: converts assertions - -\*******************************************************************/ - +/// converts assertions +/// \return - void symex_target_equationt::convert_assertions( prop_convt &prop_conv) { @@ -861,18 +550,9 @@ void symex_target_equationt::convert_assertions( prop_conv.set_to_true(disjunction(disjuncts)); } -/*******************************************************************\ - -Function: symex_target_equationt::convert_io - - Inputs: decision procedure - - Outputs: - - - Purpose: converts I/O - -\*******************************************************************/ - +/// converts I/O +/// \par parameters: decision procedure +/// \return - void symex_target_equationt::convert_io( decision_proceduret &dec_proc) { @@ -903,18 +583,6 @@ void symex_target_equationt::convert_io( } -/*******************************************************************\ - -Function: symex_target_equationt::merge_ireps - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_target_equationt::merge_ireps(SSA_stept &SSA_step) { merge_irep(SSA_step.guard); @@ -932,18 +600,6 @@ void symex_target_equationt::merge_ireps(SSA_stept &SSA_step) // converted_io_args is merged in convert_io } -/*******************************************************************\ - -Function: symex_target_equationt::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_target_equationt::output(std::ostream &out) const { for(const auto &step : SSA_steps) @@ -953,18 +609,6 @@ void symex_target_equationt::output(std::ostream &out) const } } -/*******************************************************************\ - -Function: symex_target_equationt::SSA_stept::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_target_equationt::SSA_stept::output( const namespacet &ns, std::ostream &out) const @@ -974,27 +618,27 @@ void symex_target_equationt::SSA_stept::output( out << "Thread " << source.thread_nr; if(source.pc->source_location.is_not_nil()) - out << " " << source.pc->source_location << std::endl; + out << " " << source.pc->source_location << '\n'; else - out << std::endl; + out << '\n'; } switch(type) { case goto_trace_stept::typet::ASSERT: - out << "ASSERT " << from_expr(ns, "", cond_expr) << std::endl; break; + out << "ASSERT " << from_expr(ns, "", cond_expr) << '\n'; break; case goto_trace_stept::typet::ASSUME: - out << "ASSUME " << from_expr(ns, "", cond_expr) << std::endl; break; + out << "ASSUME " << from_expr(ns, "", cond_expr) << '\n'; break; case goto_trace_stept::typet::LOCATION: - out << "LOCATION" << std::endl; break; + out << "LOCATION" << '\n'; break; case goto_trace_stept::typet::INPUT: - out << "INPUT" << std::endl; break; + out << "INPUT" << '\n'; break; case goto_trace_stept::typet::OUTPUT: - out << "OUTPUT" << std::endl; break; + out << "OUTPUT" << '\n'; break; case goto_trace_stept::typet::DECL: - out << "DECL" << std::endl; - out << from_expr(ns, "", ssa_lhs) << std::endl; + out << "DECL" << '\n'; + out << from_expr(ns, "", ssa_lhs) << '\n'; break; case goto_trace_stept::typet::ASSIGNMENT: @@ -1018,59 +662,47 @@ void symex_target_equationt::SSA_stept::output( } } - out << ")" << std::endl; + out << ")\n"; break; case goto_trace_stept::typet::DEAD: - out << "DEAD" << std::endl; break; + out << "DEAD\n"; break; case goto_trace_stept::typet::FUNCTION_CALL: - out << "FUNCTION_CALL" << std::endl; break; + out << "FUNCTION_CALL\n"; break; case goto_trace_stept::typet::FUNCTION_RETURN: - out << "FUNCTION_RETURN" << std::endl; break; + out << "FUNCTION_RETURN\n"; break; case goto_trace_stept::typet::CONSTRAINT: - out << "CONSTRAINT" << std::endl; break; + out << "CONSTRAINT\n"; break; case goto_trace_stept::typet::SHARED_READ: - out << "SHARED READ" << std::endl; break; + out << "SHARED READ\n"; break; case goto_trace_stept::typet::SHARED_WRITE: - out << "SHARED WRITE" << std::endl; break; + out << "SHARED WRITE\n"; break; case goto_trace_stept::typet::ATOMIC_BEGIN: - out << "ATOMIC_BEGIN" << std::endl; break; + out << "ATOMIC_BEGIN\n"; break; case goto_trace_stept::typet::ATOMIC_END: - out << "AUTOMIC_END" << std::endl; break; + out << "AUTOMIC_END\n"; break; case goto_trace_stept::typet::SPAWN: - out << "SPAWN" << std::endl; break; + out << "SPAWN\n"; break; case goto_trace_stept::typet::MEMORY_BARRIER: - out << "MEMORY_BARRIER" << std::endl; break; + out << "MEMORY_BARRIER\n"; break; case goto_trace_stept::typet::GOTO: - out << "IF " << from_expr(ns, "", cond_expr) << " GOTO" << std::endl; break; + out << "IF " << from_expr(ns, "", cond_expr) << " GOTO\n"; break; default: assert(false); } if(is_assert() || is_assume() || is_assignment() || is_constraint()) - out << from_expr(ns, "", cond_expr) << std::endl; + out << from_expr(ns, "", cond_expr) << '\n'; if(is_assert() || is_constraint()) - out << comment << std::endl; + out << comment << '\n'; if(is_shared_read() || is_shared_write()) - out << from_expr(ns, "", ssa_lhs) << std::endl; + out << from_expr(ns, "", ssa_lhs) << '\n'; - out << "Guard: " << from_expr(ns, "", guard) << std::endl; + out << "Guard: " << from_expr(ns, "", guard) << '\n'; } -/*******************************************************************\ - -Function: operator << - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::ostream &operator<<( std::ostream &out, const symex_target_equationt &equation) @@ -1079,18 +711,6 @@ std::ostream &operator<<( return out; } -/*******************************************************************\ - -Function: operator << - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::ostream &operator<<( std::ostream &out, const symex_target_equationt::SSA_stept &step) diff --git a/src/goto-symex/symex_target_equation.h b/src/goto-symex/symex_target_equation.h index e7f0274aac1..abee81346a7 100644 --- a/src/goto-symex/symex_target_equation.h +++ b/src/goto-symex/symex_target_equation.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Generate Equation using Symbolic Execution + #ifndef CPROVER_GOTO_SYMEX_SYMEX_TARGET_EQUATION_H #define CPROVER_GOTO_SYMEX_SYMEX_TARGET_EQUATION_H diff --git a/src/goto-symex/symex_throw.cpp b/src/goto-symex/symex_throw.cpp index e5091c566f2..a29ce901440 100644 --- a/src/goto-symex/symex_throw.cpp +++ b/src/goto-symex/symex_throw.cpp @@ -6,19 +6,10 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "goto_symex.h" - -/*******************************************************************\ - -Function: goto_symext::symex_throw - - Inputs: +/// \file +/// Symbolic Execution - Outputs: - - Purpose: - -\*******************************************************************/ +#include "goto_symex.h" void goto_symext::symex_throw(statet &state) { diff --git a/src/java_bytecode/bytecode_info.cpp b/src/java_bytecode/bytecode_info.cpp index 87b1942b54e..8c9ce696323 100644 --- a/src/java_bytecode/bytecode_info.cpp +++ b/src/java_bytecode/bytecode_info.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + // http://docs.oracle.com/javase/specs/jvms/se8/html/ // http://en.wikipedia.org/wiki/Java_bytecode_instruction_listings diff --git a/src/java_bytecode/bytecode_info.h b/src/java_bytecode/bytecode_info.h index e378c0a18c8..08462ccf5cf 100644 --- a/src/java_bytecode/bytecode_info.h +++ b/src/java_bytecode/bytecode_info.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_JAVA_BYTECODE_BYTECODE_INFO_H #define CPROVER_JAVA_BYTECODE_BYTECODE_INFO_H diff --git a/src/java_bytecode/character_refine_preprocess.cpp b/src/java_bytecode/character_refine_preprocess.cpp index f4e896eea11..8c0723599d5 100644 --- a/src/java_bytecode/character_refine_preprocess.cpp +++ b/src/java_bytecode/character_refine_preprocess.cpp @@ -9,22 +9,17 @@ Date: March 2017 \*******************************************************************/ +/// \file +/// Preprocess a goto-programs so that calls to the java Character library are +/// replaced by simple expressions. + #include #include #include "character_refine_preprocess.h" -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_char_function - - Inputs: - expr_function - A reference to a function on expressions - target - A position in a goto program - - Purpose: converts based on a function on expressions - -\*******************************************************************/ - +/// converts based on a function on expressions +/// \param expr_function: A reference to a function on expressions +/// \param target: A position in a goto program codet character_refine_preprocesst::convert_char_function( exprt (*expr_function)(const exprt &chr, const typet &type), conversion_inputt &target) @@ -37,22 +32,12 @@ codet character_refine_preprocesst::convert_char_function( return code_assignt(result, expr_function(arg, type)); } -/*******************************************************************\ - -Function: character_refine_preprocesst::in_interval_expr - - Inputs: - arg - Expression we want to bound - lower_bound - Integer lower bound - upper_bound - Integer upper bound - - Outputs: A Boolean expression - - Purpose: The returned expression is true when the first argument is in the - interval defined by the lower and upper bounds (included) - -\*******************************************************************/ - +/// The returned expression is true when the first argument is in the interval +/// defined by the lower and upper bounds (included) +/// \param arg: Expression we want to bound +/// \param lower_bound: Integer lower bound +/// \param upper_bound: Integer upper bound +/// \return A Boolean expression exprt character_refine_preprocesst::in_interval_expr( const exprt &chr, const mp_integer &lower_bound, @@ -63,21 +48,11 @@ exprt character_refine_preprocesst::in_interval_expr( binary_relation_exprt(chr, ID_le, from_integer(upper_bound, chr.type()))); } -/*******************************************************************\ - -Function: character_refine_preprocesst::in_list_expr - - Inputs: - chr - An expression of type character - list - A list of integer representing unicode characters - - Outputs: A Boolean expression - - Purpose: The returned expression is true when the given character - is equal to one of the element in the list - -\*******************************************************************/ - +/// The returned expression is true when the given character is equal to one of +/// the element in the list +/// \param chr: An expression of type character +/// \param list: A list of integer representing unicode characters +/// \return A Boolean expression exprt character_refine_preprocesst::in_list_expr( const exprt &chr, const std::list &list) { @@ -87,21 +62,11 @@ exprt character_refine_preprocesst::in_list_expr( return disjunction(ops); } -/*******************************************************************\ - -Function: character_refine_preprocesst::expr_of_char_count - - Inputs: - expr - An expression of type character - type - A type for the output - - Outputs: A integer expression of the given type - - Purpose: Determines the number of char values needed to represent - the specified character (Unicode code point). - -\*******************************************************************/ - +/// Determines the number of char values needed to represent the specified +/// character (Unicode code point). +/// \param expr: An expression of type character +/// \param type: A type for the output +/// \return A integer expression of the given type exprt character_refine_preprocesst::expr_of_char_count( const exprt &chr, const typet &type) { @@ -110,18 +75,9 @@ exprt character_refine_preprocesst::expr_of_char_count( return if_exprt(small, from_integer(1, type), from_integer(2, type)); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_char_count - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.charCount:(I)I - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.charCount:(I)I +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_char_count( conversion_inputt &target) { @@ -129,37 +85,17 @@ codet character_refine_preprocesst::convert_char_count( &character_refine_preprocesst::expr_of_char_count, target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::expr_of_char_value - Inputs: - expr - An expression of type character - type - A type for the output - - Outputs: An expression of the given type - - Purpose: Casts the given expression to the given type - -\*******************************************************************/ - +/// Casts the given expression to the given type +/// \return An expression of the given type exprt character_refine_preprocesst::expr_of_char_value( const exprt &chr, const typet &type) { return typecast_exprt(chr, type); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_char_value - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.charValue:()C - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.charValue:()C +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_char_value( conversion_inputt &target) { @@ -167,18 +103,9 @@ codet character_refine_preprocesst::convert_char_value( &character_refine_preprocesst::expr_of_char_value, target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_compare - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.compare:(CC)I - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.compare:(CC)I +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_compare(conversion_inputt &target) { const code_function_callt &function_call=target; @@ -198,18 +125,9 @@ codet character_refine_preprocesst::convert_compare(conversion_inputt &target) } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_digit_char - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.digit:(CI)I - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.digit:(CI)I +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_digit_char( conversion_inputt &target) { @@ -281,37 +199,19 @@ codet character_refine_preprocesst::convert_digit_char( return code_assignt(result, tc_expr); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_char_is_digit_int - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.digit:(II)I - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.digit:(II)I +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_digit_int(conversion_inputt &target) { return convert_digit_char(target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_for_digit - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.forDigit:(II)C - - TODO: For now the radix argument is ignored - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.forDigit:(II)C +/// +/// TODO: For now the radix argument is ignored +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_for_digit(conversion_inputt &target) { const code_function_callt &function_call=target; @@ -328,18 +228,9 @@ codet character_refine_preprocesst::convert_for_digit(conversion_inputt &target) return code_assignt(result, if_exprt(small, value1, value2)); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_get_directionality_char - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.getDirectionality:(C)I - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.getDirectionality:(C)I +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_get_directionality_char( conversion_inputt &target) { @@ -348,75 +239,39 @@ codet character_refine_preprocesst::convert_get_directionality_char( return target; } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_char_is_digit_char - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.getDirectionality:(I)I - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.getDirectionality:(I)I +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_get_directionality_int( conversion_inputt &target) { return convert_get_directionality_char(target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_get_numeric_value_char - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.getNumericValue:(C)I - - TODO: For now this is only for ASCII characters - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.getNumericValue:(C)I +/// +/// TODO: For now this is only for ASCII characters codet character_refine_preprocesst::convert_get_numeric_value_char( conversion_inputt &target) { return convert_digit_char(target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_get_numeric_value_int - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.getNumericValue:(C)I - - TODO: For now this is only for ASCII characters - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.getNumericValue:(C)I +/// +/// TODO: For now this is only for ASCII characters +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_get_numeric_value_int( conversion_inputt &target) { return convert_digit_int(target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_get_type_char - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.getType:(C)I - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.getType:(C)I +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_get_type_char( conversion_inputt &target) { @@ -425,58 +280,29 @@ codet character_refine_preprocesst::convert_get_type_char( return target; } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_get_type_int - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.getType:(I)I - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.getType:(I)I +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_get_type_int( conversion_inputt &target) { return convert_get_type_char(target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_hash_code - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.hashCode:()I - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.hashCode:()I +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_hash_code(conversion_inputt &target) { return convert_char_value(target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::expr_of_high_surrogate - - Inputs: - expr - An expression of type character - type - A type for the output - - Outputs: An expression of the given type - - Purpose: Returns the leading surrogate (a high surrogate code unit) - of the surrogate pair representing the specified - supplementary character (Unicode code point) in the UTF-16 - encoding. - -\*******************************************************************/ - +/// Returns the leading surrogate (a high surrogate code unit) of the surrogate +/// pair representing the specified supplementary character (Unicode code point) +/// in the UTF-16 encoding. +/// \param expr: An expression of type character +/// \param type: A type for the output +/// \return An expression of the given type exprt character_refine_preprocesst::expr_of_high_surrogate( const exprt &chr, const typet &type) { @@ -488,17 +314,8 @@ exprt character_refine_preprocesst::expr_of_high_surrogate( return high_surrogate; } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_high_surrogate - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.highSurrogate:(C)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.highSurrogate:(C)Z codet character_refine_preprocesst::convert_high_surrogate( conversion_inputt &target) { @@ -506,66 +323,34 @@ codet character_refine_preprocesst::convert_high_surrogate( &character_refine_preprocesst::expr_of_high_surrogate, target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::expr_of_is_ascii_lower_case - - Inputs: - chr - An expression of type character - type - A type for the output - - Outputs: A Boolean expression - - Purpose: Determines if the specified character is an ASCII lowercase - character. - -\*******************************************************************/ - +/// Determines if the specified character is an ASCII lowercase character. +/// \param chr: An expression of type character +/// \param type: A type for the output +/// \return A Boolean expression exprt character_refine_preprocesst::expr_of_is_ascii_lower_case( const exprt &chr, const typet &type) { return in_interval_expr(chr, 'a', 'z'); } -/*******************************************************************\ - -Function: character_refine_preprocesst::expr_of_is_ascii_upper_case - - Inputs: - expr - An expression of type character - type - A type for the output - - Outputs: A Boolean expression - - Purpose: Determines if the specified character is an ASCII uppercase - character. - -\*******************************************************************/ - +/// Determines if the specified character is an ASCII uppercase character. +/// \param expr: An expression of type character +/// \param type: A type for the output +/// \return A Boolean expression exprt character_refine_preprocesst::expr_of_is_ascii_upper_case( const exprt &chr, const typet &type) { return in_interval_expr(chr, 'A', 'Z'); } -/*******************************************************************\ - -Function: character_refine_preprocesst::expr_of_is_letter - - Inputs: - expr - An expression of type character - type - A type for the output - - Outputs: An expression of the given type - - Purpose: Determines if the specified character is a letter. - - TODO: for now this is only for ASCII characters, the - following unicode categories are not yet considered: - TITLECASE_LETTER MODIFIER_LETTER OTHER_LETTER LETTER_NUMBER - -\*******************************************************************/ - +/// Determines if the specified character is a letter. +/// +/// TODO: for now this is only for ASCII characters, the +/// following unicode categories are not yet considered: +/// TITLECASE_LETTER MODIFIER_LETTER OTHER_LETTER LETTER_NUMBER +/// \param expr: An expression of type character +/// \param type: A type for the output +/// \return An expression of the given type exprt character_refine_preprocesst::expr_of_is_letter( const exprt &chr, const typet &type) { @@ -574,45 +359,25 @@ exprt character_refine_preprocesst::expr_of_is_letter( expr_of_is_ascii_lower_case(chr, type)); } -/*******************************************************************\ - -Function: character_refine_preprocesst::expr_of_is_alphabetic - - Inputs: - expr - An expression of type character - type - A type for the output - - Outputs: An expression of the given type - - Purpose: Determines if the specified character (Unicode code point) - is alphabetic. - - TODO: for now this is only for ASCII characters, the - following unicode categorise are not yet considered: - TITLECASE_LETTER MODIFIER_LETTER OTHER_LETTER LETTER_NUMBER - and contributory property Other_Alphabetic as defined by the - Unicode Standard. - -\*******************************************************************/ - +/// Determines if the specified character (Unicode code point) is alphabetic. +/// +/// TODO: for now this is only for ASCII characters, the +/// following unicode categorise are not yet considered: +/// TITLECASE_LETTER MODIFIER_LETTER OTHER_LETTER LETTER_NUMBER +/// and contributory property Other_Alphabetic as defined by the +/// Unicode Standard. +/// \param expr: An expression of type character +/// \param type: A type for the output +/// \return An expression of the given type exprt character_refine_preprocesst::expr_of_is_alphabetic( const exprt &chr, const typet &type) { return expr_of_is_letter(chr, type); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_alphabetic - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isAlphabetic:(I)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isAlphabetic:(I)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_alphabetic( conversion_inputt &target) { @@ -620,22 +385,12 @@ codet character_refine_preprocesst::convert_is_alphabetic( &character_refine_preprocesst::expr_of_is_alphabetic, target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::expr_of_is_bmp_code_point - - Inputs: - expr - An expression of type character - type - A type for the output - - Outputs: A Boolean expression - - Purpose: Determines whether the specified character (Unicode code - point) is in the Basic Multilingual Plane (BMP). Such code - points can be represented using a single char. - -\*******************************************************************/ - +/// Determines whether the specified character (Unicode code point) is in the +/// Basic Multilingual Plane (BMP). Such code points can be represented using a +/// single char. +/// \param expr: An expression of type character +/// \param type: A type for the output +/// \return A Boolean expression exprt character_refine_preprocesst::expr_of_is_bmp_code_point( const exprt &chr, const typet &type) { @@ -643,18 +398,9 @@ exprt character_refine_preprocesst::expr_of_is_bmp_code_point( return is_bmp; } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_bmp_code_point - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isBmpCodePoint:(I)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isBmpCodePoint:(I)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_bmp_code_point( conversion_inputt &target) { @@ -662,20 +408,10 @@ codet character_refine_preprocesst::convert_is_bmp_code_point( &character_refine_preprocesst::expr_of_is_bmp_code_point, target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::expr_for_is_defined - - Inputs: - expr - An expression of type character - type - A type for the output - - Outputs: An expression of the given type - - Purpose: Determines if a character is defined in Unicode. - -\*******************************************************************/ - +/// Determines if a character is defined in Unicode. +/// \param expr: An expression of type character +/// \param type: A type for the output +/// \return An expression of the given type exprt character_refine_preprocesst::expr_of_is_defined( const exprt &chr, const typet &type) { @@ -707,18 +443,9 @@ exprt character_refine_preprocesst::expr_of_is_defined( return not_exprt(disjunction(intervals)); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_defined_char - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isDefined:(C)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isDefined:(C)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_defined_char( conversion_inputt &target) { @@ -726,48 +453,29 @@ codet character_refine_preprocesst::convert_is_defined_char( &character_refine_preprocesst::expr_of_is_defined, target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_char_is_digit_char - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isDefined:(I)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isDefined:(I)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_defined_int( conversion_inputt &target) { return convert_is_defined_char(target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::expr_of_is_digit - - Inputs: - chr - An expression of type character - type - A type for the output - - Outputs: An expression of the given type - - Purpose: Determines if the specified character is a digit. - A character is a digit if its general category type, - provided by Character.getType(ch), is DECIMAL_DIGIT_NUMBER. - - TODO: for now we only support these ranges of digits: - '\u0030' through '\u0039', ISO-LATIN-1 digits ('0' through '9') - '\u0660' through '\u0669', Arabic-Indic digits - '\u06F0' through '\u06F9', Extended Arabic-Indic digits - '\u0966' through '\u096F', Devanagari digits - '\uFF10' through '\uFF19', Fullwidth digits - Many other character ranges contain digits as well. - -\*******************************************************************/ - +/// Determines if the specified character is a digit. A character is a digit if +/// its general category type, provided by Character.getType(ch), is +/// DECIMAL_DIGIT_NUMBER. +/// +/// TODO: for now we only support these ranges of digits: +/// '\u0030' through '\u0039', ISO-LATIN-1 digits ('0' through '9') +/// '\u0660' through '\u0669', Arabic-Indic digits +/// '\u06F0' through '\u06F9', Extended Arabic-Indic digits +/// '\u0966' through '\u096F', Devanagari digits +/// '\uFF10' through '\uFF19', Fullwidth digits +/// Many other character ranges contain digits as well. +/// \param chr: An expression of type character +/// \param type: A type for the output +/// \return An expression of the given type exprt character_refine_preprocesst::expr_of_is_digit( const exprt &chr, const typet &type) { @@ -782,18 +490,9 @@ exprt character_refine_preprocesst::expr_of_is_digit( return digit; } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_digit_char - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isDigit:(C)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isDigit:(C)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_digit_char( conversion_inputt &target) { @@ -801,58 +500,29 @@ codet character_refine_preprocesst::convert_is_digit_char( &character_refine_preprocesst::expr_of_is_digit, target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_digit_int - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.digit:(I)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.digit:(I)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_digit_int( conversion_inputt &target) { return convert_is_digit_char(target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::expr_of_is_high_surrogate - - Inputs: - expr - An expression of type character - type - A type for the output - - Outputs: A Boolean expression - - Purpose: Determines if the given char value is a Unicode - high-surrogate code unit (also known as leading-surrogate - code unit). - -\*******************************************************************/ - +/// Determines if the given char value is a Unicode high-surrogate code unit +/// (also known as leading-surrogate code unit). +/// \param expr: An expression of type character +/// \param type: A type for the output +/// \return A Boolean expression exprt character_refine_preprocesst::expr_of_is_high_surrogate( const exprt &chr, const typet &type) { return in_interval_expr(chr, 0xD800, 0xDBFF); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_high_surrogate - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isHighSurrogate:(C)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isHighSurrogate:(C)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_high_surrogate( conversion_inputt &target) { @@ -860,26 +530,14 @@ codet character_refine_preprocesst::convert_is_high_surrogate( &character_refine_preprocesst::expr_of_is_high_surrogate, target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::expr_of_is_identifier_ignorable - - Inputs: - expr - An expression of type character - type - A type for the output - - Outputs: A Boolean expression - - Purpose: Determines if the character is one of ignorable in a Java - identifier, that is, it is in one of these ranges: - '\u0000' through '\u0008' - '\u000E' through '\u001B' - '\u007F' through '\u009F' - - TODO: For now, we ignore the FORMAT general category value - -\*******************************************************************/ - +/// Determines if the character is one of ignorable in a Java identifier, that +/// is, it is in one of these ranges: '\u0000' through '\u0008' '\u000E' through +/// '\u001B' '\u007F' through '\u009F' +/// +/// TODO: For now, we ignore the FORMAT general category value +/// \param expr: An expression of type character +/// \param type: A type for the output +/// \return A Boolean expression exprt character_refine_preprocesst::expr_of_is_identifier_ignorable( const exprt &chr, const typet &type) { @@ -891,21 +549,11 @@ exprt character_refine_preprocesst::expr_of_is_identifier_ignorable( return ignorable; } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_identifier_ignorable_char - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method - Character.isIdentifierIgnorable:(C)Z - - TODO: For now, we ignore the FORMAT general category value - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isIdentifierIgnorable:(C)Z +/// +/// TODO: For now, we ignore the FORMAT general category value +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_identifier_ignorable_char( conversion_inputt &target) { @@ -913,39 +561,20 @@ codet character_refine_preprocesst::convert_is_identifier_ignorable_char( &character_refine_preprocesst::expr_of_is_identifier_ignorable, target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_identifier_ignorable_int - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method - Character.isIdentifierIgnorable:(I)Z - - TODO: For now, we ignore the FORMAT general category value - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isIdentifierIgnorable:(I)Z +/// +/// TODO: For now, we ignore the FORMAT general category value +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_identifier_ignorable_int( conversion_inputt &target) { return convert_is_identifier_ignorable_char(target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_ideographic - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isIdeographic:(C)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isIdeographic:(C)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_ideographic( conversion_inputt &target) { @@ -957,18 +586,9 @@ codet character_refine_preprocesst::convert_is_ideographic( return code_assignt(result, is_ideograph); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_ISO_control_char - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isISOControl:(C)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isISOControl:(C)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_ISO_control_char( conversion_inputt &target) { @@ -981,39 +601,21 @@ codet character_refine_preprocesst::convert_is_ISO_control_char( return code_assignt(result, iso); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_ISO_control_int - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isISOControl:(I)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isISOControl:(I)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_ISO_control_int( conversion_inputt &target) { return convert_is_ISO_control_char(target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_java_identifier_part_char - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isJavaIdentifierPart:(C)Z - - TODO: For now we do not allow currency symbol, connecting punctuation, - combining mark, non-spacing mark - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isJavaIdentifierPart:(C)Z +/// +/// TODO: For now we do not allow currency symbol, connecting punctuation, +/// combining mark, non-spacing mark +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_java_identifier_part_char( conversion_inputt &target) { @@ -1021,40 +623,22 @@ codet character_refine_preprocesst::convert_is_java_identifier_part_char( &character_refine_preprocesst::expr_of_is_unicode_identifier_part, target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_java_identifier_part_int - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method isJavaIdentifierPart:(I)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method isJavaIdentifierPart:(I)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_java_identifier_part_int( conversion_inputt &target) { return convert_is_unicode_identifier_part_char(target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_java_identifier_start_char - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method isJavaIdentifierStart:(C)Z - - TODO: For now we only allow letters and letter numbers. - The java specification for this function is not precise on the - other characters. - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method isJavaIdentifierStart:(C)Z +/// +/// TODO: For now we only allow letters and letter numbers. +/// The java specification for this function is not precise on the +/// other characters. +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_java_identifier_start_char( conversion_inputt &target) { @@ -1062,72 +646,36 @@ codet character_refine_preprocesst::convert_is_java_identifier_start_char( &character_refine_preprocesst::expr_of_is_unicode_identifier_start, target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_char_is_digit_char - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method isJavaIdentifierStart:(I)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method isJavaIdentifierStart:(I)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_java_identifier_start_int( conversion_inputt &target) { return convert_is_java_identifier_start_char(target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_java_letter - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isJavaLetter:(C)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isJavaLetter:(C)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_java_letter( conversion_inputt &target) { return convert_is_java_identifier_start_char(target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_java_letter_or_digit - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method isJavaLetterOrDigit:(C)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method isJavaLetterOrDigit:(C)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_java_letter_or_digit( conversion_inputt &target) { return convert_is_java_identifier_part_char(target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_letter_char - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isLetter:(C)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isLetter:(C)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_letter_char( conversion_inputt &target) { @@ -1135,56 +683,28 @@ codet character_refine_preprocesst::convert_is_letter_char( &character_refine_preprocesst::expr_of_is_letter, target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_letter_int - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isLetter:(I)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isLetter:(I)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_letter_int( conversion_inputt &target) { return convert_is_letter_char(target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::expr_of_is_letter_or_digit - - Inputs: - chr - An expression of type character - type - A type for the output - - Outputs: An expression of the given type - - Purpose: Determines if the specified character is a letter or digit. - -\*******************************************************************/ - +/// Determines if the specified character is a letter or digit. +/// \param chr: An expression of type character +/// \param type: A type for the output +/// \return An expression of the given type exprt character_refine_preprocesst::expr_of_is_letter_or_digit( const exprt &chr, const typet &type) { return or_exprt(expr_of_is_letter(chr, type), expr_of_is_digit(chr, type)); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_letter_or_digit_char - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isLetterOrDigit:(C)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isLetterOrDigit:(C)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_letter_or_digit_char( conversion_inputt &target) { @@ -1192,38 +712,20 @@ codet character_refine_preprocesst::convert_is_letter_or_digit_char( &character_refine_preprocesst::expr_of_is_digit, target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_letter_or_digit_int - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isLetterOrDigit:(I)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isLetterOrDigit:(I)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_letter_or_digit_int( conversion_inputt &target) { return convert_is_letter_or_digit_char(target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_lower_case_char - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isLowerCase:(C)Z - - TODO: For now we only consider ASCII characters - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isLowerCase:(C)Z +/// +/// TODO: For now we only consider ASCII characters +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_lower_case_char( conversion_inputt &target) { @@ -1231,38 +733,20 @@ codet character_refine_preprocesst::convert_is_lower_case_char( &character_refine_preprocesst::expr_of_is_ascii_lower_case, target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_lower_case_int() - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isLowerCase:(I)Z - - TODO: For now we only consider ASCII characters - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isLowerCase:(I)Z +/// +/// TODO: For now we only consider ASCII characters +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_lower_case_int( conversion_inputt &target) { return convert_is_lower_case_char(target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_low_surrogate - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isLowSurrogate:(I)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isLowSurrogate:(I)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_low_surrogate( conversion_inputt &target) { @@ -1274,43 +758,24 @@ codet character_refine_preprocesst::convert_is_low_surrogate( return code_assignt(result, is_low_surrogate); } -/*******************************************************************\ - -Function: character_refine_preprocesst::expr_of_is_mirrored - - Inputs: - expr - An expression of type character - type - A type for the output - - Outputs: An expression of the given type - - Purpose: Determines whether the character is mirrored according to - the Unicode specification. - - TODO: For now only ASCII characters are considered - -\*******************************************************************/ - +/// Determines whether the character is mirrored according to the Unicode +/// specification. +/// +/// TODO: For now only ASCII characters are considered +/// \param expr: An expression of type character +/// \param type: A type for the output +/// \return An expression of the given type exprt character_refine_preprocesst::expr_of_is_mirrored( const exprt &chr, const typet &type) { return in_list_expr(chr, {0x28, 0x29, 0x3C, 0x3E, 0x5B, 0x5D, 0x7B, 0x7D}); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_mirrored_char - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isMirrored:(C)Z - - TODO: For now only ASCII characters are considered - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isMirrored:(C)Z +/// +/// TODO: For now only ASCII characters are considered +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_mirrored_char( conversion_inputt &target) { @@ -1318,59 +783,30 @@ codet character_refine_preprocesst::convert_is_mirrored_char( &character_refine_preprocesst::expr_of_is_mirrored, target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_mirrored_int - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isMirrored:(I)Z - - TODO: For now only ASCII characters are considered - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isMirrored:(I)Z +/// +/// TODO: For now only ASCII characters are considered +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_mirrored_int( conversion_inputt &target) { return convert_is_mirrored_char(target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_space - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isSpace:(C)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isSpace:(C)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_space(conversion_inputt &target) { return convert_is_whitespace_char(target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::expr_of_is_space_char - - Inputs: - expr - An expression of type character - type - A type for the output - - Outputs: A Boolean expression - - Purpose: Determines if the specified character is white space - according to Unicode (SPACE_SEPARATOR, LINE_SEPARATOR, or - PARAGRAPH_SEPARATOR) - -\*******************************************************************/ - +/// Determines if the specified character is white space according to Unicode +/// (SPACE_SEPARATOR, LINE_SEPARATOR, or PARAGRAPH_SEPARATOR) +/// \param expr: An expression of type character +/// \param type: A type for the output +/// \return A Boolean expression exprt character_refine_preprocesst::expr_of_is_space_char( const exprt &chr, const typet &type) { @@ -1381,18 +817,9 @@ exprt character_refine_preprocesst::expr_of_is_space_char( return or_exprt(condition0, condition1); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_space_char - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isSpaceChar:(C)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isSpaceChar:(C)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_space_char( conversion_inputt &target) { @@ -1400,58 +827,29 @@ codet character_refine_preprocesst::convert_is_space_char( &character_refine_preprocesst::expr_of_is_space_char, target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_space_char_int() - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isSpaceChar:(I)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isSpaceChar:(I)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_space_char_int( conversion_inputt &target) { return convert_is_space_char(target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::expr_of_is_supplementary_code_point - - Inputs: - expr - An expression of type character - type - A type for the output - - Outputs: A Boolean expression - - Purpose: Determines whether the specified character (Unicode code - point) is in the supplementary character range. - -\*******************************************************************/ - +/// Determines whether the specified character (Unicode code point) is in the +/// supplementary character range. +/// \param expr: An expression of type character +/// \param type: A type for the output +/// \return A Boolean expression exprt character_refine_preprocesst::expr_of_is_supplementary_code_point( const exprt &chr, const typet &type) { return binary_relation_exprt(chr, ID_gt, from_integer(0xFFFF, chr.type())); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_supplementary_code_point - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method - Character.isSupplementaryCodePoint:(I)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isSupplementaryCodePoint:(I)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_supplementary_code_point( conversion_inputt &target) { @@ -1459,39 +857,19 @@ codet character_refine_preprocesst::convert_is_supplementary_code_point( &character_refine_preprocesst::expr_of_is_supplementary_code_point, target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::expr_of_is_surrogate - - Inputs: - expr - An expression of type character - type - A type for the output - - Outputs: A Boolean expression - - Purpose: Determines if the given char value is a Unicode surrogate - code unit. - -\*******************************************************************/ - +/// Determines if the given char value is a Unicode surrogate code unit. +/// \param expr: An expression of type character +/// \param type: A type for the output +/// \return A Boolean expression exprt character_refine_preprocesst::expr_of_is_surrogate( const exprt &chr, const typet &type) { return in_interval_expr(chr, 0xD800, 0xDFFF); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_surrogate - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isSurrogate:(C)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isSurrogate:(C)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_surrogate( conversion_inputt &target) { @@ -1499,18 +877,9 @@ codet character_refine_preprocesst::convert_is_surrogate( &character_refine_preprocesst::expr_of_is_surrogate, target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_surrogate_pair - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isSurrogatePair:(CC)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isSurrogatePair:(CC)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_surrogate_pair( conversion_inputt &target) { @@ -1524,20 +893,10 @@ codet character_refine_preprocesst::convert_is_surrogate_pair( return code_assignt(result, and_exprt(is_high_surrogate, is_low_surrogate)); } -/*******************************************************************\ - -Function: character_refine_preprocesst::expr_of_is_title_case - - Inputs: - expr - An expression of type character - type - A type for the output - - Outputs: A Boolean expression - - Purpose: Determines if the specified character is a titlecase character. - -\*******************************************************************/ - +/// Determines if the specified character is a titlecase character. +/// \param expr: An expression of type character +/// \param type: A type for the output +/// \return A Boolean expression exprt character_refine_preprocesst::expr_of_is_title_case( const exprt &chr, const typet &type) { @@ -1551,18 +910,9 @@ exprt character_refine_preprocesst::expr_of_is_title_case( return disjunction(conditions); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_title_case_char - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isTitleCase:(C)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isTitleCase:(C)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_title_case_char( conversion_inputt &target) { @@ -1570,39 +920,20 @@ codet character_refine_preprocesst::convert_is_title_case_char( &character_refine_preprocesst::expr_of_is_title_case, target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_title_case_int - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isTitleCase:(I)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isTitleCase:(I)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_title_case_int( conversion_inputt &target) { return convert_is_title_case_char(target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::expr_of_is_letter_number - - Inputs: - expr - An expression of type character - type - A type for the output - - Outputs: A Boolean expression - - Purpose: Determines if the specified character is in the LETTER_NUMBER - category of Unicode - -\*******************************************************************/ - +/// Determines if the specified character is in the LETTER_NUMBER category of +/// Unicode +/// \param expr: An expression of type character +/// \param type: A type for the output +/// \return A Boolean expression exprt character_refine_preprocesst::expr_of_is_letter_number( const exprt &chr, const typet &type) { @@ -1623,23 +954,13 @@ exprt character_refine_preprocesst::expr_of_is_letter_number( } -/*******************************************************************\ - -Function: character_refine_preprocesst::expr_of_is_unicode_identifier_part - - Inputs: - expr - An expression of type character - type - A type for the output - - Outputs: A Boolean expression - - Purpose: Determines if the character may be part of a Unicode identifier. - - TODO: For now we do not allow connecting punctuation, combining mark, - non-spacing mark - -\*******************************************************************/ - +/// Determines if the character may be part of a Unicode identifier. +/// +/// TODO: For now we do not allow connecting punctuation, combining mark, +/// non-spacing mark +/// \param expr: An expression of type character +/// \param type: A type for the output +/// \return A Boolean expression exprt character_refine_preprocesst::expr_of_is_unicode_identifier_part( const exprt &chr, const typet &type) { @@ -1650,19 +971,9 @@ exprt character_refine_preprocesst::expr_of_is_unicode_identifier_part( return disjunction(conditions); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_unicode_identifier_part_char - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method - Character.isUnicodeIdentifierPart:(C)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isUnicodeIdentifierPart:(C)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_unicode_identifier_part_char( conversion_inputt &target) { @@ -1670,40 +981,20 @@ codet character_refine_preprocesst::convert_is_unicode_identifier_part_char( &character_refine_preprocesst::expr_of_is_unicode_identifier_part, target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_unicode_identifier_part_int - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method - Character.isUnicodeIdentifierPart:(I)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isUnicodeIdentifierPart:(I)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_unicode_identifier_part_int( conversion_inputt &target) { return convert_is_unicode_identifier_part_char(target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::expr_of_is_unicode_identifier_start - - Inputs: - chr - An expression of type character - type - A type for the output - - Outputs: A Boolean expression - - Purpose: Determines if the specified character is permissible as the - first character in a Unicode identifier. - -\*******************************************************************/ - +/// Determines if the specified character is permissible as the first character +/// in a Unicode identifier. +/// \param chr: An expression of type character +/// \param type: A type for the output +/// \return A Boolean expression exprt character_refine_preprocesst::expr_of_is_unicode_identifier_start( const exprt &chr, const typet &type) { @@ -1711,19 +1002,9 @@ exprt character_refine_preprocesst::expr_of_is_unicode_identifier_start( expr_of_is_letter(chr, type), expr_of_is_letter_number(chr, type)); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_unicode_identifier_start_char - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method - Character.isUnicodeIdentifierStart:(C)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isUnicodeIdentifierStart:(C)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_unicode_identifier_start_char( conversion_inputt &target) { @@ -1731,39 +1012,20 @@ codet character_refine_preprocesst::convert_is_unicode_identifier_start_char( &character_refine_preprocesst::expr_of_is_unicode_identifier_start, target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_unicode_identifier_start_int - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method - Character.isUnicodeIdentifierStart:(I)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isUnicodeIdentifierStart:(I)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_unicode_identifier_start_int( conversion_inputt &target) { return convert_is_unicode_identifier_start_char(target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_upper_case_char - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isUpperCase:(C)Z - - TODO: For now we only consider ASCII characters - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isUpperCase:(C)Z +/// +/// TODO: For now we only consider ASCII characters +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_upper_case_char( conversion_inputt &target) { @@ -1771,58 +1033,29 @@ codet character_refine_preprocesst::convert_is_upper_case_char( &character_refine_preprocesst::expr_of_is_ascii_upper_case, target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_upper_case_int - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isUpperCase:(I)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isUpperCase:(I)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_upper_case_int( conversion_inputt &target) { return convert_is_upper_case_char(target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::expr_of_is_valid_code_point - - Inputs: - chr - An expression of type character - type - A type for the output - - Outputs: A Boolean expression - - Purpose: Determines whether the specified code point is a valid - Unicode code point value. - That is, in the range of integers from 0 to 0x10FFFF - -\*******************************************************************/ - +/// Determines whether the specified code point is a valid Unicode code point +/// value. That is, in the range of integers from 0 to 0x10FFFF +/// \param chr: An expression of type character +/// \param type: A type for the output +/// \return A Boolean expression exprt character_refine_preprocesst::expr_of_is_valid_code_point( const exprt &chr, const typet &type) { return binary_relation_exprt(chr, ID_le, from_integer(0x10FFFF, chr.type())); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_valid_code_point - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isValidCodePoint:(I)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isValidCodePoint:(I)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_valid_code_point( conversion_inputt &target) { @@ -1830,26 +1063,14 @@ codet character_refine_preprocesst::convert_is_valid_code_point( &character_refine_preprocesst::expr_of_is_valid_code_point, target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::expr_of_is_whitespace - - Inputs: - expr - An expression of type character - type - A type for the output - - Outputs: A Boolean expression - - Purpose: Determines if the specified character is white space according - to Java. It is the case when it one of the following: - * a Unicode space character (SPACE_SEPARATOR, LINE_SEPARATOR, or - PARAGRAPH_SEPARATOR) but is not also a non-breaking space - ('\u00A0', '\u2007', '\u202F'). - * it is one of these: U+0009 U+000A U+000B U+000C U+000D - U+001C U+001D U+001E U+001F - -\*******************************************************************/ - +/// Determines if the specified character is white space according to Java. It +/// is the case when it one of the following: * a Unicode space character +/// (SPACE_SEPARATOR, LINE_SEPARATOR, or PARAGRAPH_SEPARATOR) but is not also a +/// non-breaking space ('\u00A0', '\u2007', '\u202F'). * it is one of these: +/// U+0009 U+000A U+000B U+000C U+000D U+001C U+001D U+001E U+001F +/// \param expr: An expression of type character +/// \param type: A type for the output +/// \return A Boolean expression exprt character_refine_preprocesst::expr_of_is_whitespace( const exprt &chr, const typet &type) { @@ -1864,18 +1085,9 @@ exprt character_refine_preprocesst::expr_of_is_whitespace( return disjunction(conditions); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_whitespace_char - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isWhitespace:(C)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isWhitespace:(C)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_whitespace_char( conversion_inputt &target) { @@ -1883,41 +1095,21 @@ codet character_refine_preprocesst::convert_is_whitespace_char( &character_refine_preprocesst::expr_of_is_whitespace, target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_is_whitespace_int - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.isWhitespace:(I)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.isWhitespace:(I)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_is_whitespace_int( conversion_inputt &target) { return convert_is_whitespace_char(target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::expr_of_low_surrogate - - Inputs: - expr - An expression of type character - type - A type for the output - - Outputs: A integer expression of the given type - - Purpose: Returns the trailing surrogate (a low surrogate code unit) - of the surrogate pair representing the specified - supplementary character (Unicode code point) in the UTF-16 - encoding. - -\*******************************************************************/ - +/// Returns the trailing surrogate (a low surrogate code unit) of the surrogate +/// pair representing the specified supplementary character (Unicode code point) +/// in the UTF-16 encoding. +/// \param expr: An expression of type character +/// \param type: A type for the output +/// \return A integer expression of the given type exprt character_refine_preprocesst::expr_of_low_surrogate( const exprt &chr, const typet &type) { @@ -1926,18 +1118,9 @@ exprt character_refine_preprocesst::expr_of_low_surrogate( return plus_exprt(uDC00, mod_exprt(chr, u0400)); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_low_surrogate - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.lowSurrogate:(I)Z - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.lowSurrogate:(I)Z +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_low_surrogate( conversion_inputt &target) { @@ -1945,21 +1128,11 @@ codet character_refine_preprocesst::convert_low_surrogate( &character_refine_preprocesst::expr_of_low_surrogate, target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::expr_of_reverse_bytes - - Inputs: - expr - An expression of type character - type - A type for the output - - Outputs: A character expression of the given type - - Purpose: Returns the value obtained by reversing the order of the - bytes in the specified char value. - -\*******************************************************************/ - +/// Returns the value obtained by reversing the order of the bytes in the +/// specified char value. +/// \param expr: An expression of type character +/// \param type: A type for the output +/// \return A character expression of the given type exprt character_refine_preprocesst::expr_of_reverse_bytes( const exprt &chr, const typet &type) { @@ -1968,18 +1141,9 @@ exprt character_refine_preprocesst::expr_of_reverse_bytes( return plus_exprt(first_byte, second_byte); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_reverse_bytes - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.reverseBytes:(C)C - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.reverseBytes:(C)C +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_reverse_bytes( conversion_inputt &target) { @@ -1987,26 +1151,14 @@ codet character_refine_preprocesst::convert_reverse_bytes( &character_refine_preprocesst::expr_of_reverse_bytes, target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::expr_of_to_chars - - Inputs: - expr - An expression of type character - type - A type for the output - - Outputs: A character array expression of the given type - - Purpose: Converts the specified character (Unicode code point) to - its UTF-16 representation stored in a char array. - If the specified code point is a BMP (Basic Multilingual - Plane or Plane 0) value, the resulting char array has the - same value as codePoint. - If the specified code point is a supplementary code point, - the resulting char array has the corresponding surrogate pair. - -\*******************************************************************/ - +/// Converts the specified character (Unicode code point) to its UTF-16 +/// representation stored in a char array. If the specified code point is a BMP +/// (Basic Multilingual Plane or Plane 0) value, the resulting char array has +/// the same value as codePoint. If the specified code point is a supplementary +/// code point, the resulting char array has the corresponding surrogate pair. +/// \param expr: An expression of type character +/// \param type: A type for the output +/// \return A character array expression of the given type exprt character_refine_preprocesst::expr_of_to_chars( const exprt &chr, const typet &type) { @@ -2022,36 +1174,18 @@ exprt character_refine_preprocesst::expr_of_to_chars( return if_exprt(expr_of_is_bmp_code_point(chr, type), case1, case2); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_to_chars - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.toChars:(I)[C - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.toChars:(I)[C +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_to_chars(conversion_inputt &target) { return convert_char_function( &character_refine_preprocesst::expr_of_to_chars, target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_to_code_point - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.toCodePoint:(CC)I - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.toCodePoint:(CC)I +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_to_code_point( conversion_inputt &target) { @@ -2077,24 +1211,14 @@ codet character_refine_preprocesst::convert_to_code_point( return code_assignt(result, pair_value); } -/*******************************************************************\ - -Function: character_refine_preprocesst::expr_of_to_lower_case - - Inputs: - chr - An expression of type character - type - A type for the output - - Outputs: An expression of the given type - - Purpose: Converts the character argument to lowercase. - - TODO: For now we only consider ASCII characters but ultimately - we should use case mapping information from the - UnicodeData file - -\*******************************************************************/ - +/// Converts the character argument to lowercase. +/// +/// TODO: For now we only consider ASCII characters but ultimately +/// we should use case mapping information from the +/// UnicodeData file +/// \param chr: An expression of type character +/// \param type: A type for the output +/// \return An expression of the given type exprt character_refine_preprocesst::expr_of_to_lower_case( const exprt &chr, const typet &type) { @@ -2105,18 +1229,9 @@ exprt character_refine_preprocesst::expr_of_to_lower_case( return res; } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_to_lower_case_char - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.toLowerCase:(C)C - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.toLowerCase:(C)C +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_to_lower_case_char( conversion_inputt &target) { @@ -2124,38 +1239,19 @@ codet character_refine_preprocesst::convert_to_lower_case_char( &character_refine_preprocesst::expr_of_to_lower_case, target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_to_lower_case_int() - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.toLowerCase:(I)I - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.toLowerCase:(I)I +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_to_lower_case_int( conversion_inputt &target) { return convert_to_lower_case_char(target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::expr_of_to_title_case - - Inputs: - chr - An expression of type character - type - A type for the output - - Outputs: An expression of the given type - - Purpose: Converts the character argument to titlecase. - -\*******************************************************************/ - +/// Converts the character argument to titlecase. +/// \param chr: An expression of type character +/// \param type: A type for the output +/// \return An expression of the given type exprt character_refine_preprocesst::expr_of_to_title_case( const exprt &chr, const typet &type) { @@ -2189,18 +1285,9 @@ exprt character_refine_preprocesst::expr_of_to_title_case( return res; } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_to_title_case_char - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.toTitleCase:(C)C - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.toTitleCase:(C)C +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_to_title_case_char( conversion_inputt &target) { @@ -2208,42 +1295,23 @@ codet character_refine_preprocesst::convert_to_title_case_char( &character_refine_preprocesst::expr_of_to_title_case, target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_to_title_case_int - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.toTitleCase:(I)I - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.toTitleCase:(I)I +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_to_title_case_int( conversion_inputt &target) { return convert_to_title_case_char(target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::expr_of_to_upper_case - - Inputs: - chr - An expression of type character - type - A type for the output - - Outputs: An expression of the given type - - Purpose: Converts the character argument to uppercase. - - TODO: For now we only consider ASCII characters but ultimately - we should use case mapping information from the - UnicodeData file - -\*******************************************************************/ - +/// Converts the character argument to uppercase. +/// +/// TODO: For now we only consider ASCII characters but ultimately +/// we should use case mapping information from the +/// UnicodeData file +/// \param chr: An expression of type character +/// \param type: A type for the output +/// \return An expression of the given type exprt character_refine_preprocesst::expr_of_to_upper_case( const exprt &chr, const typet &type) { @@ -2254,18 +1322,9 @@ exprt character_refine_preprocesst::expr_of_to_upper_case( return res; } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_to_upper_case_char - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.toUpperCase:(C)C - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.toUpperCase:(C)C +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_to_upper_case_char( conversion_inputt &target) { @@ -2273,41 +1332,21 @@ codet character_refine_preprocesst::convert_to_upper_case_char( &character_refine_preprocesst::expr_of_to_upper_case, target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::convert_to_upper_case_int - - Inputs: - target - a position in a goto program - - Purpose: Converts function call to an assignment of an expression - corresponding to the java method Character.toUpperCase:(I)I - -\*******************************************************************/ - +/// Converts function call to an assignment of an expression corresponding to +/// the java method Character.toUpperCase:(I)I +/// \param target: a position in a goto program codet character_refine_preprocesst::convert_to_upper_case_int( conversion_inputt &target) { return convert_to_upper_case_char(target); } -/*******************************************************************\ - -Function: character_refine_preprocesst::replace_character_call - - Inputs: - code - the code of a function call - - Outputs: code where character function call get replaced by - an simple instruction - - Purpose: replace function calls to functions of the Character by - an affectation if possible, returns the same code otherwise. - For this method to have an effect initialize_conversion_table - must have been called before. - -\*******************************************************************/ - +/// replace function calls to functions of the Character by an affectation if +/// possible, returns the same code otherwise. For this method to have an effect +/// initialize_conversion_table must have been called before. +/// \param code: the code of a function call +/// \return code where character function call get replaced by an simple +/// instruction codet character_refine_preprocesst::replace_character_call( const code_function_callt &code) const { @@ -2323,15 +1362,7 @@ codet character_refine_preprocesst::replace_character_call( return code; } -/*******************************************************************\ - -Function: character_refine_preprocesst::initialize_conversion_table - - Purpose: fill maps with correspondance from java method names to - conversion functions - -\*******************************************************************/ - +/// fill maps with correspondance from java method names to conversion functions void character_refine_preprocesst::initialize_conversion_table() { // All methods are listed here in alphabetic order diff --git a/src/java_bytecode/character_refine_preprocess.h b/src/java_bytecode/character_refine_preprocess.h index 45f76a5d5b6..2f41b2ec932 100644 --- a/src/java_bytecode/character_refine_preprocess.h +++ b/src/java_bytecode/character_refine_preprocess.h @@ -11,6 +11,12 @@ Date: March 2017 \*******************************************************************/ +/// \file +/// Preprocess a goto-programs so that calls to the java Character library are +/// replaced by simple expressions. For now support is limited to character in +/// the ASCII range, some methods may have incorrect specifications outside of +/// this range. + #ifndef CPROVER_JAVA_BYTECODE_CHARACTER_REFINE_PREPROCESS_H #define CPROVER_JAVA_BYTECODE_CHARACTER_REFINE_PREPROCESS_H diff --git a/src/java_bytecode/ci_lazy_methods.cpp b/src/java_bytecode/ci_lazy_methods.cpp index 5cafa74ac73..dc71b1c0cd1 100644 --- a/src/java_bytecode/ci_lazy_methods.cpp +++ b/src/java_bytecode/ci_lazy_methods.cpp @@ -6,42 +6,28 @@ Author: Chris Smowton, chris.smowton@diffblue.com \*******************************************************************/ +/// \file +/// Context-insensitive lazy methods container + #include #include "ci_lazy_methods.h" -/*******************************************************************\ - -Function: ci_lazy_methodst::add_needed_method - - Inputs: `method_symbol_name`: method name; must exist in symbol table. - - Outputs: - - Purpose: Notes `method_symbol_name` is referenced from some reachable - function, and should therefore be elaborated. - -\*******************************************************************/ - +/// Notes `method_symbol_name` is referenced from some reachable function, and +/// should therefore be elaborated. +/// \par parameters: `method_symbol_name`: method name; must exist in symbol +/// table. void ci_lazy_methodst::add_needed_method(const irep_idt &method_symbol_name) { needed_methods.push_back(method_symbol_name); } -/*******************************************************************\ - -Function: java_bytecode_parsert::parse - - Inputs: `class_symbol_name`: class name; must exist in symbol table. - - Outputs: Returns true if `class_symbol_name` is new (not seen before). - - Purpose: Notes class `class_symbol_name` will be instantiated, or - a static field belonging to it will be accessed. Also notes - that its static initializer is therefore reachable. - -\*******************************************************************/ - +/// Notes class `class_symbol_name` will be instantiated, or a static field +/// belonging to it will be accessed. Also notes that its static initializer is +/// therefore reachable. +/// \par parameters: `class_symbol_name`: class name; must exist in symbol +/// table. +/// \return Returns true if `class_symbol_name` is new (not seen before). bool ci_lazy_methodst::add_needed_class(const irep_idt &class_symbol_name) { if(!needed_classes.insert(class_symbol_name).second) diff --git a/src/java_bytecode/ci_lazy_methods.h b/src/java_bytecode/ci_lazy_methods.h index 54c4664c694..e64a3f2467c 100644 --- a/src/java_bytecode/ci_lazy_methods.h +++ b/src/java_bytecode/ci_lazy_methods.h @@ -6,6 +6,9 @@ Author: Chris Smowton, chris.smowton@diffblue.com \*******************************************************************/ +/// \file +/// Context-insensitive lazy methods container + #ifndef CPROVER_JAVA_BYTECODE_CI_LAZY_METHODS_H #define CPROVER_JAVA_BYTECODE_CI_LAZY_METHODS_H diff --git a/src/java_bytecode/expr2java.cpp b/src/java_bytecode/expr2java.cpp index e5a1d921bfa..daa89f21a98 100644 --- a/src/java_bytecode/expr2java.cpp +++ b/src/java_bytecode/expr2java.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ + #include #include @@ -21,18 +22,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "java_types.h" #include "expr2java.h" -/*******************************************************************\ - -Function: expr2javat::convert_code_function_call - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2javat::convert_code_function_call( const code_function_callt &src, unsigned indent) @@ -103,18 +92,6 @@ std::string expr2javat::convert_code_function_call( return dest; } -/*******************************************************************\ - -Function: expr2javat::convert_struct - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2javat::convert_struct( const exprt &src, unsigned &precedence) @@ -179,18 +156,6 @@ std::string expr2javat::convert_struct( return dest; } -/*******************************************************************\ - -Function: expr2javat::convert_constant - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2javat::convert_constant( const constant_exprt &src, unsigned &precedence) @@ -274,18 +239,6 @@ std::string expr2javat::convert_constant( return expr2ct::convert_constant(src, precedence); } -/*******************************************************************\ - -Function: expr2javat::convert_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2javat::convert_rec( const typet &src, const c_qualifierst &qualifiers, @@ -360,18 +313,6 @@ std::string expr2javat::convert_rec( return expr2ct::convert_rec(src, qualifiers, declarator); } -/*******************************************************************\ - -Function: expr2javat::convert_java_this - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2javat::convert_java_this( const exprt &src, unsigned precedence) @@ -379,18 +320,6 @@ std::string expr2javat::convert_java_this( return "this"; } -/*******************************************************************\ - -Function: expr2javat::convert_java_instanceof - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2javat::convert_java_instanceof( const exprt &src, unsigned precedence) @@ -404,18 +333,6 @@ std::string expr2javat::convert_java_instanceof( return convert(src.op0())+" instanceof "+convert(src.op1().type()); } -/*******************************************************************\ - -Function: expr2javat::convert_java_new - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2javat::convert_java_new( const exprt &src, unsigned precedence) @@ -441,18 +358,6 @@ std::string expr2javat::convert_java_new( return dest; } -/*******************************************************************\ - -Function: expr2javat::convert_code_java_delete - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2javat::convert_code_java_delete( const exprt &src, unsigned indent) @@ -472,18 +377,6 @@ std::string expr2javat::convert_code_java_delete( return dest; } -/*******************************************************************\ - -Function: expr2javat::convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2javat::convert_with_precedence( const exprt &src, unsigned &precedence) @@ -519,18 +412,6 @@ std::string expr2javat::convert_with_precedence( return expr2ct::convert_with_precedence(src, precedence); } -/*******************************************************************\ - -Function: expr2javat::convert_code - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2javat::convert_code( const codet &src, unsigned indent) @@ -547,18 +428,6 @@ std::string expr2javat::convert_code( return expr2ct::convert_code(src, indent); } -/*******************************************************************\ - -Function: expr2java - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2java(const exprt &expr, const namespacet &ns) { expr2javat expr2java(ns); @@ -566,18 +435,6 @@ std::string expr2java(const exprt &expr, const namespacet &ns) return expr2java.convert(expr); } -/*******************************************************************\ - -Function: type2java - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string type2java(const typet &type, const namespacet &ns) { expr2javat expr2java(ns); diff --git a/src/java_bytecode/expr2java.h b/src/java_bytecode/expr2java.h index 4df0d240cf9..daf4efb36b8 100644 --- a/src/java_bytecode/expr2java.h +++ b/src/java_bytecode/expr2java.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ + #ifndef CPROVER_JAVA_BYTECODE_EXPR2JAVA_H #define CPROVER_JAVA_BYTECODE_EXPR2JAVA_H diff --git a/src/java_bytecode/jar_file.cpp b/src/java_bytecode/jar_file.cpp index ee08a50838a..f70ef35492c 100644 --- a/src/java_bytecode/jar_file.cpp +++ b/src/java_bytecode/jar_file.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include @@ -15,18 +16,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "jar_file.h" -/*******************************************************************\ - -Function: jar_filet::open - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jar_filet::open( java_class_loader_limitt &class_loader_limit, const std::string &filename) @@ -68,18 +57,6 @@ void jar_filet::open( } } -/*******************************************************************\ - -Function: jar_filet::~jar_filet - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - jar_filet::~jar_filet() { if(mz_ok) @@ -89,18 +66,6 @@ jar_filet::~jar_filet() } } -/*******************************************************************\ - -Function: jar_filet::get_entry - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string jar_filet::get_entry(const irep_idt &name) { if(!mz_ok) @@ -130,18 +95,6 @@ std::string jar_filet::get_entry(const irep_idt &name) return dest; } -/*******************************************************************\ - -Function: jar_filet::get_manifest - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - jar_filet::manifestt jar_filet::get_manifest() { auto entry=filtered_jar.find("META-INF/MANIFEST.MF"); diff --git a/src/java_bytecode/jar_file.h b/src/java_bytecode/jar_file.h index 3ecdfc80d0f..819acf336fd 100644 --- a/src/java_bytecode/jar_file.h +++ b/src/java_bytecode/jar_file.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// JAR File Reading + #ifndef CPROVER_JAVA_BYTECODE_JAR_FILE_H #define CPROVER_JAVA_BYTECODE_JAR_FILE_H diff --git a/src/java_bytecode/java_bytecode_convert_class.cpp b/src/java_bytecode/java_bytecode_convert_class.cpp index c92c016bd02..e68409c1d49 100644 --- a/src/java_bytecode/java_bytecode_convert_class.cpp +++ b/src/java_bytecode/java_bytecode_convert_class.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// JAVA Bytecode Language Conversion + #ifdef DEBUG #include #endif @@ -74,18 +77,6 @@ class java_bytecode_convert_classt:public messaget void add_array_types(); }; -/*******************************************************************\ - -Function: java_bytecode_convert_classt::convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_convert_classt::convert(const classt &c) { std::string qualified_classname="java::"+id2string(c.name); @@ -171,18 +162,6 @@ void java_bytecode_convert_classt::convert(const classt &c) java_root_class(*class_symbol); } -/*******************************************************************\ - -Function: java_bytecode_convert_classt::generate_class_stub - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_convert_classt::generate_class_stub( const irep_idt &class_name) { @@ -217,18 +196,6 @@ void java_bytecode_convert_classt::generate_class_stub( } } -/*******************************************************************\ - -Function: java_bytecode_convert_classt::convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_convert_classt::convert( symbolt &class_symbol, const fieldt &f) @@ -290,18 +257,6 @@ void java_bytecode_convert_classt::convert( } } -/*******************************************************************\ - -Function: java_bytecode_convert_classt::add_array_types - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_convert_classt::add_array_types() { const std::string letters="ijsbcfdza"; @@ -459,18 +414,6 @@ void java_bytecode_convert_classt::add_array_types() } } -/*******************************************************************\ - -Function: java_bytecode_convert_class - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool java_bytecode_convert_class( const java_bytecode_parse_treet &parse_tree, symbol_tablet &symbol_table, diff --git a/src/java_bytecode/java_bytecode_convert_class.h b/src/java_bytecode/java_bytecode_convert_class.h index b3b71426b1d..2f4b9f387f8 100644 --- a/src/java_bytecode/java_bytecode_convert_class.h +++ b/src/java_bytecode/java_bytecode_convert_class.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// JAVA Bytecode Language Conversion + #ifndef CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_CONVERT_CLASS_H #define CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_CONVERT_CLASS_H @@ -14,6 +17,7 @@ Author: Daniel Kroening, kroening@kroening.com #include "java_bytecode_parse_tree.h" #include "java_bytecode_language.h" +#include "character_refine_preprocess.h" bool java_bytecode_convert_class( const java_bytecode_parse_treet &parse_tree, diff --git a/src/java_bytecode/java_bytecode_convert_method.cpp b/src/java_bytecode/java_bytecode_convert_method.cpp index 181176dfbaa..ad70b5cd041 100644 --- a/src/java_bytecode/java_bytecode_convert_method.cpp +++ b/src/java_bytecode/java_bytecode_convert_method.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// JAVA Bytecode Language Conversion + #ifdef DEBUG #include #endif @@ -58,24 +61,14 @@ class patternt const char *p; }; -/*******************************************************************\ - -Function: assign_parameter_names - - Inputs: `ftype`: Function type whose parameters should be named - `name_prefix`: Prefix for parameter names, typically the - parent function's name. - `symbol_table`: Global symbol table - - Outputs: Assigns parameter names (side-effects on `ftype`) to - function stub parameters, which are initially nameless - as method conversion hasn't happened. - Also creates symbols in `symbol_table`. - - Purpose: See above - -\*******************************************************************/ - +/// See above +/// \par parameters: `ftype`: Function type whose parameters should be named +/// `name_prefix`: Prefix for parameter names, typically the parent function's +/// name. +/// `symbol_table`: Global symbol table +/// \return Assigns parameter names (side-effects on `ftype`) to function stub +/// parameters, which are initially nameless as method conversion hasn't +/// happened. Also creates symbols in `symbol_table`. void assign_parameter_names( code_typet &ftype, const irep_idt &name_prefix, @@ -161,18 +154,7 @@ exprt::operandst java_bytecode_convert_methodt::pop(std::size_t n) return operands; } -/*******************************************************************\ - -Function: java_bytecode_convert_methodt::pop_residue - -Inputs: - -Outputs: - -Purpose: removes minimum(n, stack.size()) elements from the stack - -\*******************************************************************/ - +/// removes minimum(n, stack.size()) elements from the stack void java_bytecode_convert_methodt::pop_residue(std::size_t n) { std::size_t residue_size=std::min(n, stack.size()); @@ -252,25 +234,14 @@ const exprt java_bytecode_convert_methodt::variable( } } -/*******************************************************************\ - -Function: java_bytecode_convert_method_lazy - - Inputs: `class_symbol`: class this method belongs to - `method_identifier`: fully qualified method name, including - type signature (e.g. "x.y.z.f:(I)") - `m`: parsed method object to convert - `symbol_table`: global symbol table (will be modified) - - Outputs: - - Purpose: This creates a method symbol in the symtab, but doesn't - actually perform method conversion just yet. The caller - should call java_bytecode_convert_method later to give the - symbol/method a body. - -\*******************************************************************/ - +/// This creates a method symbol in the symtab, but doesn't actually perform +/// method conversion just yet. The caller should call +/// java_bytecode_convert_method later to give the symbol/method a body. +/// \par parameters: `class_symbol`: class this method belongs to +/// `method_identifier`: fully qualified method name, including type signature +/// (e.g. "x.y.z.f:(I)") +/// `m`: parsed method object to convert +/// `symbol_table`: global symbol table (will be modified) void java_bytecode_convert_method_lazy( const symbolt &class_symbol, const irep_idt &method_identifier, @@ -322,18 +293,6 @@ void java_bytecode_convert_method_lazy( symbol_table.add(method_symbol); } -/*******************************************************************\ - -Function: java_bytecode_convert_methodt::convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_convert_methodt::convert( const symbolt &class_symbol, const methodt &m) @@ -485,18 +444,6 @@ void java_bytecode_convert_methodt::convert( symbol_table.add(method_symbol); } -/*******************************************************************\ - -Function: java_bytecode_convert_methodt::get_bytecode_info - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const bytecode_infot &java_bytecode_convert_methodt::get_bytecode_info( const irep_idt &statement) { @@ -571,20 +518,12 @@ codet java_bytecode_convert_methodt::get_array_bounds_check( return bounds_checks; } -/*******************************************************************\ - -Function: replace_goto_target - - Inputs: 'repl', a block of code in which to perform replacement, and - an old_label that should be replaced throughout by new_label. - - Outputs: None (side-effects on repl) - - Purpose: Find all goto statements in 'repl' that target 'old_label' - and redirect them to 'new_label'. - -\*******************************************************************/ - +/// Find all goto statements in 'repl' that target 'old_label' and redirect them +/// to 'new_label'. +/// \par parameters: 'repl', a block of code in which to perform replacement, +/// and +/// an old_label that should be replaced throughout by new_label. +/// \return None (side-effects on repl) void java_bytecode_convert_methodt::replace_goto_target( codet &repl, const irep_idt &old_label, @@ -605,27 +544,20 @@ void java_bytecode_convert_methodt::replace_goto_target( } } -/*******************************************************************\ - -Function: java_bytecode_convert_methodt::get_block_for_pcrange - - Inputs: 'tree', a code block descriptor, and 'this_block', the corresponding - actual code_blockt. 'address_start' and 'address_limit', the Java - bytecode offsets searched for. 'next_block_start_address', the - bytecode offset of tree/this_block's successor sibling, or UINT_MAX - if none exists. - - Outputs: Returns the code_blockt most closely enclosing the given address range. - - Purpose: 'tree' describes a tree of code_blockt objects; this_block is the - corresponding block (thus they are both trees with the same shape). - The caller is looking for the single block in the tree that most - closely encloses bytecode address range [address_start,address_limit). - 'next_block_start_address' is the start address of 'tree's successor - sibling and is used to determine when the range spans out of its bounds. - -\*******************************************************************/ - +/// 'tree' describes a tree of code_blockt objects; this_block is the +/// corresponding block (thus they are both trees with the same shape). The +/// caller is looking for the single block in the tree that most closely +/// encloses bytecode address range [address_start,address_limit). +/// 'next_block_start_address' is the start address of 'tree's successor sibling +/// and is used to determine when the range spans out of its bounds. +/// \par parameters: 'tree', a code block descriptor, and 'this_block', the +/// corresponding +/// actual code_blockt. 'address_start' and 'address_limit', the Java +/// bytecode offsets searched for. 'next_block_start_address', the +/// bytecode offset of tree/this_block's successor sibling, or UINT_MAX +/// if none exists. +/// \return Returns the code_blockt most closely enclosing the given address +/// range. code_blockt &java_bytecode_convert_methodt::get_block_for_pcrange( block_tree_nodet &tree, code_blockt &this_block, @@ -644,29 +576,20 @@ code_blockt &java_bytecode_convert_methodt::get_block_for_pcrange( false); } -/*******************************************************************\ - -Function: java_bytecode_convert_methodt::get_or_create_block_for_pcrange - - Inputs: See above, plus the bytecode address map 'amap' and 'allow_merge' - which is always true except when called from get_block_for_pcrange - - Outputs: See above, plus potential side-effects on 'tree' and 'this_block' - as descibed in 'Purpose' - - Purpose: As above, but this version can additionally create a new branch - in the block_tree-node and code_blockt trees to envelop the requested - address range. For example, if the tree was initially flat, with - nodes (1-10), (11-20), (21-30) and the caller asked for range 13-28, - this would build a surrounding tree node, leaving the tree of shape - (1-10), ^( (11-20), (21-30) )^, and return a reference to the - new branch highlighted with ^^. - 'tree' and 'this_block' trees are always maintained with equal - shapes. ('this_block' may additionally contain code_declt children - which are ignored for this purpose) - -\*******************************************************************/ - +/// As above, but this version can additionally create a new branch in the +/// block_tree-node and code_blockt trees to envelop the requested address +/// range. For example, if the tree was initially flat, with nodes (1-10), +/// (11-20), (21-30) and the caller asked for range 13-28, this would build a +/// surrounding tree node, leaving the tree of shape (1-10), ^( (11-20), (21-30) +/// )^, and return a reference to the new branch highlighted with ^^. 'tree' and +/// 'this_block' trees are always maintained with equal shapes. ('this_block' +/// may additionally contain code_declt children which are ignored for this +/// purpose) +/// \par parameters: See above, plus the bytecode address map 'amap' and +/// 'allow_merge' +/// which is always true except when called from get_block_for_pcrange +/// \return See above, plus potential side-effects on 'tree' and 'this_block' as +/// descibed in 'Purpose' code_blockt &java_bytecode_convert_methodt::get_or_create_block_for_pcrange( block_tree_nodet &tree, code_blockt &this_block, @@ -884,20 +807,11 @@ static void gather_symbol_live_ranges( } } -/*******************************************************************\ - -Function: java_bytecode_convert_methodt::check_static_field_stub - - Inputs: `se`: Symbol expression referring to a static field - `basename`: The static field's basename - - Outputs: Creates a symbol table entry for the static field if one - doesn't exist already. - - Purpose: See above - -\*******************************************************************/ - +/// See above +/// \par parameters: `se`: Symbol expression referring to a static field +/// `basename`: The static field's basename +/// \return Creates a symbol table entry for the static field if one doesn't +/// exist already. void java_bytecode_convert_methodt::check_static_field_stub( const symbol_exprt &symbol_expr, const irep_idt &basename) @@ -921,20 +835,11 @@ void java_bytecode_convert_methodt::check_static_field_stub( } } -/*******************************************************************\ - -Function: java_bytecode_convert_methodt::class_needs_clinit - - Inputs: classname: Class name - - Outputs: Returns true if the given class or one of its parents - has a static initializer - - Purpose: Determine whether a `new` or static access against `classname` - should be prefixed with a static initialization check. - -\*******************************************************************/ - +/// Determine whether a `new` or static access against `classname` should be +/// prefixed with a static initialization check. +/// \param classname: Class name +/// \return Returns true if the given class or one of its parents has a static +/// initializer bool java_bytecode_convert_methodt::class_needs_clinit( const irep_idt &classname) { @@ -972,22 +877,13 @@ bool java_bytecode_convert_methodt::class_needs_clinit( return false; } -/*******************************************************************\ - -Function: java_bytecode_convert_methodt::get_or_create_clinit_wrapper - - Inputs: classname: Class name - - Outputs: Returns a symbol_exprt pointing to the given class' clinit - wrapper if one is required, or nil otherwise. - - Purpose: Create a ::clinit_wrapper the first time a static initializer - might be called. The wrapper method checks whether static init - has already taken place, calls the actual method if - not, and initializes super-classes and interfaces. - -\*******************************************************************/ - +/// Create a ::clinit_wrapper the first time a static initializer might be +/// called. The wrapper method checks whether static init has already taken +/// place, calls the actual method if not, and initializes super- +/// classes and interfaces. +/// \param classname: Class name +/// \return Returns a symbol_exprt pointing to the given class' clinit wrapper +/// if one is required, or nil otherwise. exprt java_bytecode_convert_methodt::get_or_create_clinit_wrapper( const irep_idt &classname) { @@ -1063,21 +959,11 @@ exprt java_bytecode_convert_methodt::get_or_create_clinit_wrapper( return wrapper_method_symbol.symbol_expr(); } -/*******************************************************************\ - -Function: java_bytecode_convert_methodt::get_clinit_call - - Inputs: classname: Class name - - Outputs: Returns a function call to the given class' static initializer - wrapper if one is needed, or a skip instruction otherwise. - - Purpose: Each static access to classname should be prefixed with a check - for necessary static init; this returns a call implementing - that check. - -\*******************************************************************/ - +/// Each static access to classname should be prefixed with a check for +/// necessary static init; this returns a call implementing that check. +/// \param classname: Class name +/// \return Returns a function call to the given class' static initializer +/// wrapper if one is needed, or a skip instruction otherwise. codet java_bytecode_convert_methodt::get_clinit_call( const irep_idt &classname) { @@ -1089,18 +975,6 @@ codet java_bytecode_convert_methodt::get_clinit_call( return ret; } -/*******************************************************************\ - -Function: get_bytecode_type_width - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static unsigned get_bytecode_type_width(const typet &ty) { if(ty.id()==ID_pointer) @@ -1108,18 +982,6 @@ static unsigned get_bytecode_type_width(const typet &ty) return ty.get_unsigned_int(ID_width); } -/*******************************************************************\ - -Function: java_bytecode_convert_methodt::convert_instructions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - codet java_bytecode_convert_methodt::convert_instructions( const methodt &method, const code_typet &method_type, @@ -2715,7 +2577,7 @@ codet java_bytecode_convert_methodt::convert_instructions( if(v.is_parameter) continue; // Skip anonymous variables: - if(v.symbol_expr.get_identifier()==irep_idt()) + if(v.symbol_expr.get_identifier().empty()) continue; auto &block=get_block_for_pcrange( root, @@ -2733,18 +2595,6 @@ codet java_bytecode_convert_methodt::convert_instructions( return code; } -/*******************************************************************\ - -Function: java_bytecode_convert_method - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_convert_method( const symbolt &class_symbol, const java_bytecode_parse_treet::methodt &method, diff --git a/src/java_bytecode/java_bytecode_convert_method.h b/src/java_bytecode/java_bytecode_convert_method.h index 43c1cdec380..ba0926e301a 100644 --- a/src/java_bytecode/java_bytecode_convert_method.h +++ b/src/java_bytecode/java_bytecode_convert_method.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// JAVA Bytecode Language Conversion + #ifndef CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_CONVERT_METHOD_H #define CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_CONVERT_METHOD_H diff --git a/src/java_bytecode/java_bytecode_convert_method_class.h b/src/java_bytecode/java_bytecode_convert_method_class.h index 61299ff31d3..17393900c64 100644 --- a/src/java_bytecode/java_bytecode_convert_method_class.h +++ b/src/java_bytecode/java_bytecode_convert_method_class.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// JAVA Bytecode Language Conversion + #ifndef CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_CONVERT_METHOD_CLASS_H #define CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_CONVERT_METHOD_CLASS_H diff --git a/src/java_bytecode/java_bytecode_internal_additions.cpp b/src/java_bytecode/java_bytecode_internal_additions.cpp index c0d019a4cc4..9177b22ad2b 100644 --- a/src/java_bytecode/java_bytecode_internal_additions.cpp +++ b/src/java_bytecode/java_bytecode_internal_additions.cpp @@ -6,25 +6,14 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include -#include +#include #include "java_bytecode_internal_additions.h" -/*******************************************************************\ - -Function: java_internal_additions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_internal_additions(symbol_tablet &dest) { // add __CPROVER_rounding_mode diff --git a/src/java_bytecode/java_bytecode_internal_additions.h b/src/java_bytecode/java_bytecode_internal_additions.h index 34c47f89414..70362d7d685 100644 --- a/src/java_bytecode/java_bytecode_internal_additions.h +++ b/src/java_bytecode/java_bytecode_internal_additions.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_INTERNAL_ADDITIONS_H #define CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_INTERNAL_ADDITIONS_H diff --git a/src/java_bytecode/java_bytecode_language.cpp b/src/java_bytecode/java_bytecode_language.cpp index c38b8d735fa..1d37e8382df 100644 --- a/src/java_bytecode/java_bytecode_language.cpp +++ b/src/java_bytecode/java_bytecode_language.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -28,18 +29,9 @@ Author: Daniel Kroening, kroening@kroening.com #include "expr2java.h" -/*******************************************************************\ - -Function: java_bytecode_languaget::get_language_options - - Inputs: Command-line options - - Outputs: None - - Purpose: Consume options that are java bytecode specific. - -\*******************************************************************/ - +/// Consume options that are java bytecode specific. +/// \param Command:line options +/// \return None void java_bytecode_languaget::get_language_options(const cmdlinet &cmd) { assume_inputs_non_null=cmd.isset("java-assume-inputs-non-null"); @@ -87,52 +79,17 @@ void java_bytecode_languaget::get_language_options(const cmdlinet &cmd) java_cp_include_files=".*"; } -/*******************************************************************\ - -Function: java_bytecode_languaget::extensions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::set java_bytecode_languaget::extensions() const { return { "class", "jar" }; } -/*******************************************************************\ - -Function: java_bytecode_languaget::modules_provided - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_languaget::modules_provided(std::set &modules) { // modules.insert(translation_unit(parse_path)); } -/*******************************************************************\ - -Function: java_bytecode_languaget::preprocess - - Inputs: - - Outputs: - - Purpose: ANSI-C preprocessing - -\*******************************************************************/ - +/// ANSI-C preprocessing bool java_bytecode_languaget::preprocess( std::istream &instream, const std::string &path, @@ -142,18 +99,6 @@ bool java_bytecode_languaget::preprocess( return true; } -/*******************************************************************\ - -Function: java_bytecode_languaget::parse - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool java_bytecode_languaget::parse( std::istream &instream, const std::string &path) @@ -208,27 +153,18 @@ bool java_bytecode_languaget::parse( return false; } -/*******************************************************************\ - -Function: get_virtual_method_target - - Inputs: `needed_classes`: set of classes that can be instantiated. - Any potential callee not in this set will be ignored. - `call_basename`: unqualified function name with type - signature (e.g. "f:(I)") - `classname`: class name that may define or override a - function named `call_basename`. - `symbol_table`: global symtab - - Outputs: Returns the fully qualified name of `classname`'s definition - of `call_basename` if found and `classname` is present in - `needed_classes`, or irep_idt() otherwise. - - Purpose: Find a virtual callee, if one is defined and the callee type - is known to exist. - -\*******************************************************************/ - +/// Find a virtual callee, if one is defined and the callee type is known to +/// exist. +/// \par parameters: `needed_classes`: set of classes that can be instantiated. +/// Any potential callee not in this set will be ignored. +/// `call_basename`: unqualified function name with type signature (e.g. +/// "f:(I)") +/// `classname`: class name that may define or override a function named +/// `call_basename`. +/// `symbol_table`: global symtab +/// \return Returns the fully qualified name of `classname`'s definition of +/// `call_basename` if found and `classname` is present in `needed_classes`, +/// or irep_idt() otherwise. static irep_idt get_virtual_method_target( const std::set &needed_classes, const irep_idt &call_basename, @@ -245,27 +181,17 @@ static irep_idt get_virtual_method_target( return irep_idt(); } -/*******************************************************************\ - -Function: get_virtual_method_target - - Inputs: `c`: function call whose potential target functions should - be determined. - `needed_classes`: set of classes that can be instantiated. - Any potential callee not in this set will be ignored. - `symbol_table`: global symtab - `class_hierarchy`: global class hierarchy - - Outputs: Populates `needed_methods` with all possible `c` callees, - taking `needed_classes` into account (virtual function - overrides defined on classes that are not 'needed' are - ignored) - - Purpose: Find possible callees, excluding types that are not known - to be instantiated. - -\*******************************************************************/ - +/// Find possible callees, excluding types that are not known to be +/// instantiated. +/// \par parameters: `c`: function call whose potential target functions should +/// be determined. +/// `needed_classes`: set of classes that can be instantiated. Any potential +/// callee not in this set will be ignored. +/// `symbol_table`: global symtab +/// `class_hierarchy`: global class hierarchy +/// \return Populates `needed_methods` with all possible `c` callees, taking +/// `needed_classes` into account (virtual function overrides defined on +/// classes that are not 'needed' are ignored) static void get_virtual_method_targets( const code_function_callt &c, const std::set &needed_classes, @@ -277,9 +203,9 @@ static void get_virtual_method_targets( assert(called_function.id()==ID_virtual_function); const auto &call_class=called_function.get(ID_C_class); - assert(call_class!=irep_idt()); + assert(!call_class.empty()); const auto &call_basename=called_function.get(ID_component_name); - assert(call_basename!=irep_idt()); + assert(!call_basename.empty()); auto old_size=needed_methods.size(); @@ -292,7 +218,7 @@ static void get_virtual_method_targets( call_basename, child_class, symbol_table); - if(child_method!=irep_idt()) + if(!child_method.empty()) needed_methods.push_back(child_method); } @@ -305,7 +231,7 @@ static void get_virtual_method_targets( call_basename, parent_class_id, symbol_table); - if(parent_method!=irep_idt()) + if(!parent_method.empty()) { needed_methods.push_back(parent_method); break; @@ -340,19 +266,10 @@ static void get_virtual_method_targets( } } -/*******************************************************************\ - -Function: gather_virtual_callsites - - Inputs: `e`: expression tree to search - - Outputs: Populates `result` with pointers to each function call - within e that calls a virtual function. - - Purpose: See output - -\*******************************************************************/ - +/// See output +/// \par parameters: `e`: expression tree to search +/// \return Populates `result` with pointers to each function call within e that +/// calls a virtual function. static void gather_virtual_callsites( const exprt &e, std::vector &result) @@ -368,20 +285,11 @@ static void gather_virtual_callsites( gather_virtual_callsites(*it, result); } -/*******************************************************************\ - -Function: gather_needed_globals - - Inputs: `e`: expression tree to search - `symbol_table`: global symtab - - Outputs: Populates `needed` with global variable symbols referenced - from `e` or its children. - - Purpose: See output - -\*******************************************************************/ - +/// See output +/// \par parameters: `e`: expression tree to search +/// `symbol_table`: global symtab +/// \return Populates `needed` with global variable symbols referenced from `e` +/// or its children. static void gather_needed_globals( const exprt &e, const symbol_tablet &symbol_table, @@ -405,22 +313,13 @@ static void gather_needed_globals( gather_needed_globals(*opit, symbol_table, needed); } -/*******************************************************************\ - -Function: gather_field_types - - Inputs: `class_type`: root of class tree to search - `ns`: global namespace - - Outputs: Populates `lazy_methods` with all Java reference types - reachable starting at `class_type`. For example if - `class_type` is `symbol_typet("java::A")` and A has a B - field, then `B` (but not `A`) will noted as a needed class. - - Purpose: See output - -\*******************************************************************/ - +/// See output +/// \par parameters: `class_type`: root of class tree to search +/// `ns`: global namespace +/// \return Populates `lazy_methods` with all Java reference types reachable +/// starting at `class_type`. For example if `class_type` is +/// `symbol_typet("java::A")` and A has a B field, then `B` (but not `A`) will +/// noted as a needed class. static void gather_field_types( const typet &class_type, const namespacet &ns, @@ -444,23 +343,14 @@ static void gather_field_types( } } -/*******************************************************************\ - -Function: initialize_needed_classes - - Inputs: `entry_points`: list of fully-qualified function names that - we should assume are reachable - `ns`: global namespace - `ch`: global class hierarchy - - Outputs: Populates `lazy_methods` with all Java reference types - whose references may be passed, directly or indirectly, - to any of the functions in `entry_points`. - - Purpose: See output - -\*******************************************************************/ - +/// See output +/// \par parameters: `entry_points`: list of fully-qualified function names that +/// we should assume are reachable +/// `ns`: global namespace +/// `ch`: global class hierarchy +/// \return Populates `lazy_methods` with all Java reference types whose +/// references may be passed, directly or indirectly, to any of the functions +/// in `entry_points`. static void initialize_needed_classes( const std::vector &entry_points, const namespacet &ns, @@ -495,18 +385,6 @@ static void initialize_needed_classes( lazy_methods.add_needed_class("java::java.lang.Object"); } -/*******************************************************************\ - -Function: java_bytecode_languaget::typecheck - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool java_bytecode_languaget::typecheck( symbol_tablet &symbol_table, const std::string &module) @@ -568,32 +446,19 @@ bool java_bytecode_languaget::typecheck( return false; } -/*******************************************************************\ - -Function: java_bytecode_languaget::do_ci_lazy_method_conversion - - Inputs: `symbol_table`: global symbol table - `lazy_methods`: map from method names to relevant symbol - and parsed-method objects. - - Outputs: Elaborates lazily-converted methods that may be reachable - starting from the main entry point (usually provided with - the --function command-line option) (side-effect on the - symbol_table). Returns false on success. - - Purpose: Uses a simple context-insensitive ('ci') analysis to - determine which methods may be reachable from the main - entry point. In brief, static methods are reachable if we - find a callsite in another reachable site, while virtual - methods are reachable if we find a virtual callsite - targeting a compatible type *and* a constructor callsite - indicating an object of that type may be instantiated (or - evidence that an object of that type exists before the - main function is entered, such as being passed as a - parameter). - -\*******************************************************************/ - +/// Uses a simple context-insensitive ('ci') analysis to determine which methods +/// may be reachable from the main entry point. In brief, static methods are +/// reachable if we find a callsite in another reachable site, while virtual +/// methods are reachable if we find a virtual callsite targeting a compatible +/// type *and* a constructor callsite indicating an object of that type may be +/// instantiated (or evidence that an object of that type exists before the main +/// function is entered, such as being passed as a parameter). +/// \par parameters: `symbol_table`: global symbol table +/// `lazy_methods`: map from method names to relevant symbol and parsed-method +/// objects. +/// \return Elaborates lazily-converted methods that may be reachable starting +/// from the main entry point (usually provided with the --function command- +/// line option) (side-effect on the symbol_table). Returns false on success. bool java_bytecode_languaget::do_ci_lazy_method_conversion( symbol_tablet &symbol_table, lazy_methodst &lazy_methods) @@ -740,22 +605,11 @@ bool java_bytecode_languaget::do_ci_lazy_method_conversion( return false; } -/*******************************************************************\ - -Function: java_bytecode_languaget::lazy_methods_provided - - Inputs: None - - Outputs: Populates `methods` with the complete list of lazy methods - that are available to convert (those which are valid - parameters for `convert_lazy_method`) - - Purpose: Provide feedback to `language_filest` so that when asked - for a lazy method, it can delegate to this instance of - java_bytecode_languaget. - -\*******************************************************************/ - +/// Provide feedback to `language_filest` so that when asked for a lazy method, +/// it can delegate to this instance of java_bytecode_languaget. +/// \return Populates `methods` with the complete list of lazy methods that are +/// available to convert (those which are valid parameters for +/// `convert_lazy_method`) void java_bytecode_languaget::lazy_methods_provided( std::set &methods) const { @@ -763,26 +617,15 @@ void java_bytecode_languaget::lazy_methods_provided( methods.insert(kv.first); } -/*******************************************************************\ - -Function: java_bytecode_languaget::convert_lazy_method - - Inputs: `id`: method ID to convert - `symtab`: global symbol table - - Outputs: Amends the symbol table entry for function `id`, which - should be a lazy method provided by this instance of - `java_bytecode_languaget`. It should initially have a nil - value. After this method completes, it will have a value - representing the method body, identical to that produced - using eager method conversion. - - Purpose: Promote a lazy-converted method (one whose type is known - but whose body hasn't been converted) into a fully- - elaborated one. - -\*******************************************************************/ - +/// Promote a lazy-converted method (one whose type is known but whose body +/// hasn't been converted) into a fully- elaborated one. +/// \par parameters: `id`: method ID to convert +/// `symtab`: global symbol table +/// \return Amends the symbol table entry for function `id`, which should be a +/// lazy method provided by this instance of `java_bytecode_languaget`. It +/// should initially have a nil value. After this method completes, it will +/// have a value representing the method body, identical to that produced +/// using eager method conversion. void java_bytecode_languaget::convert_lazy_method( const irep_idt &id, symbol_tablet &symtab) @@ -797,18 +640,9 @@ void java_bytecode_languaget::convert_lazy_method( string_preprocess); } -/*******************************************************************\ - -Function: java_bytecode_languaget::replace_string_methods - - Inputs: - context - a symbol table - - Purpose: Replace methods of the String library that are in the symbol table - by code generated by string_preprocess. - -\*******************************************************************/ - +/// Replace methods of the String library that are in the symbol table by code +/// generated by string_preprocess. +/// \param context: a symbol table void java_bytecode_languaget::replace_string_methods( symbol_tablet &context) { @@ -834,18 +668,6 @@ void java_bytecode_languaget::replace_string_methods( } } -/*******************************************************************\ - -Function: java_bytecode_languaget::final - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool java_bytecode_languaget::final(symbol_tablet &symbol_table) { /* @@ -872,52 +694,16 @@ bool java_bytecode_languaget::final(symbol_tablet &symbol_table) max_nondet_array_length)); } -/*******************************************************************\ - -Function: java_bytecode_languaget::show_parse - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_languaget::show_parse(std::ostream &out) { java_class_loader(main_class).output(out); } -/*******************************************************************\ - -Function: new_java_bytecode_language - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - languaget *new_java_bytecode_language() { return new java_bytecode_languaget; } -/*******************************************************************\ - -Function: java_bytecode_languaget::from_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool java_bytecode_languaget::from_expr( const exprt &expr, std::string &code, @@ -927,18 +713,6 @@ bool java_bytecode_languaget::from_expr( return false; } -/*******************************************************************\ - -Function: java_bytecode_languaget::from_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool java_bytecode_languaget::from_type( const typet &type, std::string &code, @@ -948,18 +722,6 @@ bool java_bytecode_languaget::from_type( return false; } -/*******************************************************************\ - -Function: java_bytecode_languaget::to_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool java_bytecode_languaget::to_expr( const std::string &code, const std::string &module, @@ -1007,18 +769,6 @@ bool java_bytecode_languaget::to_expr( return true; // fail for now } -/*******************************************************************\ - -Function: java_bytecode_languaget::~java_bytecode_languaget - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - java_bytecode_languaget::~java_bytecode_languaget() { } diff --git a/src/java_bytecode/java_bytecode_language.h b/src/java_bytecode/java_bytecode_language.h index 8fbf96b06e5..c107ffd0267 100644 --- a/src/java_bytecode/java_bytecode_language.h +++ b/src/java_bytecode/java_bytecode_language.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_LANGUAGE_H #define CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_LANGUAGE_H diff --git a/src/java_bytecode/java_bytecode_parse_tree.cpp b/src/java_bytecode/java_bytecode_parse_tree.cpp index 63fb5674f85..6da1a7f1872 100644 --- a/src/java_bytecode/java_bytecode_parse_tree.cpp +++ b/src/java_bytecode/java_bytecode_parse_tree.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -17,18 +18,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "java_bytecode_parse_tree.h" -/*******************************************************************\ - -Function: java_bytecode_parse_treet::swap - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_parse_treet::classt::swap( classt &other) { @@ -43,18 +32,6 @@ void java_bytecode_parse_treet::classt::swap( other.annotations.swap(annotations); } -/*******************************************************************\ - -Function: java_bytecode_parse_treet::classt::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_parse_treet::output(std::ostream &out) const { parsed_class.output(out); @@ -66,18 +43,6 @@ void java_bytecode_parse_treet::output(std::ostream &out) const out << " " << *it << '\n'; } -/*******************************************************************\ - -Function: java_bytecode_parse_treet::classt::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_parse_treet::classt::output(std::ostream &out) const { for(const auto &annotation : annotations) @@ -113,18 +78,6 @@ void java_bytecode_parse_treet::classt::output(std::ostream &out) const out << '\n'; } -/*******************************************************************\ - -Function: java_bytecode_parse_treet::annotationt::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_parse_treet::annotationt::output(std::ostream &out) const { symbol_tablet symbol_table; @@ -150,18 +103,6 @@ void java_bytecode_parse_treet::annotationt::output(std::ostream &out) const } } -/*******************************************************************\ - -Function: java_bytecode_parse_treet::annotationt::element_value_pairt::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_parse_treet::annotationt::element_value_pairt::output( std::ostream &out) const { @@ -172,18 +113,6 @@ void java_bytecode_parse_treet::annotationt::element_value_pairt::output( out << expr2java(value, ns); } -/*******************************************************************\ - -Function: java_bytecode_parse_treet::methodt::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_parse_treet::methodt::output(std::ostream &out) const { symbol_tablet symbol_table; @@ -228,7 +157,7 @@ void java_bytecode_parse_treet::methodt::output(std::ostream &out) const for(const auto &i : instructions) { - if(i.source_location.get_line()!=irep_idt()) + if(!i.source_location.get_line().empty()) out << " // " << i.source_location << '\n'; out << " " << i.address << ": "; @@ -263,18 +192,6 @@ void java_bytecode_parse_treet::methodt::output(std::ostream &out) const out << '\n'; } -/*******************************************************************\ - -Function: java_bytecode_parse_treet::fieldt::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_parse_treet::fieldt::output(std::ostream &out) const { for(const auto &annotation : annotations) diff --git a/src/java_bytecode/java_bytecode_parse_tree.h b/src/java_bytecode/java_bytecode_parse_tree.h index 4784f930beb..06b2ca5632f 100644 --- a/src/java_bytecode/java_bytecode_parse_tree.h +++ b/src/java_bytecode/java_bytecode_parse_tree.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_PARSE_TREE_H #define CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_PARSE_TREE_H diff --git a/src/java_bytecode/java_bytecode_parser.cpp b/src/java_bytecode/java_bytecode_parser.cpp index dd458860c97..4235f6faab7 100644 --- a/src/java_bytecode/java_bytecode_parser.cpp +++ b/src/java_bytecode/java_bytecode_parser.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include @@ -200,18 +201,6 @@ class java_bytecode_parsert:public parsert #define VTYPE_INFO_OBJECT 7 #define VTYPE_INFO_UNINIT 8 -/*******************************************************************\ - -Function: java_bytecode_parsert::parse - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool java_bytecode_parsert::parse() { try @@ -240,18 +229,6 @@ bool java_bytecode_parsert::parse() return false; } -/*******************************************************************\ - -Function: java_bytecode_parsert::rClassFile - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - #define ACC_PUBLIC 0x0001 #define ACC_PRIVATE 0x0002 #define ACC_PROTECTED 0x0004 @@ -329,18 +306,6 @@ void java_bytecode_parsert::rClassFile() parse_tree.loading_successful=true; } -/*******************************************************************\ - -Function: java_bytecode_parsert::get_class_refs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_parsert::get_class_refs() { // Get the class references for the benefit of a dependency @@ -383,18 +348,6 @@ void java_bytecode_parsert::get_class_refs() } } -/*******************************************************************\ - -Function: java_bytecode_parsert::get_class_refs_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_parsert::get_class_refs_rec(const typet &src) { if(src.id()==ID_code) @@ -427,18 +380,6 @@ void java_bytecode_parsert::get_class_refs_rec(const typet &src) get_class_refs_rec(src.subtype()); } -/*******************************************************************\ - -Function: java_bytecode_parsert::rconstant_pool - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_parsert::rconstant_pool() { u2 constant_pool_count=read_u2(); @@ -658,18 +599,6 @@ void java_bytecode_parsert::rconstant_pool() } } -/*******************************************************************\ - -Function: java_bytecode_parsert::rinterfaces - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_parsert::rinterfaces(classt &parsed_class) { u2 interfaces_count=read_u2(); @@ -679,18 +608,6 @@ void java_bytecode_parsert::rinterfaces(classt &parsed_class) .push_back(constant(read_u2()).type().get(ID_C_base_name)); } -/*******************************************************************\ - -Function: java_bytecode_parsert::rfields - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_parsert::rfields(classt &parsed_class) { u2 fields_count=read_u2(); @@ -722,18 +639,6 @@ void java_bytecode_parsert::rfields(classt &parsed_class) } } -/*******************************************************************\ - -Function: java_bytecode_parsert::rbytecode - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - #define T_BOOLEAN 4 #define T_CHAR 5 #define T_FLOAT 6 @@ -975,18 +880,6 @@ void java_bytecode_parsert::rbytecode( } } -/*******************************************************************\ - -Function: java_bytecode_parsert::rmethod_attribute - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_parsert::rmethod_attribute(methodt &method) { u2 attribute_name_index=read_u2(); @@ -1055,18 +948,6 @@ void java_bytecode_parsert::rmethod_attribute(methodt &method) skip_bytes(attribute_length); } -/*******************************************************************\ - -Function: java_bytecode_parsert::rfield_attribute - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_parsert::rfield_attribute(fieldt &field) { u2 attribute_name_index=read_u2(); @@ -1083,18 +964,6 @@ void java_bytecode_parsert::rfield_attribute(fieldt &field) skip_bytes(attribute_length); } -/*******************************************************************\ - -Function: java_bytecode_parsert::rcode_attribute - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_parsert::rcode_attribute(methodt &method) { u2 attribute_name_index=read_u2(); @@ -1299,18 +1168,6 @@ void java_bytecode_parsert::read_verification_type_info( } } -/*******************************************************************\ - -Function: java_bytecode_parsert::rRuntimeAnnotation_attribute - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_parsert::rRuntimeAnnotation_attribute( annotationst &annotations) { @@ -1324,18 +1181,6 @@ void java_bytecode_parsert::rRuntimeAnnotation_attribute( } } -/*******************************************************************\ - -Function: java_bytecode_parsert::rRuntimeAnnotation - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_parsert::rRuntimeAnnotation( annotationt &annotation) { @@ -1344,18 +1189,6 @@ void java_bytecode_parsert::rRuntimeAnnotation( relement_value_pairs(annotation.element_value_pairs); } -/*******************************************************************\ - -Function: java_bytecode_parsert::relement_value_pairs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_parsert::relement_value_pairs( annotationt::element_value_pairst &element_value_pairs) { @@ -1371,18 +1204,6 @@ void java_bytecode_parsert::relement_value_pairs( } } -/*******************************************************************\ - -Function: java_bytecode_parsert::relement_value_pair - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_parsert::relement_value_pair( annotationt::element_value_pairt &element_value_pair) { @@ -1442,18 +1263,6 @@ void java_bytecode_parsert::relement_value_pair( } } -/*******************************************************************\ - -Function: java_bytecode_parsert::rclass_attribute - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_parsert::rclass_attribute(classt &parsed_class) { u2 attribute_name_index=read_u2(); @@ -1502,18 +1311,6 @@ void java_bytecode_parsert::rclass_attribute(classt &parsed_class) skip_bytes(attribute_length); } -/*******************************************************************\ - -Function: java_bytecode_parsert::rmethods - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_parsert::rmethods(classt &parsed_class) { u2 methods_count=read_u2(); @@ -1522,18 +1319,6 @@ void java_bytecode_parsert::rmethods(classt &parsed_class) rmethod(parsed_class); } -/*******************************************************************\ - -Function: java_bytecode_parsert::rmethod - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - #define ACC_PUBLIC 0x0001 #define ACC_PRIVATE 0x0002 #define ACC_PROTECTED 0x0004 @@ -1578,18 +1363,6 @@ void java_bytecode_parsert::rmethod(classt &parsed_class) rmethod_attribute(method); } -/*******************************************************************\ - -Function: java_bytecode_parse - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool java_bytecode_parse( std::istream &istream, java_bytecode_parse_treet &parse_tree, @@ -1606,18 +1379,6 @@ bool java_bytecode_parse( return parser_result; } -/*******************************************************************\ - -Function: java_bytecode_parse - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool java_bytecode_parse( const std::string &file, java_bytecode_parse_treet &parse_tree, diff --git a/src/java_bytecode/java_bytecode_parser.h b/src/java_bytecode/java_bytecode_parser.h index d0732866789..e0f19ef2d60 100644 --- a/src/java_bytecode/java_bytecode_parser.h +++ b/src/java_bytecode/java_bytecode_parser.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_PARSER_H #define CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_PARSER_H diff --git a/src/java_bytecode/java_bytecode_typecheck.cpp b/src/java_bytecode/java_bytecode_typecheck.cpp index 4f09e366452..2386cdc87f0 100644 --- a/src/java_bytecode/java_bytecode_typecheck.cpp +++ b/src/java_bytecode/java_bytecode_typecheck.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// JAVA Bytecode Conversion / Type Checking + #include #include #include @@ -13,52 +16,16 @@ Author: Daniel Kroening, kroening@kroening.com #include "expr2java.h" #include "java_bytecode_typecheck.h" -/*******************************************************************\ - -Function: java_bytecode_typecheckt::to_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string java_bytecode_typecheckt::to_string(const exprt &expr) { return expr2java(expr, ns); } -/*******************************************************************\ - -Function: java_bytecode_typecheckt::to_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string java_bytecode_typecheckt::to_string(const typet &type) { return type2java(type, ns); } -/*******************************************************************\ - -Function: java_bytecode_typecheckt::typecheck_non_type_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_typecheckt::typecheck_non_type_symbol(symbolt &symbol) { assert(!symbol.is_type); @@ -66,18 +33,6 @@ void java_bytecode_typecheckt::typecheck_non_type_symbol(symbolt &symbol) typecheck_expr(symbol.value); } -/*******************************************************************\ - -Function: java_bytecode_typecheckt::typecheck - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_typecheckt::typecheck() { // The hash table iterators are not stable, @@ -112,18 +67,6 @@ void java_bytecode_typecheckt::typecheck() } } -/*******************************************************************\ - -Function: java_bytecode_typecheck - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool java_bytecode_typecheck( symbol_tablet &symbol_table, message_handlert &message_handler, @@ -134,18 +77,6 @@ bool java_bytecode_typecheck( return java_bytecode_typecheck.typecheck_main(); } -/*******************************************************************\ - -Function: java_bytecode_typecheck - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool java_bytecode_typecheck( exprt &expr, message_handlert &message_handler, diff --git a/src/java_bytecode/java_bytecode_typecheck.h b/src/java_bytecode/java_bytecode_typecheck.h index 618b6fce44d..fa35ba5eda9 100644 --- a/src/java_bytecode/java_bytecode_typecheck.h +++ b/src/java_bytecode/java_bytecode_typecheck.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// JAVA Bytecode Language Type Checking + #ifndef CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_TYPECHECK_H #define CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_TYPECHECK_H diff --git a/src/java_bytecode/java_bytecode_typecheck_code.cpp b/src/java_bytecode/java_bytecode_typecheck_code.cpp index 788f5fa592b..431e39234f5 100644 --- a/src/java_bytecode/java_bytecode_typecheck_code.cpp +++ b/src/java_bytecode/java_bytecode_typecheck_code.cpp @@ -6,19 +6,10 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "java_bytecode_typecheck.h" - -/*******************************************************************\ - -Function: java_bytecode_typecheckt::typecheck_code - - Inputs: +/// \file +/// JAVA Bytecode Conversion / Type Checking - Outputs: - - Purpose: - -\*******************************************************************/ +#include "java_bytecode_typecheck.h" void java_bytecode_typecheckt::typecheck_code(codet &code) { diff --git a/src/java_bytecode/java_bytecode_typecheck_expr.cpp b/src/java_bytecode/java_bytecode_typecheck_expr.cpp index 11e488ff7fe..d1d0e988d49 100644 --- a/src/java_bytecode/java_bytecode_typecheck_expr.cpp +++ b/src/java_bytecode/java_bytecode_typecheck_expr.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// JAVA Bytecode Conversion / Type Checking + #include #include @@ -19,18 +22,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "java_pointer_casts.h" #include "java_types.h" -/*******************************************************************\ - -Function: java_bytecode_typecheckt::typecheck_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_typecheckt::typecheck_expr(exprt &expr) { if(expr.id()==ID_code) @@ -59,18 +50,6 @@ void java_bytecode_typecheckt::typecheck_expr(exprt &expr) typecheck_expr_member(to_member_expr(expr)); } -/*******************************************************************\ - -Function: java_bytecode_typecheckt::typecheck_expr_java_new - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_typecheckt::typecheck_expr_java_new(side_effect_exprt &expr) { assert(expr.operands().empty()); @@ -78,18 +57,6 @@ void java_bytecode_typecheckt::typecheck_expr_java_new(side_effect_exprt &expr) typecheck_type(type); } -/*******************************************************************\ - -Function: java_bytecode_typecheckt::typecheck_expr_java_new_array - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_typecheckt::typecheck_expr_java_new_array( side_effect_exprt &expr) { @@ -117,18 +84,9 @@ static std::string escape_non_alnum(const std::string &toescape) return escaped.str(); } -/*******************************************************************\ - -Function: utf16_to_array - - Inputs: `in`: wide string to convert - - Outputs: Returns a Java char array containing the same wchars. - - Purpose: Convert UCS-2 or UTF-16 to an array expression. - -\*******************************************************************/ - +/// Convert UCS-2 or UTF-16 to an array expression. +/// \par parameters: `in`: wide string to convert +/// \return Returns a Java char array containing the same wchars. static array_exprt utf16_to_array(const std::wstring &in) { const auto jchar=java_char_type(); @@ -138,18 +96,6 @@ static array_exprt utf16_to_array(const std::wstring &in) return ret; } -/*******************************************************************\ - -Function: java_bytecode_typecheckt::typecheck_expr_java_string_literal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_typecheckt::typecheck_expr_java_string_literal(exprt &expr) { const irep_idt value=expr.get(ID_value); @@ -264,18 +210,6 @@ void java_bytecode_typecheckt::typecheck_expr_java_string_literal(exprt &expr) expr=address_of_exprt(new_symbol.symbol_expr()); } -/*******************************************************************\ - -Function: java_bytecode_typecheckt::typecheck_expr_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_typecheckt::typecheck_expr_symbol(symbol_exprt &expr) { irep_idt identifier=expr.get_identifier(); @@ -324,18 +258,6 @@ void java_bytecode_typecheckt::typecheck_expr_symbol(symbol_exprt &expr) } } -/*******************************************************************\ - -Function: java_bytecode_typecheckt::typecheck_expr_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_typecheckt::typecheck_expr_member(member_exprt &expr) { // The member might be in a parent class or an opaque class, which we resolve diff --git a/src/java_bytecode/java_bytecode_typecheck_type.cpp b/src/java_bytecode/java_bytecode_typecheck_type.cpp index 647aa35a45e..79b2146f07a 100644 --- a/src/java_bytecode/java_bytecode_typecheck_type.cpp +++ b/src/java_bytecode/java_bytecode_typecheck_type.cpp @@ -6,22 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// JAVA Bytecode Conversion / Type Checking + #include #include "java_bytecode_typecheck.h" -/*******************************************************************\ - -Function: java_bytecode_typecheckt::typecheck_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_typecheckt::typecheck_type(typet &type) { if(type.id()==ID_symbol) @@ -62,18 +53,6 @@ void java_bytecode_typecheckt::typecheck_type(typet &type) } } -/*******************************************************************\ - -Function: java_bytecode_typecheckt::typecheck_type_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_bytecode_typecheckt::typecheck_type_symbol(symbolt &symbol) { assert(symbol.is_type); diff --git a/src/java_bytecode/java_bytecode_vtable.cpp b/src/java_bytecode/java_bytecode_vtable.cpp index d70225d9beb..d6a7b7fb4c0 100644 --- a/src/java_bytecode/java_bytecode_vtable.cpp +++ b/src/java_bytecode/java_bytecode_vtable.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include diff --git a/src/java_bytecode/java_bytecode_vtable.h b/src/java_bytecode/java_bytecode_vtable.h index 3e33d408a6e..44a7f35bf1b 100644 --- a/src/java_bytecode/java_bytecode_vtable.h +++ b/src/java_bytecode/java_bytecode_vtable.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_VTABLE_H #define CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_VTABLE_H diff --git a/src/java_bytecode/java_class_loader.cpp b/src/java_bytecode/java_class_loader.cpp index fdd37c4b312..dfb849a4986 100644 --- a/src/java_bytecode/java_class_loader.cpp +++ b/src/java_bytecode/java_class_loader.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include @@ -18,18 +19,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "java_class_loader.h" #include "jar_file.h" -/*******************************************************************\ - -Function: java_class_loadert::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - java_bytecode_parse_treet &java_class_loadert::operator()( const irep_idt &class_name) { @@ -72,18 +61,6 @@ java_bytecode_parse_treet &java_class_loadert::operator()( return class_map[class_name]; } -/*******************************************************************\ - -Function: java_class_loadert::set_java_cp_include_files - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_class_loadert::set_java_cp_include_files( std::string &_java_cp_include_files) { @@ -91,18 +68,6 @@ void java_class_loadert::set_java_cp_include_files( jar_pool.set_message_handler(get_message_handler()); } -/*******************************************************************\ - -Function: java_class_loadert::get_parse_tree - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - java_bytecode_parse_treet &java_class_loadert::get_parse_tree( java_class_loader_limitt &class_loader_limit, const irep_idt &class_name) @@ -196,18 +161,6 @@ java_bytecode_parse_treet &java_class_loadert::get_parse_tree( return parse_tree; } -/*******************************************************************\ - -Function: java_class_loadert::load_entire_jar - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_class_loadert::load_entire_jar( java_class_loader_limitt &class_loader_limit, const std::string &file) @@ -224,18 +177,6 @@ void java_class_loadert::load_entire_jar( jar_files.pop_front(); } -/*******************************************************************\ - -Function: java_class_loadert::read_jar_file - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_class_loadert::read_jar_file( java_class_loader_limitt &class_loader_limit, const irep_idt &file) @@ -271,18 +212,6 @@ void java_class_loadert::read_jar_file( } } -/*******************************************************************\ - -Function: java_class_loadert::file_to_class_name - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string java_class_loadert::file_to_class_name(const std::string &file) { std::string result=file; @@ -310,18 +239,6 @@ std::string java_class_loadert::file_to_class_name(const std::string &file) return result; } -/*******************************************************************\ - -Function: java_class_loadert::class_name_to_file - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string java_class_loadert::class_name_to_file(const irep_idt &class_name) { std::string result=id2string(class_name); diff --git a/src/java_bytecode/java_class_loader.h b/src/java_bytecode/java_class_loader.h index c4676ff31f0..f6996fb2efd 100644 --- a/src/java_bytecode/java_class_loader.h +++ b/src/java_bytecode/java_class_loader.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_JAVA_BYTECODE_JAVA_CLASS_LOADER_H #define 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 index 3a9ed66d3d5..7ba1d4fe0ee 100644 --- a/src/java_bytecode/java_class_loader_limit.cpp +++ b/src/java_bytecode/java_class_loader_limit.cpp @@ -6,22 +6,15 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// limit class path loading + #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 - -\*******************************************************************/ - +/// initializes class with either regex matcher or match set +/// \par parameters: parameter from `java-cp-include-files` void java_class_loader_limitt::setup_class_load_limit( std::string &java_cp_include_files) { @@ -54,18 +47,8 @@ void java_class_loader_limitt::setup_class_load_limit( } } -/*******************************************************************\ - -Function: java_class_loader_limitt::load_class_file - - Inputs: class file name - - Outputs: true if file should be loaded, else false - - Purpose: - -\*******************************************************************/ - +/// \par parameters: class file name +/// \return true if file should be loaded, else false bool java_class_loader_limitt::load_class_file(const irep_idt &file_name) { if(regex_match) diff --git a/src/java_bytecode/java_class_loader_limit.h b/src/java_bytecode/java_class_loader_limit.h index fa5e21ffd95..149561f29e4 100644 --- a/src/java_bytecode/java_class_loader_limit.h +++ b/src/java_bytecode/java_class_loader_limit.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// limit class path loading + #ifndef CPROVER_JAVA_BYTECODE_JAVA_CLASS_LOADER_LIMIT_H #define CPROVER_JAVA_BYTECODE_JAVA_CLASS_LOADER_LIMIT_H diff --git a/src/java_bytecode/java_entry_point.cpp b/src/java_bytecode/java_entry_point.cpp index 8d7b479ff60..bb7e488c8a5 100644 --- a/src/java_bytecode/java_entry_point.cpp +++ b/src/java_bytecode/java_entry_point.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include @@ -22,7 +23,7 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -#include +#include #include #include @@ -33,18 +34,6 @@ Author: Daniel Kroening, kroening@kroening.com #define INITIALIZE CPROVER_PREFIX "initialize" -/*******************************************************************\ - -Function: create_initialize - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static void create_initialize(symbol_tablet &symbol_table) { symbolt initialize; @@ -85,18 +74,6 @@ static bool should_init_symbol(const symbolt &sym) return has_prefix(id2string(sym.name), "java::java.lang.String.Literal"); } -/*******************************************************************\ - -Function: java_static_lifetime_init - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_static_lifetime_init( symbol_tablet &symbol_table, const source_locationt &source_location, @@ -155,18 +132,6 @@ void java_static_lifetime_init( } } -/*******************************************************************\ - -Function: java_build_arguments - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt::operandst java_build_arguments( const symbolt &function, code_blockt &init_code, @@ -234,18 +199,6 @@ exprt::operandst java_build_arguments( return main_arguments; } -/*******************************************************************\ - -Function: java_record_outputs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void java_record_outputs( const symbolt &function, const exprt::operandst &main_arguments, @@ -494,24 +447,14 @@ main_function_resultt get_main_symbol( return res; // give up with error } -/*******************************************************************\ - -Function: java_entry_point - - Inputs: - symbol_table - main class - message_handler - assume_init_pointers_not_null - allow pointers in initialization code to be - null - max_nondet_array_length - - Outputs: true if error occurred on entry point search - - Purpose: find entry point and create initialization code for function - -\*******************************************************************/ - +/// find entry point and create initialization code for function +/// symbol_table +/// main class +/// message_handler +/// \param assume_init_pointers_not_null: allow pointers in initialization code +/// to be null +/// max_nondet_array_length +/// \return true if error occurred on entry point search bool java_entry_point( symbol_tablet &symbol_table, const irep_idt &main_class, diff --git a/src/java_bytecode/java_entry_point.h b/src/java_bytecode/java_entry_point.h index 69f5023609f..c05a78b0689 100644 --- a/src/java_bytecode/java_entry_point.h +++ b/src/java_bytecode/java_entry_point.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_JAVA_BYTECODE_JAVA_ENTRY_POINT_H #define CPROVER_JAVA_BYTECODE_JAVA_ENTRY_POINT_H diff --git a/src/java_bytecode/java_local_variable_table.cpp b/src/java_bytecode/java_local_variable_table.cpp index 85e9766d5ab..ee7d061f9d6 100644 --- a/src/java_bytecode/java_local_variable_table.cpp +++ b/src/java_bytecode/java_local_variable_table.cpp @@ -6,6 +6,9 @@ Author: Chris Smowton, chris.smowton@diffblue.com \*******************************************************************/ +/// \file +/// Java local variable table processing + #include "java_bytecode_convert_method_class.h" #include "java_types.h" @@ -141,20 +144,11 @@ struct is_predecessor_oft // Helper routines for the find-initialisers code below: -/*******************************************************************\ - -Function: gather_transitive_predecessors - - Inputs: `start`: Variable to find the predecessors of - `predecessor_map`: Map from local variables - to sets of predecessors - Outputs: `result`: populated with all transitive predecessors of - `start` found in `predecessor_map` - - Purpose: See above - -\*******************************************************************/ - +/// See above +/// `start`: Variable to find the predecessors of `predecessor_map`: Map from +/// local variables to sets of predecessors +/// \param Outputs: `result`: populated with all transitive predecessors of +/// `start` found in `predecessor_map` static void gather_transitive_predecessors( local_variable_with_holest *start, const predecessor_mapt &predecessor_map, @@ -169,20 +163,11 @@ static void gather_transitive_predecessors( gather_transitive_predecessors(pred, predecessor_map, result); } -/*******************************************************************\ - -Function: is_store_to_slot - - Inputs: `inst`: Java bytecode instruction - `slotidx`: local variable slot number - - Outputs: Returns true if `inst` is any form of store instruction - targeting slot `slotidx` - - Purpose: See above - -\*******************************************************************/ - +/// See above +/// \par parameters: `inst`: Java bytecode instruction +/// `slotidx`: local variable slot number +/// \return Returns true if `inst` is any form of store instruction targeting +/// slot `slotidx` static bool is_store_to_slot( const java_bytecode_convert_methodt::instructiont &inst, unsigned slotidx) @@ -209,19 +194,10 @@ static bool is_store_to_slot( return storeslotidx==slotidx; } -/*******************************************************************\ - -Function: maybe_add_hole - - Inputs: `from`, `to`: bounds of a gap in `var`'s live range, - inclusive and exclusive respectively - - Outputs: Adds a hole to `var`, unless it would be of zero size. - - Purpose: See above - -\*******************************************************************/ - +/// See above +/// \par parameters: `from`, `to`: bounds of a gap in `var`'s live range, +/// inclusive and exclusive respectively +/// \return Adds a hole to `var`, unless it would be of zero size. static void maybe_add_hole( local_variable_with_holest &var, unsigned from, @@ -232,22 +208,13 @@ static void maybe_add_hole( var.holes.push_back({from, to-from}); } -/*******************************************************************\ - -Function: populate_variable_address_map - - Inputs: `firstvar`-`varlimit`: range of local variable table - entries to consider - - Outputs: `live_variable_at_address` is populated with a sequence of - local variable table entry pointers, such that - `live_variable_at_address[addr]` yields the unique table - entry covering that address. Asserts if entries overlap. - - Purpose: See above - -\*******************************************************************/ - +/// See above +/// \par parameters: `firstvar`-`varlimit`: range of local variable table +/// entries to consider +/// \return `live_variable_at_address` is populated with a sequence of local +/// variable table entry pointers, such that `live_variable_at_address[addr]` +/// yields the unique table entry covering that address. Asserts if entries +/// overlap. static void populate_variable_address_map( local_variable_table_with_holest::iterator firstvar, local_variable_table_with_holest::iterator varlimit, @@ -269,32 +236,20 @@ static void populate_variable_address_map( } } -/*******************************************************************\ - -Function: populate_predecessor_map - - Inputs: `firstvar`-`varlimit`: range of local variable table - entries to consider - `live_variable_at_address`: map from bytecode address - to table entry (drawn from firstvar-varlimit) live - at that address - `amap`: map from bytecode address to instructions - - Outputs: Populates `predecessor_map` with a graph from local variable - table entries to their predecessors (table entries which - may flow together and thus may be considered the same live - range). - - Purpose: Usually a live variable range begins with a store - instruction initialising the relevant local variable slot, - but instead of or in addition to this, control flow edges - may exist from bytecode addresses that fall under a - table entry which differs, but which has the same variable - name and type descriptor. This indicates a split live - range, and will be recorded in the predecessor map. - -\*******************************************************************/ - +/// Usually a live variable range begins with a store instruction initialising +/// the relevant local variable slot, but instead of or in addition to this, +/// control flow edges may exist from bytecode addresses that fall under a table +/// entry which differs, but which has the same variable name and type +/// descriptor. This indicates a split live range, and will be recorded in the +/// predecessor map. +/// \par parameters: `firstvar`-`varlimit`: range of local variable table +/// entries to consider +/// `live_variable_at_address`: map from bytecode address to table entry (drawn +/// from firstvar-varlimit) live at that address +/// `amap`: map from bytecode address to instructions +/// \return Populates `predecessor_map` with a graph from local variable table +/// entries to their predecessors (table entries which may flow together and +/// thus may be considered the same live range). static void populate_predecessor_map( local_variable_table_with_holest::iterator firstvar, local_variable_table_with_holest::iterator varlimit, @@ -393,24 +348,14 @@ static void populate_predecessor_map( } } -/*******************************************************************\ - -Function: get_common_dominator - - Inputs: `merge_vars`: Set of variables we want the common dominator - for. - `dominator_analysis`: Already-initialised dominator tree - - Outputs: Returns the bytecode address of the closest common - dominator of all given variable table entries. - In the worst case the function entry point should always - satisfy this criterion. - - Purpose: Used to find out where to put a variable declaration that - subsumes several variable live ranges. - -\*******************************************************************/ - +/// Used to find out where to put a variable declaration that subsumes several +/// variable live ranges. +/// \par parameters: `merge_vars`: Set of variables we want the common dominator +/// for. +/// `dominator_analysis`: Already-initialised dominator tree +/// \return Returns the bytecode address of the closest common dominator of all +/// given variable table entries. In the worst case the function entry point +/// should always satisfy this criterion. static unsigned get_common_dominator( const std::set &merge_vars, const java_cfg_dominatorst &dominator_analysis) @@ -460,24 +405,14 @@ static unsigned get_common_dominator( throw "variable live ranges with no common dominator?"; } -/*******************************************************************\ - -Function: populate_live_range_holes - - Inputs: `merge_vars`: a set of 2+ variable table entries to merge - `expanded_live_range_start`: address where the merged - variable will be declared - - Outputs: Adds holes to `merge_into`, indicating where gaps in the - variable's live range fall. For example, if the - declaration happens at address 10 and the entries in - `merge_into` have live ranges [(20-30), (40-50)] then - holes will be added at (10-20) and (30-40). - - Purpose: See above - -\*******************************************************************/ - +/// See above +/// \par parameters: `merge_vars`: a set of 2+ variable table entries to merge +/// `expanded_live_range_start`: address where the merged variable will be +/// declared +/// \return Adds holes to `merge_into`, indicating where gaps in the variable's +/// live range fall. For example, if the declaration happens at address 10 and +/// the entries in `merge_into` have live ranges [(20-30), (40-50)] then holes +/// will be added at (10-20) and (30-40). static void populate_live_range_holes( local_variable_with_holest &merge_into, const std::set &merge_vars, @@ -500,22 +435,13 @@ static void populate_live_range_holes( } } -/*******************************************************************\ - -Function: merge_variable_table_entries - - Inputs: `merge_vars`: a set of 2+ variable table entries to merge - `dominator_analysis`: already-calculated dominator tree - - Outputs: Populates `merge_into` as a combined variable table entry, - with live range holes if the `merge_vars` entries do not - cover a contiguous address range, beginning the combined - live range at the common dominator of all `merge_vars`. - - Purpose: See above - -\*******************************************************************/ - +/// See above +/// \par parameters: `merge_vars`: a set of 2+ variable table entries to merge +/// `dominator_analysis`: already-calculated dominator tree +/// \return Populates `merge_into` as a combined variable table entry, with live +/// range holes if the `merge_vars` entries do not cover a contiguous address +/// range, beginning the combined live range at the common dominator of all +/// `merge_vars`. static void merge_variable_table_entries( local_variable_with_holest &merge_into, const std::set &merge_vars, @@ -559,28 +485,17 @@ static void merge_variable_table_entries( v->var.length=0; } -/*******************************************************************\ - -Function: find_initialisers_for_slot - - Inputs: `firstvar`-`varlimit`: sequence of variable table entries, - all of which should concern the same slot index. - `amap`: Map from bytecode address to instruction - - Outputs: Side-effect: merges variable table entries which flow into - one another (e.g. there are branches from one live range - to another without re-initialising the local slot). - - Purpose: Given a sequence of users of the same local variable slot, - this figures out which ones are related by control flow, - and combines them into a single entry with holes, such that - after combination we can create a single - declaration per variable table entry, - placed at the live range's start address, which may - be moved back so that the declaration dominates all uses. - -\*******************************************************************/ - +/// Given a sequence of users of the same local variable slot, this figures out +/// which ones are related by control flow, and combines them into a single +/// entry with holes, such that after combination we can create a single +/// declaration per variable table entry, placed at the live range's start +/// address, which may be moved back so that the declaration dominates all uses. +/// \par parameters: `firstvar`-`varlimit`: sequence of variable table entries, +/// all of which should concern the same slot index. +/// `amap`: Map from bytecode address to instruction +/// \return Side-effect: merges variable table entries which flow into one +/// another (e.g. there are branches from one live range to another without +/// re-initialising the local slot). void java_bytecode_convert_methodt::find_initialisers_for_slot( local_variable_table_with_holest::iterator firstvar, local_variable_table_with_holest::iterator varlimit, @@ -647,23 +562,13 @@ void java_bytecode_convert_methodt::find_initialisers_for_slot( } } -/*******************************************************************\ - -Function: walk_to_next_index - - Inputs: `it1` and `it2`, which are iterators into the same vector, - of which `itend` is the end() iterator. - - Outputs: Moves `it1` and `it2` to delimit a sequence of variable - table entries with slot index equal to it2->var.index - on entering this function, or to both equal itend if - it2==itend on entry. - - Purpose: Walk a vector, a contiguous block of entries with equal - slot index at a time. - -\*******************************************************************/ - +/// Walk a vector, a contiguous block of entries with equal slot index at a +/// time. +/// \par parameters: `it1` and `it2`, which are iterators into the same vector, +/// of which `itend` is the end() iterator. +/// \return Moves `it1` and `it2` to delimit a sequence of variable table +/// entries with slot index equal to it2->var.index on entering this function, +/// or to both equal itend if it2==itend on entry. static void walk_to_next_index( local_variable_table_with_holest::iterator &it1, local_variable_table_with_holest::iterator &it2, @@ -682,21 +587,12 @@ static void walk_to_next_index( it1=old_it2; } -/*******************************************************************\ - -Function: find_initialisers - - Inputs: `vars`: Local variable table - `amap`: Map from bytecode index to instruction - `dominator_analysis`: Already computed dominator tree for - the Java function described by `amap` - - Outputs: Combines entries in `vars` which flow together - - Purpose: See `find_initialisers_for_slot` above for more detail. - -\*******************************************************************/ - +/// See `find_initialisers_for_slot` above for more detail. +/// \par parameters: `vars`: Local variable table +/// `amap`: Map from bytecode index to instruction +/// `dominator_analysis`: Already computed dominator tree for the Java function +/// described by `amap` +/// \return Combines entries in `vars` which flow together void java_bytecode_convert_methodt::find_initialisers( local_variable_table_with_holest &vars, const address_mapt &amap, @@ -715,18 +611,9 @@ void java_bytecode_convert_methodt::find_initialisers( find_initialisers_for_slot(it1, it2, amap, dominator_analysis); } -/*******************************************************************\ - -Function: cleanup_var_table - - Inputs: `vars_with_holes`: variable table - - Outputs: Removes zero-size entries from `vars_with_holes` - - Purpose: See above - -\*******************************************************************/ - +/// See above +/// \par parameters: `vars_with_holes`: variable table +/// \return Removes zero-size entries from `vars_with_holes` static void cleanup_var_table( std::vector &vars_with_holes) { @@ -749,22 +636,12 @@ static void cleanup_var_table( vars_with_holes.resize(vars_with_holes.size()-toremove); } -/*******************************************************************\ - -Function: setup_local_variables - - Inputs: `m`: Java method - `amap`: Map from bytecode indices to instructions in `m` - - Outputs: Populates `this->vars_with_holes` equal to - `this->local_variable_table`, only with variable table - entries that flow together combined. - Also symbol-table registers all locals. - - Purpose: See `find_initialisers_for_slot` above for more detail. - -\*******************************************************************/ - +/// See `find_initialisers_for_slot` above for more detail. +/// \par parameters: `m`: Java method +/// `amap`: Map from bytecode indices to instructions in `m` +/// \return Populates `this->vars_with_holes` equal to +/// `this->local_variable_table`, only with variable table entries that flow +/// together combined. Also symbol-table registers all locals. void java_bytecode_convert_methodt::setup_local_variables( const methodt &m, const address_mapt &amap) @@ -827,22 +704,12 @@ void java_bytecode_convert_methodt::setup_local_variables( } } -/*******************************************************************\ - -Function: find_variable_for_slot - - Inputs: `address`: Address to find a variable table entry for - `var_list`: List of candidates that use the slot we're - interested in - - Outputs: Returns the list entry covering this address (taking live - range holes into account), or creates/returns an anonymous - variable entry if nothing covers `address`. - - Purpose: See above - -\*******************************************************************/ - +/// See above +/// \par parameters: `address`: Address to find a variable table entry for +/// `var_list`: List of candidates that use the slot we're interested in +/// \return Returns the list entry covering this address (taking live range +/// holes into account), or creates/returns an anonymous variable entry if +/// nothing covers `address`. const java_bytecode_convert_methodt::variablet & java_bytecode_convert_methodt::find_variable_for_slot( size_t address, diff --git a/src/java_bytecode/java_object_factory.cpp b/src/java_bytecode/java_object_factory.cpp index 31d5741140a..ff00c5b1ef7 100644 --- a/src/java_bytecode/java_object_factory.cpp +++ b/src/java_bytecode/java_object_factory.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -28,18 +29,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "java_types.h" #include "java_utils.h" -/*******************************************************************\ - -Function: new_tmp_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static symbolt &new_tmp_symbol( symbol_tablet &symbol_table, const source_locationt &loc, @@ -130,27 +119,18 @@ class java_object_factoryt update_in_placet); }; -/*******************************************************************\ - -Function: allocate_dynamic_object - - Inputs: - target_expr - expression to which the necessary memory will be allocated - allocate_type - type of the object allocated - symbol_table - symbol table - loc - location in the source - output_code - code block to which the necessary code is added - symbols_created - created symbols to be declared by the caller - cast_needed - Boolean flags saying where we need to cast the malloc site - - Outputs: Expression representing the malloc site allocated. - - Purpose: Generates code for allocating a dynamic object. - This is used in allocate_object and for allocating strings - in the library preprocessing. - -\*******************************************************************/ - +/// Generates code for allocating a dynamic object. This is used in +/// allocate_object and for allocating strings in the library preprocessing. +/// \param target_expr: expression to which the necessary memory will be +/// allocated +/// \param allocate_type: type of the object allocated +/// \param symbol_table: symbol table +/// \param loc: location in the source +/// \param output_code: code block to which the necessary code is added +/// \param symbols_created: created symbols to be declared by the caller +/// \param cast_needed: Boolean flags saying where we need to cast the malloc +/// site +/// \return Expression representing the malloc site allocated. exprt allocate_dynamic_object( const exprt &target_expr, const typet &allocate_type, @@ -202,27 +182,18 @@ exprt allocate_dynamic_object( } } -/*******************************************************************\ - -Function: allocate_dynamic_object_with_decl - - Inputs: - target_expr - expression to which the necessary memory will be allocated - allocate_type - type of the object allocated - symbol_table - symbol table - loc - location in the source - output_code - code block to which the necessary code is added - cast_needed - Boolean flags saying where we need to cast the malloc site - - Outputs: Expression representing the malloc site allocated. - - Purpose: Generates code for allocating a dynamic object. - This is a static version of allocate_dynamic_object that can - be called from outside java_object_factory and which takes care - of creating the associated declarations. - -\*******************************************************************/ - +/// Generates code for allocating a dynamic object. This is a static version of +/// allocate_dynamic_object that can be called from outside java_object_factory +/// and which takes care of creating the associated declarations. +/// \param target_expr: expression to which the necessary memory will be +/// allocated +/// \param allocate_type: type of the object allocated +/// \param symbol_table: symbol table +/// \param loc: location in the source +/// \param output_code: code block to which the necessary code is added +/// \param cast_needed: Boolean flags saying where we need to cast the malloc +/// site +/// \return Expression representing the malloc site allocated. exprt allocate_dynamic_object_with_decl( const exprt &target_expr, const typet &allocate_type, @@ -254,25 +225,15 @@ exprt allocate_dynamic_object_with_decl( return result; } -/*******************************************************************\ - -Function: java_object_factoryt::allocate_object - - Inputs: - assignments - The code block to add code to - target_expr - The expression which we are allocating a symbol for - allocate_type - - create_dynamic_objects - Whether to create a symbol with static - lifetime or - - Outputs: the allocated object - - Purpose: Returns false if we can't figure out the size of allocate_type. - allocate_type may differ from target_expr, e.g. for target_expr - having type int* and allocate_type being an int[10]. - -\*******************************************************************/ - +/// Returns false if we can't figure out the size of allocate_type. +/// allocate_type may differ from target_expr, e.g. for target_expr having type +/// int* and allocate_type being an int[10]. +/// \param assignments: The code block to add code to +/// \param target_expr: The expression which we are allocating a symbol for +/// \param allocate_type: +/// \param create_dynamic_objects: Whether to create a symbol with static +/// lifetime or +/// \return the allocated object exprt java_object_factoryt::allocate_object( code_blockt &assignments, const exprt &target_expr, @@ -309,20 +270,9 @@ exprt java_object_factoryt::allocate_object( } } -/*******************************************************************\ - -Function: java_object_factoryt::get_null_assignment - - Inputs: `expr`: pointer-typed lvalue expression to initialise - `ptr_type`: pointer type to write - - Outputs: - - Purpose: Adds an instruction to `init_code` null-initialising - `expr`. - -\*******************************************************************/ - +/// Adds an instruction to `init_code` null-initialising `expr`. +/// \par parameters: `expr`: pointer-typed lvalue expression to initialise +/// `ptr_type`: pointer type to write code_assignt java_object_factoryt::get_null_assignment( const exprt &expr, const pointer_typet &ptr_type) @@ -333,29 +283,17 @@ code_assignt java_object_factoryt::get_null_assignment( return code; } -/*******************************************************************\ - -Function: java_object_factoryt::gen_pointer_target_init - - Inputs: `expr`: pointer-typed lvalue expression to initialise - `target_type`: structure type to initialise, which may - not match *expr (for example, expr might be void*) - `create_dynamic_objects`: if true, use malloc to allocate - objects; otherwise generate fresh static symbols. - `update_in_place`: - NO_UPDATE_IN_PLACE: initialise `expr` from scratch - MUST_UPDATE_IN_PLACE: reinitialise an existing object - MAY_UPDATE_IN_PLACE: invalid input - - Outputs: - - Purpose: Initialises an object tree rooted at `expr`, allocating - child objects as necessary and nondet-initialising their - members, or if MUST_UPDATE_IN_PLACE is set, re-initialising - already-allocated objects. - -\*******************************************************************/ - +/// Initialises an object tree rooted at `expr`, allocating child objects as +/// necessary and nondet-initialising their members, or if MUST_UPDATE_IN_PLACE +/// is set, re-initialising already-allocated objects. +/// \par parameters: `expr`: pointer-typed lvalue expression to initialise +/// `target_type`: structure type to initialise, which may not match *expr (for +/// example, expr might be void*) +/// `create_dynamic_objects`: if true, use malloc to allocate objects; otherwise +/// generate fresh static symbols. +/// `update_in_place`: NO_UPDATE_IN_PLACE: initialise `expr` from scratch +/// MUST_UPDATE_IN_PLACE: reinitialise an existing object MAY_UPDATE_IN_PLACE: +/// invalid input void java_object_factoryt::gen_pointer_target_init( code_blockt &assignments, const exprt &expr, @@ -409,40 +347,25 @@ void java_object_factoryt::gen_pointer_target_init( } } -/*******************************************************************\ - -Function: java_object_factoryt::gen_nondet_init - - Inputs: `expr`: lvalue expression to initialise - `is_sub`: If true, `expr` is a substructure of a larger - object, which in Java necessarily means a base class. - not match *expr (for example, expr might be void*) - `class_identifier`: clsid to initialise @java.lang.Object. - @class_identifier - `skip_classid`: if true, skip initialising @class_identifier - `create_dynamic_objects`: if true, use malloc to allocate - objects; otherwise generate fresh static symbols. - `override`: If true, initialise with `override_type` instead - of `expr.type()`. Used at the moment for - reference arrays, which are implemented as void* - arrays but should be init'd as their true type with - appropriate casts. - `override_type`: Override type per above - `update_in_place`: - NO_UPDATE_IN_PLACE: initialise `expr` from scratch - MUST_UPDATE_IN_PLACE: reinitialise an existing object - MAY_UPDATE_IN_PLACE: generate a runtime nondet branch - between the NO_ and MUST_ cases. - - Outputs: - - Purpose: Initialises a primitive or object tree rooted at `expr`, - allocating child objects as necessary and nondet-initialising - their members, or if MUST_UPDATE_IN_PLACE is set, - re-initialising already-allocated objects. - -\*******************************************************************/ - +/// Initialises a primitive or object tree rooted at `expr`, allocating child +/// objects as necessary and nondet-initialising their members, or if +/// MUST_UPDATE_IN_PLACE is set, re-initialising already-allocated objects. +/// \par parameters: `expr`: lvalue expression to initialise +/// `is_sub`: If true, `expr` is a substructure of a larger object, which in +/// Java necessarily means a base class. not match *expr (for example, expr +/// might be void*) +/// `class_identifier`: clsid to initialise @java.lang.Object. @class_identifier +/// `skip_classid`: if true, skip initialising @class_identifier +/// `create_dynamic_objects`: if true, use malloc to allocate objects; otherwise +/// generate fresh static symbols. +/// `override`: If true, initialise with `override_type` instead of +/// `expr.type()`. Used at the moment for reference arrays, which are +/// implemented as void* arrays but should be init'd as their true type with +/// appropriate casts. +/// `override_type`: Override type per above +/// `update_in_place`: NO_UPDATE_IN_PLACE: initialise `expr` from scratch +/// MUST_UPDATE_IN_PLACE: reinitialise an existing object MAY_UPDATE_IN_PLACE: +/// generate a runtime nondet branch between the NO_ and MUST_ cases. void java_object_factoryt::gen_nondet_init( code_blockt &assignments, const exprt &expr, @@ -646,24 +569,15 @@ void java_object_factoryt::gen_nondet_init( } } -/*******************************************************************\ - -Function: java_object_factoryt::allocate_nondet_length_array - - Inputs: `lhs`, symbol to assign the new array structure - `max_length_expr`, maximum length of the new array - (minimum is fixed at zero for now) - `element_type`, actual element type of the array (the array - for all reference types will have void* type, but this - will be annotated as the true member type) - - Outputs: Appends instructions to `assignments` - - Purpose: Allocates a fresh array. Single-use herem at the moment, but - useful to keep as a separate function for downstream branches. - -\*******************************************************************/ - +/// Allocates a fresh array. Single-use herem at the moment, but useful to keep +/// as a separate function for downstream branches. +/// \par parameters: `lhs`, symbol to assign the new array structure +/// `max_length_expr`, maximum length of the new array (minimum is fixed at zero +/// for now) +/// `element_type`, actual element type of the array (the array for all +/// reference types will have void* type, but this will be annotated as the +/// true member type) +/// \return Appends instructions to `assignments` void java_object_factoryt::allocate_nondet_length_array( code_blockt &assignments, const exprt &lhs, @@ -702,26 +616,15 @@ void java_object_factoryt::allocate_nondet_length_array( side_effect_exprt java_new_array(ID_java_new_array, lhs.type()); java_new_array.copy_to_operands(length_sym_expr); + java_new_array.set(ID_length_upper_bound, max_length_expr); java_new_array.type().subtype().set(ID_C_element_type, element_type); codet assign=code_assignt(lhs, java_new_array); assign.add_source_location()=loc; assignments.copy_to_operands(assign); } -/*******************************************************************\ - -Function: java_object_factoryt::gen_nondet_array_init - - Inputs: - - Outputs: - - Purpose: create code to initialize a Java array with size - `max_nondet_array_length`, loop over elements and initialize - them - -\*******************************************************************/ - +/// create code to initialize a Java array with size `max_nondet_array_length`, +/// loop over elements and initialize them void java_object_factoryt::gen_nondet_array_init( code_blockt &assignments, const exprt &expr, @@ -841,28 +744,16 @@ void java_object_factoryt::gen_nondet_array_init( assignments.move_to_operands(init_done_label); } -/*******************************************************************\ - -Function: object_factory - - Inputs: `type`: type of new object to create - `allow_null`: if true, may return null; otherwise always - allocates an object - `max_nondet_array_length`: upper bound on size of initialised - arrays. - `loc`: source location for all generated code - `message_handler`: logging - - Outputs: `symbol_table` gains any new symbols created, as per - gen_nondet_init above. - `init_code` gains any instructions requried to initialise - either the returned value or its child objects - - Purpose: Similar to `gen_nondet_init` above, but always creates a - fresh static global object or primitive nondet expression. - -\*******************************************************************/ - +/// Similar to `gen_nondet_init` above, but always creates a fresh static global +/// object or primitive nondet expression. +/// \par parameters: `type`: type of new object to create +/// `allow_null`: if true, may return null; otherwise always allocates an object +/// `max_nondet_array_length`: upper bound on size of initialised arrays. +/// `loc`: source location for all generated code +/// `message_handler`: logging +/// \return `symbol_table` gains any new symbols created, as per gen_nondet_init +/// above. `init_code` gains any instructions requried to initialise either +/// the returned value or its child objects exprt object_factory( const typet &type, const irep_idt base_name, @@ -926,39 +817,25 @@ exprt object_factory( return object; } -/*******************************************************************\ - -Function: gen_nondet_init - - Inputs: `expr`: lvalue expression to initialise - `loc`: source location for all generated code - `skip_classid`: if true, skip initialising @class_identifier - `create_dyn_objs`: if true, use malloc to allocate - objects; otherwise generate fresh static symbols. - `assume_non_null`: never initialise pointer members with - null, unless forced to by recursive datatypes - `message_handler`: logging - `max_nondet_array_length`: upper bound on size of initialised - arrays. - `update_in_place`: - NO_UPDATE_IN_PLACE: initialise `expr` from scratch - MUST_UPDATE_IN_PLACE: reinitialise an existing object - MAY_UPDATE_IN_PLACE: generate a runtime nondet branch - between the NO_ and MUST_ cases. - - Outputs: `init_code` gets an instruction sequence to initialise or - reinitialise `expr` and child objects it refers to. - `symbol_table` is modified with any new symbols created. This - includes any necessary temporaries, and if `create_dyn_objs` - is false, any allocated objects. - - Purpose: Initialises a primitive or object tree rooted at `expr`, - allocating child objects as necessary and nondet-initialising - their members, or if MAY_ or MUST_UPDATE_IN_PLACE is set, - re-initialising already-allocated objects. - -\*******************************************************************/ - +/// Initialises a primitive or object tree rooted at `expr`, allocating child +/// objects as necessary and nondet-initialising their members, or if MAY_ or +/// MUST_UPDATE_IN_PLACE is set, re-initialising already-allocated objects. +/// \par parameters: `expr`: lvalue expression to initialise +/// `loc`: source location for all generated code +/// `skip_classid`: if true, skip initialising @class_identifier +/// `create_dyn_objs`: if true, use malloc to allocate objects; otherwise +/// generate fresh static symbols. +/// `assume_non_null`: never initialise pointer members with null, unless forced +/// to by recursive datatypes +/// `message_handler`: logging +/// `max_nondet_array_length`: upper bound on size of initialised arrays. +/// `update_in_place`: NO_UPDATE_IN_PLACE: initialise `expr` from scratch +/// MUST_UPDATE_IN_PLACE: reinitialise an existing object MAY_UPDATE_IN_PLACE: +/// generate a runtime nondet branch between the NO_ and MUST_ cases. +/// \return `init_code` gets an instruction sequence to initialise or +/// reinitialise `expr` and child objects it refers to. `symbol_table` is +/// modified with any new symbols created. This includes any necessary +/// temporaries, and if `create_dyn_objs` is false, any allocated objects. void gen_nondet_init( const exprt &expr, code_blockt &init_code, diff --git a/src/java_bytecode/java_object_factory.h b/src/java_bytecode/java_object_factory.h index 69ab7250ca7..287a8824c74 100644 --- a/src/java_bytecode/java_object_factory.h +++ b/src/java_bytecode/java_object_factory.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_JAVA_BYTECODE_JAVA_OBJECT_FACTORY_H #define CPROVER_JAVA_BYTECODE_JAVA_OBJECT_FACTORY_H diff --git a/src/java_bytecode/java_pointer_casts.cpp b/src/java_bytecode/java_pointer_casts.cpp index 174bad0a9b1..c2f04e4d1a5 100644 --- a/src/java_bytecode/java_pointer_casts.cpp +++ b/src/java_bytecode/java_pointer_casts.cpp @@ -6,24 +6,17 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// JAVA Pointer Casts + #include #include #include #include "java_pointer_casts.h" -/*******************************************************************\ - -Function: clean_deref - - Inputs: pointer - - Outputs: dereferenced pointer - - Purpose: dereference pointer expression - -\*******************************************************************/ - +/// dereference pointer expression +/// \return dereferenced pointer static exprt clean_deref(const exprt &ptr) { return ptr.id()==ID_address_of @@ -31,19 +24,9 @@ static exprt clean_deref(const exprt &ptr) : dereference_exprt(ptr, ptr.type().subtype()); } -/*******************************************************************\ - -Function: find_superclass_with_type - - Inputs: pointer - target type to search - - Outputs: true iff a super class with target type is found - - Purpose: - -\*******************************************************************/ - +/// \par parameters: pointer +/// target type to search +/// \return true iff a super class with target type is found bool find_superclass_with_type( exprt &ptr, const typet &target_type, @@ -77,18 +60,8 @@ bool find_superclass_with_type( } -/*******************************************************************\ - -Function: look_through_casts - - Inputs: input expression - - Outputs: recursively search target of typecast - - Purpose: - -\*******************************************************************/ - +/// \par parameters: input expression +/// \return recursively search target of typecast static const exprt &look_through_casts(const exprt &in) { if(in.id()==ID_typecast) @@ -101,20 +74,10 @@ static const exprt &look_through_casts(const exprt &in) } -/*******************************************************************\ - -Function: make_clean_pointer_cast - - Inputs: raw pointer - target type - namespace - - Outputs: cleaned up typecast expression - - Purpose: - -\*******************************************************************/ - +/// \par parameters: raw pointer +/// target type +/// namespace +/// \return cleaned up typecast expression exprt make_clean_pointer_cast( const exprt &rawptr, const typet &target_type, diff --git a/src/java_bytecode/java_pointer_casts.h b/src/java_bytecode/java_pointer_casts.h index 7b5d23a3c8a..eff1f6ccef8 100644 --- a/src/java_bytecode/java_pointer_casts.h +++ b/src/java_bytecode/java_pointer_casts.h @@ -6,6 +6,9 @@ Author: DiffBlue \*******************************************************************/ +/// \file +/// JAVA Pointer Casts + #ifndef CPROVER_JAVA_BYTECODE_JAVA_POINTER_CASTS_H #define CPROVER_JAVA_BYTECODE_JAVA_POINTER_CASTS_H diff --git a/src/java_bytecode/java_root_class.cpp b/src/java_bytecode/java_root_class.cpp index db6c810182a..1e93ca62d16 100644 --- a/src/java_bytecode/java_root_class.cpp +++ b/src/java_bytecode/java_root_class.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include diff --git a/src/java_bytecode/java_root_class.h b/src/java_bytecode/java_root_class.h index e0ce4f7dddc..fcdb11333db 100644 --- a/src/java_bytecode/java_root_class.h +++ b/src/java_bytecode/java_root_class.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_JAVA_BYTECODE_JAVA_ROOT_CLASS_H #define CPROVER_JAVA_BYTECODE_JAVA_ROOT_CLASS_H diff --git a/src/java_bytecode/java_string_library_preprocess.cpp b/src/java_bytecode/java_string_library_preprocess.cpp index e70a368e145..0a3ef95be8f 100644 --- a/src/java_bytecode/java_string_library_preprocess.cpp +++ b/src/java_bytecode/java_string_library_preprocess.cpp @@ -11,6 +11,11 @@ Date: April 2017 \*******************************************************************/ +/// \file +/// Java_string_libraries_preprocess, gives code for methods on strings of the +/// java standard library. In particular methods from java.lang.String, +/// java.lang.StringBuilder, java.lang.StringBuffer. + #include #include #include @@ -22,19 +27,8 @@ Date: April 2017 #include "java_string_library_preprocess.h" -/*******************************************************************\ - -Function: java_string_library_preprocesst::java_type_matches_tag - - Inputs: - type - a type - tag - a string - - Output: Boolean telling whether the type is a struct with the given - tag or a symbolic type with the tag prefixed by "java::" - -\*******************************************************************/ - +/// \param type: a type +/// \param tag: a string bool java_string_library_preprocesst::java_type_matches_tag( const typet &type, const std::string &tag) { @@ -51,16 +45,7 @@ bool java_string_library_preprocesst::java_type_matches_tag( return false; } -/*******************************************************************\ - -Function: java_string_library_preprocesst::is_java_string_pointer_type - - Inputs: a type - - Output: Boolean telling whether the type is that of java string pointer - -\*******************************************************************/ - +/// \par parameters: a type bool java_string_library_preprocesst::is_java_string_pointer_type( const typet &type) { @@ -73,49 +58,21 @@ bool java_string_library_preprocesst::is_java_string_pointer_type( return false; } -/*******************************************************************\ - -Function: java_string_library_preprocesst::is_java_string_type - - Inputs: a type - - Output: Boolean telling whether the type is that of java string - -\*******************************************************************/ - +/// \par parameters: a type bool java_string_library_preprocesst::is_java_string_type( const typet &type) { return java_type_matches_tag(type, "java.lang.String"); } -/*******************************************************************\ - -Function: java_string_library_preprocesst::is_java_string_builder_type - - Inputs: a type - - Output: Boolean telling whether the type is that of java StringBuilder - -\*******************************************************************/ - +/// \par parameters: a type bool java_string_library_preprocesst::is_java_string_builder_type( const typet &type) { return java_type_matches_tag(type, "java.lang.StringBuilder"); } -/*******************************************************************\ - -Function: java_string_library_preprocesst::is_java_string_builder_pointer_type - - Inputs: a type - - Output: Boolean telling whether the type is that of java StringBuilder - pointers - -\*******************************************************************/ - +/// \par parameters: a type bool java_string_library_preprocesst::is_java_string_builder_pointer_type( const typet &type) { @@ -128,33 +85,14 @@ bool java_string_library_preprocesst::is_java_string_builder_pointer_type( return false; } -/*******************************************************************\ - -Function: java_string_library_preprocesst::is_java_string_buffer_type - - Inputs: a type - - Output: Boolean telling whether the type is that of java StringBuffer - -\*******************************************************************/ - +/// \par parameters: a type bool java_string_library_preprocesst::is_java_string_buffer_type( const typet &type) { return java_type_matches_tag(type, "java.lang.StringBuffer"); } -/*******************************************************************\ - -Function: java_string_library_preprocesst::is_java_string_buffer_pointer_type - - Inputs: a type - - Output: Boolean telling whether the type is that of java StringBuffer - pointers - -\*******************************************************************/ - +/// \par parameters: a type bool java_string_library_preprocesst::is_java_string_buffer_pointer_type( const typet &type) { @@ -167,33 +105,14 @@ bool java_string_library_preprocesst::is_java_string_buffer_pointer_type( return false; } -/*******************************************************************\ - -Function: java_string_library_preprocesst::is_java_char_sequence_type - - Inputs: a type - - Output: Boolean telling whether the type is that of java char sequence - -\*******************************************************************/ - +/// \par parameters: a type bool java_string_library_preprocesst::is_java_char_sequence_type( const typet &type) { return java_type_matches_tag(type, "java.lang.CharSequence"); } -/*******************************************************************\ - -Function: java_string_library_preprocesst::is_java_char_sequence_pointer_type - - Inputs: a type - - Output: Boolean telling whether the type is that of a pointer - to a java char sequence - -\*******************************************************************/ - +/// \par parameters: a type bool java_string_library_preprocesst::is_java_char_sequence_pointer_type( const typet &type) { @@ -206,33 +125,16 @@ bool java_string_library_preprocesst::is_java_char_sequence_pointer_type( return false; } -/*******************************************************************\ - -Function: java_string_library_preprocesst::is_java_char_array_type - - Inputs: a type - - Output: Boolean telling whether the type is that of java char array - -\*******************************************************************/ - +/// \par parameters: a type bool java_string_library_preprocesst::is_java_char_array_type( const typet &type) { return java_type_matches_tag(type, "array[char]"); } -/*******************************************************************\ - -Function: java_string_library_preprocesst::is_java_char_array_pointer_type - - Inputs: a type - - Outputs: Boolean telling whether the type is that of a pointer - to a java char array - -\*******************************************************************/ - +/// \par parameters: a type +/// \return Boolean telling whether the type is that of a pointer to a java char +/// array bool java_string_library_preprocesst::is_java_char_array_pointer_type( const typet &type) { @@ -245,17 +147,7 @@ bool java_string_library_preprocesst::is_java_char_array_pointer_type( return false; } -/*******************************************************************\ - -Function: java_string_library_preprocesst::string_data_type - - Inputs: - symbol_table - a symbol_table containing an entry for java Strings - - Output: the type of data fields in java Strings. - -\*******************************************************************/ - +/// \param symbol_table: a symbol_table containing an entry for java Strings typet string_data_type(symbol_tablet symbol_table) { symbolt sym=symbol_table.lookup("java::java.lang.String"); @@ -266,32 +158,15 @@ typet string_data_type(symbol_tablet symbol_table) return data_type; } -/*******************************************************************\ - -Function: java_string_library_preprocesst::string_length_type - - Outputs: the type of the length field in java Strings. - -\*******************************************************************/ - +/// \return the type of the length field in java Strings. typet string_length_type() { return java_int_type(); } -/*******************************************************************\ - -Function: java_string_library_preprocesst::add_string_type - - Inputs: - class_name - a name for the class such as "java.lang.String" - symbol_table - symbol table to which the class will be added - - Purpose: Add to the symbol table type declaration for a String-like - Java class. - -\*******************************************************************/ - +/// Add to the symbol table type declaration for a String-like Java class. +/// \param class_name: a name for the class such as "java.lang.String" +/// \param symbol_table: symbol table to which the class will be added void java_string_library_preprocesst::add_string_type( const irep_idt &class_name, symbol_tablet &symbol_table) { @@ -323,22 +198,11 @@ void java_string_library_preprocesst::add_string_type( string_symbol->is_type=true; } -/*******************************************************************\ - -Function: fresh_array - - Inputs: - type - an array type - location - a location in the program - symbol_table - symbol table - - Output: a new symbol - - Purpose: add a symbol in the table with static lifetime and name - containing `cprover_string_array` and given type - -\*******************************************************************/ - +/// add a symbol in the table with static lifetime and name containing +/// `cprover_string_array` and given type +/// \param type: an array type +/// \param location: a location in the program +/// \param symbol_table: symbol table symbol_exprt java_string_library_preprocesst::fresh_array( const typet &type, const source_locationt &location, @@ -355,19 +219,10 @@ symbol_exprt java_string_library_preprocesst::fresh_array( return array_symbol.symbol_expr(); } -/*******************************************************************\ - -Function: java_string_library_preprocesst::declare_function - - Inputs: - function_name - a name - type - a type - symbol_table - symbol table - - Purpose: declare a function with the given name and type - -\*******************************************************************/ - +/// declare a function with the given name and type +/// \param function_name: a name +/// \param type: a type +/// \param symbol_table: symbol table void java_string_library_preprocesst::declare_function( irep_idt function_name, const typet &type, symbol_tablet &symbol_table) { @@ -381,24 +236,12 @@ void java_string_library_preprocesst::declare_function( symbol_table.add(func_symbol); } -/*******************************************************************\ - -Function: string_refine_preprocesst::process_arguments - - Inputs: - params - a list of function parameters - loc - location in the source - symbol_table - symbol table - init_code - code block, in which declaration of some arguments - may be added - - Output: a list of expressions - - Purpose: calls string_refine_preprocesst::process_operands with a - list of parameters. - -\*******************************************************************/ - +/// calls string_refine_preprocesst::process_operands with a list of parameters. +/// \param params: a list of function parameters +/// \param loc: location in the source +/// \param symbol_table: symbol table +/// \param init_code: code block, in which declaration of some arguments may be +/// added exprt::operandst java_string_library_preprocesst::process_parameters( const code_typet::parameterst ¶ms, const source_locationt &loc, @@ -414,23 +257,13 @@ exprt::operandst java_string_library_preprocesst::process_parameters( return process_operands(ops, loc, symbol_table, init_code); } -/*******************************************************************\ - -Function: java_string_library_preprocesst::process_single_operand - - Inputs: - processed_ops - the list of processed operands to populate - op_to_process - a list of expressions - loc - location in the source - symbol_table - symbol table - init_code - code block, in which declaration of some arguments - may be added - - Purpose: Creates a string_exprt from the input exprt and adds it to - processed_ops - -\*******************************************************************/ - +/// Creates a string_exprt from the input exprt and adds it to processed_ops +/// \param processed_ops: the list of processed operands to populate +/// \param op_to_process: a list of expressions +/// \param loc: location in the source +/// \param symbol_table: symbol table +/// \param init_code: code block, in which declaration of some arguments may be +/// added void java_string_library_preprocesst::process_single_operand( exprt::operandst &processed_ops, const exprt &op_to_process, @@ -452,28 +285,16 @@ void java_string_library_preprocesst::process_single_operand( processed_ops.push_back(string_expr); } -/*******************************************************************\ - -Function: java_string_library_preprocesst::process_operands - - Inputs: - operands - a list of expressions - loc - location in the source - symbol_table - symbol table - init_code - code block, in which declaration of some arguments - may be added - - Output: a list of expressions - - Purpose: for each expression that is of a type implementing strings, - we declare a new `cprover_string` whose contents is deduced - from the expression and replace the - expression by this cprover_string in the output list; - in the other case the expression is kept as is for the output list. - Also does the same thing for char array references. - -\*******************************************************************/ - +/// for each expression that is of a type implementing strings, we declare a new +/// `cprover_string` whose contents is deduced from the expression and replace +/// the expression by this cprover_string in the output list; in the other case +/// the expression is kept as is for the output list. Also does the same thing +/// for char array references. +/// \param operands: a list of expressions +/// \param loc: location in the source +/// \param symbol_table: symbol table +/// \param init_code: code block, in which declaration of some arguments may be +/// added exprt::operandst java_string_library_preprocesst::process_operands( const exprt::operandst &operands, const source_locationt &loc, @@ -500,25 +321,14 @@ exprt::operandst java_string_library_preprocesst::process_operands( return ops; } -/*******************************************************************\ - -Function: java_string_library_preprocesst::process_equals_function_operands - - Inputs: - operands - a list of expressions - loc - location in the source - symbol_table - symbol table - init_code - code block, in which declaration of some arguments - may be added - - Output: a list of expressions - - Purpose: Converts the operands of the equals function to string - expressions and outputs these conversions. As a side effect - of the conversions it adds some code to init_code. - -\*******************************************************************/ - +/// Converts the operands of the equals function to string expressions and +/// outputs these conversions. As a side effect of the conversions it adds some +/// code to init_code. +/// \param operands: a list of expressions +/// \param loc: location in the source +/// \param symbol_table: symbol table +/// \param init_code: code block, in which declaration of some arguments may be +/// added exprt::operandst java_string_library_preprocesst::process_equals_function_operands( const exprt::operandst &operands, @@ -544,20 +354,9 @@ exprt::operandst return ops; } -/*******************************************************************\ - -Function: java_string_library_preprocesst::get_data_type - - Inputs: - type - a type containing a "data" component - symbol_table - symbol table - - Output: type of the "data" component - - Purpose: Finds the type of the data component - -\*******************************************************************/ - +/// Finds the type of the data component +/// \param type: a type containing a "data" component +/// \param symbol_table: symbol table typet java_string_library_preprocesst::get_data_type( const typet &type, const symbol_tablet &symbol_table) { @@ -578,20 +377,9 @@ typet java_string_library_preprocesst::get_data_type( } } -/*******************************************************************\ - -Function: java_string_library_preprocesst::get_length_type - - Inputs: - type - a type containing a "length" component - symbol_table - symbol table - - Output: type of the "length" component - - Purpose: Finds the type of the length component - -\*******************************************************************/ - +/// Finds the type of the length component +/// \param type: a type containing a "length" component +/// \param symbol_table: symbol table typet java_string_library_preprocesst::get_length_type( const typet &type, const symbol_tablet &symbol_table) { @@ -612,20 +400,9 @@ typet java_string_library_preprocesst::get_length_type( } } -/*******************************************************************\ - -Function: java_string_library_preprocesst::get_length - - Inputs: - expr - an expression of structured type with length component - symbol_table - symbol table - - Output: expression representing the "length" member - - Purpose: access length member - -\*******************************************************************/ - +/// access length member +/// \param expr: an expression of structured type with length component +/// \param symbol_table: symbol table exprt java_string_library_preprocesst::get_length( const exprt &expr, const symbol_tablet &symbol_table) { @@ -633,43 +410,21 @@ exprt java_string_library_preprocesst::get_length( expr, "length", get_length_type(expr.type(), symbol_table)); } -/*******************************************************************\ - -Function: java_string_library_preprocesst::get_data - - Inputs: - expr - an expression of structured type with length component - symbol_table - symbol table - - Output: expression representing the "data" member - - Purpose: access data member - -\*******************************************************************/ - +/// access data member +/// \param expr: an expression of structured type with length component +/// \param symbol_table: symbol table exprt java_string_library_preprocesst::get_data( const exprt &expr, const symbol_tablet &symbol_table) { return member_exprt(expr, "data", get_data_type(expr.type(), symbol_table)); } -/*******************************************************************\ - -Function: string_refine_preprocesst::replace_char_array - - Inputs: - array_pointer - an expression of type char array pointer - loc - location in the source - symbol_table - symbol table - code - code block, in which some assignments will be added - - Output: a string expression - - Purpose: we declare a new `cprover_string` whose contents is deduced - from the char array. - -\*******************************************************************/ - +/// we declare a new `cprover_string` whose contents is deduced from the char +/// array. +/// \param array_pointer: an expression of type char array pointer +/// \param loc: location in the source +/// \param symbol_table: symbol table +/// \param code: code block, in which some assignments will be added string_exprt java_string_library_preprocesst::replace_char_array( const exprt &array_pointer, const source_locationt &loc, @@ -704,22 +459,11 @@ string_exprt java_string_library_preprocesst::replace_char_array( return string_expr; } -/*******************************************************************\ - -Function: java_string_library_preprocesst::fresh_string - - Inputs: - type - a type for refined strings - loc - a location in the program - symbol_table - symbol table - - Output: a new symbol - - Purpose: add a symbol with static lifetime and name containing - `cprover_string` and given type - -\*******************************************************************/ - +/// add a symbol with static lifetime and name containing `cprover_string` and +/// given type +/// \param type: a type for refined strings +/// \param loc: a location in the program +/// \param symbol_table: symbol table symbol_exprt java_string_library_preprocesst::fresh_string( const typet &type, const source_locationt &loc, symbol_tablet &symbol_table) { @@ -729,22 +473,11 @@ symbol_exprt java_string_library_preprocesst::fresh_string( return string_symbol.symbol_expr(); } -/*******************************************************************\ - -Function: java_string_library_preprocesst::fresh_string_expr - - Inputs: - loc - a location in the program - symbol_table - symbol table - code - code block to which allocation instruction will be added - - Output: a new string_expr - - Purpose: add symbols with prefix cprover_string_length and - cprover_string_data and construct a string_expr from them. - -\*******************************************************************/ - +/// add symbols with prefix cprover_string_length and cprover_string_data and +/// construct a string_expr from them. +/// \param loc: a location in the program +/// \param symbol_table: symbol table +/// \param code: code block to which allocation instruction will be added string_exprt java_string_library_preprocesst::fresh_string_expr( const source_locationt &loc, symbol_tablet &symbol_table, code_blockt &code) { @@ -765,22 +498,11 @@ string_exprt java_string_library_preprocesst::fresh_string_expr( return str; } -/*******************************************************************\ - -Function: java_string_library_preprocesst::fresh_string_expr_symbol - - Inputs: - loc - a location in the program - symbol_table - symbol table - code - code block to which allocation instruction will be added - - Output: a new expression of refined string type - - Purpose: add symbols with prefix cprover_string_length and - cprover_string_data and construct a string_expr from them. - -\*******************************************************************/ - +/// add symbols with prefix cprover_string_length and cprover_string_data and +/// construct a string_expr from them. +/// \param loc: a location in the program +/// \param symbol_table: symbol table +/// \param code: code block to which allocation instruction will be added exprt java_string_library_preprocesst::fresh_string_expr_symbol( const source_locationt &loc, symbol_tablet &symbol_table, code_blockt &code) { @@ -795,22 +517,11 @@ exprt java_string_library_preprocesst::fresh_string_expr_symbol( return sym.symbol_expr(); } -/*******************************************************************\ - -Function: java_string_library_preprocesst::allocate_fresh_string - - Inputs: - type - a type for string - loc - a location in the program - symbol_table - symbol table - code - code block to which allocation instruction will be added - - Output: a new string - - Purpose: declare a new String and allocate it - -\*******************************************************************/ - +/// declare a new String and allocate it +/// \param type: a type for string +/// \param loc: a location in the program +/// \param symbol_table: symbol table +/// \param code: code block to which allocation instruction will be added exprt java_string_library_preprocesst::allocate_fresh_string( const typet &type, const source_locationt &loc, @@ -824,22 +535,11 @@ exprt java_string_library_preprocesst::allocate_fresh_string( return str; } -/*******************************************************************\ - -Function: java_string_library_preprocesst::allocate_fresh_array - - Inputs: - type - a type for string - loc - a location in the program - symbol_table - symbol table - code - code block to which allocation instruction will be added - - Output: a new array - - Purpose: declare a new character array and allocate it - -\*******************************************************************/ - +/// declare a new character array and allocate it +/// \param type: a type for string +/// \param loc: a location in the program +/// \param symbol_table: symbol table +/// \param code: code block to which allocation instruction will be added exprt java_string_library_preprocesst::allocate_fresh_array( const typet &type, const source_locationt &loc, @@ -853,20 +553,10 @@ exprt java_string_library_preprocesst::allocate_fresh_array( return array; } -/*******************************************************************\ - -Function: java_string_library_preprocesst::make_function_application - - Inputs: - function_name - the name of the function - arguments - a list of arguments - type - return type of the function - symbol_table - a symbol table - - Output: a function application representing: function_name(arguments) - -\*******************************************************************/ - +/// \param function_name: the name of the function +/// \param arguments: a list of arguments +/// \param type: return type of the function +/// \param symbol_table: a symbol table exprt java_string_library_preprocesst::make_function_application( const irep_idt &function_name, const exprt::operandst &arguments, @@ -885,23 +575,11 @@ exprt java_string_library_preprocesst::make_function_application( return call; } -/*******************************************************************\ - -Function: java_string_library_preprocesst::code_assign_function_application - - Inputs: - lhs - an expression - function_name - the name of the function - arguments - a list of arguments - symbol_table - a symbol table - - Output: the following code: - > lhs=function_name_length(arguments) - - Purpose: assign the result of a function call - -\*******************************************************************/ - +/// assign the result of a function call +/// \param lhs: an expression +/// \param function_name: the name of the function +/// \param arguments: a list of arguments +/// \param symbol_table: a symbol table codet java_string_library_preprocesst::code_assign_function_application( const exprt &lhs, const irep_idt &function_name, @@ -913,23 +591,11 @@ codet java_string_library_preprocesst::code_assign_function_application( return code_assignt(lhs, fun_app); } -/*******************************************************************\ - -Function: java_string_library_preprocesst::code_return_function_application - - Inputs: - function_name - the name of the function - arguments - a list of arguments - type - the return type - symbol_table - a symbol table - - Output: the following code: - > return function_name_length(arguments) - - Purpose: return the result of a function call - -\*******************************************************************/ - +/// return the result of a function call +/// \param function_name: the name of the function +/// \param arguments: a list of arguments +/// \param type: the return type +/// \param symbol_table: a symbol table codet java_string_library_preprocesst::code_return_function_application( const irep_idt &function_name, const exprt::operandst &arguments, @@ -941,22 +607,10 @@ codet java_string_library_preprocesst::code_return_function_application( return code_returnt(fun_app); } -/*******************************************************************\ - -Function: java_string_library_preprocesst::code_assign_function_to_string_expr - - Inputs: - string_expr - a string expression - function_name - the name of the function - arguments - arguments of the function - symbol_table - symbol table - - Output: return the following code: - > str.length <- function_name_length(arguments) - > str.data <- function_name_data(arguments) - -\*******************************************************************/ - +/// \param string_expr: a string expression +/// \param function_name: the name of the function +/// \param arguments: arguments of the function +/// \param symbol_table: symbol table codet java_string_library_preprocesst::code_assign_function_to_string_expr( const string_exprt &string_expr, const irep_idt &function_name, @@ -976,24 +630,11 @@ codet java_string_library_preprocesst::code_assign_function_to_string_expr( return code_blockt({assign_fun_length, assign_fun_data}); } -/*******************************************************************\ - -Function: java_string_library_preprocesst::string_expr_of_function_application - - Inputs: - function_name - the name of the function - arguments - arguments of the function - loc - a location in the program - symbol_table - symbol table - code - code block in which we add instructions - - Output: return a string expr str and add the following code: - > array str.data - > str.length <- function_name_length(arguments) - > str.data <- function_name_data(arguments) - -\*******************************************************************/ - +/// \param function_name: the name of the function +/// \param arguments: arguments of the function +/// \param loc: a location in the program +/// \param symbol_table: symbol table +/// \param code: code block in which we add instructions string_exprt java_string_library_preprocesst:: string_expr_of_function_application( const irep_idt &function_name, @@ -1008,25 +649,11 @@ string_exprt java_string_library_preprocesst:: return string_expr; } -/*******************************************************************\ - -Function: java_string_library_preprocesst:: - code_assign_components_to_java_string - - Inputs: - lhs - expression representing the java string to assign to - rhs_array - pointer to the array to assign - rhs_length - length of the array to assign - symbol_table - symbol table - - Output: return the following code: - > lhs = { {Object}, length=rhs_length, data=rhs_array } - - Purpose: Produce code for an assignment of a string expr to a - Java string. - -\*******************************************************************/ - +/// Produce code for an assignment of a string expr to a Java string. +/// \param lhs: expression representing the java string to assign to +/// \param rhs_array: pointer to the array to assign +/// \param rhs_length: length of the array to assign +/// \param symbol_table: symbol table codet java_string_library_preprocesst::code_assign_components_to_java_string( const exprt &lhs, const exprt &rhs_array, @@ -1056,24 +683,10 @@ codet java_string_library_preprocesst::code_assign_components_to_java_string( return code; } -/*******************************************************************\ - -Function: java_string_library_preprocesst:: - code_assign_string_expr_to_java_string - - Inputs: - lhs - an expression representing a java string - rhs - a string expression - symbol_table - symbol table - - Output: return the following code: - > lhs = { {Object}, length=rhs.length, data=rhs.data } - - Purpose: Produce code for an assignemnt of a string expr to a Java - string. - -\*******************************************************************/ - +/// Produce code for an assignemnt of a string expr to a Java string. +/// \param lhs: an expression representing a java string +/// \param rhs: a string expression +/// \param symbol_table: symbol table codet java_string_library_preprocesst::code_assign_string_expr_to_java_string( const exprt &lhs, const string_exprt &rhs, @@ -1083,26 +696,11 @@ codet java_string_library_preprocesst::code_assign_string_expr_to_java_string( lhs, address_of_exprt(rhs.content()), rhs.length(), symbol_table); } -/*******************************************************************\ - -Function: java_string_library_preprocesst:: - code_assign_string_expr_to_new_java_string - - Inputs: - lhs - an expression representing a java string - rhs - a string expression - loc - a location in the program - symbol_table - symbol table - - Output: return the following code: - > data = new array[]; - > *data = rhs.data; - > lhs = { {Object} , length=rhs.length, data=data} - - Purpose: Produce code for an assignment of a string from a string expr. - -\*******************************************************************/ - +/// Produce code for an assignment of a string from a string expr. +/// \param lhs: an expression representing a java string +/// \param rhs: a string expression +/// \param loc: a location in the program +/// \param symbol_table: symbol table codet java_string_library_preprocesst:: code_assign_string_expr_to_new_java_string( const exprt &lhs, @@ -1125,22 +723,9 @@ codet java_string_library_preprocesst:: return code; } -/*******************************************************************\ - -Function: java_string_library_preprocesst:: - code_assign_java_string_to_string_expr - - Inputs: - lhs - a string expression - rhs - an expression representing a java string - symbol_table - symbol table - - Output: return the following code: - > lhs.length=rhs->length - > lhs.data=*(rhs->data) - -\*******************************************************************/ - +/// \param lhs: a string expression +/// \param rhs: an expression representing a java string +/// \param symbol_table: symbol table codet java_string_library_preprocesst::code_assign_java_string_to_string_expr( const string_exprt &lhs, const exprt &rhs, symbol_tablet &symbol_table) { @@ -1167,23 +752,10 @@ codet java_string_library_preprocesst::code_assign_java_string_to_string_expr( return code; } -/*******************************************************************\ - -Function: java_string_library_preprocesst:: - code_assign_string_literal_to_string_expr - - Inputs: - lhs - an expression representing a java string - tmp_string - a temporary string to hold the literal - s - the literal to be assigned - symbol_table - symbol table - - Output: return the following code: - > tmp_string = "s" - > lhs = (string_expr) tmp_string - -\*******************************************************************/ - +/// \param lhs: an expression representing a java string +/// \param tmp_string: a temporary string to hold the literal +/// \param s: the literal to be assigned +/// \param symbol_table: symbol table codet java_string_library_preprocesst:: code_assign_string_literal_to_string_expr( const string_exprt &lhs, @@ -1198,25 +770,13 @@ codet java_string_library_preprocesst:: return code; } -/*******************************************************************\ - -Function: java_string_library_preprocesst:: - make_string_builder_append_object_code - - Inputs: - type - type of the function called - loc - location in the program - symbol_table - symbol table - - Outputs: code for the StringBuilder.append(Object) function: - > string1 = arguments[1].toString() - > string_expr1 = string_to_string_expr(string1) - > string_expr2 = concat(this, string_expr1) - > this = string_expr_to_string(string_expr2) - > return this - -\*******************************************************************/ - +/// \param type: type of the function called +/// \param loc: location in the program +/// \param symbol_table: symbol table +/// \return code for the StringBuilder.append(Object) function: > string1 = +/// arguments[1].toString() > string_expr1 = string_to_string_expr(string1) > +/// string_expr2 = concat(this, string_expr1) > this = +/// string_expr_to_string(string_expr2) > return this codet java_string_library_preprocesst::make_string_builder_append_object_code( const code_typet &type, const source_locationt &loc, @@ -1269,24 +829,13 @@ codet java_string_library_preprocesst::make_string_builder_append_object_code( return code; } -/*******************************************************************\ - -Function: java_string_library_preprocesst::make_equals_code - - Inputs: - type - type of the function call - loc - location in the program_invocation_name - symbol_table - symbol table - - Outputs: Code corresponding to: - > string_expr1 = {this->length; *this->data} - > string_expr2 = {arg->length; *arg->data} - > return cprover_string_equal(string_expr1, string_expr2) - - Purpose: Used to provide code for the Java String.equals(Object) function. - -\*******************************************************************/ - +/// Used to provide code for the Java String.equals(Object) function. +/// \param type: type of the function call +/// \param loc: location in the program_invocation_name +/// \param symbol_table: symbol table +/// \return Code corresponding to: > string_expr1 = {this->length; *this->data} +/// > string_expr2 = {arg->length; *arg->data} > return +/// cprover_string_equal(string_expr1, string_expr2) codet java_string_library_preprocesst::make_equals_function_code( const code_typet &type, const source_locationt &loc, @@ -1307,28 +856,14 @@ codet java_string_library_preprocesst::make_equals_function_code( return code; } -/*******************************************************************\ - -Function: java_string_library_preprocesst:: - make_string_builder_append_float_code - - Inputs: - type - type of the function call - loc - location in the program_invocation_name - symbol_table - symbol table - - Outputs: Code corresponding to: - > string1 = arguments[1].toString() - > string_expr1 = string_to_string_expr(string1) - > string_expr2 = concat(this, string_expr1) - > this = string_expr_to_string(string_expr2) - > return this - - Purpose: Used to provide code for the Java StringBuilder.append(F) - function. - -\*******************************************************************/ - +/// Used to provide code for the Java StringBuilder.append(F) function. +/// \param type: type of the function call +/// \param loc: location in the program_invocation_name +/// \param symbol_table: symbol table +/// \return Code corresponding to: > string1 = arguments[1].toString() > +/// string_expr1 = string_to_string_expr(string1) > string_expr2 = +/// concat(this, string_expr1) > this = string_expr_to_string(string_expr2) > +/// return this codet java_string_library_preprocesst::make_string_builder_append_float_code( const code_typet &type, const source_locationt &loc, @@ -1386,20 +921,10 @@ codet java_string_library_preprocesst::make_string_builder_append_float_code( return code; } -/*******************************************************************\ - -Function: java_string_library_preprocesst::string_literal - - Inputs: - s - a string - - Outputs: an expression representing a Java string literal with the - given content. - - Purpose: construct a Java string literal from a constant string value - -\*******************************************************************/ - +/// construct a Java string literal from a constant string value +/// \param s: a string +/// \return an expression representing a Java string literal with the given +/// content. exprt java_string_library_preprocesst::string_literal(const std::string &s) { exprt string_literal(ID_java_string_literal); @@ -1407,37 +932,20 @@ exprt java_string_library_preprocesst::string_literal(const std::string &s) return string_literal; } -/*******************************************************************\ - -Function: java_string_library_preprocesst::make_float_to_string_code - - Inputs: - type - type of the function call - loc - location in the program_invocation_name - symbol_table - symbol table - - Outputs: Code corresponding to: - > String * str; - > str = MALLOC(String); - > String * tmp_string; - > int string_expr_length; - > char[] string_expr_content; - > CPROVER_string string_expr_sym; - > if arguments[1]==NaN - > then {tmp_string="NaN"; string_expr=(string_expr)tmp_string} - > if arguments[1]==Infinity - > then {tmp_string="Infinity"; string_expr=(string_expr)tmp_string} - > if 1e-3 then string_expr=cprover_float_to_string(arguments[1]) - > else string_expr=cprover_float_to_scientific_notation_string(arg[1]) - > string_expr_sym=string_expr; - > str=(String*) string_expr; - > return str; - - Purpose: Provide code for the Float.toString(F) function. - -\*******************************************************************/ - +/// Provide code for the Float.toString(F) function. +/// \param type: type of the function call +/// \param loc: location in the program_invocation_name +/// \param symbol_table: symbol table +/// \return Code corresponding to: > String * str; > str = MALLOC(String); > +/// String * tmp_string; > int string_expr_length; > char[] +/// string_expr_content; > CPROVER_string string_expr_sym; > if +/// arguments[1]==NaN > then {tmp_string="NaN"; +/// string_expr=(string_expr)tmp_string} > if arguments[1]==Infinity > then +/// {tmp_string="Infinity"; string_expr=(string_expr)tmp_string} > if +/// 1e-3 then +/// string_expr=cprover_float_to_string(arguments[1]) > else +/// string_expr=cprover_float_to_scientific_notation_string(arg[1]) > +/// string_expr_sym=string_expr; > str=(String*) string_expr; > return str; codet java_string_library_preprocesst::make_float_to_string_code( const code_typet &type, const source_locationt &loc, @@ -1536,30 +1044,18 @@ codet java_string_library_preprocesst::make_float_to_string_code( return code; } -/*******************************************************************\ - -Function: java_string_library_preprocesst::make_init_function_from_call - - Inputs: - function_name - name of the function to be called - type - the type of the function call - loc - location in program - symbol_table - the symbol table to populate - ignore_first_arg - boolean flag telling that the first argument - should not be part of the arguments of the call - (but only used to be assigned the result) - - Outputs: code for the String.(args) function: - > cprover_string_length = fun(arg).length; - > cprover_string_array = fun(arg).data; - > this->length = cprover_string_length; - > this->data = cprover_string_array; - > cprover_string = {.=cprover_string_length, .=cprover_string_array}; - - Purpose: Generate the goto code for string initialization. - -\*******************************************************************/ - +/// Generate the goto code for string initialization. +/// \param function_name: name of the function to be called +/// \param type: the type of the function call +/// \param loc: location in program +/// \param symbol_table: the symbol table to populate +/// \param ignore_first_arg: boolean flag telling that the first argument should +/// not be part of the arguments of the call (but only used to be assigned the +/// result) +/// \return code for the String.(args) function: > cprover_string_length = +/// fun(arg).length; > cprover_string_array = fun(arg).data; > this->length = +/// cprover_string_length; > this->data = cprover_string_array; > +/// cprover_string = {.=cprover_string_length, .=cprover_string_array}; codet java_string_library_preprocesst::make_init_function_from_call( const irep_idt &function_name, const code_typet &type, @@ -1596,24 +1092,13 @@ codet java_string_library_preprocesst::make_init_function_from_call( return code; } -/*******************************************************************\ - -Function: java_string_library_preprocesst:: - make_assign_and_return_function_from_call - - Inputs: - function_name - name of the function to be called - type - the type of the function call - loc - location in program - symbol_table - the symbol table to populate - - Outputs: Code calling function with the given function name. - - Purpose: Call a cprover internal function, assign the result to - object `this` and return it. - -\*******************************************************************/ - +/// Call a cprover internal function, assign the result to object `this` and +/// return it. +/// \param function_name: name of the function to be called +/// \param type: the type of the function call +/// \param loc: location in program +/// \param symbol_table: the symbol table to populate +/// \return Code calling function with the given function name. codet java_string_library_preprocesst:: make_assign_and_return_function_from_call( const irep_idt &function_name, @@ -1632,24 +1117,13 @@ codet java_string_library_preprocesst:: return code; } -/*******************************************************************\ - -Function: java_string_library_preprocesst::make_assign_function_from_call - - Inputs: - function_name - name of the function to be called - type - the type of the function call - loc - location in program - symbol_table - the symbol table to populate - - Outputs: Code assigning result of a call to the function with given - function name. - - Purpose: Call a cprover internal function and assign the result to - object `this`. - -\*******************************************************************/ - +/// Call a cprover internal function and assign the result to object `this`. +/// \param function_name: name of the function to be called +/// \param type: the type of the function call +/// \param loc: location in program +/// \param symbol_table: the symbol table to populate +/// \return Code assigning result of a call to the function with given function +/// name. codet java_string_library_preprocesst::make_assign_function_from_call( const irep_idt &function_name, const code_typet &type, @@ -1663,25 +1137,13 @@ codet java_string_library_preprocesst::make_assign_function_from_call( return code; } -/*******************************************************************\ - -Function: java_string_library_preprocesst::make_string_to_char_array_code - - Inputs: - type - type of the function called - loc - location in the source - symbol_table - the symbol table - - Outputs: Code corresponding to - > return_tmp0 = malloc(array[char]); - > return_tmp0->data=&((s->data)[0]) - > return_tmp0->length=s->length - - Purpose: Used to provide our own implementation of the - java.lang.String.toCharArray:()[C function. - -\*******************************************************************/ - +/// Used to provide our own implementation of the +/// java.lang.String.toCharArray:()[C function. +/// \param type: type of the function called +/// \param loc: location in the source +/// \param symbol_table: the symbol table +/// \return Code corresponding to > return_tmp0 = malloc(array[char]); > +/// return_tmp0->data=&((s->data)[0]) > return_tmp0->length=s->length codet java_string_library_preprocesst::make_string_to_char_array_code( const code_typet &type, const source_locationt &loc, @@ -1721,26 +1183,14 @@ codet java_string_library_preprocesst::make_string_to_char_array_code( return code; } -/*******************************************************************\ - -Function: java_string_library_preprocesst::make_object_get_class_code - - Inputs: - type - type of the function called - loc - location in the source - symbol_table - the symbol table - - Outputs: Code corresponding to - > Class class1; - > string_expr1 = substr(this->@class_identifier, 6) - > class1=Class.forName(string_expr1) - > return class1 - - Purpose: Used to provide our own implementation of the - java.lang.Object.getClass() function. - -\*******************************************************************/ - +/// Used to provide our own implementation of the java.lang.Object.getClass() +/// function. +/// \param type: type of the function called +/// \param loc: location in the source +/// \param symbol_table: the symbol table +/// \return Code corresponding to > Class class1; > string_expr1 = +/// substr(this->@class_identifier, 6) > class1=Class.forName(string_expr1) > +/// return class1 codet java_string_library_preprocesst::make_object_get_class_code( const code_typet &type, const source_locationt &loc, @@ -1808,24 +1258,13 @@ codet java_string_library_preprocesst::make_object_get_class_code( return code; } -/*******************************************************************\ - -Function: java_string_library_preprocesst::make_function_from_call - - Inputs: - function_name - name of the function to be called - type - type of the function - loc - location in the source - symbol_table - symbol table - - Outputs: Code corresponding to: - > return function_name(args); - - Purpose: Provide code for a function that calls a function from the - solver and simply returns it. - -\*******************************************************************/ - +/// Provide code for a function that calls a function from the solver and simply +/// returns it. +/// \param function_name: name of the function to be called +/// \param type: type of the function +/// \param loc: location in the source +/// \param symbol_table: symbol table +/// \return Code corresponding to: > return function_name(args); codet java_string_library_preprocesst::make_function_from_call( const irep_idt &function_name, const code_typet &type, @@ -1840,28 +1279,14 @@ codet java_string_library_preprocesst::make_function_from_call( return code; } -/*******************************************************************\ - -Function: - java_string_library_preprocesst::make_string_returning_function_from_call - - Inputs: - function_name - name of the function to be called - type - type of the function - loc - location in the source - symbol_table - symbol table - - Outputs: Code corresponding to: - > string_expr = function_name(args) - > string = new String - > string = string_expr_to_string(string) - > return string - - Purpose: Provide code for a function that calls a function from the - solver and return the string_expr result as a Java string. - -\*******************************************************************/ - +/// Provide code for a function that calls a function from the solver and return +/// the string_expr result as a Java string. +/// \param function_name: name of the function to be called +/// \param type: type of the function +/// \param loc: location in the source +/// \param symbol_table: symbol table +/// \return Code corresponding to: > string_expr = function_name(args) > string +/// = new String > string = string_expr_to_string(string) > return string codet java_string_library_preprocesst:: make_string_returning_function_from_call( const irep_idt &function_name, @@ -1894,28 +1319,14 @@ codet java_string_library_preprocesst:: return code; } -/*******************************************************************\ - -Function: - java_string_library_preprocesst::make_copy_string_code - - Inputs: - type - type of the function - loc - location in the source - symbol_table - symbol table - - Outputs: Code corresponding to: - > string_expr = string_to_string_expr(arg0) - > string_expr_sym = { string_expr.length; string_expr.content } - > str = new String - > str = string_expr_to_string(string_expr) - > return str - - Purpose: Generates code for a function which copies a string object to a new - string object. - -\*******************************************************************/ - +/// Generates code for a function which copies a string object to a new string +/// object. +/// \param type: type of the function +/// \param loc: location in the source +/// \param symbol_table: symbol table +/// \return Code corresponding to: > string_expr = string_to_string_expr(arg0) > +/// string_expr_sym = { string_expr.length; string_expr.content } > str = new +/// String > str = string_expr_to_string(string_expr) > return str codet java_string_library_preprocesst::make_copy_string_code( const code_typet &type, const source_locationt &loc, @@ -1947,25 +1358,14 @@ codet java_string_library_preprocesst::make_copy_string_code( return code; } -/*******************************************************************\ - -Function: java_string_library_preprocesst::make_copy_constructor_code - - Inputs: - type - type of the function - loc - location in the source - symbol_table - symbol table - - Outputs: Code corresponding to: - > string_expr = java_string_to_string_expr(arg1) - > string_expr_sym = { string_expr.length; string_expr.content } - > this = string_expr_to_java_string(string_expr) - - Purpose: Generates code for a constructor of a string object from another - string object. - -\*******************************************************************/ - +/// Generates code for a constructor of a string object from another string +/// object. +/// \param type: type of the function +/// \param loc: location in the source +/// \param symbol_table: symbol table +/// \return Code corresponding to: > string_expr = +/// java_string_to_string_expr(arg1) > string_expr_sym = { string_expr.length; +/// string_expr.content } > this = string_expr_to_java_string(string_expr) codet java_string_library_preprocesst::make_copy_constructor_code( const code_typet &type, const source_locationt &loc, @@ -1995,24 +1395,12 @@ codet java_string_library_preprocesst::make_copy_constructor_code( return code; } -/*******************************************************************\ - -Function: java_string_library_preprocesst::make_string_length_code - - Inputs: - type - type of the function - loc - location in the source - symbol_table - symbol table - - Outputs: Code corresponding to: - > str_expr = java_string_to_string_expr(this) - > str_expr_sym = str_expr - > return this->length - - Purpose: Generates code for the String.length method - -\*******************************************************************/ - +/// Generates code for the String.length method +/// \param type: type of the function +/// \param loc: location in the source +/// \param symbol_table: symbol table +/// \return Code corresponding to: > str_expr = java_string_to_string_expr(this) +/// > str_expr_sym = str_expr > return this->length codet java_string_library_preprocesst::make_string_length_code( const code_typet &type, const source_locationt &loc, @@ -2041,25 +1429,14 @@ codet java_string_library_preprocesst::make_string_length_code( return code; } -/*******************************************************************\ - -Function: java_string_library_preprocesst::code_for_function - - Inputs: - function_id - name of the function - type - its type - loc - location in the program - symbol_table - a symbol table - - Outputs: Code for the body of the String functions if they are part - of the supported String functions, nil_exprt otherwise. - - Purpose: Should be called to provide code for string functions that - are used in the code but for which no implementation is - provided. - -\*******************************************************************/ - +/// Should be called to provide code for string functions that are used in the +/// code but for which no implementation is provided. +/// \param function_id: name of the function +/// \param type: its type +/// \param loc: location in the program +/// \param symbol_table: a symbol table +/// \return Code for the body of the String functions if they are part of the +/// supported String functions, nil_exprt otherwise. exprt java_string_library_preprocesst::code_for_function( const irep_idt &function_id, const code_typet &type, @@ -2097,35 +1474,17 @@ exprt java_string_library_preprocesst::code_for_function( return nil_exprt(); } -/*******************************************************************\ - -Function: java_string_library_preprocesst::is_known_string_type - - Inputs: - class_name - name of the class - - Outputs: True if the type is one that is known to our preprocessing, - false otherwise - - Purpose: Check whether a class name is known as a string type. - -\*******************************************************************/ - +/// Check whether a class name is known as a string type. +/// \param class_name: name of the class +/// \return True if the type is one that is known to our preprocessing, false +/// otherwise bool java_string_library_preprocesst::is_known_string_type( irep_idt class_name) { return string_types.find(class_name)!=string_types.end(); } -/*******************************************************************\ - -Function: java_string_library_preprocesst::initialize_conversion_table - - Purpose: fill maps with correspondence from java method names to - conversion functions - -\*******************************************************************/ - +/// fill maps with correspondence from java method names to conversion functions void java_string_library_preprocesst::initialize_conversion_table() { character_preprocess.initialize_conversion_table(); diff --git a/src/java_bytecode/java_string_library_preprocess.h b/src/java_bytecode/java_string_library_preprocess.h index f89732300ef..e2297b8726a 100644 --- a/src/java_bytecode/java_string_library_preprocess.h +++ b/src/java_bytecode/java_string_library_preprocess.h @@ -8,6 +8,9 @@ Date: March 2017 \*******************************************************************/ +/// \file +/// Produce code for simple implementation of String Java libraries + #ifndef CPROVER_JAVA_BYTECODE_JAVA_STRING_LIBRARY_PREPROCESS_H #define CPROVER_JAVA_BYTECODE_JAVA_STRING_LIBRARY_PREPROCESS_H diff --git a/src/java_bytecode/java_types.cpp b/src/java_bytecode/java_types.cpp index 9d78c7a36a7..dc3a18d3654 100644 --- a/src/java_bytecode/java_types.cpp +++ b/src/java_bytecode/java_types.cpp @@ -6,164 +6,58 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include #include +#include #include #include #include "java_types.h" -/*******************************************************************\ - -Function: java_int_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet java_int_type() { return signedbv_typet(32); } -/*******************************************************************\ - -Function: java_void_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet java_void_type() { return void_typet(); } -/*******************************************************************\ - -Function: java_long_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet java_long_type() { return signedbv_typet(64); } -/*******************************************************************\ - -Function: java_short_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet java_short_type() { return signedbv_typet(16); } -/*******************************************************************\ - -Function: java_byte_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet java_byte_type() { return signedbv_typet(8); } -/*******************************************************************\ - -Function: java_char_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet java_char_type() { return unsignedbv_typet(16); } -/*******************************************************************\ - -Function: java_float_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet java_float_type() { return ieee_float_spect::single_precision().to_type(); } -/*******************************************************************\ - -Function: java_double_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet java_double_type() { return ieee_float_spect::double_precision().to_type(); } -/*******************************************************************\ - -Function: java_boolean_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet java_boolean_type() { // The Java standard doesn't really prescribe the width @@ -172,36 +66,17 @@ typet java_boolean_type() return c_bool_typet(8); } -/*******************************************************************\ - -Function: java_reference_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - reference_typet java_reference_type(const typet &subtype) { - return reference_typet(subtype); + return to_reference_type(reference_type(subtype)); } -/*******************************************************************\ - -Function: java_array_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ +reference_typet java_lang_object_type() +{ + return java_reference_type(symbol_typet("java::java.lang.Object")); +} -pointer_typet java_array_type(const char subtype) +reference_typet java_array_type(const char subtype) { std::string subtype_str; @@ -227,55 +102,22 @@ pointer_typet java_array_type(const char subtype) symbol_type.set(ID_C_base_name, class_name); symbol_type.set(ID_C_element_type, java_type_from_char(subtype)); - return pointer_typet(symbol_type); + return java_reference_type(symbol_type); } -/*******************************************************************\ - -Function: is_java_array_tag - - Inputs: Struct tag 'tag' - - Outputs: True if the given struct is a Java array - - Purpose: See above - -\*******************************************************************/ - +/// See above +/// \par parameters: Struct tag 'tag' +/// \return True if the given struct is a Java array bool is_java_array_tag(const irep_idt& tag) { return has_prefix(id2string(tag), "java::array["); } -/*******************************************************************\ - -Function: is_reference_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool is_reference_type(const char t) { return 'a' == t; } -/*******************************************************************\ - -Function: java_type_from_char - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet java_type_from_char(char t) { switch(t) @@ -294,19 +136,7 @@ typet java_type_from_char(char t) } } -/*******************************************************************\ - -Function: java_bytecode_promotion - - Inputs: - - Outputs: - - Purpose: Java does not support byte/short return types. - These are always promoted. - -\*******************************************************************/ - +/// Java does not support byte/short return types. These are always promoted. typet java_bytecode_promotion(const typet &type) { if(type==java_boolean_type() || @@ -318,19 +148,7 @@ typet java_bytecode_promotion(const typet &type) return type; } -/*******************************************************************\ - -Function: java_bytecode_promotion - - Inputs: - - Outputs: - - Purpose: Java does not support byte/short return types. - These are always promoted. - -\*******************************************************************/ - +/// Java does not support byte/short return types. These are always promoted. exprt java_bytecode_promotion(const exprt &expr) { typet new_type=java_bytecode_promotion(expr.type()); @@ -341,18 +159,6 @@ exprt java_bytecode_promotion(const exprt &expr) return typecast_exprt(expr, new_type); } -/*******************************************************************\ - -Function: java_type_from_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet java_type_from_string(const std::string &src) { if(src.empty()) @@ -453,18 +259,6 @@ typet java_type_from_string(const std::string &src) } } -/*******************************************************************\ - -Function: java_char_from_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - char java_char_from_type(const typet &type) { const irep_idt &id=type.id(); @@ -497,18 +291,6 @@ char java_char_from_type(const typet &type) return 'a'; } -/*******************************************************************\ - -Function: java_classname - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - // java/lang/Object -> java.lang.Object static std::string slash_to_dot(const std::string &src) { @@ -519,18 +301,6 @@ static std::string slash_to_dot(const std::string &src) return result; } -/*******************************************************************\ - -Function: java_classname - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - symbol_typet java_classname(const std::string &id) { if(!id.empty() && id[0]=='[') diff --git a/src/java_bytecode/java_types.h b/src/java_bytecode/java_types.h index 2b32d5fec43..3d71114d545 100644 --- a/src/java_bytecode/java_types.h +++ b/src/java_bytecode/java_types.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_JAVA_BYTECODE_JAVA_TYPES_H #define CPROVER_JAVA_BYTECODE_JAVA_TYPES_H @@ -21,9 +22,10 @@ typet java_float_type(); typet java_double_type(); typet java_boolean_type(); reference_typet java_reference_type(const typet &subtype); +reference_typet java_lang_object_type(); symbol_typet java_classname(const std::string &); -pointer_typet java_array_type(const char subtype); +reference_typet java_array_type(const char subtype); bool is_reference_type(char t); diff --git a/src/java_bytecode/java_utils.cpp b/src/java_bytecode/java_utils.cpp index 2e84c77f870..0754eae13a3 100644 --- a/src/java_bytecode/java_utils.cpp +++ b/src/java_bytecode/java_utils.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include diff --git a/src/java_bytecode/java_utils.h b/src/java_bytecode/java_utils.h index ec7e6a9ad8e..af69bdad4b9 100644 --- a/src/java_bytecode/java_utils.h +++ b/src/java_bytecode/java_utils.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #ifndef CPROVER_JAVA_BYTECODE_JAVA_UTILS_H diff --git a/src/jsil/Makefile b/src/jsil/Makefile index 60e907197a5..61380167d05 100644 --- a/src/jsil/Makefile +++ b/src/jsil/Makefile @@ -37,6 +37,8 @@ jsil_y.tab.h: jsil_y.tab.cpp jsil_lex.yy.cpp: scanner.l $(LEX) -Pyyjsil -o$@ scanner.l +generated_files: jsil_lex.yy.cpp jsil_y.tab.cpp jsil_y.tab.h + # extra dependencies jsil_y.tab$(OBJEXT): jsil_y.tab.cpp jsil_y.tab.h jsil_lex.yy$(OBJEXT): jsil_y.tab.cpp jsil_lex.yy.cpp jsil_y.tab.h diff --git a/src/jsil/expr2jsil.cpp b/src/jsil/expr2jsil.cpp index e100aa13432..811a9a1608b 100644 --- a/src/jsil/expr2jsil.cpp +++ b/src/jsil/expr2jsil.cpp @@ -6,6 +6,9 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ +/// \file +/// Jsil Language + #include #include "expr2jsil.h" @@ -18,18 +21,6 @@ class expr2jsilt:public expr2ct protected: }; -/*******************************************************************\ - -Function: expr2jsil - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string expr2jsil(const exprt &expr, const namespacet &ns) { expr2jsilt expr2jsil(ns); @@ -37,18 +28,6 @@ std::string expr2jsil(const exprt &expr, const namespacet &ns) return expr2jsil.convert(expr); } -/*******************************************************************\ - -Function: type2jsil - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string type2jsil(const typet &type, const namespacet &ns) { expr2jsilt expr2jsil(ns); diff --git a/src/jsil/expr2jsil.h b/src/jsil/expr2jsil.h index b1b41df2198..f8f99620380 100644 --- a/src/jsil/expr2jsil.h +++ b/src/jsil/expr2jsil.h @@ -6,6 +6,9 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ +/// \file +/// Jsil Language + #ifndef CPROVER_JSIL_EXPR2JSIL_H #define CPROVER_JSIL_EXPR2JSIL_H diff --git a/src/jsil/jsil_convert.cpp b/src/jsil/jsil_convert.cpp index 4e013b6f34e..aa4ff02fffc 100644 --- a/src/jsil/jsil_convert.cpp +++ b/src/jsil/jsil_convert.cpp @@ -6,6 +6,9 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ +/// \file +/// Jsil Language Conversion + #include #include @@ -31,18 +34,6 @@ class jsil_convertt:public messaget bool convert_code(const symbolt &symbol, codet &code); }; -/*******************************************************************\ - -Function: jsil_convertt::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool jsil_convertt::operator()(const jsil_parse_treet &parse_tree) { for(jsil_parse_treet::itemst::const_iterator @@ -74,18 +65,6 @@ bool jsil_convertt::operator()(const jsil_parse_treet &parse_tree) return false; } -/*******************************************************************\ - -Function: jsil_convertt::convert_code - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool jsil_convertt::convert_code(const symbolt &symbol, codet &code) { if(code.get_statement()==ID_block) @@ -137,18 +116,6 @@ bool jsil_convertt::convert_code(const symbolt &symbol, codet &code) return false; } -/*******************************************************************\ - -Function: jsil_convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool jsil_convert( const jsil_parse_treet &parse_tree, symbol_tablet &symbol_table, diff --git a/src/jsil/jsil_convert.h b/src/jsil/jsil_convert.h index 7c50b694ecd..601d64e1b35 100644 --- a/src/jsil/jsil_convert.h +++ b/src/jsil/jsil_convert.h @@ -6,6 +6,9 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ +/// \file +/// Jsil Language Conversion + #ifndef CPROVER_JSIL_JSIL_CONVERT_H #define CPROVER_JSIL_JSIL_CONVERT_H diff --git a/src/jsil/jsil_entry_point.cpp b/src/jsil/jsil_entry_point.cpp index 4959326bf02..ba1860ce6fc 100644 --- a/src/jsil/jsil_entry_point.cpp +++ b/src/jsil/jsil_entry_point.cpp @@ -6,6 +6,9 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ +/// \file +/// Jsil Language + #include #include #include @@ -19,18 +22,6 @@ Author: Michael Tautschnig, tautschn@amazon.com #define INITIALIZE CPROVER_PREFIX "initialize" -/*******************************************************************\ - -Function: create_initialize - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static void create_initialize(symbol_tablet &symbol_table) { symbolt initialize; @@ -58,18 +49,6 @@ static void create_initialize(symbol_tablet &symbol_table) throw "failed to add " CPROVER_PREFIX "initialize"; } -/*******************************************************************\ - -Function: jsil_entry_point - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool jsil_entry_point( symbol_tablet &symbol_table, message_handlert &message_handler) diff --git a/src/jsil/jsil_entry_point.h b/src/jsil/jsil_entry_point.h index c374d395626..fd9453769da 100644 --- a/src/jsil/jsil_entry_point.h +++ b/src/jsil/jsil_entry_point.h @@ -6,6 +6,9 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ +/// \file +/// Jsil Language + #ifndef CPROVER_JSIL_JSIL_ENTRY_POINT_H #define CPROVER_JSIL_JSIL_ENTRY_POINT_H diff --git a/src/jsil/jsil_internal_additions.cpp b/src/jsil/jsil_internal_additions.cpp index 9f583fbb56b..88c93bf1808 100644 --- a/src/jsil/jsil_internal_additions.cpp +++ b/src/jsil/jsil_internal_additions.cpp @@ -6,28 +6,19 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ +/// \file +/// Jsil Language + #include #include #include -#include +#include #include "jsil_types.h" #include "jsil_internal_additions.h" -/*******************************************************************\ - -Function: jsil_internal_additions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_internal_additions(symbol_tablet &dest) { // add __CPROVER_rounding_mode diff --git a/src/jsil/jsil_internal_additions.h b/src/jsil/jsil_internal_additions.h index f57cc098189..1aed9edd692 100644 --- a/src/jsil/jsil_internal_additions.h +++ b/src/jsil/jsil_internal_additions.h @@ -6,6 +6,9 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ +/// \file +/// Jsil Language + #ifndef CPROVER_JSIL_JSIL_INTERNAL_ADDITIONS_H #define CPROVER_JSIL_JSIL_INTERNAL_ADDITIONS_H diff --git a/src/jsil/jsil_language.cpp b/src/jsil/jsil_language.cpp index 6c022e65069..baa9cebee0c 100644 --- a/src/jsil/jsil_language.cpp +++ b/src/jsil/jsil_language.cpp @@ -6,6 +6,9 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ +/// \file +/// Jsil Language + #include #include @@ -18,52 +21,17 @@ Author: Michael Tautschnig, tautschn@amazon.com #include "jsil_language.h" -/*******************************************************************\ - -Function: jsil_languaget::extensions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::set jsil_languaget::extensions() const { return { "jsil" }; } -/*******************************************************************\ - -Function: jsil_languaget::modules_provided - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_languaget::modules_provided(std::set &modules) { modules.insert(get_base_name(parse_path, true)); } -/*******************************************************************\ - -Function: jsil_languaget::interfaces - - Inputs: - - Outputs: - - Purpose: Adding symbols for all procedure declarations - -\*******************************************************************/ - +/// Adding symbols for all procedure declarations bool jsil_languaget::interfaces(symbol_tablet &symbol_table) { if(jsil_convert(parse_tree, symbol_table, get_message_handler())) @@ -73,18 +41,6 @@ bool jsil_languaget::interfaces(symbol_tablet &symbol_table) return false; } -/*******************************************************************\ - -Function: jsil_languaget::preprocess - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool jsil_languaget::preprocess( std::istream &instream, const std::string &path, @@ -94,18 +50,6 @@ bool jsil_languaget::preprocess( return true; } -/*******************************************************************\ - -Function: jsil_languaget::parse - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool jsil_languaget::parse( std::istream &instream, const std::string &path) @@ -131,18 +75,7 @@ bool jsil_languaget::parse( return result; } -/*******************************************************************\ - -Function: jsil_languaget::typecheck - - Inputs: - - Outputs: - - Purpose: Converting from parse tree and type checking. - -\*******************************************************************/ - +/// Converting from parse tree and type checking. bool jsil_languaget::typecheck( symbol_tablet &symbol_table, const std::string &module) @@ -153,18 +86,6 @@ bool jsil_languaget::typecheck( return false; } -/*******************************************************************\ - -Function: jsil_languaget::final - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool jsil_languaget::final(symbol_tablet &symbol_table) { if(jsil_entry_point( @@ -175,52 +96,16 @@ bool jsil_languaget::final(symbol_tablet &symbol_table) return false; } -/*******************************************************************\ - -Function: jsil_languaget::show_parse - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_languaget::show_parse(std::ostream &out) { parse_tree.output(out); } -/*******************************************************************\ - -Function: new_jsil_language - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - languaget *new_jsil_language() { return new jsil_languaget; } -/*******************************************************************\ - -Function: jsil_languaget::from_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool jsil_languaget::from_expr( const exprt &expr, std::string &code, @@ -230,18 +115,6 @@ bool jsil_languaget::from_expr( return false; } -/*******************************************************************\ - -Function: jsil_languaget::from_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool jsil_languaget::from_type( const typet &type, std::string &code, @@ -251,18 +124,6 @@ bool jsil_languaget::from_type( return false; } -/*******************************************************************\ - -Function: jsil_languaget::to_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool jsil_languaget::to_expr( const std::string &code, const std::string &module, @@ -307,18 +168,6 @@ bool jsil_languaget::to_expr( return result; } -/*******************************************************************\ - -Function: jsil_languaget::~jsil_languaget - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - jsil_languaget::~jsil_languaget() { } diff --git a/src/jsil/jsil_language.h b/src/jsil/jsil_language.h index 349f0b58740..2f6f376525b 100644 --- a/src/jsil/jsil_language.h +++ b/src/jsil/jsil_language.h @@ -6,6 +6,9 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ +/// \file +/// Jsil Language + #ifndef CPROVER_JSIL_JSIL_LANGUAGE_H #define CPROVER_JSIL_JSIL_LANGUAGE_H diff --git a/src/jsil/jsil_parse_tree.cpp b/src/jsil/jsil_parse_tree.cpp index 874e36ccef6..75573ad0637 100644 --- a/src/jsil/jsil_parse_tree.cpp +++ b/src/jsil/jsil_parse_tree.cpp @@ -6,24 +6,15 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ +/// \file +/// Jsil Language + #include #include "jsil_types.h" #include "jsil_parse_tree.h" -/*******************************************************************\ - -Function: insert_at_label - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static bool insert_at_label( const codet &code, const irep_idt &label, @@ -49,18 +40,6 @@ static bool insert_at_label( return true; } -/*******************************************************************\ - -Function: jsil_declarationt::to_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_declarationt::to_symbol(symbolt &symbol) const { symbol.clear(); @@ -101,18 +80,6 @@ void jsil_declarationt::to_symbol(symbolt &symbol) const symbol.value.swap(code); } -/*******************************************************************\ - -Function: jsil_declarationt::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_declarationt::output(std::ostream &out) const { out << "Declarator: " << find(ID_declarator).pretty() << "\n"; @@ -121,18 +88,6 @@ void jsil_declarationt::output(std::ostream &out) const out << "Value: " << find(ID_value).pretty() << "\n"; } -/*******************************************************************\ - -Function: jsil_parse_treet::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_parse_treet::output(std::ostream &out) const { for(itemst::const_iterator diff --git a/src/jsil/jsil_parse_tree.h b/src/jsil/jsil_parse_tree.h index 5a83cf18e8b..55ee57de51b 100644 --- a/src/jsil/jsil_parse_tree.h +++ b/src/jsil/jsil_parse_tree.h @@ -6,6 +6,9 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ +/// \file +/// Jsil Language + #ifndef CPROVER_JSIL_JSIL_PARSE_TREE_H #define CPROVER_JSIL_JSIL_PARSE_TREE_H diff --git a/src/jsil/jsil_parser.cpp b/src/jsil/jsil_parser.cpp index e6d17c1e13c..de11bc731e8 100644 --- a/src/jsil/jsil_parser.cpp +++ b/src/jsil/jsil_parser.cpp @@ -6,22 +6,13 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ +/// \file +/// Jsil Language + #include "jsil_parser.h" jsil_parsert jsil_parser; -/*******************************************************************\ - -Function: yyjsilerror - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - extern char *yyjsiltext; int yyjsilerror(const std::string &error) diff --git a/src/jsil/jsil_parser.h b/src/jsil/jsil_parser.h index 7cf55a32f69..2aad7767e34 100644 --- a/src/jsil/jsil_parser.h +++ b/src/jsil/jsil_parser.h @@ -6,6 +6,9 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ +/// \file +/// Jsil Language + #ifndef CPROVER_JSIL_JSIL_PARSER_H #define CPROVER_JSIL_JSIL_PARSER_H diff --git a/src/jsil/jsil_typecheck.cpp b/src/jsil/jsil_typecheck.cpp index a644f1acf99..c94e02b2e7d 100644 --- a/src/jsil/jsil_typecheck.cpp +++ b/src/jsil/jsil_typecheck.cpp @@ -6,6 +6,9 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ +/// \file +/// Jsil Language + #include #include #include @@ -15,69 +18,22 @@ Author: Michael Tautschnig, tautschn@amazon.com #include "jsil_typecheck.h" -/*******************************************************************\ - -Function: java_bytecode_typecheckt::to_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string jsil_typecheckt::to_string(const exprt &expr) { return expr2jsil(expr, ns); } -/*******************************************************************\ - -Function: java_bytecode_typecheckt::to_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string jsil_typecheckt::to_string(const typet &type) { return type2jsil(type, ns); } -/*******************************************************************\ - -Function: jsil_typecheckt::add_prefix - - Inputs: - - Outputs: - - Purpose: Prefix parameters and variables with a procedure name - -\*******************************************************************/ - +/// Prefix parameters and variables with a procedure name irep_idt jsil_typecheckt::add_prefix(const irep_idt &ds) { return id2string(proc_name) + "::" + id2string(ds); } -/*******************************************************************\ - -Function: jsil_typecheckt::update_expr_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::update_expr_type(exprt &expr, const typet &type) { expr.type()=type; @@ -100,18 +56,6 @@ void jsil_typecheckt::update_expr_type(exprt &expr, const typet &type) } } -/*******************************************************************\ - -Function: jsil_typecheckt::make_type_compatible - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::make_type_compatible( exprt &expr, const typet &type, @@ -151,18 +95,6 @@ void jsil_typecheckt::make_type_compatible( } } -/*******************************************************************\ - -Function: jsil_typecheckt::typecheck_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_type(typet &type) { if(type.id()==ID_code) @@ -201,18 +133,6 @@ void jsil_typecheckt::typecheck_type(typet &type) } } -/*******************************************************************\ - -Function: jsil_typecheckt::typecheck_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_expr(exprt &expr) { // first do sub-nodes @@ -222,36 +142,12 @@ void jsil_typecheckt::typecheck_expr(exprt &expr) typecheck_expr_main(expr); } -/*******************************************************************\ - -Function: jsil_typecheckt::typecheck_expr_operands - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_expr_operands(exprt &expr) { Forall_operands(it, expr) typecheck_expr(*it); } -/*******************************************************************\ - -Function: jsil_typecheckt::typecheck_expr_main - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_expr_main(exprt &expr) { if(expr.id()==ID_code) @@ -369,18 +265,6 @@ void jsil_typecheckt::typecheck_expr_main(exprt &expr) } } -/*******************************************************************\ - -Function: jsil_typecheckt::typecheck_expr_side_effect_throw - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_expr_side_effect_throw( side_effect_expr_throwt &expr) { @@ -390,18 +274,6 @@ void jsil_typecheckt::typecheck_expr_side_effect_throw( typecheck_symbol_expr(s); } -/*******************************************************************\ - -Function: jsil_typecheckt::typecheck_expr_constant - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_expr_constant(exprt &expr) { if(expr.id()==ID_null) @@ -412,18 +284,6 @@ void jsil_typecheckt::typecheck_expr_constant(exprt &expr) expr.type()=jsil_empty_type(); } -/*******************************************************************\ - -Function: jsil_typecheck_baset::typecheck_expr_proto_field - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_expr_proto_field(exprt &expr) { if(expr.operands().size()!=2) @@ -440,18 +300,6 @@ void jsil_typecheckt::typecheck_expr_proto_field(exprt &expr) expr.type()=jsil_value_or_empty_type(); } -/*******************************************************************\ - -Function: jsil_typecheck_baset::typecheck_expr_proto_field - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_expr_proto_obj(exprt &expr) { if(expr.operands().size()!=2) @@ -468,18 +316,6 @@ void jsil_typecheckt::typecheck_expr_proto_obj(exprt &expr) expr.type()=bool_typet(); } -/*******************************************************************\ - -Function: jsil_typecheck_baset::typecheck_expr_delete - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_expr_delete(exprt &expr) { if(expr.operands().size()!=2) @@ -496,18 +332,6 @@ void jsil_typecheckt::typecheck_expr_delete(exprt &expr) expr.type()=bool_typet(); } -/*******************************************************************\ - -Function: jsil_typecheck_baset::typecheck_expr_hasfield - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_expr_index(exprt &expr) { if(expr.operands().size()!=2) @@ -528,18 +352,6 @@ void jsil_typecheckt::typecheck_expr_index(exprt &expr) expr.type()=jsil_value_type(); } -/*******************************************************************\ - -Function: jsil_typecheck_baset::typecheck_expr_hasfield - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_expr_has_field(exprt &expr) { if(expr.operands().size()!=2) @@ -556,18 +368,6 @@ void jsil_typecheckt::typecheck_expr_has_field(exprt &expr) expr.type()=bool_typet(); } -/*******************************************************************\ - -Function: jsil_typecheck_baset::typecheck_expr_field - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_expr_field(exprt &expr) { if(expr.operands().size()!=1) @@ -583,18 +383,6 @@ void jsil_typecheckt::typecheck_expr_field(exprt &expr) expr.type()=string_typet(); } -/*******************************************************************\ - -Function: jsil_typecheck_baset::typecheck_expr_base - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_expr_base(exprt &expr) { if(expr.operands().size()!=1) @@ -610,18 +398,6 @@ void jsil_typecheckt::typecheck_expr_base(exprt &expr) expr.type()=jsil_value_type(); } -/*******************************************************************\ - -Function: jsil_typecheck_baset::typecheck_expr_ref - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_expr_ref(exprt &expr) { if(expr.operands().size()!=3) @@ -652,18 +428,6 @@ void jsil_typecheckt::typecheck_expr_ref(exprt &expr) } } -/*******************************************************************\ - -Function: jsil_typecheck_baset::typecheck_expr_concatenation - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_expr_concatenation(exprt &expr) { if(expr.operands().size()!=2) @@ -680,18 +444,6 @@ void jsil_typecheckt::typecheck_expr_concatenation(exprt &expr) expr.type()=string_typet(); } -/*******************************************************************\ - -Function: jsil_typecheck_baset::typecheck_expr_subtype - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_expr_subtype(exprt &expr) { if(expr.operands().size()!=2) @@ -708,18 +460,6 @@ void jsil_typecheckt::typecheck_expr_subtype(exprt &expr) expr.type()=bool_typet(); } -/*******************************************************************\ - -Function: jsil_typecheck_baset::typecheck_expr_binary_boolean - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_expr_binary_boolean(exprt &expr) { if(expr.operands().size()!=2) @@ -736,18 +476,6 @@ void jsil_typecheckt::typecheck_expr_binary_boolean(exprt &expr) expr.type()=bool_typet(); } -/*******************************************************************\ - -Function: jsil_typecheck_baset::typecheck_expr_binary_arith - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_expr_binary_arith(exprt &expr) { if(expr.operands().size()!=2) @@ -765,18 +493,6 @@ void jsil_typecheckt::typecheck_expr_binary_arith(exprt &expr) expr.type()=floatbv_typet(); } -/*******************************************************************\ - -Function: jsil_typecheck_baset::typecheck_exp_binary_equal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_exp_binary_equal(exprt &expr) { if(expr.operands().size()!=2) @@ -792,18 +508,6 @@ void jsil_typecheckt::typecheck_exp_binary_equal(exprt &expr) expr.type()=bool_typet(); } -/*******************************************************************\ - -Function: jsil_typecheck_baset::typecheck_expr_binary_compare - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_expr_binary_compare(exprt &expr) { if(expr.operands().size()!=2) @@ -820,18 +524,6 @@ void jsil_typecheckt::typecheck_expr_binary_compare(exprt &expr) expr.type()=bool_typet(); } -/*******************************************************************\ - -Function: jsil_typecheck_baset::typecheck_expr_unary_boolean - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_expr_unary_boolean(exprt &expr) { if(expr.operands().size()!=1) @@ -847,18 +539,6 @@ void jsil_typecheckt::typecheck_expr_unary_boolean(exprt &expr) expr.type()=bool_typet(); } -/*******************************************************************\ - -Function: jsil_typecheck_baset::typecheck_expr_unary_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_expr_unary_string(exprt &expr) { if(expr.operands().size()!=1) @@ -874,18 +554,6 @@ void jsil_typecheckt::typecheck_expr_unary_string(exprt &expr) expr.type()=floatbv_typet(); } -/*******************************************************************\ - -Function: jsil_typecheck_baset::typecheck_expr_unary_num - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_expr_unary_num(exprt &expr) { if(expr.operands().size()!=1) @@ -899,18 +567,6 @@ void jsil_typecheckt::typecheck_expr_unary_num(exprt &expr) make_type_compatible(expr.op0(), floatbv_typet(), true); } -/*******************************************************************\ - -Function: jsil_typecheckt::typecheck_symbol_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_symbol_expr(symbol_exprt &symbol_expr) { irep_idt identifier=symbol_expr.get_identifier(); @@ -989,18 +645,6 @@ void jsil_typecheckt::typecheck_symbol_expr(symbol_exprt &symbol_expr) } } -/*******************************************************************\ - -Function: jsil_typecheckt::typecheck_code - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_code(codet &code) { const irep_idt &statement=code.get_statement(); @@ -1049,54 +693,18 @@ void jsil_typecheckt::typecheck_code(codet &code) } } -/*******************************************************************\ - -Function: jsil_typecheckt::typecheck_return - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_return(code_returnt &code) { if(code.has_return_value()) typecheck_expr(code.return_value()); } -/*******************************************************************\ - -Function: jsil_typecheckt::typecheck_block - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_block(codet &code) { Forall_operands(it, code) typecheck_code(to_code(*it)); } -/*******************************************************************\ - -Function: jsil_typecheckt::typecheck_try_catch - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_try_catch(code_try_catcht &code) { // A special case of try catch with one catch clause @@ -1115,18 +723,6 @@ void jsil_typecheckt::typecheck_try_catch(code_try_catcht &code) typecheck_code(code.get_catch_code(0)); } -/*******************************************************************\ - -Function: jsil_typecheckt::typecheck_function_call - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_function_call( code_function_callt &call) { @@ -1229,18 +825,6 @@ void jsil_typecheckt::typecheck_function_call( } } -/*******************************************************************\ - -Function: jsil_typecheckt::typecheck_ifthenelse - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_ifthenelse(code_ifthenelset &code) { exprt &cond=code.cond(); @@ -1253,18 +837,6 @@ void jsil_typecheckt::typecheck_ifthenelse(code_ifthenelset &code) typecheck_code(to_code(code.else_case())); } -/*******************************************************************\ - -Function: jsil_typecheckt::typecheck_assign - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck_assign(code_assignt &code) { typecheck_expr(code.op0()); @@ -1273,20 +845,9 @@ void jsil_typecheckt::typecheck_assign(code_assignt &code) make_type_compatible(code.op0(), code.op1().type(), false); } -/*******************************************************************\ - -Function: java_bytecode_typecheckt::typecheck_non_type_symbol - - Inputs: any symbol - - Outputs: - - Purpose: typecheking procedure declaration; any other symbols - should have been typechecked during typecheking of procedure - declaration - -\*******************************************************************/ - +/// typecheking procedure declaration; any other symbols should have been +/// typechecked during typecheking of procedure declaration +/// \par parameters: any symbol void jsil_typecheckt::typecheck_non_type_symbol(symbolt &symbol) { assert(!symbol.is_type); @@ -1319,18 +880,6 @@ void jsil_typecheckt::typecheck_non_type_symbol(symbolt &symbol) } } -/*******************************************************************\ - -Function: java_bytecode_typecheckt::typecheck - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsil_typecheckt::typecheck() { // The hash table iterators are not stable, @@ -1361,18 +910,6 @@ void jsil_typecheckt::typecheck() } } -/*******************************************************************\ - -Function: jsil_typecheck - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool jsil_typecheck( symbol_tablet &symbol_table, message_handlert &message_handler) @@ -1381,23 +918,14 @@ bool jsil_typecheck( return jsil_typecheck.typecheck_main(); } -/*******************************************************************\ - -Function: jsil_typecheck - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool jsil_typecheck( exprt &expr, message_handlert &message_handler, const namespacet &ns) { + const unsigned errors_before= + message_handler.get_message_count(messaget::M_ERROR); + symbol_tablet symbol_table; jsil_typecheckt jsil_typecheck( @@ -1424,5 +952,5 @@ bool jsil_typecheck( jsil_typecheck.error() << e << messaget::eom; } - return jsil_typecheck.get_error_found(); + return message_handler.get_message_count(messaget::M_ERROR)!=errors_before; } diff --git a/src/jsil/jsil_typecheck.h b/src/jsil/jsil_typecheck.h index 68988a80273..a1be82cfddb 100644 --- a/src/jsil/jsil_typecheck.h +++ b/src/jsil/jsil_typecheck.h @@ -6,6 +6,9 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ +/// \file +/// Jsil Language + #ifndef CPROVER_JSIL_JSIL_TYPECHECK_H #define CPROVER_JSIL_JSIL_TYPECHECK_H diff --git a/src/jsil/jsil_types.cpp b/src/jsil/jsil_types.cpp index ffccfd16bbe..68c75b8827a 100644 --- a/src/jsil/jsil_types.cpp +++ b/src/jsil/jsil_types.cpp @@ -6,22 +6,13 @@ Author: Daiva Naudziuniene, daivan@amazon.com \*******************************************************************/ +/// \file +/// Jsil Language + #include #include "jsil_types.h" -/*******************************************************************\ - -Function: jsil_any_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet jsil_any_type() { return jsil_union_typet({ // NOLINT(whitespace/braces) @@ -31,18 +22,6 @@ typet jsil_any_type() }); } -/*******************************************************************\ - -Function: jsil_value_or_empty_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet jsil_value_or_empty_type() { return jsil_union_typet({ // NOLINT(whitespace/braces) @@ -51,18 +30,6 @@ typet jsil_value_or_empty_type() }); } -/*******************************************************************\ - -Function: jsil_value_or_reference_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet jsil_value_or_reference_type() { return jsil_union_typet({ // NOLINT(whitespace/braces) @@ -71,18 +38,6 @@ typet jsil_value_or_reference_type() }); } -/*******************************************************************\ - -Function: jsil_value_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet jsil_value_type() { return jsil_union_typet({ // NOLINT(whitespace/braces) @@ -93,18 +48,6 @@ typet jsil_value_type() }); } -/*******************************************************************\ - -Function: jsil_prim_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet jsil_prim_type() { return jsil_union_typet({ // NOLINT(whitespace/braces) @@ -114,18 +57,6 @@ typet jsil_prim_type() }); } -/*******************************************************************\ - -Function: jsil_reference_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet jsil_reference_type() { return jsil_union_typet({ // NOLINT(whitespace/braces) @@ -134,52 +65,16 @@ typet jsil_reference_type() }); } -/*******************************************************************\ - -Function: jsil_member_reference_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet jsil_member_reference_type() { return typet("jsil_member_reference_type"); } -/*******************************************************************\ - -Function: jsil_variable_reference_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet jsil_variable_reference_type() { return typet("jsil_variable_reference_type"); } -/*******************************************************************\ - -Function: jsil_object_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet jsil_object_type() { return jsil_union_typet({ // NOLINT(whitespace/braces) @@ -188,120 +83,36 @@ typet jsil_object_type() }); } -/*******************************************************************\ - -Function: jsil_user_object_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet jsil_user_object_type() { return typet("jsil_user_object_type"); } -/*******************************************************************\ - -Function: jsil_builtin_object_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet jsil_builtin_object_type() { return typet("jsil_builtin_object_type"); } -/*******************************************************************\ - -Function: jsil_null_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet jsil_null_type() { return typet("jsil_null_type"); } -/*******************************************************************\ - -Function: jsil_undefined_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet jsil_undefined_type() { return typet("jsil_undefined_type"); } -/*******************************************************************\ - -Function: jsil_kind - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet jsil_kind() { return typet("jsil_kind"); } -/*******************************************************************\ - -Function: jsil_empty_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet jsil_empty_type() { return typet("jsil_empty_type"); } -/*******************************************************************\ - -Function: jsil_is_subtype - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool jsil_is_subtype(const typet &type1, const typet &type2) { if(type2.id()==ID_union) @@ -317,54 +128,18 @@ bool jsil_is_subtype(const typet &type1, const typet &type2) return type1.id()==type2.id(); } -/*******************************************************************\ - -Function: jsil_incompatible_types - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool jsil_incompatible_types(const typet &type1, const typet &type2) { return jsil_union_typet(type1).intersect_with( jsil_union_typet(type2)).components().empty(); } -/*******************************************************************\ - -Function: jsil_union - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet jsil_union(const typet &type1, const typet &type2) { return jsil_union_typet(type1) .union_with(jsil_union_typet(type2)).to_type(); } -/*******************************************************************\ - -Function: compare_components - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool compare_components( const union_typet::componentt &comp1, const union_typet::componentt &comp2) @@ -372,18 +147,6 @@ bool compare_components( return comp1.type().id() &types): union_typet() { @@ -402,18 +165,6 @@ jsil_union_typet::jsil_union_typet(const std::vector &types): std::sort(elements.begin(), elements.end(), compare_components); } -/*******************************************************************\ - -Function: jsil_union_typet::union_with - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - jsil_union_typet jsil_union_typet::union_with( const jsil_union_typet &other) const { @@ -431,17 +182,6 @@ jsil_union_typet jsil_union_typet::union_with( return result; } -/*******************************************************************\ - -Function: jsil_union_typet::intersect_with - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ jsil_union_typet jsil_union_typet::intersect_with( const jsil_union_typet &other) const { @@ -459,18 +199,6 @@ jsil_union_typet jsil_union_typet::intersect_with( return result; } -/*******************************************************************\ - -Function: jsil_union_typet::is_subtype - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool jsil_union_typet::is_subtype(const jsil_union_typet &other) const { auto it=components().begin(); @@ -504,18 +232,6 @@ bool jsil_union_typet::is_subtype(const jsil_union_typet &other) const return true; } -/*******************************************************************\ - -Function: jsil_union_typet::to_type() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const typet &jsil_union_typet::to_type() const { auto &elements=components(); diff --git a/src/jsil/jsil_types.h b/src/jsil/jsil_types.h index b27be7f3219..b3b5a159b40 100644 --- a/src/jsil/jsil_types.h +++ b/src/jsil/jsil_types.h @@ -6,6 +6,9 @@ Author: Daiva Naudziuniene, daivan@amazon.com \*******************************************************************/ +/// \file +/// Jsil Language + #ifndef CPROVER_JSIL_JSIL_TYPES_H #define CPROVER_JSIL_JSIL_TYPES_H diff --git a/src/json/json_parser.cpp b/src/json/json_parser.cpp index 04c6d7dbfde..30b0ee61586 100644 --- a/src/json/json_parser.cpp +++ b/src/json/json_parser.cpp @@ -6,24 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "json_parser.h" json_parsert json_parser; -/*******************************************************************\ - -Function: parse_json - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - // 'do it all' function bool parse_json( std::istream &in, @@ -48,18 +37,6 @@ bool parse_json( return result; } -/*******************************************************************\ - -Function: parse_json - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - // 'do it all' function bool parse_json( const std::string &filename, diff --git a/src/json/json_parser.h b/src/json/json_parser.h index 2983d2542a5..d3d28aa6fa2 100644 --- a/src/json/json_parser.h +++ b/src/json/json_parser.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_JSON_JSON_PARSER_H #define CPROVER_JSON_JSON_PARSER_H diff --git a/src/langapi/language_ui.cpp b/src/langapi/language_ui.cpp index 73016a87874..fe24dff1887 100644 --- a/src/langapi/language_ui.cpp +++ b/src/langapi/language_ui.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ + #include #include #include @@ -18,55 +19,21 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "language_ui.h" #include "mode.h" -/*******************************************************************\ - -Function: language_uit::language_uit - - Inputs: - - Outputs: - - Purpose: Constructor - -\*******************************************************************/ - +/// Constructor language_uit::language_uit( const cmdlinet &cmdline, ui_message_handlert &_ui_message_handler): - ui_message_handler(_ui_message_handler), - _cmdline(cmdline) + _cmdline(cmdline), + ui_message_handler(_ui_message_handler) { set_message_handler(ui_message_handler); } -/*******************************************************************\ - -Function: language_uit::~language_uit - - Inputs: - - Outputs: - - Purpose: Destructor - -\*******************************************************************/ - +/// Destructor language_uit::~language_uit() { } -/*******************************************************************\ - -Function: language_uit::parse() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool language_uit::parse() { for(unsigned i=0; i<_cmdline.args.size(); i++) @@ -78,18 +45,6 @@ bool language_uit::parse() return false; } -/*******************************************************************\ - -Function: language_uit::parse() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool language_uit::parse(const std::string &filename) { #ifdef _MSC_VER @@ -115,7 +70,10 @@ bool language_uit::parse(const std::string &filename) if(lf.language==NULL) { - error("failed to figure out type of file", filename); + source_locationt location; + location.set_file(filename); + error().source_location=location; + error() << "failed to figure out type of file" << eom; return true; } @@ -128,7 +86,7 @@ bool language_uit::parse(const std::string &filename) if(language.parse(infile, filename)) { if(get_ui()==ui_message_handlert::uit::PLAIN) - std::cerr << "PARSING ERROR" << std::endl; + std::cerr << "PARSING ERROR\n"; return true; } @@ -138,18 +96,6 @@ bool language_uit::parse(const std::string &filename) return false; } -/*******************************************************************\ - -Function: language_uit::typecheck - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool language_uit::typecheck() { status() << "Converting" << eom; @@ -165,18 +111,6 @@ bool language_uit::typecheck() return false; } -/*******************************************************************\ - -Function: language_uit::final - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool language_uit::final() { language_files.set_message_handler(*message_handler); @@ -194,18 +128,6 @@ bool language_uit::final() return false; } -/*******************************************************************\ - -Function: language_uit::show_symbol_table - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void language_uit::show_symbol_table(bool brief) { switch(get_ui()) @@ -223,41 +145,17 @@ void language_uit::show_symbol_table(bool brief) } } -/*******************************************************************\ - -Function: language_uit::show_symbol_table_xml_ui - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void language_uit::show_symbol_table_xml_ui(bool brief) { error() << "cannot show symbol table in this format" << eom; } -/*******************************************************************\ - -Function: language_uit::show_symbol_table_plain - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void language_uit::show_symbol_table_plain( std::ostream &out, bool brief) { if(!brief) - out << '\n' << "Symbols:" << '\n' << std::endl; + out << "\nSymbols:\n\n"; // we want to sort alphabetically std::set symbols; @@ -293,7 +191,7 @@ void language_uit::show_symbol_table_plain( if(brief) { - out << symbol.name << " " << type_str << std::endl; + out << symbol.name << " " << type_str << '\n'; continue; } diff --git a/src/langapi/language_ui.h b/src/langapi/language_ui.h index b82507f4c75..76fe7f2445c 100644 --- a/src/langapi/language_ui.h +++ b/src/langapi/language_ui.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ + #ifndef CPROVER_LANGAPI_LANGUAGE_UI_H #define CPROVER_LANGAPI_LANGUAGE_UI_H @@ -48,10 +49,9 @@ class language_uit:public messaget return ui_message_handler.get_ui(); } - ui_message_handlert &ui_message_handler; - protected: const cmdlinet &_cmdline; + ui_message_handlert &ui_message_handler; }; #endif // CPROVER_LANGAPI_LANGUAGE_UI_H diff --git a/src/langapi/language_util.cpp b/src/langapi/language_util.cpp index d8c53ec9341..7e0121ced47 100644 --- a/src/langapi/language_util.cpp +++ b/src/langapi/language_util.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ + #include #include @@ -16,18 +17,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "language_util.h" #include "mode.h" -/*******************************************************************\ - -Function: get_language - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static languaget* get_language( const namespacet &ns, const irep_idt &identifier) @@ -48,18 +37,6 @@ static languaget* get_language( return ptr; } -/*******************************************************************\ - -Function: from_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string from_expr( const namespacet &ns, const irep_idt &identifier, @@ -73,18 +50,6 @@ std::string from_expr( return result; } -/*******************************************************************\ - -Function: from_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string from_type( const namespacet &ns, const irep_idt &identifier, @@ -98,18 +63,6 @@ std::string from_type( return result; } -/*******************************************************************\ - -Function: type_to_name - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string type_to_name( const namespacet &ns, const irep_idt &identifier, @@ -123,54 +76,18 @@ std::string type_to_name( return result; } -/*******************************************************************\ - -Function: from_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string from_expr(const exprt &expr) { symbol_tablet symbol_table; return from_expr(namespacet(symbol_table), "", expr); } -/*******************************************************************\ - -Function: from_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string from_type(const typet &type) { symbol_tablet symbol_table; return from_type(namespacet(symbol_table), "", type); } -/*******************************************************************\ - -Function: to_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt to_expr( const namespacet &ns, const irep_idt &identifier, @@ -188,18 +105,6 @@ exprt to_expr( return expr; } -/*******************************************************************\ - -Function: type_to_name - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string type_to_name(const typet &type) { symbol_tablet symbol_table; diff --git a/src/langapi/language_util.h b/src/langapi/language_util.h index ded56e9ba04..9893aea4b68 100644 --- a/src/langapi/language_util.h +++ b/src/langapi/language_util.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ + #ifndef CPROVER_LANGAPI_LANGUAGE_UTIL_H #define CPROVER_LANGAPI_LANGUAGE_UTIL_H diff --git a/src/langapi/languages.cpp b/src/langapi/languages.cpp index 31ab9d37e7a..618210bba9c 100644 --- a/src/langapi/languages.cpp +++ b/src/langapi/languages.cpp @@ -6,37 +6,14 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -#include "languages.h" - -/*******************************************************************\ - -Function: languagest::languagest - - Inputs: - Outputs: - - Purpose: - -\*******************************************************************/ +#include "languages.h" languagest::languagest(const namespacet &_ns, languaget *_language):ns(_ns) { language=_language; } -/*******************************************************************\ - -Function: languagest::~languagest - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - languagest::~languagest() { delete language; diff --git a/src/langapi/languages.h b/src/langapi/languages.h index 0c8dda97ada..92cd5381ab3 100644 --- a/src/langapi/languages.h +++ b/src/langapi/languages.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ + #ifndef CPROVER_LANGAPI_LANGUAGES_H #define CPROVER_LANGAPI_LANGUAGES_H diff --git a/src/langapi/mode.cpp b/src/langapi/mode.cpp index 525a9519afd..a558c9be5e9 100644 --- a/src/langapi/mode.cpp +++ b/src/langapi/mode.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ + #include #include #include @@ -28,18 +29,6 @@ struct language_entryt typedef std::list languagest; languagest languages; -/*******************************************************************\ - -Function: register_language - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void register_language(language_factoryt factory) { languages.push_back(language_entryt()); @@ -49,18 +38,6 @@ void register_language(language_factoryt factory) languages.back().mode=l->id(); } -/*******************************************************************\ - -Function: get_language_from_mode - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - languaget *get_language_from_mode(const irep_idt &mode) { for(languagest::const_iterator it=languages.begin(); @@ -72,18 +49,6 @@ languaget *get_language_from_mode(const irep_idt &mode) return NULL; } -/*******************************************************************\ - -Function: get_language_from_filename - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - languaget *get_language_from_filename(const std::string &filename) { std::size_t ext_pos=filename.rfind('.'); @@ -118,18 +83,6 @@ languaget *get_language_from_filename(const std::string &filename) return NULL; } -/*******************************************************************\ - -Function: get_default_language - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - languaget *get_default_language() { assert(!languages.empty()); diff --git a/src/langapi/mode.h b/src/langapi/mode.h index 5e0f8cf83f6..e8cf679d0e2 100644 --- a/src/langapi/mode.h +++ b/src/langapi/mode.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ + #ifndef CPROVER_LANGAPI_MODE_H #define CPROVER_LANGAPI_MODE_H diff --git a/src/linking/linking.cpp b/src/linking/linking.cpp index 173d5b2cf4c..645cbf32e06 100644 --- a/src/linking/linking.cpp +++ b/src/linking/linking.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// ANSI-C Linking + #include #include @@ -22,18 +25,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "linking.h" #include "linking_class.h" -/*******************************************************************\ - -Function: linkingt::expr_to_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string linkingt::expr_to_string( const namespacet &ns, const irep_idt &identifier, @@ -42,18 +33,6 @@ std::string linkingt::expr_to_string( return from_expr(ns, identifier, expr); } -/*******************************************************************\ - -Function: linkingt::type_to_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string linkingt::type_to_string( const namespacet &ns, const irep_idt &identifier, @@ -62,18 +41,6 @@ std::string linkingt::type_to_string( return from_type(ns, identifier, type); } -/*******************************************************************\ - -Function: follow_tags_symbols - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static const typet &follow_tags_symbols( const namespacet &ns, const typet &type) @@ -90,18 +57,6 @@ static const typet &follow_tags_symbols( return type; } -/*******************************************************************\ - -Function: linkingt::type_to_string_verbose - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string linkingt::type_to_string_verbose( const namespacet &ns, const symbolt &symbol, @@ -156,18 +111,6 @@ std::string linkingt::type_to_string_verbose( return type_to_string(ns, symbol.name, type); } -/*******************************************************************\ - -Function: linkingt::detailed_conflict_report - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void linkingt::detailed_conflict_report_rec( const symbolt &old_symbol, const symbolt &new_symbol, @@ -422,18 +365,6 @@ void linkingt::detailed_conflict_report_rec( #endif } -/*******************************************************************\ - -Function: linkingt::link_error - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void linkingt::link_error( const symbolt &old_symbol, const symbolt &new_symbol, @@ -454,18 +385,6 @@ void linkingt::link_error( throw 0; } -/*******************************************************************\ - -Function: linkingt::link_warning - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void linkingt::link_warning( const symbolt &old_symbol, const symbolt &new_symbol, @@ -484,18 +403,6 @@ void linkingt::link_warning( << type_to_string_verbose(ns, new_symbol) << eom; } -/*******************************************************************\ - -Function: linkingt::rename - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - irep_idt linkingt::rename(const irep_idt id) { unsigned cnt=0; @@ -520,18 +427,6 @@ irep_idt linkingt::rename(const irep_idt id) } } -/*******************************************************************\ - -Function: linkingt::needs_renaming_non_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool linkingt::needs_renaming_non_type( const symbolt &old_symbol, const symbolt &new_symbol) @@ -546,18 +441,6 @@ bool linkingt::needs_renaming_non_type( return false; } -/*******************************************************************\ - -Function: linkingt::duplicate_code_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void linkingt::duplicate_code_symbol( symbolt &old_symbol, symbolt &new_symbol) @@ -593,10 +476,16 @@ void linkingt::duplicate_code_symbol( } // handle (incomplete) function prototypes else if(base_type_eq(old_t.return_type(), new_t.return_type(), ns) && - ((old_t.parameters().empty() && old_t.has_ellipsis()) || - (new_t.parameters().empty() && new_t.has_ellipsis()))) + ((old_t.parameters().empty() && + old_t.has_ellipsis() && + old_symbol.value.is_nil()) || + (new_t.parameters().empty() && + new_t.has_ellipsis() && + new_symbol.value.is_nil()))) { - if(old_t.parameters().empty() && old_t.has_ellipsis()) + if(old_t.parameters().empty() && + old_t.has_ellipsis() && + old_symbol.value.is_nil()) { old_symbol.type=new_symbol.type; old_symbol.location=new_symbol.location; @@ -830,6 +719,7 @@ void linkingt::duplicate_code_symbol( old_symbol.value=new_symbol.value; old_symbol.type=new_symbol.type; // for parameter identifiers old_symbol.is_weak=new_symbol.is_weak; + old_symbol.location=new_symbol.location; old_symbol.is_macro=new_symbol.is_macro; } else if(to_code_type(old_symbol.type).get_inlined()) @@ -853,18 +743,6 @@ void linkingt::duplicate_code_symbol( } } -/*******************************************************************\ - -Function: linkingt::adjust_object_type_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool linkingt::adjust_object_type_rec( const typet &t1, const typet &t2, @@ -1019,18 +897,6 @@ bool linkingt::adjust_object_type_rec( return true; } -/*******************************************************************\ - -Function: linkingt::adjust_object_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool linkingt::adjust_object_type( const symbolt &old_symbol, const symbolt &new_symbol, @@ -1046,18 +912,6 @@ bool linkingt::adjust_object_type( return result; } -/*******************************************************************\ - -Function: linkingt::duplicate_object_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void linkingt::duplicate_object_symbol( symbolt &old_symbol, symbolt &new_symbol) @@ -1093,6 +947,8 @@ void linkingt::duplicate_object_symbol( } else if(set_to_new) old_symbol.type=new_symbol.type; + + object_type_updates.insert(old_symbol.name, old_symbol.symbol_expr()); } // care about initializers @@ -1142,18 +998,6 @@ void linkingt::duplicate_object_symbol( } } -/*******************************************************************\ - -Function: linkingt::duplicate_non_type_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void linkingt::duplicate_non_type_symbol( symbolt &old_symbol, symbolt &new_symbol) @@ -1183,18 +1027,6 @@ void linkingt::duplicate_non_type_symbol( old_symbol.is_extern=old_symbol.is_extern && new_symbol.is_extern; } -/*******************************************************************\ - -Function: linkingt::duplicate_type_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void linkingt::duplicate_type_symbol( symbolt &old_symbol, symbolt &new_symbol) @@ -1272,18 +1104,6 @@ void linkingt::duplicate_type_symbol( "unexpected difference between type symbols"); } -/*******************************************************************\ - -Function: linkingt::needs_renaming_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool linkingt::needs_renaming_type( const symbolt &old_symbol, const symbolt &new_symbol) @@ -1328,18 +1148,6 @@ bool linkingt::needs_renaming_type( return true; // different } -/*******************************************************************\ - -Function: linkingt::do_type_dependencies - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void linkingt::do_type_dependencies(id_sett &needs_to_be_renamed) { // Any type that uses a symbol that will be renamed also @@ -1395,18 +1203,6 @@ void linkingt::do_type_dependencies(id_sett &needs_to_be_renamed) } } -/*******************************************************************\ - -Function: linkingt::rename_symbols - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void linkingt::rename_symbols(const id_sett &needs_to_be_renamed) { namespacet src_ns(src_symbol_table); @@ -1439,18 +1235,6 @@ void linkingt::rename_symbols(const id_sett &needs_to_be_renamed) } } -/*******************************************************************\ - -Function: linkingt::copy_symbols - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void linkingt::copy_symbols() { // First apply the renaming @@ -1501,19 +1285,16 @@ void linkingt::copy_symbols() else duplicate_non_type_symbol(old_symbol, new_symbol); } -} - -/*******************************************************************\ - -Function: linkingt::typecheck - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ + // Apply type updates to initializers + Forall_symbols(s_it, main_symbol_table.symbols) + { + if(!s_it->second.is_type && + !s_it->second.is_macro && + s_it->second.value.is_not_nil()) + object_type_updates(s_it->second.value); + } +} void linkingt::typecheck() { @@ -1551,18 +1332,6 @@ void linkingt::typecheck() copy_symbols(); } -/*******************************************************************\ - -Function: linking - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool linking( symbol_tablet &dest_symbol_table, symbol_tablet &new_symbol_table, diff --git a/src/linking/linking.h b/src/linking/linking.h index 22b54e55613..b565a65231e 100644 --- a/src/linking/linking.h +++ b/src/linking/linking.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// ANSI-C Linking + #ifndef CPROVER_LINKING_LINKING_H #define CPROVER_LINKING_LINKING_H diff --git a/src/linking/linking_class.h b/src/linking/linking_class.h index dba9481f3ab..d3fa633af2f 100644 --- a/src/linking/linking_class.h +++ b/src/linking/linking_class.h @@ -6,11 +6,15 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// ANSI-C Linking + #ifndef CPROVER_LINKING_LINKING_CLASS_H #define CPROVER_LINKING_LINKING_CLASS_H #include #include +#include #include #include @@ -31,6 +35,7 @@ class linkingt:public typecheckt virtual void typecheck(); rename_symbolt rename_symbol; + replace_symbolt object_type_updates; protected: typedef std::unordered_set id_sett; diff --git a/src/linking/remove_internal_symbols.cpp b/src/linking/remove_internal_symbols.cpp index 5b4a7b13625..3aca40f8219 100644 --- a/src/linking/remove_internal_symbols.cpp +++ b/src/linking/remove_internal_symbols.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening \*******************************************************************/ +/// \file +/// Remove symbols that are internal only + #include #include #include @@ -15,18 +18,6 @@ Author: Daniel Kroening #include "remove_internal_symbols.h" -/*******************************************************************\ - -Function: get_symbols_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void get_symbols_rec( const namespacet &ns, const symbolt &symbol, @@ -70,25 +61,15 @@ void get_symbols_rec( } } -/*******************************************************************\ - -Function: remove_internal_symbols - - Inputs: symbol table - - Outputs: symbol table, with internal symbols removed - - Purpose: A symbol is EXPORTED if it is a - * non-static function with body that is not extern inline - * symbol used in an EXPORTED symbol - * type used in an EXPORTED symbol - - Read - http://gcc.gnu.org/ml/gcc/2006-11/msg00006.html - on "extern inline" - -\*******************************************************************/ - +/// A symbol is EXPORTED if it is a * non-static function with body that is not +/// extern inline * symbol used in an EXPORTED symbol * type used in an EXPORTED +/// symbol +/// +/// Read +/// http://gcc.gnu.org/ml/gcc/2006-11/msg00006.html +/// on "extern inline" +/// \par parameters: symbol table +/// \return symbol table, with internal symbols removed void remove_internal_symbols( symbol_tablet &symbol_table) { diff --git a/src/linking/remove_internal_symbols.h b/src/linking/remove_internal_symbols.h index 40711162e73..f9d8a465162 100644 --- a/src/linking/remove_internal_symbols.h +++ b/src/linking/remove_internal_symbols.h @@ -6,6 +6,9 @@ Author: Daniel Kroening \*******************************************************************/ +/// \file +/// Remove symbols that are internal only + #ifndef CPROVER_LINKING_REMOVE_INTERNAL_SYMBOLS_H #define CPROVER_LINKING_REMOVE_INTERNAL_SYMBOLS_H diff --git a/src/linking/static_lifetime_init.cpp b/src/linking/static_lifetime_init.cpp index 29f5005d685..2ea7762ab9f 100644 --- a/src/linking/static_lifetime_init.cpp +++ b/src/linking/static_lifetime_init.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -16,25 +17,13 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -#include +#include #include #include "static_lifetime_init.h" #include "zero_initializer.h" -/*******************************************************************\ - -Function: static_lifetime_init - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool static_lifetime_init( symbol_tablet &symbol_table, const source_locationt &source_location, @@ -156,7 +145,6 @@ bool static_lifetime_init( // call designated "initialization" functions - #if 0 for(const std::string &id : symbols) { const symbolt &symbol=ns.lookup(id); @@ -170,7 +158,6 @@ bool static_lifetime_init( dest.move_to_operands(function_call); } } - #endif return false; } diff --git a/src/linking/static_lifetime_init.h b/src/linking/static_lifetime_init.h index da9543addf6..0955fc1f57c 100644 --- a/src/linking/static_lifetime_init.h +++ b/src/linking/static_lifetime_init.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_LINKING_STATIC_LIFETIME_INIT_H #define CPROVER_LINKING_STATIC_LIFETIME_INIT_H diff --git a/src/linking/zero_initializer.cpp b/src/linking/zero_initializer.cpp index 9e96c48480b..95016b9229e 100644 --- a/src/linking/zero_initializer.cpp +++ b/src/linking/zero_initializer.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Linking: Zero Initialization + #include #include @@ -15,7 +18,7 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -#include +#include #include #include "zero_initializer.h" @@ -56,18 +59,6 @@ class zero_initializert:public messaget const source_locationt &source_location); }; -/*******************************************************************\ - -Function: zero_initializert::zero_initializer_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt zero_initializert::zero_initializer_rec( const typet &type, const source_locationt &source_location) @@ -319,18 +310,6 @@ exprt zero_initializert::zero_initializer_rec( } } -/*******************************************************************\ - -Function: zero_initializer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt zero_initializer( const typet &type, const source_locationt &source_location, @@ -341,18 +320,6 @@ exprt zero_initializer( return z_i(type, source_location); } -/*******************************************************************\ - -Function: zero_initializer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt zero_initializer( const typet &type, const source_locationt &source_location, diff --git a/src/linking/zero_initializer.h b/src/linking/zero_initializer.h index 766fdf26784..3bb440b8b74 100644 --- a/src/linking/zero_initializer.h +++ b/src/linking/zero_initializer.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Linking: Zero Initialization + #ifndef CPROVER_LINKING_ZERO_INITIALIZER_H #define CPROVER_LINKING_ZERO_INITIALIZER_H diff --git a/src/memory-models/mm2cpp.cpp b/src/memory-models/mm2cpp.cpp index bc3eb0d9e18..a151658d491 100644 --- a/src/memory-models/mm2cpp.cpp +++ b/src/memory-models/mm2cpp.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -32,18 +33,6 @@ class mm2cppt void check_acyclic(const exprt &, unsigned indent); }; -/*******************************************************************\ - -Function: mm2cppt::text2c - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string mm2cppt::text2c(const irep_idt &src) { std::string result; @@ -61,18 +50,6 @@ std::string mm2cppt::text2c(const irep_idt &src) return result; } -/*******************************************************************\ - -Function: mm2cppt::check_acyclic - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void mm2cppt::check_acyclic(const exprt &expr, unsigned indent) { if(expr.id()==ID_symbol) @@ -154,18 +131,6 @@ void mm2cppt::check_acyclic(const exprt &expr, unsigned indent) throw "acyclic cannot do "+expr.id_string(); } -/*******************************************************************\ - -Function: mm2cppt::instruction2cpp - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void mm2cppt::instruction2cpp(const codet &code, unsigned indent) { const irep_idt &statement=code.get_statement(); @@ -216,18 +181,6 @@ void mm2cppt::instruction2cpp(const codet &code, unsigned indent) } } -/*******************************************************************\ - -Function: mm2cpp - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void mm2cppt::operator()(const irept &instruction) { out << "// Generated by mmcc\n"; @@ -248,18 +201,6 @@ void mm2cppt::operator()(const irept &instruction) out << '\n'; } -/*******************************************************************\ - -Function: mm2cpp - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void mm2cpp( const irep_idt &model_name, const irept &instruction, diff --git a/src/memory-models/mm2cpp.h b/src/memory-models/mm2cpp.h index 1d6c45ee2b7..99d43d15ccb 100644 --- a/src/memory-models/mm2cpp.h +++ b/src/memory-models/mm2cpp.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_MEMORY_MODELS_MM2CPP_H #define CPROVER_MEMORY_MODELS_MM2CPP_H diff --git a/src/memory-models/mm_parser.cpp b/src/memory-models/mm_parser.cpp index e631543489a..15b0aee55d3 100644 --- a/src/memory-models/mm_parser.cpp +++ b/src/memory-models/mm_parser.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include "mm_parser.h" mm_parsert mm_parser; diff --git a/src/memory-models/mm_parser.h b/src/memory-models/mm_parser.h index 11240cf8786..847e31687cf 100644 --- a/src/memory-models/mm_parser.h +++ b/src/memory-models/mm_parser.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_MEMORY_MODELS_MM_PARSER_H #define CPROVER_MEMORY_MODELS_MM_PARSER_H diff --git a/src/memory-models/mmcc_main.cpp b/src/memory-models/mmcc_main.cpp index a30d45515d5..9e73843b3ce 100644 --- a/src/memory-models/mmcc_main.cpp +++ b/src/memory-models/mmcc_main.cpp @@ -6,22 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// mmcc Main Module + #include #include "mmcc_parse_options.h" -/*******************************************************************\ - -Function: main / wmain - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - #ifdef _MSC_VER int wmain(int argc, const wchar_t **argv_wide) { diff --git a/src/memory-models/mmcc_parse_options.cpp b/src/memory-models/mmcc_parse_options.cpp index 859393f9726..586aea20ec3 100644 --- a/src/memory-models/mmcc_parse_options.cpp +++ b/src/memory-models/mmcc_parse_options.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// mmcc Command Line Option Processing + #include #include @@ -17,40 +20,17 @@ Author: Daniel Kroening, kroening@kroening.com #include "mm2cpp.h" #include "mmcc_parse_options.h" -/*******************************************************************\ - -Function: mmcc_parse_optionst::mmcc_parse_optionst - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - mmcc_parse_optionst::mmcc_parse_optionst(int argc, const char **argv): parse_options_baset(MMCC_OPTIONS, argc, argv) { } -/*******************************************************************\ - -Function: mmcc_parse_optionst::doit - - Inputs: - - Outputs: - - Purpose: invoke main modules - -\*******************************************************************/ - +/// invoke main modules int mmcc_parse_optionst::doit() { if(cmdline.isset("version")) { - std::cout << CBMC_VERSION << std::endl; + std::cout << CBMC_VERSION << '\n'; return 0; } @@ -92,18 +72,6 @@ int mmcc_parse_optionst::doit() return 0; } -/*******************************************************************\ - -Function: mmcc_parse_optionst::convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - int mmcc_parse_optionst::convert( std::istream &in, const std::string &file) @@ -125,18 +93,7 @@ int mmcc_parse_optionst::convert( return 0; } -/*******************************************************************\ - -Function: mmcc_parse_optionst::help - - Inputs: - - Outputs: - - Purpose: display command line help - -\*******************************************************************/ - +/// display command line help void mmcc_parse_optionst::help() { std::cout << diff --git a/src/memory-models/mmcc_parse_options.h b/src/memory-models/mmcc_parse_options.h index 07745b47944..357ae91df20 100644 --- a/src/memory-models/mmcc_parse_options.h +++ b/src/memory-models/mmcc_parse_options.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// mmcc Command Line Option Processing + #ifndef CPROVER_MEMORY_MODELS_MMCC_PARSE_OPTIONS_H #define CPROVER_MEMORY_MODELS_MMCC_PARSE_OPTIONS_H diff --git a/src/musketeer/cycles_visitor.cpp b/src/musketeer/cycles_visitor.cpp index 762b667c6d2..89d68e13ad5 100644 --- a/src/musketeer/cycles_visitor.cpp +++ b/src/musketeer/cycles_visitor.cpp @@ -6,6 +6,9 @@ Author: Vincent Nimal \*******************************************************************/ +/// \file +/// cycles visitor for computing edges involved for fencing + #include #include @@ -17,18 +20,6 @@ class instrumentert; /* implemented: BTWN1, BTWN4 */ #define BTWN1 -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* po^+ /\ U{C_1, ..., C_n} \/ delays */ void cycles_visitort::po_edges(std::set &edges) { @@ -253,18 +244,6 @@ void cycles_visitort::po_edges(std::set &edges) } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* C_j /\ po^+ /\ poWR */ void cycles_visitort::powr_constraint( const event_grapht::critical_cyclet &C_j, @@ -285,18 +264,6 @@ void cycles_visitort::powr_constraint( } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* C_j /\ po^+ /\ poWW */ void cycles_visitort::poww_constraint( const event_grapht::critical_cyclet &C_j, @@ -317,18 +284,6 @@ void cycles_visitort::poww_constraint( } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* C_j /\ po^+ /\ poRW */ void cycles_visitort::porw_constraint( const event_grapht::critical_cyclet &C_j, @@ -349,18 +304,6 @@ void cycles_visitort::porw_constraint( } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* C_j /\ po^+ /\ poRR */ void cycles_visitort::porr_constraint( const event_grapht::critical_cyclet &C_j, @@ -381,18 +324,6 @@ void cycles_visitort::porr_constraint( } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* C_j /\ comWR */ void cycles_visitort::com_constraint( const event_grapht::critical_cyclet &C_j, diff --git a/src/musketeer/cycles_visitor.h b/src/musketeer/cycles_visitor.h index f125b511668..0b9b122eed8 100644 --- a/src/musketeer/cycles_visitor.h +++ b/src/musketeer/cycles_visitor.h @@ -6,6 +6,9 @@ Author: Vincent Nimal \*******************************************************************/ +/// \file +/// cycles visitor for computing edges involved for fencing + #ifndef CPROVER_MUSKETEER_CYCLES_VISITOR_H #define CPROVER_MUSKETEER_CYCLES_VISITOR_H diff --git a/src/musketeer/fence_assert.cpp b/src/musketeer/fence_assert.cpp index 06bea8537fc..d44faf74689 100644 --- a/src/musketeer/fence_assert.cpp +++ b/src/musketeer/fence_assert.cpp @@ -7,19 +7,10 @@ Author: Vincent Nimal \*******************************************************************/ -#include "fence_assert.h" - -/*******************************************************************\ - -Function: - - Inputs: +/// \file +/// ILP construction for cycles affecting user-assertions and resolution - Outputs: - - Purpose: - -\*******************************************************************/ +#include "fence_assert.h" bool fence_assert_insertert::find_assert( const event_grapht::critical_cyclet &cycle) const @@ -28,18 +19,6 @@ bool fence_assert_insertert::find_assert( return true; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void fence_assert_insertert::process_cycles_selection() { for(std::set::const_iterator diff --git a/src/musketeer/fence_assert.h b/src/musketeer/fence_assert.h index 7e18e1f8e56..bc21b8b5319 100644 --- a/src/musketeer/fence_assert.h +++ b/src/musketeer/fence_assert.h @@ -7,6 +7,9 @@ Author: Vincent Nimal \*******************************************************************/ +/// \file +/// ILP construction for cycles affecting user-assertions and resolution + #ifndef CPROVER_MUSKETEER_FENCE_ASSERT_H #define CPROVER_MUSKETEER_FENCE_ASSERT_H diff --git a/src/musketeer/fence_inserter.cpp b/src/musketeer/fence_inserter.cpp index 20236dfb956..c534452707c 100644 --- a/src/musketeer/fence_inserter.cpp +++ b/src/musketeer/fence_inserter.cpp @@ -6,6 +6,9 @@ Author: Vincent Nimal \*******************************************************************/ +/// \file +/// ILP construction for all cycles and resolution + #include #include @@ -21,18 +24,6 @@ Author: Vincent Nimal class abstract_eventt; -/*******************************************************************\ - -Function: fence_insertert::fence_cost - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - unsigned fence_insertert::fence_cost(fence_typet f) const { switch(f) @@ -52,18 +43,6 @@ unsigned fence_insertert::fence_cost(fence_typet f) const return 0; } -/*******************************************************************\ - -Function: fence_insertert::compute - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void fence_insertert::compute() { compute_fence_options(); @@ -76,18 +55,6 @@ void fence_insertert::compute() instrumenter.message.result() << "no cycle concerned" << messaget::eom; } -/*******************************************************************\ - -Function: fence_insertert::preprocess - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void fence_insertert::preprocess() { process_cycles_selection(); @@ -239,18 +206,6 @@ void fence_insertert::preprocess() } } -/*******************************************************************\ - -Function: fence_insertert::mip_set_var - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void inline fence_insertert::mip_set_var( ilpt &ilp, unsigned &i) @@ -353,18 +308,6 @@ void inline fence_insertert::mip_set_var( #endif } -/*******************************************************************\ - -Function: fence_insertert::mip_set_cst - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void inline fence_insertert::mip_set_cst(ilpt &ilp, unsigned &i) { #ifdef HAVE_GLPK @@ -459,18 +402,6 @@ void inline fence_insertert::mip_set_cst(ilpt &ilp, unsigned &i) #endif } -/*******************************************************************\ - -Function: fence_insertert::mip_fill_matrix - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void inline fence_insertert::mip_fill_matrix( ilpt &ilp, unsigned &i, @@ -768,18 +699,6 @@ void inline fence_insertert::mip_fill_matrix( #endif } -/*******************************************************************\ - -Function: fence_insertert::solve() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void fence_insertert::solve() { #ifdef HAVE_GLPK @@ -889,35 +808,11 @@ void fence_insertert::solve() #endif } -/*******************************************************************\ - -Function: fence_insertert::import_freq - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void fence_insertert::import_freq() { /* TODO */ } -/*******************************************************************\ - -Function: fence_insertert::print_to_file - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void fence_insertert::print_to_file() { /* removes redundant (due to several call to the same fenced function) */ @@ -931,7 +826,7 @@ void fence_insertert::print_to_file() s << to_string(it->second) << "|" << first.source_location.get_file() << "|" << first.source_location.get_line() << "|" - << first.source_location.get_column() << std::endl; + << first.source_location.get_column() << '\n'; non_redundant_display.insert(s.str()); } @@ -944,18 +839,6 @@ void fence_insertert::print_to_file() results.close(); } -/*******************************************************************\ - -Function: fence_insertert::print_to_file_2 - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* prints final results */ void fence_insertert::print_to_file_2() { @@ -972,7 +855,7 @@ void fence_insertert::print_to_file_2() s << to_string(it->second) << "|" << first.source_location.get_file() << "|" << first.source_location.get_line() << "|" << second.source_location.get_file() - << "|" << second.source_location.get_line() << std::endl; + << "|" << second.source_location.get_line() << '\n'; non_redundant_display.insert(s.str()); } @@ -985,18 +868,6 @@ void fence_insertert::print_to_file_2() results.close(); } -/*******************************************************************\ - -Function: fence_insertert::print_to_file_3 - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* prints final results */ void fence_insertert::print_to_file_3() { @@ -1018,7 +889,7 @@ void fence_insertert::print_to_file_3() << second.source_location.get_file() << "|" << second.source_location.get_function() << "|" << second.source_location.get_line() - << "|" << second.variable << std::endl; + << "|" << second.variable << '\n'; non_redundant_display.insert(s.str()); } catch(std::string s) @@ -1038,18 +909,6 @@ void fence_insertert::print_to_file_3() results.close(); } -/*******************************************************************\ - -Function: fence_insertert::print_to_file_4 - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* prints final results */ void fence_insertert::print_to_file_4() { @@ -1074,7 +933,7 @@ void fence_insertert::print_to_file_4() << second.source_location.get_function() << "|" << second.source_location.get_line() << "|" << second.variable << "|" - << get_type(second.variable).get("#c_type") << std::endl; + << get_type(second.variable).get("#c_type") << '\n'; non_redundant_display.insert(s.str()); } catch (std::string s) @@ -1094,18 +953,6 @@ void fence_insertert::print_to_file_4() results.close(); } -/*******************************************************************\ - -Function: fence_insertert::to_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string fence_insertert::to_string(fence_typet f) const { switch(f) @@ -1119,35 +966,11 @@ std::string fence_insertert::to_string(fence_typet f) const assert(0); } -/*******************************************************************\ - -Function: fence_inserter::col_to_var - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - inline unsigned fence_insertert::col_to_var(unsigned u) const { return (u-u%fence_options)/fence_options+(u%fence_options!=0?1:0); } -/*******************************************************************\ - -Function: fence_insertert::col_to_fence - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - inline fence_insertert::fence_typet fence_insertert::col_to_fence(unsigned u) const { @@ -1162,18 +985,6 @@ inline fence_insertert::fence_typet fence_insertert::col_to_fence(unsigned u) assert(0); } -/*******************************************************************\ - -Function: fence_insertert::var_fence_to_col - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - inline unsigned fence_insertert::var_fence_to_col(fence_typet f, unsigned var) const { @@ -1188,18 +999,6 @@ inline unsigned fence_insertert::var_fence_to_col(fence_typet f, unsigned var) assert(0); } -/*******************************************************************\ - -Function: fence_insertert::compute_fence_options - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void fence_insertert::compute_fence_options() { switch(model) @@ -1218,18 +1017,6 @@ void fence_insertert::compute_fence_options() } } -/*******************************************************************\ - -Function: fence_insertert::print_vars - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void fence_insertert::print_vars() const { instrumenter.message.statistics() @@ -1249,18 +1036,6 @@ void fence_insertert::print_vars() const << messaget::eom; } -/*******************************************************************\ - -Function: fence_insertert::get_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet fence_insertert::get_type(const irep_idt &id) { std::string copy=id2string(id); @@ -1306,18 +1081,6 @@ typet fence_insertert::get_type(const irep_idt &id) } } -/*******************************************************************\ - -Function: fence_insertert::type_component - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet fence_insertert::type_component( std::list::const_iterator it, std::list::const_iterator end, diff --git a/src/musketeer/fence_inserter.h b/src/musketeer/fence_inserter.h index 4d867b1ea90..70676a01560 100644 --- a/src/musketeer/fence_inserter.h +++ b/src/musketeer/fence_inserter.h @@ -6,6 +6,9 @@ Author: Vincent Nimal \*******************************************************************/ +/// \file +/// ILP construction for all cycles and resolution + #ifndef CPROVER_MUSKETEER_FENCE_INSERTER_H #define CPROVER_MUSKETEER_FENCE_INSERTER_H diff --git a/src/musketeer/fence_shared.cpp b/src/musketeer/fence_shared.cpp index 61d3651baf1..b53f67a5cf4 100644 --- a/src/musketeer/fence_shared.cpp +++ b/src/musketeer/fence_shared.cpp @@ -6,6 +6,7 @@ Author: Vincent Nimal \*******************************************************************/ + #include #include #include @@ -30,7 +31,7 @@ Author: Vincent Nimal #endif #define OUTPUT(s, fence, file, line, id, type) \ - s<::const_iterator diff --git a/src/musketeer/fence_user_def.h b/src/musketeer/fence_user_def.h index 1f95a4c84cf..04a1236fd46 100644 --- a/src/musketeer/fence_user_def.h +++ b/src/musketeer/fence_user_def.h @@ -7,6 +7,9 @@ Author: Vincent Nimal \*******************************************************************/ +/// \file +/// ILP construction for cycles containing user-placed fences and resolution + #ifndef CPROVER_MUSKETEER_FENCE_USER_DEF_H #define CPROVER_MUSKETEER_FENCE_USER_DEF_H diff --git a/src/musketeer/fencer.cpp b/src/musketeer/fencer.cpp index 4fc213908d4..1f612d35e3b 100644 --- a/src/musketeer/fencer.cpp +++ b/src/musketeer/fencer.cpp @@ -6,6 +6,9 @@ Author: Vincent Nimal \*******************************************************************/ +/// \file +/// Fence inference: Main + #include #include @@ -18,18 +21,6 @@ Author: Vincent Nimal #include "fence_assert.h" #include "fencer.h" -/*******************************************************************\ - -Function: fencer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void fence_weak_memory( memory_modelt model, value_setst &value_sets, diff --git a/src/musketeer/fencer.h b/src/musketeer/fencer.h index cc28d439497..b15cb631971 100644 --- a/src/musketeer/fencer.h +++ b/src/musketeer/fencer.h @@ -6,6 +6,9 @@ Author: Vincent Nimal \*******************************************************************/ +/// \file +/// Fence inference + #ifndef CPROVER_MUSKETEER_FENCER_H #define CPROVER_MUSKETEER_FENCER_H diff --git a/src/musketeer/graph_visitor.cpp b/src/musketeer/graph_visitor.cpp index a55a1bd22e5..2ecca9e8651 100644 --- a/src/musketeer/graph_visitor.cpp +++ b/src/musketeer/graph_visitor.cpp @@ -6,24 +6,15 @@ Author: Vincent Nimal \*******************************************************************/ +/// \file +/// graph visitor for computing edges involved for fencing + #include "fence_inserter.h" #include "graph_visitor.h" /* implemented: BTWN1, BTWN4 */ #define BTWN1 -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void const_graph_visitort::graph_explore( event_grapht &egraph, event_idt next, @@ -66,18 +57,6 @@ void const_graph_visitort::graph_explore( } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void const_graph_visitort::const_graph_explore( event_grapht &egraph, event_idt next, @@ -119,18 +98,6 @@ void const_graph_visitort::const_graph_explore( } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void const_graph_visitort::graph_explore_BC( event_grapht &egraph, event_idt next, @@ -193,18 +160,6 @@ void const_graph_visitort::graph_explore_BC( } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void const_graph_visitort::const_graph_explore_BC( event_grapht &egraph, event_idt next, @@ -260,18 +215,6 @@ void const_graph_visitort::const_graph_explore_BC( } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void const_graph_visitort::graph_explore_AC( event_grapht &egraph, event_idt next, @@ -332,18 +275,6 @@ void const_graph_visitort::graph_explore_AC( } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void const_graph_visitort::const_graph_explore_AC( event_grapht &egraph, event_idt next, @@ -400,18 +331,6 @@ void const_graph_visitort::const_graph_explore_AC( } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void const_graph_visitort::PT( const edget &e, std::set &edges) @@ -454,18 +373,8 @@ void const_graph_visitort::PT( edges.insert(fence_inserter.map_from_e[e]); } -/*******************************************************************\ - -Function: - - Inputs: e in comWR /\ C_j (invisible variables) - - Outputs: e's in po /\ C (problem variables) - - Purpose: - -\*******************************************************************/ - +/// \par parameters: e in comWR /\ C_j (invisible variables) +/// \return e's in po /\ C (problem variables) void const_graph_visitort::CT( const edget &edge, std::set &edges) @@ -519,18 +428,8 @@ void const_graph_visitort::CT( } } -/*******************************************************************\ - -Function: - - Inputs: e in comWR /\ C_j (invisible variables) - - Outputs: e's in poRW/\ C (problem variables) - - Purpose: - -\*******************************************************************/ - +/// \par parameters: e in comWR /\ C_j (invisible variables) +/// \return e's in poRW/\ C (problem variables) void const_graph_visitort::CT_not_powr( const edget &edge, std::set &edges) diff --git a/src/musketeer/graph_visitor.h b/src/musketeer/graph_visitor.h index 0574cae885f..2df40b7e1d3 100644 --- a/src/musketeer/graph_visitor.h +++ b/src/musketeer/graph_visitor.h @@ -6,6 +6,9 @@ Author: Vincent Nimal \*******************************************************************/ +/// \file +/// graph visitor for computing edges involved for fencing + #ifndef CPROVER_MUSKETEER_GRAPH_VISITOR_H #define CPROVER_MUSKETEER_GRAPH_VISITOR_H diff --git a/src/musketeer/ilp.h b/src/musketeer/ilp.h index cecc47fb0a8..b8cbe4e9202 100644 --- a/src/musketeer/ilp.h +++ b/src/musketeer/ilp.h @@ -6,6 +6,9 @@ Author: Vincent Nimal \*******************************************************************/ +/// \file +/// ILP structure + #ifdef HAVE_GLPK #include #endif diff --git a/src/musketeer/infer_mode.h b/src/musketeer/infer_mode.h index b163437985c..66ab97cdf36 100644 --- a/src/musketeer/infer_mode.h +++ b/src/musketeer/infer_mode.h @@ -6,6 +6,7 @@ \*******************************************************************/ + #ifndef CPROVER_MUSKETEER_INFER_MODE_H #define CPROVER_MUSKETEER_INFER_MODE_H diff --git a/src/musketeer/languages.cpp b/src/musketeer/languages.cpp index 92ceefa1a72..a7e4497a038 100644 --- a/src/musketeer/languages.cpp +++ b/src/musketeer/languages.cpp @@ -6,24 +6,15 @@ Module: Language Registration \*******************************************************************/ +/// \file +/// Language Registration + #include #include #include "musketeer_parse_options.h" -/*******************************************************************\ - -Function: goto_instrument_parse_optionst::register_languages - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_fence_inserter_parse_optionst::register_languages() { register_language(new_ansi_c_language); diff --git a/src/musketeer/musketeer_main.cpp b/src/musketeer/musketeer_main.cpp index 238283400f8..b233c0080a0 100644 --- a/src/musketeer/musketeer_main.cpp +++ b/src/musketeer/musketeer_main.cpp @@ -6,19 +6,10 @@ Author: Vincent Nimal \*******************************************************************/ -#include "musketeer_parse_options.h" - -/*******************************************************************\ - -Function: main - - Inputs: +/// \file +/// Main Module - Outputs: - - Purpose: - -\*******************************************************************/ +#include "musketeer_parse_options.h" int main(int argc, const char **argv) { diff --git a/src/musketeer/musketeer_parse_options.cpp b/src/musketeer/musketeer_parse_options.cpp index ae40a2f2318..16860e7b20d 100644 --- a/src/musketeer/musketeer_parse_options.cpp +++ b/src/musketeer/musketeer_parse_options.cpp @@ -6,6 +6,9 @@ Module: Main Module \*******************************************************************/ +/// \file +/// Main Module + #include #include #include @@ -46,18 +49,6 @@ Module: Main Module #include "replace_async.h" #include "infer_mode.h" -/*******************************************************************\ - -Function: goto_fence_inserter_parse_optionst::set_verbosity - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_fence_inserter_parse_optionst::set_verbosity() { unsigned int v=8; // default @@ -72,23 +63,12 @@ void goto_fence_inserter_parse_optionst::set_verbosity() ui_message_handler.set_verbosity(v); } -/*******************************************************************\ - -Function: goto_fence_inserter_parse_optionst::doit - - Inputs: - - Outputs: - - Purpose: invoke main modules - -\*******************************************************************/ - +/// invoke main modules int goto_fence_inserter_parse_optionst::doit() { if(cmdline.isset("version")) { - std::cout << MUSKETEER_VERSION << std::endl; + std::cout << MUSKETEER_VERSION << '\n'; return 0; } @@ -150,18 +130,6 @@ int goto_fence_inserter_parse_optionst::doit() } } -/*******************************************************************\ - -Function: goto_fence_inserter_parse_optionst::get_goto_program - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_fence_inserter_parse_optionst::get_goto_program( goto_functionst &goto_functions) { @@ -174,18 +142,6 @@ void goto_fence_inserter_parse_optionst::get_goto_program( config.set_from_symbol_table(symbol_table); } -/*******************************************************************\ - -Function: goto_fence_inserter_parse_optionst::instrument_goto_program - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_fence_inserter_parse_optionst::instrument_goto_program( goto_functionst &goto_functions) { @@ -435,18 +391,7 @@ void goto_fence_inserter_parse_optionst::instrument_goto_program( label_properties(goto_functions); } -/*******************************************************************\ - -Function: goto_fence_inserter_parse_optionst::help - - Inputs: - - Outputs: - - Purpose: display command line help - -\*******************************************************************/ - +/// display command line help void goto_fence_inserter_parse_optionst::help() { std::cout << diff --git a/src/musketeer/musketeer_parse_options.h b/src/musketeer/musketeer_parse_options.h index ca93c9de488..13d0a07ef19 100644 --- a/src/musketeer/musketeer_parse_options.h +++ b/src/musketeer/musketeer_parse_options.h @@ -6,6 +6,9 @@ Module: Command Line Parsing \*******************************************************************/ +/// \file +/// Command Line Parsing + #ifndef CPROVER_MUSKETEER_MUSKETEER_PARSE_OPTIONS_H #define CPROVER_MUSKETEER_MUSKETEER_PARSE_OPTIONS_H diff --git a/src/musketeer/pensieve.cpp b/src/musketeer/pensieve.cpp index 649182e1696..a58c4bf05de 100644 --- a/src/musketeer/pensieve.cpp +++ b/src/musketeer/pensieve.cpp @@ -6,6 +6,7 @@ Author: Vincent Nimal \*******************************************************************/ + #include #include #include @@ -16,18 +17,6 @@ Author: Vincent Nimal #include "pensieve.h" -/*******************************************************************\ - -Function: fencer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void fence_pensieve( value_setst &value_sets, symbol_tablet &symbol_table, diff --git a/src/musketeer/pensieve.h b/src/musketeer/pensieve.h index 298919f182f..9513a26c433 100644 --- a/src/musketeer/pensieve.h +++ b/src/musketeer/pensieve.h @@ -6,6 +6,9 @@ Author: Vincent Nimal \*******************************************************************/ +/// \file +/// Fence insertion following criteria of Pensieve (PPoPP'05) + #ifndef CPROVER_MUSKETEER_PENSIEVE_H #define CPROVER_MUSKETEER_PENSIEVE_H diff --git a/src/musketeer/propagate_const_function_pointers.cpp b/src/musketeer/propagate_const_function_pointers.cpp index 0fb2f0aad18..07838ce8d35 100644 --- a/src/musketeer/propagate_const_function_pointers.cpp +++ b/src/musketeer/propagate_const_function_pointers.cpp @@ -6,6 +6,9 @@ Author: Vincent Nimal \*******************************************************************/ +/// \file +/// Constant Function Pointer Propagation + #include #include #include @@ -140,20 +143,10 @@ class const_function_pointer_propagationt } }; -/*******************************************************************\ - -Function: - - Inputs: 'it' pointing to the callsite to update, 'function' the function - actually called, 'stack_scope' the place where the constant was - defined in the call stack - - Outputs: - - Purpose: - -\*******************************************************************/ - +/// \par parameters: 'it' pointing to the callsite to update, 'function' the +/// function +/// actually called, 'stack_scope' the place where the constant was +/// defined in the call stack void const_function_pointer_propagationt::dup_caller_and_inline_callee( const symbol_exprt &const_function, unsigned stack_scope) @@ -341,19 +334,8 @@ void const_function_pointer_propagationt::dup_caller_and_inline_callee( callsite_stack.swap(new_callsite_stack); } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: adds const pointers (instantiated here or propagated) passed - as arguments in the map - -\*******************************************************************/ - +/// adds const pointers (instantiated here or propagated) passed as arguments in +/// the map void const_function_pointer_propagationt::arg_stackt::add_args( const symbol_exprt &const_function, goto_programt::instructionst::iterator it) @@ -431,18 +413,6 @@ void const_function_pointer_propagationt::arg_stackt::add_args( } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void const_function_pointer_propagationt::arg_stackt::remove_args() { /* remove the parameter names */ @@ -453,18 +423,6 @@ void const_function_pointer_propagationt::arg_stackt::remove_args() } } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void const_function_pointer_propagationt::propagate( const irep_idt &function_id) { @@ -585,18 +543,6 @@ void const_function_pointer_propagationt::propagate( functions_met.erase(function_id); } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void propagate_const_function_pointers( symbol_tablet &symbol_table, goto_functionst &goto_functions, diff --git a/src/musketeer/propagate_const_function_pointers.h b/src/musketeer/propagate_const_function_pointers.h index 0749a1ac4bd..af1b5497b41 100644 --- a/src/musketeer/propagate_const_function_pointers.h +++ b/src/musketeer/propagate_const_function_pointers.h @@ -6,6 +6,9 @@ Author: Vincent Nimal \*******************************************************************/ +/// \file +/// Constant Function Pointer Propagation + #ifndef CPROVER_MUSKETEER_PROPAGATE_CONST_FUNCTION_POINTERS_H #define CPROVER_MUSKETEER_PROPAGATE_CONST_FUNCTION_POINTERS_H diff --git a/src/musketeer/replace_async.h b/src/musketeer/replace_async.h index 6ef0b710860..9f3a85e1159 100644 --- a/src/musketeer/replace_async.h +++ b/src/musketeer/replace_async.h @@ -8,6 +8,7 @@ Date: December 2013 \*******************************************************************/ + #ifndef CPROVER_MUSKETEER_REPLACE_ASYNC_H #define CPROVER_MUSKETEER_REPLACE_ASYNC_H diff --git a/src/path-symex/build_goto_trace.cpp b/src/path-symex/build_goto_trace.cpp index 4e7eafc2c94..eefb5361f5c 100644 --- a/src/path-symex/build_goto_trace.cpp +++ b/src/path-symex/build_goto_trace.cpp @@ -6,20 +6,12 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "build_goto_trace.h" - -/*******************************************************************\ - -Function: build_goto_trace - - Inputs: +/// \file +/// Build Goto Trace from State History - Outputs: - - Purpose: follow state history to build a goto trace - -\*******************************************************************/ +#include "build_goto_trace.h" +/// follow state history to build a goto trace void build_goto_trace( const path_symex_statet &state, const decision_proceduret &decision_procedure, @@ -113,7 +105,7 @@ void build_goto_trace( const irep_idt &comment= instruction.source_location.get_comment(); - if(comment!=irep_idt()) + if(!comment.empty()) trace_step.comment=id2string(comment); else trace_step.comment="assertion"; diff --git a/src/path-symex/build_goto_trace.h b/src/path-symex/build_goto_trace.h index e6fd1a6d493..beb1a0e609d 100644 --- a/src/path-symex/build_goto_trace.h +++ b/src/path-symex/build_goto_trace.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Build Goto Trace from Path Symex History + // NOLINT(build/header_guard) as this file is also symlinked #ifndef CPROVER_PATH_SYMEX_BUILD_GOTO_TRACE_H #define CPROVER_PATH_SYMEX_BUILD_GOTO_TRACE_H diff --git a/src/path-symex/loc_ref.h b/src/path-symex/loc_ref.h index 9a8ea0dc341..8f192c79583 100644 --- a/src/path-symex/loc_ref.h +++ b/src/path-symex/loc_ref.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Program Locations + #ifndef CPROVER_PATH_SYMEX_LOC_REF_H #define CPROVER_PATH_SYMEX_LOC_REF_H diff --git a/src/path-symex/locs.cpp b/src/path-symex/locs.cpp index fa8e9c4cbbd..8827605768d 100644 --- a/src/path-symex/locs.cpp +++ b/src/path-symex/locs.cpp @@ -6,19 +6,10 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "locs.h" - -/*******************************************************************\ - -Function: locst::locst - - Inputs: - - Outputs: - - Purpose: +/// \file +/// Program Locations -\*******************************************************************/ +#include "locs.h" locst::locst( const namespacet &_ns): @@ -26,18 +17,6 @@ locst::locst( { } -/*******************************************************************\ - -Function: locst::build - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void locst::build(const goto_functionst &goto_functions) { // build locations @@ -102,18 +81,6 @@ void locst::build(const goto_functionst &goto_functions) } } -/*******************************************************************\ - -Function: locst::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void locst::output(std::ostream &out) const { irep_idt function; diff --git a/src/path-symex/locs.h b/src/path-symex/locs.h index 7f626a1d2bf..67f52da1584 100644 --- a/src/path-symex/locs.h +++ b/src/path-symex/locs.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// CFG made of Program Locations, built from goto_functionst + #ifndef CPROVER_PATH_SYMEX_LOCS_H #define CPROVER_PATH_SYMEX_LOCS_H diff --git a/src/path-symex/path_replay.cpp b/src/path-symex/path_replay.cpp index 9dcb0a0c920..6044692839c 100644 --- a/src/path-symex/path_replay.cpp +++ b/src/path-symex/path_replay.cpp @@ -6,19 +6,10 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "path_replay.h" - -/*******************************************************************\ - -Function: path_replayt::get_branches - - Inputs: +/// \file +/// Dense Data Structure for Path Replay - Outputs: - - Purpose: - -\*******************************************************************/ +#include "path_replay.h" void get_branches(path_symex_step_reft history) { diff --git a/src/path-symex/path_replay.h b/src/path-symex/path_replay.h index 70861e8e5a8..27b6359af9e 100644 --- a/src/path-symex/path_replay.h +++ b/src/path-symex/path_replay.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Dense Data Structure for Path Replay + #ifndef CPROVER_PATH_SYMEX_PATH_REPLAY_H #define CPROVER_PATH_SYMEX_PATH_REPLAY_H diff --git a/src/path-symex/path_symex.cpp b/src/path-symex/path_symex.cpp index eb58b330ab6..3ae6b858b7f 100644 --- a/src/path-symex/path_symex.cpp +++ b/src/path-symex/path_symex.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Concrete Symbolic Transformer + #include #include #include @@ -13,7 +16,7 @@ Author: Daniel Kroening, kroening@kroening.com #include #include #include -#include +#include #include @@ -26,18 +29,6 @@ Author: Daniel Kroening, kroening@kroening.com #include #endif -/*******************************************************************\ - -Function: path_symext::propagate - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool path_symext::propagate(const exprt &src) { // propagate things that are 'simple enough' @@ -97,18 +88,6 @@ bool path_symext::propagate(const exprt &src) } } -/*******************************************************************\ - -Function: path_symext::assign - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void path_symext::assign( path_symex_statet &state, const exprt &lhs, @@ -152,18 +131,6 @@ void path_symext::assign( assign_rec(state, _guard, ssa_lhs, ssa_rhs); } -/*******************************************************************\ - -Function: path_symext::symex_malloc - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - inline static typet c_sizeof_type_rec(const exprt &expr) { const irept &sizeof_type=expr.find(ID_C_c_sizeof_type); @@ -300,18 +267,6 @@ void path_symext::symex_malloc( } -/*******************************************************************\ - -Function: get_old_va_symb - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static irep_idt get_old_va_symbol( const path_symex_statet &state, const exprt &src) @@ -329,18 +284,6 @@ static irep_idt get_old_va_symbol( return irep_idt(); } -/*******************************************************************\ - -Function: path_symext::symex_va_arg_next - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void path_symext::symex_va_arg_next( path_symex_statet &state, const exprt &lhs, @@ -400,18 +343,6 @@ void path_symext::symex_va_arg_next( assign(state, lhs, rhs); } -/*******************************************************************\ - -Function: path_symext::assign_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void path_symext::assign_rec( path_symex_statet &state, exprt::operandst &guard, @@ -421,8 +352,8 @@ void path_symext::assign_rec( // const typet &ssa_lhs_type=state.var_map.ns.follow(ssa_lhs.type()); #ifdef DEBUG - std::cout << "assign_rec: " << ssa_lhs.pretty() << std::endl; - // std::cout << "ssa_lhs_type: " << ssa_lhs_type.id() << std::endl; + std::cout << "assign_rec: " << ssa_lhs.pretty() << '\n'; + // std::cout << "ssa_lhs_type: " << ssa_lhs_type.id() << '\n'; #endif if(ssa_lhs.id()==ID_symbol) @@ -435,8 +366,8 @@ void path_symext::assign_rec( #ifdef DEBUG const irep_idt &ssa_identifier=symbol_expr.get_identifier(); - std::cout << "SSA symbol identifier: " << ssa_identifier << std::endl; - std::cout << "full identifier: " << full_identifier << std::endl; + std::cout << "SSA symbol identifier: " << ssa_identifier << '\n'; + std::cout << "full identifier: " << full_identifier << '\n'; #endif var_mapt::var_infot &var_info=state.var_map[full_identifier]; @@ -447,7 +378,7 @@ void path_symext::assign_rec( symbol_exprt new_lhs=var_info.ssa_symbol(); #ifdef DEBUG - std::cout << "new_lhs: " << new_lhs.get_identifier() << std::endl; + std::cout << "new_lhs: " << new_lhs.get_identifier() << '\n'; #endif // record new state of lhs @@ -469,8 +400,8 @@ void path_symext::assign_rec( if(!base_type_eq(ssa_rhs.type(), new_lhs.type(), state.var_map.ns)) { #ifdef DEBUG - std::cout << "ssa_rhs: " << ssa_rhs.pretty() << std::endl; - std::cout << "new_lhs: " << new_lhs.pretty() << std::endl; + std::cout << "ssa_rhs: " << ssa_rhs.pretty() << '\n'; + std::cout << "new_lhs: " << new_lhs.pretty() << '\n'; #endif throw "assign_rec got different types"; } @@ -493,7 +424,7 @@ void path_symext::assign_rec( else if(ssa_lhs.id()==ID_member) { #ifdef DEBUG - std::cout << "assign_rec ID_member" << std::endl; + std::cout << "assign_rec ID_member\n"; #endif const member_exprt &ssa_lhs_member_expr=to_member_expr(ssa_lhs); @@ -532,7 +463,7 @@ void path_symext::assign_rec( else if(ssa_lhs.id()==ID_index) { #ifdef DEBUG - std::cout << "assign_rec ID_index" << std::endl; + std::cout << "assign_rec ID_index\n"; #endif throw "unexpected array index on lhs"; @@ -540,7 +471,7 @@ void path_symext::assign_rec( else if(ssa_lhs.id()==ID_dereference) { #ifdef DEBUG - std::cout << "assign_rec ID_dereference" << std::endl; + std::cout << "assign_rec ID_dereference\n"; #endif throw "unexpected dereference on lhs"; @@ -548,7 +479,7 @@ void path_symext::assign_rec( else if(ssa_lhs.id()==ID_if) { #ifdef DEBUG - std::cout << "assign_rec ID_if" << std::endl; + std::cout << "assign_rec ID_if\n"; #endif const if_exprt &lhs_if_expr=to_if_expr(ssa_lhs); @@ -568,7 +499,7 @@ void path_symext::assign_rec( ssa_lhs.id()==ID_byte_extract_big_endian) { #ifdef DEBUG - std::cout << "assign_rec ID_byte_extract" << std::endl; + std::cout << "assign_rec ID_byte_extract\n"; #endif const byte_extract_exprt &byte_extract_expr= @@ -679,18 +610,6 @@ void path_symext::assign_rec( } } -/*******************************************************************\ - -Function: path_symext::function_call_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void path_symext::function_call_rec( path_symex_statet &state, const code_function_callt &call, @@ -698,7 +617,7 @@ void path_symext::function_call_rec( std::list &further_states) { #ifdef DEBUG - std::cout << "function_call_rec: " << function.pretty() << std::endl; + std::cout << "function_call_rec: " << function.pretty() << '\n'; #endif if(function.id()==ID_symbol) @@ -780,7 +699,7 @@ void path_symext::function_call_rec( const code_typet::parametert &function_parameter=function_parameters[i]; irep_idt identifier=function_parameter.get_identifier(); - if(identifier==irep_idt()) + if(identifier.empty()) throw "function_call " + id2string(function_identifier) + " no identifier for function parameter"; @@ -874,18 +793,6 @@ void path_symext::function_call_rec( throw "TODO: function_call "+function.id_string(); } -/*******************************************************************\ - -Function: path_symext::return_from_function - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void path_symext::return_from_function(path_symex_statet &state) { path_symex_statet::threadt &thread=state.threads[state.get_current_thread()]; @@ -921,18 +828,6 @@ void path_symext::return_from_function(path_symex_statet &state) } } -/*******************************************************************\ - -Function: path_symext::set_return_value - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void path_symext::set_return_value( path_symex_statet &state, const exprt &v) @@ -945,18 +840,6 @@ void path_symext::set_return_value( thread.call_stack.back().return_rhs=v; } -/*******************************************************************\ - -Function: path_symext::do_goto - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void path_symext::do_goto( path_symex_statet &state, std::list &further_states) @@ -1002,18 +885,6 @@ void path_symext::do_goto( state.history->guard=negated_guard; } -/*******************************************************************\ - -Function: path_symext::do_goto - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void path_symext::do_goto( path_symex_statet &state, bool taken) @@ -1050,18 +921,6 @@ void path_symext::do_goto( } } -/*******************************************************************\ - -Function: path_symext::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void path_symext::operator()( path_symex_statet &state, std::list &further_states) @@ -1073,7 +932,7 @@ void path_symext::operator()( std::cout << "path_symext::operator(): " << state.pc() << " " << instruction.type - << std::endl; + << '\n'; #endif switch(instruction.type) @@ -1224,18 +1083,6 @@ void path_symext::operator()( } } -/*******************************************************************\ - -Function: path_symext::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void path_symext::operator()(path_symex_statet &state) { std::list further_states; @@ -1244,18 +1091,6 @@ void path_symext::operator()(path_symex_statet &state) throw "path_symext got unexpected further states"; } -/*******************************************************************\ - -Function: path_symex - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void path_symex( path_symex_statet &state, std::list &further_states) @@ -1264,36 +1099,12 @@ void path_symex( path_symex(state, further_states); } -/*******************************************************************\ - -Function: path_symex - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void path_symex(path_symex_statet &state) { path_symext path_symex; path_symex(state); } -/*******************************************************************\ - -Function: path_symex_goto - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void path_symex_goto( path_symex_statet &state, bool taken) @@ -1302,18 +1113,6 @@ void path_symex_goto( path_symex.do_goto(state, taken); } -/*******************************************************************\ - -Function: path_symex_assert_fail - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void path_symex_assert_fail(path_symex_statet &state) { path_symext path_symex; diff --git a/src/path-symex/path_symex.h b/src/path-symex/path_symex.h index 731ea87608e..cc7a8912783 100644 --- a/src/path-symex/path_symex.h +++ b/src/path-symex/path_symex.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Concrete Symbolic Transformer + // NOLINT(build/header_guard) as this file is also symlinked #ifndef CPROVER_PATH_SYMEX_PATH_SYMEX_H #define CPROVER_PATH_SYMEX_PATH_SYMEX_H diff --git a/src/path-symex/path_symex_class.h b/src/path-symex/path_symex_class.h index 4eec3d4ff4c..933b871e9fa 100644 --- a/src/path-symex/path_symex_class.h +++ b/src/path-symex/path_symex_class.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Concrete Symbolic Transformer + #ifndef CPROVER_PATH_SYMEX_PATH_SYMEX_CLASS_H #define CPROVER_PATH_SYMEX_PATH_SYMEX_CLASS_H diff --git a/src/path-symex/path_symex_history.cpp b/src/path-symex/path_symex_history.cpp index 7829f72c67a..502f3af19eb 100644 --- a/src/path-symex/path_symex_history.cpp +++ b/src/path-symex/path_symex_history.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// History of path-based symbolic simulator + #include #include @@ -14,18 +17,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "path_symex_history.h" -/*******************************************************************\ - -Function: path_symex_stept::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void path_symex_stept::output(std::ostream &out) const { out << "PCs:"; @@ -45,18 +36,6 @@ void path_symex_stept::output(std::ostream &out) const out << "\n"; } -/*******************************************************************\ - -Function: path_symex_stept::convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void path_symex_stept::convert(decision_proceduret &dest) const { if(ssa_rhs.is_not_nil()) @@ -66,18 +45,6 @@ void path_symex_stept::convert(decision_proceduret &dest) const dest << guard; } -/*******************************************************************\ - -Function: path_symex_step_reft::build_history - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void path_symex_step_reft::build_history( std::vector &dest) const { diff --git a/src/path-symex/path_symex_history.h b/src/path-symex/path_symex_history.h index 3847138dc71..35cfcb6d591 100644 --- a/src/path-symex/path_symex_history.h +++ b/src/path-symex/path_symex_history.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// History for path-based symbolic simulator + #ifndef CPROVER_PATH_SYMEX_PATH_SYMEX_HISTORY_H #define CPROVER_PATH_SYMEX_PATH_SYMEX_HISTORY_H diff --git a/src/path-symex/path_symex_state.cpp b/src/path-symex/path_symex_state.cpp index ebb7dda863a..293de5966c0 100644 --- a/src/path-symex/path_symex_state.cpp +++ b/src/path-symex/path_symex_state.cpp @@ -6,11 +6,14 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// State of path-based symbolic simulator + #include #include #include -#include +#include #include @@ -23,18 +26,6 @@ Author: Daniel Kroening, kroening@kroening.com #include #endif -/*******************************************************************\ - -Function: initial_state - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - path_symex_statet initial_state( var_mapt &var_map, const locst &locs, @@ -50,82 +41,34 @@ path_symex_statet initial_state( return s; } -/*******************************************************************\ - -Function: path_symex_statet::get_pc - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - loc_reft path_symex_statet::get_pc() const { assert(current_threadreturn_location << std::endl; - out << std::endl; + out << " " << it->return_location << '\n'; + out << '\n'; } -/*******************************************************************\ - -Function: path_symex_statet::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void path_symex_statet::output(std::ostream &out) const { for(unsigned t=0; t #include @@ -18,22 +21,10 @@ Author: Daniel Kroening, kroening@kroening.com #include #endif -/*******************************************************************\ - -Function: path_symex_statet::read - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt path_symex_statet::read(const exprt &src, bool propagate) { #ifdef DEBUG - // std::cout << "path_symex_statet::read " << src.pretty() << std::endl; + // std::cout << "path_symex_statet::read " << src.pretty() << '\n'; #endif // This has three phases! @@ -49,29 +40,17 @@ exprt path_symex_statet::read(const exprt &src, bool propagate) exprt tmp5=simplify_expr(tmp4, var_map.ns); #ifdef DEBUG - // std::cout << " ==> " << tmp.pretty() << std::endl; + // std::cout << " ==> " << tmp.pretty() << '\n'; #endif return tmp5; } -/*******************************************************************\ - -Function: path_symex_statet::expand_structs_and_arrays - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt path_symex_statet::expand_structs_and_arrays(const exprt &src) { #ifdef DEBUG std::cout << "expand_structs_and_arrays: " - << from_expr(var_map.ns, "", src) << std::endl; + << from_expr(var_map.ns, "", src) << '\n'; #endif const typet &src_type=var_map.ns.follow(src.type()); @@ -180,18 +159,6 @@ exprt path_symex_statet::expand_structs_and_arrays(const exprt &src) return src; } -/*******************************************************************\ - -Function: path_symex_statet::array_theory - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt path_symex_statet::array_theory(const exprt &src, bool propagate) { // top-level constant-sized arrays only right now @@ -244,25 +211,13 @@ exprt path_symex_statet::array_theory(const exprt &src, bool propagate) return src; } -/*******************************************************************\ - -Function: path_symex_statet::instantiate_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt path_symex_statet::instantiate_rec( const exprt &src, bool propagate) { #ifdef DEBUG std::cout << "instantiate_rec: " - << from_expr(var_map.ns, "", src) << std::endl; + << from_expr(var_map.ns, "", src) << '\n'; #endif // check whether this is a symbol(.member|[index])* @@ -348,18 +303,6 @@ exprt path_symex_statet::instantiate_rec( return src2; } -/*******************************************************************\ - -Function: path_symex_statet::read_symbol_member_index - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt path_symex_statet::read_symbol_member_index( const exprt &src, bool propagate) @@ -451,7 +394,7 @@ exprt path_symex_statet::read_symbol_member_index( #ifdef DEBUG std::cout << "read_symbol_member_index_rec " << identifier - << " var_info " << var_info.full_identifier << std::endl; + << " var_info " << var_info.full_identifier << '\n'; #endif // warning: reference is not stable @@ -464,7 +407,7 @@ exprt path_symex_statet::read_symbol_member_index( else { // we do some SSA symbol - if(var_state.ssa_symbol.get_identifier()==irep_idt()) + if(var_state.ssa_symbol.get_identifier().empty()) { // produce one var_state.ssa_symbol=var_info.ssa_symbol(); @@ -474,18 +417,6 @@ exprt path_symex_statet::read_symbol_member_index( } } -/*******************************************************************\ - -Function: path_symex_statet::is_symbol_member_index - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool path_symex_statet::is_symbol_member_index(const exprt &src) const { const typet final_type=src.type(); @@ -539,18 +470,6 @@ bool path_symex_statet::is_symbol_member_index(const exprt &src) const } } -/*******************************************************************\ - -Function: path_symex_statet::array_index_as_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string path_symex_statet::array_index_as_string(const exprt &src) const { exprt tmp=simplify_expr(src, var_map.ns); @@ -562,18 +481,6 @@ std::string path_symex_statet::array_index_as_string(const exprt &src) const return "[*]"; } -/*******************************************************************\ - -Function: path_symex_statet::dereference_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt path_symex_statet::dereference_rec( const exprt &src, bool propagate) @@ -610,24 +517,12 @@ exprt path_symex_statet::dereference_rec( return src2; } -/*******************************************************************\ - -Function: path_symex_statet::instantiate_rec_address - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt path_symex_statet::instantiate_rec_address( const exprt &src, bool propagate) { #ifdef DEBUG - std::cout << "instantiate_rec_address: " << src.id() << std::endl; + std::cout << "instantiate_rec_address: " << src.id() << '\n'; #endif if(src.id()==ID_symbol) @@ -687,7 +582,7 @@ exprt path_symex_statet::instantiate_rec_address( { // this shouldn't really happen #ifdef DEBUG - std::cout << "SRC: " << src.pretty() << std::endl; + std::cout << "SRC: " << src.pretty() << '\n'; #endif throw "address of unexpected `"+src.id_string()+"'"; } diff --git a/src/path-symex/var_map.cpp b/src/path-symex/var_map.cpp index d981cf1cca9..97563e31240 100644 --- a/src/path-symex/var_map.cpp +++ b/src/path-symex/var_map.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Variable Numbering + #include #include @@ -14,24 +17,12 @@ Author: Daniel Kroening, kroening@kroening.com #include "var_map.h" -/*******************************************************************\ - -Function: var_mapt::var_infot::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - var_mapt::var_infot &var_mapt::operator()( const irep_idt &symbol, const irep_idt &suffix, const typet &type) { - assert(symbol!=irep_idt()); + assert(!symbol.empty()); std::string full_identifier= id2string(symbol)+id2string(suffix); @@ -53,18 +44,6 @@ var_mapt::var_infot &var_mapt::operator()( return result.first->second; } -/*******************************************************************\ - -Function: var_mapt::var_infot::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void var_mapt::var_infot::output(std::ostream &out) const { out << "full_identifier: " << full_identifier << "\n"; @@ -89,18 +68,6 @@ void var_mapt::var_infot::output(std::ostream &out) const out << "\n"; } -/*******************************************************************\ - -Function: var_mapt::init - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void var_mapt::init(var_infot &var_info) { if(has_prefix(id2string(var_info.symbol), "symex_dynamic::")) @@ -141,36 +108,12 @@ void var_mapt::init(var_infot &var_info) var_info.number=local_count++; } -/*******************************************************************\ - -Function: var_mapt::var_infot::ssa_identifier - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - irep_idt var_mapt::var_infot::ssa_identifier() const { return id2string(full_identifier)+ "#"+std::to_string(ssa_counter); } -/*******************************************************************\ - -Function: var_mapt::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void var_mapt::output(std::ostream &out) const { for(id_mapt::const_iterator diff --git a/src/path-symex/var_map.h b/src/path-symex/var_map.h index cb5c7c7d9f5..11ffcdbdc49 100644 --- a/src/path-symex/var_map.h +++ b/src/path-symex/var_map.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Variable Numbering + #ifndef CPROVER_PATH_SYMEX_VAR_MAP_H #define CPROVER_PATH_SYMEX_VAR_MAP_H diff --git a/src/pointer-analysis/add_failed_symbols.cpp b/src/pointer-analysis/add_failed_symbols.cpp index 0a8f757a6d8..5def51a4499 100644 --- a/src/pointer-analysis/add_failed_symbols.cpp +++ b/src/pointer-analysis/add_failed_symbols.cpp @@ -6,41 +6,20 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Pointer Dereferencing + #include #include #include #include "add_failed_symbols.h" -/*******************************************************************\ - -Function: failed_symbol_id - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - irep_idt failed_symbol_id(const irep_idt &id) { return id2string(id)+"$object"; } -/*******************************************************************\ - -Function: add_failed_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void add_failed_symbol(symbolt &symbol, symbol_tablet &symbol_table) { if(!symbol.is_lvalue) @@ -70,18 +49,6 @@ void add_failed_symbol(symbolt &symbol, symbol_tablet &symbol_table) } } -/*******************************************************************\ - -Function: add_failed_symbols - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void add_failed_symbols(symbol_tablet &symbol_table) { // the symbol table iterators are not stable, and @@ -102,18 +69,6 @@ void add_failed_symbols(symbol_tablet &symbol_table) } } -/*******************************************************************\ - -Function: get_failed_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt get_failed_symbol( const symbol_exprt &expr, const namespacet &ns) @@ -121,7 +76,7 @@ exprt get_failed_symbol( const symbolt &symbol=ns.lookup(expr); irep_idt failed_symbol_id=symbol.type.get(ID_C_failed_symbol); - if(failed_symbol_id==irep_idt()) + if(failed_symbol_id.empty()) return nil_exprt(); const symbolt &failed_symbol=ns.lookup(failed_symbol_id); diff --git a/src/pointer-analysis/add_failed_symbols.h b/src/pointer-analysis/add_failed_symbols.h index ce1a3b97c9a..2ae2228f564 100644 --- a/src/pointer-analysis/add_failed_symbols.h +++ b/src/pointer-analysis/add_failed_symbols.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Pointer Dereferencing + #ifndef CPROVER_POINTER_ANALYSIS_ADD_FAILED_SYMBOLS_H #define CPROVER_POINTER_ANALYSIS_ADD_FAILED_SYMBOLS_H diff --git a/src/pointer-analysis/dereference.cpp b/src/pointer-analysis/dereference.cpp index 8638dff9e67..5b4baf0b02f 100644 --- a/src/pointer-analysis/dereference.cpp +++ b/src/pointer-analysis/dereference.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbolic Execution of ANSI-C + #ifdef DEBUG #include #include @@ -18,22 +21,12 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -#include +#include #include "dereference.h" -/*******************************************************************\ - -Function: dereferencet::operator() - - Inputs: expression, to be dereferenced - - Outputs: returns object after dereferencing - - Purpose: - -\*******************************************************************/ - +/// \par parameters: expression, to be dereferenced +/// \return returns object after dereferencing exprt dereferencet::operator()(const exprt &pointer) { if(pointer.type().id()!=ID_pointer) @@ -44,7 +37,7 @@ exprt dereferencet::operator()(const exprt &pointer) const typet &type=pointer.type().subtype(); #ifdef DEBUG - std::cout << "DEREF: " << from_expr(ns, "", pointer) << std::endl; + std::cout << "DEREF: " << from_expr(ns, "", pointer) << '\n'; #endif return dereference_rec( @@ -53,18 +46,6 @@ exprt dereferencet::operator()(const exprt &pointer) type); } -/*******************************************************************\ - -Function: dereferencet::read_object - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt dereferencet::read_object( const exprt &object, const exprt &offset, @@ -169,18 +150,6 @@ exprt dereferencet::read_object( return binary_exprt(object, byte_extract_id(), simplified_offset, dest_type); } -/*******************************************************************\ - -Function: dereferencet::dereference_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt dereferencet::dereference_rec( const exprt &address, const exprt &offset, @@ -235,18 +204,6 @@ exprt dereferencet::dereference_rec( } } -/*******************************************************************\ - -Function: dereferencet::dereference_if - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt dereferencet::dereference_if( const if_exprt &expr, const exprt &offset, @@ -259,18 +216,6 @@ exprt dereferencet::dereference_if( return if_exprt(expr.cond(), true_case, false_case); } -/*******************************************************************\ - -Function: dereferencet::dereference_plus - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt dereferencet::dereference_plus( const exprt &expr, const exprt &offset, @@ -306,18 +251,6 @@ exprt dereferencet::dereference_plus( return dereference_rec(pointer, new_offset, type); } -/*******************************************************************\ - -Function: dereferencet::dereference_typecast - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt dereferencet::dereference_typecast( const typecast_exprt &expr, const exprt &offset, @@ -350,18 +283,6 @@ exprt dereferencet::dereference_typecast( throw "dereferencet: unexpected cast"; } -/*******************************************************************\ - -Function: dereferencet::type_compatible - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool dereferencet::type_compatible( const typet &object_type, const typet &dereference_type) const diff --git a/src/pointer-analysis/dereference.h b/src/pointer-analysis/dereference.h index 5036f702cde..968395b604f 100644 --- a/src/pointer-analysis/dereference.h +++ b/src/pointer-analysis/dereference.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Pointer Dereferencing + #ifndef CPROVER_POINTER_ANALYSIS_DEREFERENCE_H #define CPROVER_POINTER_ANALYSIS_DEREFERENCE_H diff --git a/src/pointer-analysis/dereference_callback.cpp b/src/pointer-analysis/dereference_callback.cpp index c13e2f359e4..a28a51892e1 100644 --- a/src/pointer-analysis/dereference_callback.cpp +++ b/src/pointer-analysis/dereference_callback.cpp @@ -6,19 +6,10 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "dereference_callback.h" - -/*******************************************************************\ - -Function: dereference_callbackt::~dereference_callbackt - - Inputs: +/// \file +/// Pointer Dereferencing - Outputs: - - Purpose: - -\*******************************************************************/ +#include "dereference_callback.h" dereference_callbackt::~dereference_callbackt() { diff --git a/src/pointer-analysis/dereference_callback.h b/src/pointer-analysis/dereference_callback.h index 9d9d1b69449..d02ea726f4b 100644 --- a/src/pointer-analysis/dereference_callback.h +++ b/src/pointer-analysis/dereference_callback.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Pointer Dereferencing + #ifndef CPROVER_POINTER_ANALYSIS_DEREFERENCE_CALLBACK_H #define CPROVER_POINTER_ANALYSIS_DEREFERENCE_CALLBACK_H diff --git a/src/pointer-analysis/goto_program_dereference.cpp b/src/pointer-analysis/goto_program_dereference.cpp index 3370abe7635..44340aa0fc4 100644 --- a/src/pointer-analysis/goto_program_dereference.cpp +++ b/src/pointer-analysis/goto_program_dereference.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Dereferencing Operations on GOTO Programs + #include #include #include @@ -15,18 +18,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_program_dereference.h" -/*******************************************************************\ - -Function: goto_program_dereferencet::has_failed_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool goto_program_dereferencet::has_failed_symbol( const exprt &expr, const symbolt *&symbol) @@ -41,7 +32,7 @@ bool goto_program_dereferencet::has_failed_symbol( const irep_idt &failed_symbol= ptr_symbol.type.get("#failed_symbol"); - if(failed_symbol==irep_idt()) + if(failed_symbol.empty()) return false; return !ns.lookup(failed_symbol, symbol); @@ -50,18 +41,6 @@ bool goto_program_dereferencet::has_failed_symbol( return false; } -/*******************************************************************\ - -Function: goto_program_dereferencet::is_valid_object - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool goto_program_dereferencet::is_valid_object( const irep_idt &identifier) { @@ -84,18 +63,6 @@ bool goto_program_dereferencet::is_valid_object( return false; } -/*******************************************************************\ - -Function: goto_program_dereferencet::dereference_failure - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_program_dereferencet::dereference_failure( const std::string &property, const std::string &msg, @@ -125,18 +92,6 @@ void goto_program_dereferencet::dereference_failure( } } -/*******************************************************************\ - -Function: goto_program_dereferencet::dereference_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_program_dereferencet::dereference_rec( exprt &expr, guardt &guard, @@ -274,18 +229,6 @@ void goto_program_dereferencet::dereference_rec( } } -/*******************************************************************\ - -Function: goto_program_dereferencet::get_value_set - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_program_dereferencet::get_value_set( const exprt &expr, value_setst::valuest &dest) @@ -293,18 +236,6 @@ void goto_program_dereferencet::get_value_set( value_sets.get_values(current_target, expr, dest); } -/*******************************************************************\ - -Function: goto_program_dereferencet::dereference_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_program_dereferencet::dereference_expr( exprt &expr, const bool checks_only, @@ -321,18 +252,6 @@ void goto_program_dereferencet::dereference_expr( dereference_rec(expr, guard, mode); } -/*******************************************************************\ - -Function: goto_program_dereferencet::dereference_program - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_program_dereferencet::dereference_program( goto_programt &goto_program, bool checks_only) @@ -357,18 +276,6 @@ void goto_program_dereferencet::dereference_program( } } -/*******************************************************************\ - -Function: goto_program_dereferencet::dereference - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_program_dereferencet::dereference_program( goto_functionst &goto_functions, bool checks_only) @@ -380,18 +287,6 @@ void goto_program_dereferencet::dereference_program( dereference_program(it->second.body, checks_only); } -/*******************************************************************\ - -Function: goto_program_dereferencet::dereference - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_program_dereferencet::dereference_instruction( goto_programt::targett target, bool checks_only) @@ -457,18 +352,6 @@ void goto_program_dereferencet::dereference_instruction( } } -/*******************************************************************\ - -Function: goto_program_dereferencet::dereference - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_program_dereferencet::dereference_expression( goto_programt::const_targett target, exprt &expr) @@ -481,54 +364,18 @@ void goto_program_dereferencet::dereference_expression( dereference_expr(expr, false, value_set_dereferencet::modet::READ); } -/*******************************************************************\ - -Function: goto_program_dereferencet::pointer_checks - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_program_dereferencet::pointer_checks( goto_programt &goto_program) { dereference_program(goto_program, true); } -/*******************************************************************\ - -Function: goto_program_dereferencet::pointer_checks - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void goto_program_dereferencet::pointer_checks( goto_functionst &goto_functions) { dereference_program(goto_functions, true); } -/*******************************************************************\ - -Function: remove_pointers - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void remove_pointers( goto_programt &goto_program, symbol_tablet &symbol_table, @@ -544,18 +391,6 @@ void remove_pointers( goto_program_dereference.dereference_program(goto_program); } -/*******************************************************************\ - -Function: remove_pointers - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void remove_pointers( goto_functionst &goto_functions, symbol_tablet &symbol_table, @@ -572,18 +407,6 @@ void remove_pointers( goto_program_dereference.dereference_program(it->second.body); } -/*******************************************************************\ - -Function: pointer_checks - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void pointer_checks( goto_programt &goto_program, symbol_tablet &symbol_table, @@ -596,18 +419,6 @@ void pointer_checks( goto_program_dereference.pointer_checks(goto_program); } -/*******************************************************************\ - -Function: pointer_checks - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void pointer_checks( goto_functionst &goto_functions, symbol_tablet &symbol_table, @@ -620,18 +431,6 @@ void pointer_checks( goto_program_dereference.pointer_checks(goto_functions); } -/*******************************************************************\ - -Function: dereference - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dereference( goto_programt::const_targett target, exprt &expr, diff --git a/src/pointer-analysis/goto_program_dereference.h b/src/pointer-analysis/goto_program_dereference.h index 33904035fdc..c2fb0e9a1ff 100644 --- a/src/pointer-analysis/goto_program_dereference.h +++ b/src/pointer-analysis/goto_program_dereference.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Value Set + #ifndef CPROVER_POINTER_ANALYSIS_GOTO_PROGRAM_DEREFERENCE_H #define CPROVER_POINTER_ANALYSIS_GOTO_PROGRAM_DEREFERENCE_H diff --git a/src/pointer-analysis/object_numbering.h b/src/pointer-analysis/object_numbering.h index beddfb76ab6..6e731bd072c 100644 --- a/src/pointer-analysis/object_numbering.h +++ b/src/pointer-analysis/object_numbering.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Value Set + #ifndef CPROVER_POINTER_ANALYSIS_OBJECT_NUMBERING_H #define CPROVER_POINTER_ANALYSIS_OBJECT_NUMBERING_H diff --git a/src/pointer-analysis/pointer_offset_sum.cpp b/src/pointer-analysis/pointer_offset_sum.cpp index e0fa65ab519..ba6a17d2074 100644 --- a/src/pointer-analysis/pointer_offset_sum.cpp +++ b/src/pointer-analysis/pointer_offset_sum.cpp @@ -6,19 +6,10 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "pointer_offset_sum.h" - -/*******************************************************************\ - -Function: pointer_offset_sum - - Inputs: +/// \file +/// Pointer Analysis - Outputs: - - Purpose: - -\*******************************************************************/ +#include "pointer_offset_sum.h" exprt pointer_offset_sum(const exprt &a, const exprt &b) { diff --git a/src/pointer-analysis/pointer_offset_sum.h b/src/pointer-analysis/pointer_offset_sum.h index c5569cf1685..e4e6dc238ff 100644 --- a/src/pointer-analysis/pointer_offset_sum.h +++ b/src/pointer-analysis/pointer_offset_sum.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Pointer Dereferencing + #ifndef CPROVER_POINTER_ANALYSIS_POINTER_OFFSET_SUM_H #define CPROVER_POINTER_ANALYSIS_POINTER_OFFSET_SUM_H diff --git a/src/pointer-analysis/rewrite_index.cpp b/src/pointer-analysis/rewrite_index.cpp index 61e10530738..1594267afbd 100644 --- a/src/pointer-analysis/rewrite_index.cpp +++ b/src/pointer-analysis/rewrite_index.cpp @@ -6,22 +6,14 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Pointer Dereferencing + #include #include "rewrite_index.h" -/*******************************************************************\ - -Function: rewrite_index - - Inputs: - - Outputs: - - Purpose: rewrite a[i] to *(a+i) - -\*******************************************************************/ - +/// rewrite a[i] to *(a+i) dereference_exprt rewrite_index(const index_exprt &index_expr) { dereference_exprt result; diff --git a/src/pointer-analysis/rewrite_index.h b/src/pointer-analysis/rewrite_index.h index ee5f3b9bbfa..26cf5b19513 100644 --- a/src/pointer-analysis/rewrite_index.h +++ b/src/pointer-analysis/rewrite_index.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Pointer Dereferencing + #ifndef CPROVER_POINTER_ANALYSIS_REWRITE_INDEX_H #define CPROVER_POINTER_ANALYSIS_REWRITE_INDEX_H diff --git a/src/pointer-analysis/show_value_sets.cpp b/src/pointer-analysis/show_value_sets.cpp index cd5f4c84e17..be1b1893ba4 100644 --- a/src/pointer-analysis/show_value_sets.cpp +++ b/src/pointer-analysis/show_value_sets.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Show Value Sets + #include #include @@ -13,18 +16,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "value_set_analysis.h" #include "show_value_sets.h" -/*******************************************************************\ - -Function: show_value_sets - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void show_value_sets( ui_message_handlert::uit ui, const goto_functionst &goto_functions, @@ -36,7 +27,7 @@ void show_value_sets( { xmlt xml; convert(goto_functions, value_set_analysis, xml); - std::cout << xml << std::endl; + std::cout << xml << '\n'; } break; @@ -50,18 +41,6 @@ void show_value_sets( } } -/*******************************************************************\ - -Function: show_value_sets - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void show_value_sets( ui_message_handlert::uit ui, const goto_programt &goto_program, @@ -73,7 +52,7 @@ void show_value_sets( { xmlt xml; convert(goto_program, value_set_analysis, xml); - std::cout << xml << std::endl; + std::cout << xml << '\n'; } break; diff --git a/src/pointer-analysis/show_value_sets.h b/src/pointer-analysis/show_value_sets.h index b98acbacd93..d25b7addd4e 100644 --- a/src/pointer-analysis/show_value_sets.h +++ b/src/pointer-analysis/show_value_sets.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Show Value Sets + #ifndef CPROVER_POINTER_ANALYSIS_SHOW_VALUE_SETS_H #define CPROVER_POINTER_ANALYSIS_SHOW_VALUE_SETS_H diff --git a/src/pointer-analysis/value_set.cpp b/src/pointer-analysis/value_set.cpp index b35952dc064..9c30fbe3ca7 100644 --- a/src/pointer-analysis/value_set.cpp +++ b/src/pointer-analysis/value_set.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Value Set + #include #include @@ -19,7 +22,7 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -#include +#include #ifdef DEBUG #include @@ -32,18 +35,6 @@ Author: Daniel Kroening, kroening@kroening.com const value_sett::object_map_dt value_sett::object_map_dt::blank; object_numberingt value_sett::object_numbering; -/*******************************************************************\ - -Function: value_sett::field_sensitive - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_sett::field_sensitive( const irep_idt &id, const typet &type, @@ -59,18 +50,6 @@ bool value_sett::field_sensitive( return ns.follow(type).id()==ID_struct; } -/*******************************************************************\ - -Function: value_sett::insert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - value_sett::entryt &value_sett::get_entry( const entryt &e, const typet &type, @@ -89,18 +68,6 @@ value_sett::entryt &value_sett::get_entry( return r.first->second; } -/*******************************************************************\ - -Function: value_sett::insert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_sett::insert( object_mapt &dest, unsigned n, @@ -126,18 +93,6 @@ bool value_sett::insert( } } -/*******************************************************************\ - -Function: value_sett::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_sett::output( const namespacet &ns, std::ostream &out) const @@ -224,22 +179,10 @@ void value_sett::output( } } - out << " } " << std::endl; + out << " } \n"; } } -/*******************************************************************\ - -Function: value_sett::to_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt value_sett::to_expr(object_map_dt::const_iterator it) const { const exprt &object=object_numbering[it->first]; @@ -260,18 +203,6 @@ exprt value_sett::to_expr(object_map_dt::const_iterator it) const return od; } -/*******************************************************************\ - -Function: value_sett::make_union - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_sett::make_union(const value_sett::valuest &new_values) { bool result=false; @@ -311,18 +242,6 @@ bool value_sett::make_union(const value_sett::valuest &new_values) return result; } -/*******************************************************************\ - -Function: value_sett::make_union - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_sett::make_union(object_mapt &dest, const object_mapt &src) const { bool result=false; @@ -338,18 +257,6 @@ bool value_sett::make_union(object_mapt &dest, const object_mapt &src) const return result; } -/*******************************************************************\ - -Function: value_sett::eval_pointer_offset - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_sett::eval_pointer_offset( exprt &expr, const namespacet &ns) const @@ -386,7 +293,7 @@ bool value_sett::eval_pointer_offset( if(mod && ptr_offset!=previous_offset) return false; - new_expr=from_integer(ptr_offset, index_type()); + new_expr=from_integer(ptr_offset, expr.type()); previous_offset=ptr_offset; mod=true; } @@ -403,18 +310,6 @@ bool value_sett::eval_pointer_offset( return mod; } -/*******************************************************************\ - -Function: value_sett::get_value_set - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_sett::get_value_set( const exprt &expr, value_setst::valuest &dest, @@ -432,22 +327,10 @@ void value_sett::get_value_set( #if 0 for(value_setst::valuest::const_iterator it=dest.begin(); it!=dest.end(); it++) - std::cout << "GET_VALUE_SET: " << from_expr(ns, "", *it) << std::endl; + std::cout << "GET_VALUE_SET: " << from_expr(ns, "", *it) << '\n'; #endif } -/*******************************************************************\ - -Function: value_sett::get_value_set - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_sett::get_value_set( const exprt &expr, object_mapt &dest, @@ -461,18 +344,6 @@ void value_sett::get_value_set( get_value_set_rec(tmp, dest, "", tmp.type(), ns); } -/*******************************************************************\ - -Function: value_sett::get_value_set_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_sett::get_value_set_rec( const exprt &expr, object_mapt &dest, @@ -482,7 +353,7 @@ void value_sett::get_value_set_rec( { #if 0 std::cout << "GET_VALUE_SET_REC EXPR: " << from_expr(ns, "", expr) << "\n"; - std::cout << "GET_VALUE_SET_REC SUFFIX: " << suffix << std::endl; + std::cout << "GET_VALUE_SET_REC SUFFIX: " << suffix << '\n'; #endif const typet &expr_type=ns.follow(expr.type()); @@ -717,10 +588,23 @@ void value_sett::get_value_set_rec( if(i_is_set) { - i*=pointer_offset_size(ptr_operand.type().subtype(), ns); + typet pointer_sub_type=ptr_operand.type().subtype(); + if(pointer_sub_type.id()==ID_empty) + pointer_sub_type=char_type(); + + mp_integer size=pointer_offset_size(pointer_sub_type, ns); + + if(size<=0) + { + i_is_set=false; + } + else + { + i*=size; - if(expr.id()==ID_minus) - i.negate(); + if(expr.id()==ID_minus) + i.negate(); + } } get_value_set_rec( @@ -985,7 +869,7 @@ void value_sett::get_value_set_rec( else { #if 0 - std::cout << "WARNING: not doing " << expr.id() << std::endl; + std::cout << "WARNING: not doing " << expr.id() << '\n'; #endif } @@ -1003,18 +887,6 @@ void value_sett::get_value_set_rec( #endif } -/*******************************************************************\ - -Function: value_sett::dereference_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_sett::dereference_rec( const exprt &src, exprt &dest) const @@ -1033,18 +905,6 @@ void value_sett::dereference_rec( dest=src; } -/*******************************************************************\ - -Function: value_sett::get_reference_set - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_sett::get_reference_set( const exprt &expr, value_setst::valuest &dest, @@ -1060,18 +920,6 @@ void value_sett::get_reference_set( dest.push_back(to_expr(it)); } -/*******************************************************************\ - -Function: value_sett::get_reference_set_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_sett::get_reference_set_rec( const exprt &expr, object_mapt &dest, @@ -1079,7 +927,7 @@ void value_sett::get_reference_set_rec( { #if 0 std::cout << "GET_REFERENCE_SET_REC EXPR: " << from_expr(ns, "", expr) - << std::endl; + << '\n'; #endif if(expr.id()==ID_symbol || @@ -1105,7 +953,7 @@ void value_sett::get_reference_set_rec( #if 0 for(expr_sett::const_iterator it=value_set.begin(); it!=value_set.end(); it++) - std::cout << "VALUE_SET: " << from_expr(ns, "", *it) << std::endl; + std::cout << "VALUE_SET: " << from_expr(ns, "", *it) << '\n'; #endif return; @@ -1155,7 +1003,14 @@ void value_sett::get_reference_set_rec( } else if(!to_integer(offset, i) && o.offset_is_zero()) - o.offset=i*pointer_offset_size(array_type.subtype(), ns); + { + mp_integer size=pointer_offset_size(array_type.subtype(), ns); + + if(size<=0) + o.offset_is_set=false; + else + o.offset=i*size; + } else o.offset_is_set=false; @@ -1230,18 +1085,6 @@ void value_sett::get_reference_set_rec( insert(dest, exprt(ID_unknown, expr.type())); } -/*******************************************************************\ - -Function: value_sett::assign - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_sett::assign( const exprt &lhs, const exprt &rhs, @@ -1250,8 +1093,8 @@ void value_sett::assign( bool add_to_sets) { #if 0 - std::cout << "ASSIGN LHS: " << from_expr(ns, "", lhs) << std::endl; - std::cout << "ASSIGN RHS: " << from_expr(ns, "", rhs) << std::endl; + std::cout << "ASSIGN LHS: " << from_expr(ns, "", lhs) << '\n'; + std::cout << "ASSIGN RHS: " << from_expr(ns, "", rhs) << '\n'; output(ns, std::cout); #endif @@ -1363,18 +1206,6 @@ void value_sett::assign( } } -/*******************************************************************\ - -Function: value_sett::do_free - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_sett::do_free( const exprt &op, const namespacet &ns) @@ -1455,18 +1286,6 @@ void value_sett::do_free( } } -/*******************************************************************\ - -Function: value_sett::assign_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_sett::assign_rec( const exprt &lhs, const object_mapt &values_rhs, @@ -1475,16 +1294,16 @@ void value_sett::assign_rec( bool add_to_sets) { #if 0 - std::cout << "ASSIGN_REC LHS: " << from_expr(ns, "", lhs) << std::endl; - std::cout << "ASSIGN_REC LHS ID: " << lhs.id() << std::endl; - std::cout << "ASSIGN_REC SUFFIX: " << suffix << std::endl; + std::cout << "ASSIGN_REC LHS: " << from_expr(ns, "", lhs) << '\n'; + std::cout << "ASSIGN_REC LHS ID: " << lhs.id() << '\n'; + std::cout << "ASSIGN_REC SUFFIX: " << suffix << '\n'; for(object_map_dt::const_iterator it=values_rhs.read().begin(); it!=values_rhs.read().end(); it++) std::cout << "ASSIGN_REC RHS: " << - from_expr(ns, "", object_numbering[it->first]) << std::endl; - std::cout << std::endl; + from_expr(ns, "", object_numbering[it->first]) << '\n'; + std::cout << '\n'; #endif if(lhs.id()==ID_symbol) @@ -1600,18 +1419,6 @@ void value_sett::assign_rec( throw "assign NYI: `"+lhs.id_string()+"'"; } -/*******************************************************************\ - -Function: value_sett::do_function_call - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_sett::do_function_call( const irep_idt &function, const exprt::operandst &arguments, @@ -1658,18 +1465,6 @@ void value_sett::do_function_call( // we could delete the dummy_arg_* now. } -/*******************************************************************\ - -Function: value_sett::do_end_function - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_sett::do_end_function( const exprt &lhs, const namespacet &ns) @@ -1682,18 +1477,6 @@ void value_sett::do_end_function( assign(lhs, rhs, ns, false, false); } -/*******************************************************************\ - -Function: value_sett::apply_code - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_sett::apply_code( const codet &code, const namespacet &ns) @@ -1802,6 +1585,9 @@ void value_sett::apply_code( else if(statement==ID_array_copy) { } + else if(statement==ID_array_replace) + { + } else if(statement==ID_assume) { guard(to_code_assume(code).op0(), ns); @@ -1821,23 +1607,11 @@ void value_sett::apply_code( } else { - // std::cerr << code.pretty() << std::endl; + // std::cerr << code.pretty() << '\n'; throw "value_sett: unexpected statement: "+id2string(statement); } } -/*******************************************************************\ - -Function: value_sett::guard - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_sett::guard( const exprt &expr, const namespacet &ns) @@ -1872,18 +1646,6 @@ void value_sett::guard( } } -/*******************************************************************\ - -Function: value_sett::make_member - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt value_sett::make_member( const exprt &src, const irep_idt &component_name, diff --git a/src/pointer-analysis/value_set.h b/src/pointer-analysis/value_set.h index 51bf74d48f2..8fc7c0218f4 100644 --- a/src/pointer-analysis/value_set.h +++ b/src/pointer-analysis/value_set.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Value Set + #ifndef CPROVER_POINTER_ANALYSIS_VALUE_SET_H #define CPROVER_POINTER_ANALYSIS_VALUE_SET_H diff --git a/src/pointer-analysis/value_set_analysis.cpp b/src/pointer-analysis/value_set_analysis.cpp index 4e98c10aee4..549fd53a348 100644 --- a/src/pointer-analysis/value_set_analysis.cpp +++ b/src/pointer-analysis/value_set_analysis.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Value Set Propagation + #include #include #include @@ -15,54 +18,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "value_set_analysis.h" -/*******************************************************************\ - -Function: value_set_analysist::initialize - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_analysist::initialize( const goto_programt &goto_program) { baset::initialize(goto_program); } -/*******************************************************************\ - -Function: value_set_analysist::initialize - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_analysist::initialize( const goto_functionst &goto_functions) { baset::initialize(goto_functions); } -/*******************************************************************\ - -Function: value_set_analysist::convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_analysist::convert( const goto_programt &goto_program, const irep_idt &identifier, @@ -77,7 +44,7 @@ void value_set_analysist::convert( if(location==previous_location) continue; - if(location.is_nil() || location.get_file()==irep_idt()) + if(location.is_nil() || location.get_file().empty()) continue; // find value set @@ -114,18 +81,6 @@ void value_set_analysist::convert( } } } -/*******************************************************************\ - -Function: convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void convert( const goto_functionst &goto_functions, const value_set_analysist &value_set_analysis, @@ -144,18 +99,6 @@ void convert( } } -/*******************************************************************\ - -Function: convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void convert( const goto_programt &goto_program, const value_set_analysist &value_set_analysis, diff --git a/src/pointer-analysis/value_set_analysis.h b/src/pointer-analysis/value_set_analysis.h index 3437b34af2c..b41355abd73 100644 --- a/src/pointer-analysis/value_set_analysis.h +++ b/src/pointer-analysis/value_set_analysis.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Value Set Propagation + #ifndef CPROVER_POINTER_ANALYSIS_VALUE_SET_ANALYSIS_H #define CPROVER_POINTER_ANALYSIS_VALUE_SET_ANALYSIS_H diff --git a/src/pointer-analysis/value_set_analysis_fi.cpp b/src/pointer-analysis/value_set_analysis_fi.cpp index 3ed2a07bc7d..63aaa330ac9 100644 --- a/src/pointer-analysis/value_set_analysis_fi.cpp +++ b/src/pointer-analysis/value_set_analysis_fi.cpp @@ -7,6 +7,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Value Set Propagation (Flow Insensitive) + #include #include #include @@ -16,18 +19,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "value_set_analysis_fi.h" -/*******************************************************************\ - -Function: value_set_analysis_fit::initialize - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_analysis_fit::initialize( const goto_programt &goto_program) { @@ -35,18 +26,6 @@ void value_set_analysis_fit::initialize( add_vars(goto_program); } -/*******************************************************************\ - -Function: value_set_analysis_fit::initialize - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_analysis_fit::initialize( const goto_functionst &goto_functions) { @@ -54,18 +33,6 @@ void value_set_analysis_fit::initialize( add_vars(goto_functions); } -/*******************************************************************\ - -Function: value_set_analysis_fit::add_vars - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_analysis_fit::add_vars( const goto_programt &goto_program) { @@ -114,18 +81,6 @@ void value_set_analysis_fit::add_vars( } } -/*******************************************************************\ - -Function: value_set_analysis_fit::get_entries - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_analysis_fit::get_entries( const symbolt &symbol, std::list &dest) @@ -133,18 +88,6 @@ void value_set_analysis_fit::get_entries( get_entries_rec(symbol.name, "", symbol.type, dest); } -/*******************************************************************\ - -Function: value_set_analysis_fit::get_entries - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_analysis_fit::get_entries_rec( const irep_idt &identifier, const std::string &suffix, @@ -182,18 +125,6 @@ void value_set_analysis_fit::get_entries_rec( } } -/*******************************************************************\ - -Function: value_set_analysis_fit::add_vars - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_analysis_fit::add_vars( const goto_functionst &goto_functions) { @@ -221,18 +152,6 @@ void value_set_analysis_fit::add_vars( } } -/*******************************************************************\ - -Function: value_set_analysis_fit::get_globals - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_analysis_fit::get_globals( std::list &dest) { @@ -243,18 +162,6 @@ void value_set_analysis_fit::get_globals( get_entries(it->second, dest); } -/*******************************************************************\ - -Function: value_set_analysis_fit::check_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_set_analysis_fit::check_type(const typet &type) { if(type.id()==ID_pointer) diff --git a/src/pointer-analysis/value_set_analysis_fi.h b/src/pointer-analysis/value_set_analysis_fi.h index e1c8f320cab..da50d27357c 100644 --- a/src/pointer-analysis/value_set_analysis_fi.h +++ b/src/pointer-analysis/value_set_analysis_fi.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Value Set Propagation (flow insensitive) + #ifndef CPROVER_POINTER_ANALYSIS_VALUE_SET_ANALYSIS_FI_H #define CPROVER_POINTER_ANALYSIS_VALUE_SET_ANALYSIS_FI_H diff --git a/src/pointer-analysis/value_set_analysis_fivr.cpp b/src/pointer-analysis/value_set_analysis_fivr.cpp index 0180768250c..dab177cc5f4 100644 --- a/src/pointer-analysis/value_set_analysis_fivr.cpp +++ b/src/pointer-analysis/value_set_analysis_fivr.cpp @@ -7,6 +7,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Value Set Propagation (Flow Insensitive) + #include #include #include @@ -16,18 +19,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "value_set_analysis_fivr.h" -/*******************************************************************\ - -Function: value_set_analysis_fivrt::initialize - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_analysis_fivrt::initialize( const goto_programt &goto_program) { @@ -35,18 +26,6 @@ void value_set_analysis_fivrt::initialize( add_vars(goto_program); } -/*******************************************************************\ - -Function: value_set_analysis_fivrt::initialize - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_analysis_fivrt::initialize( const goto_functionst &goto_functions) { @@ -54,18 +33,6 @@ void value_set_analysis_fivrt::initialize( add_vars(goto_functions); } -/*******************************************************************\ - -Function: value_set_analysis_fivrt::add_vars - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_analysis_fivrt::add_vars( const goto_programt &goto_program) { @@ -104,18 +71,6 @@ void value_set_analysis_fivrt::add_vars( } } -/*******************************************************************\ - -Function: value_set_analysis_fivrt::get_entries - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_analysis_fivrt::get_entries( const symbolt &symbol, std::list &dest) @@ -123,18 +78,6 @@ void value_set_analysis_fivrt::get_entries( get_entries_rec(symbol.name, "", symbol.type, dest); } -/*******************************************************************\ - -Function: value_set_analysis_fivrt::get_entries - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_analysis_fivrt::get_entries_rec( const irep_idt &identifier, const std::string &suffix, @@ -172,18 +115,6 @@ void value_set_analysis_fivrt::get_entries_rec( } } -/*******************************************************************\ - -Function: value_set_analysis_fivrt::add_vars - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_analysis_fivrt::add_vars( const goto_functionst &goto_functions) { @@ -211,18 +142,6 @@ void value_set_analysis_fivrt::add_vars( } } -/*******************************************************************\ - -Function: value_set_analysis_fivrt::get_globals - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_analysis_fivrt::get_globals( std::list &dest) { @@ -233,18 +152,6 @@ void value_set_analysis_fivrt::get_globals( get_entries(it->second, dest); } -/*******************************************************************\ - -Function: value_set_analysis_fivrt::check_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_set_analysis_fivrt::check_type(const typet &type) { if(type.id()==ID_pointer) diff --git a/src/pointer-analysis/value_set_analysis_fivr.h b/src/pointer-analysis/value_set_analysis_fivr.h index e6e30cfb456..d583379ab0e 100644 --- a/src/pointer-analysis/value_set_analysis_fivr.h +++ b/src/pointer-analysis/value_set_analysis_fivr.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Value Set Propagation + #ifndef CPROVER_POINTER_ANALYSIS_VALUE_SET_ANALYSIS_FIVR_H #define CPROVER_POINTER_ANALYSIS_VALUE_SET_ANALYSIS_FIVR_H @@ -47,11 +50,11 @@ class value_set_analysis_fivrt: { forall_goto_program_instructions(it, goto_program) { - out << "**** " << it->source_location << std::endl; + out << "**** " << it->source_location << '\n'; output(it, out); - out << std::endl; + out << '\n'; goto_program.output_instruction(ns, "", out, it); - out << std::endl; + out << '\n'; } } diff --git a/src/pointer-analysis/value_set_analysis_fivrns.cpp b/src/pointer-analysis/value_set_analysis_fivrns.cpp index 1b7d2422186..5fbd77522bf 100644 --- a/src/pointer-analysis/value_set_analysis_fivrns.cpp +++ b/src/pointer-analysis/value_set_analysis_fivrns.cpp @@ -7,6 +7,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Value Set Propagation (Flow Insensitive, Validity Regions) + #include #include #include @@ -16,18 +19,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "value_set_analysis_fivrns.h" -/*******************************************************************\ - -Function: value_set_analysis_fivrnst::initialize - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_analysis_fivrnst::initialize( const goto_programt &goto_program) { @@ -35,18 +26,6 @@ void value_set_analysis_fivrnst::initialize( add_vars(goto_program); } -/*******************************************************************\ - -Function: value_set_analysis_fivrnst::initialize - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_analysis_fivrnst::initialize( const goto_functionst &goto_functions) { @@ -54,18 +33,6 @@ void value_set_analysis_fivrnst::initialize( add_vars(goto_functions); } -/*******************************************************************\ - -Function: value_set_analysis_fivrnst::add_vars - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_analysis_fivrnst::add_vars( const goto_programt &goto_program) { @@ -104,18 +71,6 @@ void value_set_analysis_fivrnst::add_vars( } } -/*******************************************************************\ - -Function: value_set_analysis_fivrnst::get_entries - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_analysis_fivrnst::get_entries( const symbolt &symbol, std::list &dest) @@ -123,18 +78,6 @@ void value_set_analysis_fivrnst::get_entries( get_entries_rec(symbol.name, "", symbol.type, dest); } -/*******************************************************************\ - -Function: value_set_analysis_fivrnst::get_entries - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_analysis_fivrnst::get_entries_rec( const irep_idt &identifier, const std::string &suffix, @@ -172,18 +115,6 @@ void value_set_analysis_fivrnst::get_entries_rec( } } -/*******************************************************************\ - -Function: value_set_analysis_fivrnst::add_vars - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_analysis_fivrnst::add_vars( const goto_functionst &goto_functions) { @@ -211,18 +142,6 @@ void value_set_analysis_fivrnst::add_vars( } } -/*******************************************************************\ - -Function: value_set_analysis_fivrnst::get_globals - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_analysis_fivrnst::get_globals( std::list &dest) { @@ -233,18 +152,6 @@ void value_set_analysis_fivrnst::get_globals( get_entries(it->second, dest); } -/*******************************************************************\ - -Function: value_set_analysis_fivrnst::check_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_set_analysis_fivrnst::check_type(const typet &type) { if(type.id()==ID_pointer) diff --git a/src/pointer-analysis/value_set_analysis_fivrns.h b/src/pointer-analysis/value_set_analysis_fivrns.h index b4d45524db2..a5fd4fd3fcd 100644 --- a/src/pointer-analysis/value_set_analysis_fivrns.h +++ b/src/pointer-analysis/value_set_analysis_fivrns.h @@ -7,6 +7,9 @@ Author: Daniel Kroening, kroening@kroening.com, \*******************************************************************/ +/// \file +/// Value Set Analysis (Flow Insensitive, Validity Regions) + #ifndef CPROVER_POINTER_ANALYSIS_VALUE_SET_ANALYSIS_FIVRNS_H #define CPROVER_POINTER_ANALYSIS_VALUE_SET_ANALYSIS_FIVRNS_H @@ -49,11 +52,11 @@ class value_set_analysis_fivrnst: { forall_goto_program_instructions(it, goto_program) { - out << "**** " << it->source_location << std::endl; + out << "**** " << it->source_location << '\n'; output(it, out); - out << std::endl; + out << '\n'; goto_program.output_instruction(ns, "", out, it); - out << std::endl; + out << '\n'; } } diff --git a/src/pointer-analysis/value_set_dereference.cpp b/src/pointer-analysis/value_set_dereference.cpp index 411adddbe8e..9efd87c5793 100644 --- a/src/pointer-analysis/value_set_dereference.cpp +++ b/src/pointer-analysis/value_set_dereference.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbolic Execution of ANSI-C + #ifdef DEBUG #include #endif @@ -28,8 +31,8 @@ Author: Daniel Kroening, kroening@kroening.com #include #include #include +#include -#include #include #include @@ -42,35 +45,11 @@ Author: Daniel Kroening, kroening@kroening.com // global data, horrible unsigned int value_set_dereferencet::invalid_counter=0; -/*******************************************************************\ - -Function: value_set_dereferencet::has_dereference - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_set_dereferencet::has_dereference(const exprt &expr) { return has_subexpr(expr, ID_dereference); } -/*******************************************************************\ - -Function: value_set_dereferencet::get_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const exprt &value_set_dereferencet::get_symbol(const exprt &expr) { if(expr.id()==ID_member || expr.id()==ID_index) @@ -79,19 +58,9 @@ const exprt &value_set_dereferencet::get_symbol(const exprt &expr) return expr; } -/*******************************************************************\ - -Function: value_set_dereferencet::dereference - - Inputs: expression dest, to be dereferenced under given guard, - and given mode - - Outputs: returns pointer after dereferencing - - Purpose: - -\*******************************************************************/ - +/// \par parameters: expression dest, to be dereferenced under given guard, +/// and given mode +/// \return returns pointer after dereferencing exprt value_set_dereferencet::dereference( const exprt &pointer, const guardt &guard, @@ -122,7 +91,7 @@ exprt value_set_dereferencet::dereference( const typet &type=pointer.type().subtype(); #if 0 - std::cout << "DEREF: " << from_expr(ns, "", pointer) << std::endl; + std::cout << "DEREF: " << from_expr(ns, "", pointer) << '\n'; #endif // collect objects the pointer may point to @@ -135,7 +104,7 @@ exprt value_set_dereferencet::dereference( it=points_to_set.begin(); it!=points_to_set.end(); it++) - std::cout << "P: " << from_expr(ns, "", *it) << std::endl; + std::cout << "P: " << from_expr(ns, "", *it) << '\n'; #endif // get the values of these @@ -151,7 +120,7 @@ exprt value_set_dereferencet::dereference( #if 0 std::cout << "V: " << from_expr(ns, "", value.pointer_guard) << " --> "; - std::cout << from_expr(ns, "", value.value) << std::endl; + std::cout << from_expr(ns, "", value.value) << '\n'; #endif values.push_back(value); @@ -235,25 +204,12 @@ exprt value_set_dereferencet::dereference( } #if 0 - std::cout << "R: " << from_expr(ns, "", value) << std::endl - << std::endl; + std::cout << "R: " << from_expr(ns, "", value) << "\n\n"; #endif return value; } -/*******************************************************************\ - -Function: value_set_dereferencet::dereference_type_compare - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_set_dereferencet::dereference_type_compare( const typet &object_type, const typet &dereference_type) const @@ -282,23 +238,20 @@ bool value_set_dereferencet::dereference_type_compare( object_type.id()==ID_code) return true; + // bitvectors of same width are ok + if((dereference_type.id()==ID_signedbv || + dereference_type.id()==ID_unsignedbv) && + (object_type.id()==ID_signedbv || + object_type.id()==ID_unsignedbv) && + to_bitvector_type(dereference_type).get_width()== + to_bitvector_type(object_type).get_width()) + return true; + // really different return false; } -/*******************************************************************\ - -Function: value_set_dereferencet::invalid_pointer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_dereferencet::invalid_pointer( const exprt &pointer, const guardt &guard) @@ -316,18 +269,6 @@ void value_set_dereferencet::invalid_pointer( tmp_guard); } -/*******************************************************************\ - -Function: value_set_dereferencet::build_reference_to - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - value_set_dereferencet::valuet value_set_dereferencet::build_reference_to( const exprt &what, const modet mode, @@ -353,7 +294,7 @@ value_set_dereferencet::valuet value_set_dereferencet::build_reference_to( const exprt &object=o.object(); #if 0 - std::cout << "O: " << from_expr(ns, "", root_object) << std::endl; + std::cout << "O: " << from_expr(ns, "", root_object) << '\n'; #endif valuet result; @@ -468,9 +409,6 @@ value_set_dereferencet::valuet value_set_dereferencet::build_reference_to( const symbolt &memory_symbol=ns.lookup(CPROVER_PREFIX "memory"); exprt symbol_expr=symbol_exprt(memory_symbol.name, memory_symbol.type); - exprt pointer_offset=unary_exprt( - ID_pointer_offset, pointer_expr, index_type()); - if(base_type_eq( ns.follow(memory_symbol.type).subtype(), dereference_type, ns)) @@ -478,10 +416,18 @@ value_set_dereferencet::valuet value_set_dereferencet::build_reference_to( // Types match already, what a coincidence! // We can use an index expression. - exprt index_expr=index_exprt(symbol_expr, pointer_offset); + exprt index_expr=index_exprt(symbol_expr, pointer_offset(pointer_expr)); index_expr.type()=ns.follow(memory_symbol.type).subtype(); result.value=index_expr; } + else if(dereference_type_compare( + ns.follow(memory_symbol.type).subtype(), + dereference_type)) + { + exprt index_expr=index_exprt(symbol_expr, pointer_offset(pointer_expr)); + index_expr.type()=ns.follow(memory_symbol.type).subtype(); + result.value=typecast_exprt(index_expr, dereference_type); + } else { // We need to use byte_extract. @@ -493,7 +439,8 @@ value_set_dereferencet::valuet value_set_dereferencet::build_reference_to( else { exprt byte_extract(byte_extract_id(), dereference_type); - byte_extract.copy_to_operands(symbol_expr, pointer_offset); + byte_extract.copy_to_operands( + symbol_expr, pointer_offset(pointer_expr)); result.value=byte_extract; } } @@ -554,12 +501,14 @@ value_set_dereferencet::valuet value_set_dereferencet::build_reference_to( if(o.offset().is_constant()) offset=o.offset(); else - offset=unary_exprt(ID_pointer_offset, pointer_expr, index_type()); + offset=pointer_offset(pointer_expr); exprt adjusted_offset; // are we doing a byte? mp_integer element_size= + dereference_type.id()==ID_empty? + pointer_offset_size(char_type(), ns): pointer_offset_size(dereference_type, ns); if(element_size==1) @@ -567,6 +516,10 @@ value_set_dereferencet::valuet value_set_dereferencet::build_reference_to( // no need to adjust offset adjusted_offset=offset; } + else if(element_size<=0) + { + throw "unknown or invalid type size of:\n"+dereference_type.pretty(); + } else { exprt element_size_expr= @@ -604,8 +557,7 @@ value_set_dereferencet::valuet value_set_dereferencet::build_reference_to( result.value=o.root_object(); // this is relative to the root object - const exprt offset= - unary_exprt(ID_pointer_offset, pointer_expr, index_type()); + const exprt offset=pointer_offset(pointer_expr); if(memory_model(result.value, dereference_type, tmp_guard, offset)) { @@ -634,18 +586,6 @@ value_set_dereferencet::valuet value_set_dereferencet::build_reference_to( return result; } -/*******************************************************************\ - -Function: value_set_dereferencet::valid_check - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_dereferencet::valid_check( const exprt &object, const guardt &guard, @@ -698,18 +638,6 @@ void value_set_dereferencet::valid_check( } } -/*******************************************************************\ - -Function: value_set_dereferencet::bounds_check - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_dereferencet::bounds_check( const index_exprt &expr, const guardt &guard) @@ -783,18 +711,6 @@ void value_set_dereferencet::bounds_check( } } -/*******************************************************************\ - -Function: value_set_dereferencet::memory_model - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - inline static unsigned bv_width( const typet &type, const namespacet &ns) @@ -864,18 +780,6 @@ bool value_set_dereferencet::memory_model( return memory_model_bytes(value, to_type, guard, offset); } -/*******************************************************************\ - -Function: value_set_dereferencet::memory_model_conversion - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_set_dereferencet::memory_model_conversion( exprt &value, const typet &to_type, @@ -903,18 +807,6 @@ bool value_set_dereferencet::memory_model_conversion( return true; } -/*******************************************************************\ - -Function: value_set_dereferencet::memory_model_bytes - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_set_dereferencet::memory_model_bytes( exprt &value, const typet &to_type, @@ -966,7 +858,13 @@ bool value_set_dereferencet::memory_model_bytes( // upper bound { mp_integer from_width=pointer_offset_size(from_type, ns); - mp_integer to_width=pointer_offset_size(to_type, ns); + if(from_width<=0) + throw "unknown or invalid type size:\n"+from_type.pretty(); + + mp_integer to_width= + to_type.id()==ID_empty?0: pointer_offset_size(to_type, ns); + if(to_width<0) + throw "unknown or invalid type size:\n"+to_type.pretty(); exprt bound=from_integer(from_width-to_width, offset.type()); diff --git a/src/pointer-analysis/value_set_dereference.h b/src/pointer-analysis/value_set_dereference.h index 19dde8e0f16..4687d671ec6 100644 --- a/src/pointer-analysis/value_set_dereference.h +++ b/src/pointer-analysis/value_set_dereference.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Pointer Dereferencing + #ifndef CPROVER_POINTER_ANALYSIS_VALUE_SET_DEREFERENCE_H #define CPROVER_POINTER_ANALYSIS_VALUE_SET_DEREFERENCE_H diff --git a/src/pointer-analysis/value_set_domain.cpp b/src/pointer-analysis/value_set_domain.cpp index 74656d23fe6..7ddfd6deb29 100644 --- a/src/pointer-analysis/value_set_domain.cpp +++ b/src/pointer-analysis/value_set_domain.cpp @@ -6,22 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Value Set + #include #include "value_set_domain.h" -/*******************************************************************\ - -Function: value_set_domaint::transform - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_domaint::transform( const namespacet &ns, locationt from_l, diff --git a/src/pointer-analysis/value_set_domain.h b/src/pointer-analysis/value_set_domain.h index df028b0d4e1..e59250a0bc0 100644 --- a/src/pointer-analysis/value_set_domain.h +++ b/src/pointer-analysis/value_set_domain.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Value Set + #ifndef CPROVER_POINTER_ANALYSIS_VALUE_SET_DOMAIN_H #define CPROVER_POINTER_ANALYSIS_VALUE_SET_DOMAIN_H diff --git a/src/pointer-analysis/value_set_domain_fi.cpp b/src/pointer-analysis/value_set_domain_fi.cpp index a5d0668fe90..c56e1bdb321 100644 --- a/src/pointer-analysis/value_set_domain_fi.cpp +++ b/src/pointer-analysis/value_set_domain_fi.cpp @@ -7,22 +7,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Value Set Domain (Flow Insensitive) + #include #include "value_set_domain_fi.h" -/*******************************************************************\ - -Function: value_set_domain_fit::transform - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_set_domain_fit::transform( const namespacet &ns, locationt from_l, @@ -35,7 +26,7 @@ bool value_set_domain_fit::transform( // std::cout << "transforming: " << // from_l->function << " " << from_l->location_number << " to " << -// to_l->function << " " << to_l->location_number << std::endl; +// to_l->function << " " << to_l->location_number << '\n'; switch(from_l->type) { diff --git a/src/pointer-analysis/value_set_domain_fi.h b/src/pointer-analysis/value_set_domain_fi.h index ebcb9008f4c..24e2ac1be2c 100644 --- a/src/pointer-analysis/value_set_domain_fi.h +++ b/src/pointer-analysis/value_set_domain_fi.h @@ -7,6 +7,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Value Set (Flow Insensitive) + #ifndef CPROVER_POINTER_ANALYSIS_VALUE_SET_DOMAIN_FI_H #define CPROVER_POINTER_ANALYSIS_VALUE_SET_DOMAIN_FI_H diff --git a/src/pointer-analysis/value_set_domain_fivr.cpp b/src/pointer-analysis/value_set_domain_fivr.cpp index 51e63dfb91f..4defd25047f 100644 --- a/src/pointer-analysis/value_set_domain_fivr.cpp +++ b/src/pointer-analysis/value_set_domain_fivr.cpp @@ -7,22 +7,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Value Set Domain (Flow Insensitive, Sharing, Validity Regions) + #include #include "value_set_domain_fivr.h" -/*******************************************************************\ - -Function: value_set_domain_fivrt::transform - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_set_domain_fivrt::transform( const namespacet &ns, locationt from_l, @@ -34,7 +25,7 @@ bool value_set_domain_fivrt::transform( #if 0 std::cout << "Transforming: " << from_l->function << " " << from_l->location_number << " to " << - to_l->function << " " << to_l->location_number << std::endl; + to_l->function << " " << to_l->location_number << '\n'; #endif switch(from_l->type) diff --git a/src/pointer-analysis/value_set_domain_fivr.h b/src/pointer-analysis/value_set_domain_fivr.h index e1f82153191..4ecb8879517 100644 --- a/src/pointer-analysis/value_set_domain_fivr.h +++ b/src/pointer-analysis/value_set_domain_fivr.h @@ -7,6 +7,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Value Set (Flow Insensitive, Sharing, Validity Regions) + #ifndef CPROVER_POINTER_ANALYSIS_VALUE_SET_DOMAIN_FIVR_H #define CPROVER_POINTER_ANALYSIS_VALUE_SET_DOMAIN_FIVR_H diff --git a/src/pointer-analysis/value_set_domain_fivrns.cpp b/src/pointer-analysis/value_set_domain_fivrns.cpp index 8c8ef147dfa..f4ecf668429 100644 --- a/src/pointer-analysis/value_set_domain_fivrns.cpp +++ b/src/pointer-analysis/value_set_domain_fivrns.cpp @@ -7,22 +7,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Value Set Domain (Flow Insensitive, Validity Regions) + #include #include "value_set_domain_fivrns.h" -/*******************************************************************\ - -Function: value_set_domain_fivrnst::transform - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_set_domain_fivrnst::transform( const namespacet &ns, locationt from_l, @@ -34,7 +25,7 @@ bool value_set_domain_fivrnst::transform( #if 0 std::cout << "Transforming: " << from_l->function << " " << from_l->location_number << " to " << - to_l->function << " " << to_l->location_number << std::endl; + to_l->function << " " << to_l->location_number << '\n'; #endif switch(from_l->type) diff --git a/src/pointer-analysis/value_set_domain_fivrns.h b/src/pointer-analysis/value_set_domain_fivrns.h index 62d4aeedc3e..4e7827e4617 100644 --- a/src/pointer-analysis/value_set_domain_fivrns.h +++ b/src/pointer-analysis/value_set_domain_fivrns.h @@ -7,6 +7,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Value Set Domain (Flow Insensitive, Validity Regions) + #ifndef CPROVER_POINTER_ANALYSIS_VALUE_SET_DOMAIN_FIVRNS_H #define CPROVER_POINTER_ANALYSIS_VALUE_SET_DOMAIN_FIVRNS_H diff --git a/src/pointer-analysis/value_set_fi.cpp b/src/pointer-analysis/value_set_fi.cpp index 1add85c924d..149af498760 100644 --- a/src/pointer-analysis/value_set_fi.cpp +++ b/src/pointer-analysis/value_set_fi.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Value Set (Flow Insensitive, Sharing) + #include #include @@ -18,7 +21,7 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -#include +#include #include "value_set_fi.h" @@ -38,18 +41,6 @@ static const char *alloc_adapter_prefix="alloc_adaptor::"; (it)!=(map).end(); \ (it)++) -/*******************************************************************\ - -Function: value_set_fit::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fit::output( const namespacet &ns, std::ostream &out) const @@ -144,53 +135,29 @@ void value_set_fit::output( } } -/*******************************************************************\ - -Function: value_set_fit::flatten - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fit::flatten( const entryt &e, object_mapt &dest) const { #if 0 - std::cout << "FLATTEN: " << e.identifier << e.suffix << std::endl; + std::cout << "FLATTEN: " << e.identifier << e.suffix << '\n'; #endif flatten_seent seen; flatten_rec(e, dest, seen); #if 0 - std::cout << "FLATTEN: Done." << std::endl; + std::cout << "FLATTEN: Done.\n"; #endif } -/*******************************************************************\ - -Function: value_set_fit::flatten_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fit::flatten_rec( const entryt &e, object_mapt &dest, flatten_seent &seen) const { #if 0 - std::cout << "FLATTEN_REC: " << e.identifier << e.suffix << std::endl; + std::cout << "FLATTEN_REC: " << e.identifier << e.suffix << '\n'; #endif std::string identifier = id2string(e.identifier); @@ -255,18 +222,6 @@ void value_set_fit::flatten_rec( seen.erase(identifier + e.suffix); } -/*******************************************************************\ - -Function: value_set_fit::to_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt value_set_fit::to_expr(object_map_dt::const_iterator it) const { const exprt &object=object_numbering[it->first]; @@ -287,18 +242,6 @@ exprt value_set_fit::to_expr(object_map_dt::const_iterator it) const return od; } -/*******************************************************************\ - -Function: value_set_fit::make_union - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_set_fit::make_union(const value_set_fit::valuest &new_values) { assert(0); @@ -338,18 +281,6 @@ bool value_set_fit::make_union(const value_set_fit::valuest &new_values) return result; } -/*******************************************************************\ - -Function: value_set_fit::make_union - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_set_fit::make_union(object_mapt &dest, const object_mapt &src) const { bool result=false; @@ -363,18 +294,6 @@ bool value_set_fit::make_union(object_mapt &dest, const object_mapt &src) const return result; } -/*******************************************************************\ - -Function: value_set_fit::get_value_set - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fit::get_value_set( const exprt &expr, std::list &value_set, @@ -433,22 +352,10 @@ void value_set_fit::get_value_set( #if 0 for(expr_sett::const_iterator it=value_set.begin(); it!=value_set.end(); it++) - std::cout << "GET_VALUE_SET: " << from_expr(ns, "", *it) << std::endl; + std::cout << "GET_VALUE_SET: " << from_expr(ns, "", *it) << '\n'; #endif } -/*******************************************************************\ - -Function: value_set_fit::get_value_set - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fit::get_value_set( const exprt &expr, object_mapt &dest, @@ -461,18 +368,6 @@ void value_set_fit::get_value_set( get_value_set_rec(tmp, dest, "", tmp.type(), ns, recset); } -/*******************************************************************\ - -Function: value_set_fit::get_value_set_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fit::get_value_set_rec( const exprt &expr, object_mapt &dest, @@ -483,9 +378,9 @@ void value_set_fit::get_value_set_rec( { #if 0 std::cout << "GET_VALUE_SET_REC EXPR: " << from_expr(ns, "", expr) - << std::endl; - std::cout << "GET_VALUE_SET_REC SUFFIX: " << suffix << std::endl; - std::cout << std::endl; + << '\n'; + std::cout << "GET_VALUE_SET_REC SUFFIX: " << suffix << '\n'; + std::cout << '\n'; #endif if(expr.type().id()=="#REF#") @@ -790,18 +685,6 @@ void value_set_fit::get_value_set_rec( insert(dest, exprt(ID_unknown, original_type)); } -/*******************************************************************\ - -Function: value_set_fit::dereference_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fit::dereference_rec( const exprt &src, exprt &dest) const @@ -820,18 +703,6 @@ void value_set_fit::dereference_rec( dest=src; } -/*******************************************************************\ - -Function: value_set_fit::get_reference_set - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fit::get_reference_set( const exprt &expr, expr_sett &dest, @@ -881,18 +752,6 @@ void value_set_fit::get_reference_set( } } -/*******************************************************************\ - -Function: value_set_fit::get_reference_set_sharing - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fit::get_reference_set_sharing( const exprt &expr, expr_sett &dest, @@ -905,18 +764,6 @@ void value_set_fit::get_reference_set_sharing( dest.insert(to_expr(it)); } -/*******************************************************************\ - -Function: value_set_fit::get_reference_set_sharing_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fit::get_reference_set_sharing_rec( const exprt &expr, object_mapt &dest, @@ -924,7 +771,7 @@ void value_set_fit::get_reference_set_sharing_rec( { #if 0 std::cout << "GET_REFERENCE_SET_REC EXPR: " << from_expr(ns, "", expr) - << std::endl; + << '\n'; #endif if(expr.type().id()=="#REF#") @@ -999,7 +846,7 @@ void value_set_fit::get_reference_set_sharing_rec( for(expr_sett::const_iterator it=value_set.begin(); it!=value_set.end(); it++) - std::cout << "VALUE_SET: " << from_expr(ns, "", *it) << std::endl; + std::cout << "VALUE_SET: " << from_expr(ns, "", *it) << '\n'; #endif return; @@ -1115,26 +962,14 @@ void value_set_fit::get_reference_set_sharing_rec( insert(dest, exprt(ID_unknown, expr.type())); } -/*******************************************************************\ - -Function: value_set_fit::assign - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fit::assign( const exprt &lhs, const exprt &rhs, const namespacet &ns) { #if 0 - std::cout << "ASSIGN LHS: " << from_expr(ns, "", lhs) << std::endl; - std::cout << "ASSIGN RHS: " << from_expr(ns, "", rhs) << std::endl; + std::cout << "ASSIGN LHS: " << from_expr(ns, "", lhs) << '\n'; + std::cout << "ASSIGN RHS: " << from_expr(ns, "", rhs) << '\n'; #endif if(rhs.id()==ID_if) @@ -1290,18 +1125,6 @@ void value_set_fit::assign( } } -/*******************************************************************\ - -Function: value_set_fit::do_free - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fit::do_free( const exprt &op, const namespacet &ns) @@ -1379,18 +1202,6 @@ void value_set_fit::do_free( } } -/*******************************************************************\ - -Function: value_set_fit::assign_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fit::assign_rec( const exprt &lhs, const object_mapt &values_rhs, @@ -1399,12 +1210,12 @@ void value_set_fit::assign_rec( assign_recursion_sett &recursion_set) { #if 0 - std::cout << "ASSIGN_REC LHS: " << from_expr(ns, "", lhs) << std::endl; - std::cout << "ASSIGN_REC SUFFIX: " << suffix << std::endl; + std::cout << "ASSIGN_REC LHS: " << from_expr(ns, "", lhs) << '\n'; + std::cout << "ASSIGN_REC SUFFIX: " << suffix << '\n'; for(object_map_dt::const_iterator it=values_rhs.read().begin(); it!=values_rhs.read().end(); it++) - std::cout << "ASSIGN_REC RHS: " << to_expr(it) << std::endl; + std::cout << "ASSIGN_REC RHS: " << to_expr(it) << '\n'; #endif if(lhs.type().id()=="#REF#") @@ -1541,18 +1352,6 @@ void value_set_fit::assign_rec( throw "assign NYI: `"+lhs.id_string()+"'"; } -/*******************************************************************\ - -Function: value_set_fit::do_function_call - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fit::do_function_call( const irep_idt &function, const exprt::operandst &arguments, @@ -1602,18 +1401,6 @@ void value_set_fit::do_function_call( } } -/*******************************************************************\ - -Function: value_set_fit::do_end_function - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fit::do_end_function( const exprt &lhs, const namespacet &ns) @@ -1627,18 +1414,6 @@ void value_set_fit::do_end_function( assign(lhs, rhs, ns); } -/*******************************************************************\ - -Function: value_set_fit::apply_code - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fit::apply_code( const exprt &code, const namespacet &ns) @@ -1727,7 +1502,9 @@ void value_set_fit::apply_code( else if(statement==ID_fence) { } - else if(statement==ID_array_copy) + else if(statement==ID_array_copy || + statement==ID_array_replace || + statement==ID_array_set) { } else if(statement==ID_input || statement==ID_output) diff --git a/src/pointer-analysis/value_set_fi.h b/src/pointer-analysis/value_set_fi.h index 13defa545ae..76f2666d836 100644 --- a/src/pointer-analysis/value_set_fi.h +++ b/src/pointer-analysis/value_set_fi.h @@ -7,6 +7,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Value Set (Flow Insensitive, Sharing) + #ifndef CPROVER_POINTER_ANALYSIS_VALUE_SET_FI_H #define CPROVER_POINTER_ANALYSIS_VALUE_SET_FI_H diff --git a/src/pointer-analysis/value_set_fivr.cpp b/src/pointer-analysis/value_set_fivr.cpp index 45e721137e0..2acb06ad601 100644 --- a/src/pointer-analysis/value_set_fivr.cpp +++ b/src/pointer-analysis/value_set_fivr.cpp @@ -7,6 +7,9 @@ Author: Daniel Kroening, kroening@kroening.com, \*******************************************************************/ +/// \file +/// Value Set (Flow Insensitive, Sharing, Validity Regions) + #include #include @@ -19,7 +22,7 @@ Author: Daniel Kroening, kroening@kroening.com, #include #include -#include +#include #include "value_set_fivr.h" @@ -51,18 +54,6 @@ static const char *alloc_adapter_prefix="alloc_adaptor::"; (it)++) \ if((map).is_valid_at((it)->first, from_function, from_target_index)) /* NOLINT(*) */ -/*******************************************************************\ - -Function: value_set_fivrt::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrt::output( const namespacet &ns, std::ostream &out) const @@ -182,7 +173,7 @@ void value_set_fivrt::output( if(vr != object_map.read().validity_ranges.end()) { if(vr->second.empty()) - std::cout << " Empty validity record" << std::endl; + std::cout << " Empty validity record\n"; else { for(object_map_dt::vrange_listt::const_iterator vit = @@ -196,13 +187,13 @@ void value_set_fivrt::output( from_target_index>=vit->from && from_target_index<=vit->to) out << " (*)"; - out << std::endl; + out << '\n'; } } } else { - out << " No validity information" << std::endl; + out << " No validity information\n"; } #endif @@ -221,46 +212,22 @@ void value_set_fivrt::output( } } -/*******************************************************************\ - -Function: value_set_fivrt::flatten - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrt::flatten( const entryt &e, object_mapt &dest) const { #if 0 - std::cout << "FLATTEN: " << e.identifier << e.suffix << std::endl; + std::cout << "FLATTEN: " << e.identifier << e.suffix << '\n'; #endif flatten_seent seen; flatten_rec(e, dest, seen, from_function, from_target_index); #if 0 - std::cout << "FLATTEN: Done." << std::endl; + std::cout << "FLATTEN: Done.\n"; #endif } -/*******************************************************************\ - -Function: value_set_fivrt::flatten_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrt::flatten_rec( const entryt &e, object_mapt &dest, @@ -269,7 +236,7 @@ void value_set_fivrt::flatten_rec( unsigned at_index) const { #if 0 - std::cout << "FLATTEN_REC: " << e.identifier << e.suffix << std::endl; + std::cout << "FLATTEN_REC: " << e.identifier << e.suffix << '\n'; #endif std::string identifier=id2string(e.identifier); @@ -376,18 +343,6 @@ void value_set_fivrt::flatten_rec( seen.erase(identifier + e.suffix); } -/*******************************************************************\ - -Function: value_set_fivrt::to_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt value_set_fivrt::to_expr(object_map_dt::const_iterator it) const { const exprt &object=object_numbering[it->first]; @@ -408,18 +363,6 @@ exprt value_set_fivrt::to_expr(object_map_dt::const_iterator it) const return od; } -/*******************************************************************\ - -Function: value_set_fivrt::make_union - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_set_fivrt::make_union( object_mapt &dest, const object_mapt &src) const @@ -435,18 +378,6 @@ bool value_set_fivrt::make_union( return result; } -/*******************************************************************\ - -Function: value_set_fivrnst::make_valid_union - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_set_fivrt::make_valid_union( object_mapt &dest, const object_mapt &src) const @@ -462,18 +393,6 @@ bool value_set_fivrt::make_valid_union( return result; } -/*******************************************************************\ - -Function: value_set_fivrt::copy_objects - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrt::copy_objects( object_mapt &dest, const object_mapt &src) const @@ -488,18 +407,6 @@ void value_set_fivrt::copy_objects( } } -/*******************************************************************\ - -Function: value_set_fivrt::get_value_set - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrt::get_value_set( const exprt &expr, std::list &value_set, @@ -560,22 +467,10 @@ void value_set_fivrt::get_value_set( for(std::list::const_iterator it=value_set.begin(); it!=value_set.end(); it++) - std::cout << "GET_VALUE_SET: " << from_expr(ns, "", *it) << std::endl; + std::cout << "GET_VALUE_SET: " << from_expr(ns, "", *it) << '\n'; #endif } -/*******************************************************************\ - -Function: value_set_fivrt::get_value_set - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrt::get_value_set( const exprt &expr, object_mapt &dest, @@ -588,18 +483,6 @@ void value_set_fivrt::get_value_set( get_value_set_rec(tmp, dest, "", tmp.type(), ns, recset); } -/*******************************************************************\ - -Function: value_set_fivrt::get_value_set_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrt::get_value_set_rec( const exprt &expr, object_mapt &dest, @@ -609,9 +492,9 @@ void value_set_fivrt::get_value_set_rec( gvs_recursion_sett &recursion_set) const { #if 0 - std::cout << "GET_VALUE_SET_REC EXPR: " << expr << std::endl; - std::cout << "GET_VALUE_SET_REC SUFFIX: " << suffix << std::endl; - std::cout << std::endl; + std::cout << "GET_VALUE_SET_REC EXPR: " << expr << '\n'; + std::cout << "GET_VALUE_SET_REC SUFFIX: " << suffix << '\n'; + std::cout << '\n'; #endif if(expr.type().id()=="#REF#") @@ -916,18 +799,6 @@ void value_set_fivrt::get_value_set_rec( insert_from(dest, exprt(ID_unknown, original_type)); } -/*******************************************************************\ - -Function: value_set_fivrt::dereference_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrt::dereference_rec( const exprt &src, exprt &dest) const @@ -946,18 +817,6 @@ void value_set_fivrt::dereference_rec( dest=src; } -/*******************************************************************\ - -Function: value_set_fivrt::get_reference_set - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrt::get_reference_set( const exprt &expr, expr_sett &dest, @@ -1007,18 +866,6 @@ void value_set_fivrt::get_reference_set( } } -/*******************************************************************\ - -Function: value_set_fivrt::get_reference_set_sharing - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrt::get_reference_set_sharing( const exprt &expr, expr_sett &dest, @@ -1031,18 +878,6 @@ void value_set_fivrt::get_reference_set_sharing( dest.insert(to_expr(it)); } -/*******************************************************************\ - -Function: value_set_fivrt::get_reference_set_sharing_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrt::get_reference_set_sharing_rec( const exprt &expr, object_mapt &dest, @@ -1050,7 +885,7 @@ void value_set_fivrt::get_reference_set_sharing_rec( { #if 0 std::cout << "GET_REFERENCE_SET_REC EXPR: " << from_expr(ns, "", expr) - << std::endl; + << '\n'; #endif if(expr.type().id()=="#REF#") @@ -1125,7 +960,7 @@ void value_set_fivrt::get_reference_set_sharing_rec( for(expr_sett::const_iterator it=value_set.begin(); it!=value_set.end(); it++) - std::cout << "VALUE_SET: " << from_expr(ns, "", *it) << std::endl; + std::cout << "VALUE_SET: " << from_expr(ns, "", *it) << '\n'; #endif return; @@ -1243,18 +1078,6 @@ void value_set_fivrt::get_reference_set_sharing_rec( insert_from(dest, exprt(ID_unknown, expr.type())); } -/*******************************************************************\ - -Function: value_set_fivrt::assign - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrt::assign( const exprt &lhs, const exprt &rhs, @@ -1262,9 +1085,9 @@ void value_set_fivrt::assign( bool add_to_sets) { #if 0 - std::cout << "ASSIGN LHS: " << lhs << std::endl; - std::cout << "ASSIGN LTYPE: " << ns.follow(lhs.type()) << std::endl; - std::cout << "ASSIGN RHS: " << from_expr(ns, "", rhs) << std::endl; + std::cout << "ASSIGN LHS: " << lhs << '\n'; + std::cout << "ASSIGN LTYPE: " << ns.follow(lhs.type()) << '\n'; + std::cout << "ASSIGN RHS: " << from_expr(ns, "", rhs) << '\n'; #endif if(rhs.id()==ID_if) @@ -1373,7 +1196,7 @@ void value_set_fivrt::assign( if(rhs.id()==ID_array_of) { assert(rhs.operands().size()==1); -// std::cout << "AOF: " << rhs.op0() << std::endl; +// std::cout << "AOF: " << rhs.op0() << '\n'; assign(lhs_index, rhs.op0(), ns, add_to_sets); } else if(rhs.id()==ID_array || @@ -1414,18 +1237,6 @@ void value_set_fivrt::assign( } } -/*******************************************************************\ - -Function: value_set_fivrt::do_free - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrt::do_free( const exprt &op, const namespacet &ns) @@ -1507,18 +1318,6 @@ void value_set_fivrt::do_free( } } -/*******************************************************************\ - -Function: value_set_fivrt::assign_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrt::assign_rec( const exprt &lhs, const object_mapt &values_rhs, @@ -1528,12 +1327,12 @@ void value_set_fivrt::assign_rec( bool add_to_sets) { #if 0 - std::cout << "ASSIGN_REC LHS: " << lhs << std::endl; - std::cout << "ASSIGN_REC SUFFIX: " << suffix << std::endl; + std::cout << "ASSIGN_REC LHS: " << lhs << '\n'; + std::cout << "ASSIGN_REC SUFFIX: " << suffix << '\n'; for(object_map_dt::const_iterator it=values_rhs.read().begin(); it!=values_rhs.read().end(); it++) - std::cout << "ASSIGN_REC RHS: " << to_expr(it) << std::endl; + std::cout << "ASSIGN_REC RHS: " << to_expr(it) << '\n'; #endif if(lhs.type().id()=="#REF#") @@ -1693,18 +1492,6 @@ void value_set_fivrt::assign_rec( throw "assign NYI: `"+lhs.id_string()+"'"; } -/*******************************************************************\ - -Function: value_set_fivrt::do_function_call - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrt::do_function_call( const irep_idt &function, const exprt::operandst &arguments, @@ -1733,7 +1520,7 @@ void value_set_fivrt::do_function_call( "argument$"+std::to_string(i); add_var(identifier, ""); exprt dummy_lhs=symbol_exprt(identifier, arguments[i].type()); -// std::cout << arguments[i] << std::endl; +// std::cout << arguments[i] << '\n'; assign(dummy_lhs, arguments[i], ns, true); @@ -1772,18 +1559,6 @@ void value_set_fivrt::do_function_call( } } -/*******************************************************************\ - -Function: value_set_fivrt::do_end_function - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrt::do_end_function( const exprt &lhs, const namespacet &ns) @@ -1797,18 +1572,6 @@ void value_set_fivrt::do_end_function( assign(lhs, rhs, ns); } -/*******************************************************************\ - -Function: value_set_fivrt::apply_code - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrt::apply_code( const exprt &code, const namespacet &ns) @@ -1905,18 +1668,6 @@ void value_set_fivrt::apply_code( "value_set_fivrt: unexpected statement: "+id2string(statement); } -/*******************************************************************\ - -Function: value_set_fivrt::insert_to - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_set_fivrt::insert_to( object_mapt &dest, unsigned n, @@ -1925,7 +1676,7 @@ bool value_set_fivrt::insert_to( object_map_dt &map=dest.write(); if(map.find(n)==map.end()) { -// std::cout << "NEW(" << n << "): " << object_numbering[n] << std::endl; +// std::cout << "NEW(" << n << "): " << object_numbering[n] << '\n'; // new map[n]=object; map.set_valid_at(n, to_function, to_target_index); @@ -1933,7 +1684,7 @@ bool value_set_fivrt::insert_to( } else { -// std::cout << "UPD " << n << std::endl; +// std::cout << "UPD " << n << '\n'; objectt &old=map[n]; bool res=map.set_valid_at(n, to_function, to_target_index); @@ -1958,18 +1709,6 @@ bool value_set_fivrt::insert_to( } } -/*******************************************************************\ - -Function: value_set_fivrt::insert_from - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_set_fivrt::insert_from( object_mapt &dest, unsigned n, @@ -1978,7 +1717,7 @@ bool value_set_fivrt::insert_from( object_map_dt &map=dest.write(); if(map.find(n)==map.end()) { -// std::cout << "NEW(" << n << "): " << object_numbering[n] << std::endl; +// std::cout << "NEW(" << n << "): " << object_numbering[n] << '\n'; // new map[n]=object; map.set_valid_at(n, from_function, from_target_index); @@ -1986,7 +1725,7 @@ bool value_set_fivrt::insert_from( } else { -// std::cout << "UPD " << n << std::endl; +// std::cout << "UPD " << n << '\n'; objectt &old=map[n]; bool res=map.set_valid_at(n, from_function, from_target_index); @@ -2011,18 +1750,6 @@ bool value_set_fivrt::insert_from( } } -/*******************************************************************\ - -Function: value_set_fivrt::object_map_dt::set_valid_at - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_set_fivrt::object_map_dt::set_valid_at( unsigned inx, const validity_ranget &vr) @@ -2036,18 +1763,6 @@ bool value_set_fivrt::object_map_dt::set_valid_at( return res; } -/*******************************************************************\ - -Function: value_set_fivrt::object_map_dt::set_valid_at - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_set_fivrt::object_map_dt::set_valid_at( unsigned inx, unsigned f, @@ -2119,18 +1834,6 @@ bool value_set_fivrt::object_map_dt::set_valid_at( return true; } -/*******************************************************************\ - -Function: value_set_fivrt::object_map_dt::is_valid_at - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_set_fivrt::object_map_dt::is_valid_at( unsigned inx, unsigned f, @@ -2138,7 +1841,7 @@ bool value_set_fivrt::object_map_dt::is_valid_at( { #if 0 std::cout << "IS_VALID_AT: " << inx << ", " << f << ", line " << line << - std::endl; + '\n'; #endif validity_rangest::const_iterator vrs=validity_ranges.find(inx); @@ -2161,18 +1864,6 @@ bool value_set_fivrt::object_map_dt::is_valid_at( return false; } -/*******************************************************************\ - -Function: value_set_fivrt::recursive_find - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_set_fivrt::recursive_find( const irep_idt &ident, const object_mapt &rhs, @@ -2212,18 +1903,6 @@ bool value_set_fivrt::recursive_find( return false; } -/*******************************************************************\ - -Function: value_set_fivrt::handover - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_set_fivrt::handover(void) { bool changed=false; @@ -2240,7 +1919,7 @@ bool value_set_fivrt::handover(void) if(t_it==temporary_values.end()) { -// std::cout << "OLD VALUES FOR: " << ident << std::endl; +// std::cout << "OLD VALUES FOR: " << ident << '\n'; Forall_valid_objects(o_it, state_map.write()) { if(state_map.write().set_valid_at(o_it->first, @@ -2250,7 +1929,7 @@ bool value_set_fivrt::handover(void) } else { -// std::cout << "NEW VALUES FOR: " << ident << std::endl; +// std::cout << "NEW VALUES FOR: " << ident << '\n'; if(make_union(state_map, t_it->second.object_map)) changed=true; } diff --git a/src/pointer-analysis/value_set_fivr.h b/src/pointer-analysis/value_set_fivr.h index e12563252ae..92c5ab45b37 100644 --- a/src/pointer-analysis/value_set_fivr.h +++ b/src/pointer-analysis/value_set_fivr.h @@ -7,6 +7,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Value Set (Flow Insensitive, Sharing, Validity Regions) + #ifndef CPROVER_POINTER_ANALYSIS_VALUE_SET_FIVR_H #define CPROVER_POINTER_ANALYSIS_VALUE_SET_FIVR_H diff --git a/src/pointer-analysis/value_set_fivrns.cpp b/src/pointer-analysis/value_set_fivrns.cpp index c94afc8f95d..034b0839da0 100644 --- a/src/pointer-analysis/value_set_fivrns.cpp +++ b/src/pointer-analysis/value_set_fivrns.cpp @@ -7,6 +7,9 @@ Author: Daniel Kroening, kroening@kroening.com, \*******************************************************************/ +/// \file +/// Value Set (Flow Insensitive, Validity Regions) + #include #include @@ -19,7 +22,7 @@ Author: Daniel Kroening, kroening@kroening.com, #include #include -#include +#include #include "value_set_fivrns.h" @@ -51,18 +54,6 @@ static const char *alloc_adapter_prefix="alloc_adaptor::"; (it)++) \ if((map).is_valid_at((it)->first, from_function, from_target_index)) /* NOLINT(*) */ -/*******************************************************************\ - -Function: value_set_fivrnst::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrnst::output( const namespacet &ns, std::ostream &out) const @@ -74,18 +65,6 @@ void value_set_fivrnst::output( output_entry(v_it->second, ns, out); } -/*******************************************************************\ - -Function: value_set_fivrnst::output_entry - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrnst::output_entry( const entryt &e, const namespacet &ns, @@ -182,7 +161,7 @@ void value_set_fivrnst::output_entry( if(vr != object_map.read().validity_ranges.end()) { if(vr->second.empty()) - std::cout << " Empty validity record" << std::endl; + std::cout << " Empty validity record\n"; else { for(object_map_dt::vrange_listt::const_iterator vit = @@ -196,13 +175,13 @@ void value_set_fivrnst::output_entry( from_target_index>=vit->from && from_target_index<=vit->to) out << " (*)"; - out << std::endl; + out << '\n'; } } } else { - out << " No validity information" << std::endl; + out << " No validity information\n"; } #endif @@ -220,18 +199,6 @@ void value_set_fivrnst::output_entry( out << " } \n"; } -/*******************************************************************\ - -Function: value_set_fivrnst::to_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt value_set_fivrnst::to_expr(object_map_dt::const_iterator it) const { const exprt &object=object_numbering[it->first]; @@ -252,18 +219,6 @@ exprt value_set_fivrnst::to_expr(object_map_dt::const_iterator it) const return od; } -/*******************************************************************\ - -Function: value_set_fivrnst::make_union - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_set_fivrnst::make_union( object_mapt &dest, const object_mapt &src) const @@ -279,18 +234,6 @@ bool value_set_fivrnst::make_union( return result; } -/*******************************************************************\ - -Function: value_set_fivrnst::make_valid_union - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_set_fivrnst::make_valid_union( object_mapt &dest, const object_mapt &src) const @@ -306,18 +249,6 @@ bool value_set_fivrnst::make_valid_union( return result; } -/*******************************************************************\ - -Function: value_set_fivrnst::copy_objects - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrnst::copy_objects( object_mapt &dest, const object_mapt &src) const @@ -332,18 +263,6 @@ void value_set_fivrnst::copy_objects( } } -/*******************************************************************\ - -Function: value_set_fivrnst::get_value_set - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrnst::get_value_set( const exprt &expr, std::list &value_set, @@ -358,22 +277,10 @@ void value_set_fivrnst::get_value_set( #if 0 for(std::list::const_iterator it=value_set.begin(); it!=value_set.end(); it++) - std::cout << "GET_VALUE_SET: " << from_expr(ns, "", *it) << std::endl; + std::cout << "GET_VALUE_SET: " << from_expr(ns, "", *it) << '\n'; #endif } -/*******************************************************************\ - -Function: value_set_fivrnst::get_value_set - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrnst::get_value_set( const exprt &expr, object_mapt &dest, @@ -385,18 +292,6 @@ void value_set_fivrnst::get_value_set( get_value_set_rec(tmp, dest, "", tmp.type(), ns); } -/*******************************************************************\ - -Function: value_set_fivrnst::get_value_set_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrnst::get_value_set_rec( const exprt &expr, object_mapt &dest, @@ -405,9 +300,9 @@ void value_set_fivrnst::get_value_set_rec( const namespacet &ns) const { #if 0 - std::cout << "GET_VALUE_SET_REC EXPR: " << expr << std::endl; - std::cout << "GET_VALUE_SET_REC SUFFIX: " << suffix << std::endl; - std::cout << std::endl; + std::cout << "GET_VALUE_SET_REC EXPR: " << expr << '\n'; + std::cout << "GET_VALUE_SET_REC SUFFIX: " << suffix << '\n'; + std::cout << '\n'; #endif if(expr.id()==ID_unknown || expr.id()==ID_invalid) @@ -690,18 +585,6 @@ void value_set_fivrnst::get_value_set_rec( insert_from(dest, exprt(ID_unknown, original_type)); } -/*******************************************************************\ - -Function: value_set_fivrnst::dereference_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrnst::dereference_rec( const exprt &src, exprt &dest) const @@ -720,18 +603,6 @@ void value_set_fivrnst::dereference_rec( dest=src; } -/*******************************************************************\ - -Function: value_set_fivrnst::get_reference_set - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrnst::get_reference_set( const exprt &expr, expr_sett &dest, @@ -744,18 +615,6 @@ void value_set_fivrnst::get_reference_set( dest.insert(to_expr(it)); } -/*******************************************************************\ - -Function: value_set_fivrnst::get_reference_set_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrnst::get_reference_set_rec( const exprt &expr, object_mapt &dest, @@ -763,7 +622,7 @@ void value_set_fivrnst::get_reference_set_rec( { #if 0 std::cout << "GET_REFERENCE_SET_REC EXPR: " << from_expr(ns, "", expr) - << std::endl; + << '\n'; #endif if(expr.id()==ID_symbol || @@ -788,7 +647,7 @@ void value_set_fivrnst::get_reference_set_rec( #if 0 for(expr_sett::const_iterator it=value_set.begin(); it!=value_set.end(); it++) - std::cout << "VALUE_SET: " << from_expr(ns, "", *it) << std::endl; + std::cout << "VALUE_SET: " << from_expr(ns, "", *it) << '\n'; #endif return; @@ -906,18 +765,6 @@ void value_set_fivrnst::get_reference_set_rec( insert_from(dest, exprt(ID_unknown, expr.type())); } -/*******************************************************************\ - -Function: value_set_fivrnst::assign - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrnst::assign( const exprt &lhs, const exprt &rhs, @@ -925,9 +772,9 @@ void value_set_fivrnst::assign( bool add_to_sets) { #if 0 - std::cout << "ASSIGN LHS: " << lhs << std::endl; - std::cout << "ASSIGN LTYPE: " << ns.follow(lhs.type()) << std::endl; - std::cout << "ASSIGN RHS: " << from_expr(ns, "", rhs) << std::endl; + std::cout << "ASSIGN LHS: " << lhs << '\n'; + std::cout << "ASSIGN LTYPE: " << ns.follow(lhs.type()) << '\n'; + std::cout << "ASSIGN RHS: " << from_expr(ns, "", rhs) << '\n'; #endif if(rhs.id()==ID_if) @@ -1036,7 +883,7 @@ void value_set_fivrnst::assign( if(rhs.id()==ID_array_of) { assert(rhs.operands().size()==1); -// std::cout << "AOF: " << rhs.op0() << std::endl; +// std::cout << "AOF: " << rhs.op0() << '\n'; assign(lhs_index, rhs.op0(), ns, add_to_sets); } else if(rhs.id()==ID_array || @@ -1076,18 +923,6 @@ void value_set_fivrnst::assign( } } -/*******************************************************************\ - -Function: value_set_fivrnst::do_free - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrnst::do_free( const exprt &op, const namespacet &ns) @@ -1166,18 +1001,6 @@ void value_set_fivrnst::do_free( } } -/*******************************************************************\ - -Function: value_set_fivrnst::assign_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrnst::assign_rec( const exprt &lhs, const object_mapt &values_rhs, @@ -1186,12 +1009,12 @@ void value_set_fivrnst::assign_rec( bool add_to_sets) { #if 0 - std::cout << "ASSIGN_REC LHS: " << lhs << std::endl; - std::cout << "ASSIGN_REC SUFFIX: " << suffix << std::endl; + std::cout << "ASSIGN_REC LHS: " << lhs << '\n'; + std::cout << "ASSIGN_REC SUFFIX: " << suffix << '\n'; for(object_map_dt::const_iterator it=values_rhs.read().begin(); it!=values_rhs.read().end(); it++) - std::cout << "ASSIGN_REC RHS: " << to_expr(it) << std::endl; + std::cout << "ASSIGN_REC RHS: " << to_expr(it) << '\n'; #endif if(lhs.id()==ID_symbol) @@ -1320,18 +1143,6 @@ void value_set_fivrnst::assign_rec( throw "assign NYI: `"+lhs.id_string()+"'"; } -/*******************************************************************\ - -Function: value_set_fivrnst::do_function_call - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrnst::do_function_call( const irep_idt &function, const exprt::operandst &arguments, @@ -1360,7 +1171,7 @@ void value_set_fivrnst::do_function_call( "argument$"+std::to_string(i); add_var(identifier, ""); exprt dummy_lhs=symbol_exprt(identifier, arguments[i].type()); -// std::cout << arguments[i] << std::endl; +// std::cout << arguments[i] << '\n'; assign(dummy_lhs, arguments[i], ns, true); @@ -1399,18 +1210,6 @@ void value_set_fivrnst::do_function_call( } } -/*******************************************************************\ - -Function: value_set_fivrnst::do_end_function - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrnst::do_end_function( const exprt &lhs, const namespacet &ns) @@ -1426,18 +1225,6 @@ void value_set_fivrnst::do_end_function( assign(lhs, rhs, ns); } -/*******************************************************************\ - -Function: value_set_fivrnst::apply_code - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void value_set_fivrnst::apply_code( const exprt &code, const namespacet &ns) @@ -1537,18 +1324,6 @@ void value_set_fivrnst::apply_code( } } -/*******************************************************************\ - -Function: value_set_fivrnst::insert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_set_fivrnst::insert_to( object_mapt &dest, unsigned n, @@ -1557,7 +1332,7 @@ bool value_set_fivrnst::insert_to( object_map_dt &map = dest.write(); if(map.find(n)==map.end()) { -// std::cout << "NEW(" << n << "): " << object_numbering[n] << std::endl; +// std::cout << "NEW(" << n << "): " << object_numbering[n] << '\n'; // new map[n]=object; map.set_valid_at(n, to_function, to_target_index); @@ -1565,7 +1340,7 @@ bool value_set_fivrnst::insert_to( } else { -// std::cout << "UPD " << n << std::endl; +// std::cout << "UPD " << n << '\n'; objectt &old=map[n]; bool res = map.set_valid_at(n, to_function, to_target_index); @@ -1590,18 +1365,6 @@ bool value_set_fivrnst::insert_to( } } -/*******************************************************************\ - -Function: value_set_fivrnst::insert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_set_fivrnst::insert_from( object_mapt &dest, unsigned n, @@ -1610,7 +1373,7 @@ bool value_set_fivrnst::insert_from( object_map_dt &map = dest.write(); if(map.find(n)==map.end()) { -// std::cout << "NEW(" << n << "): " << object_numbering[n] << std::endl; +// std::cout << "NEW(" << n << "): " << object_numbering[n] << '\n'; // new map[n]=object; map.set_valid_at(n, from_function, from_target_index); @@ -1618,7 +1381,7 @@ bool value_set_fivrnst::insert_from( } else { -// std::cout << "UPD " << n << std::endl; +// std::cout << "UPD " << n << '\n'; objectt &old=map[n]; bool res = map.set_valid_at(n, from_function, from_target_index); @@ -1643,18 +1406,6 @@ bool value_set_fivrnst::insert_from( } } -/*******************************************************************\ - -Function: value_set_fivrnst::object_map_dt::set_valid_at - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_set_fivrnst::object_map_dt::set_valid_at( unsigned inx, unsigned f, @@ -1726,18 +1477,6 @@ bool value_set_fivrnst::object_map_dt::set_valid_at( return true; } -/*******************************************************************\ - -Function: value_set_fivrnst::object_map_dt::is_valid_at - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_set_fivrnst::object_map_dt::is_valid_at( unsigned inx, unsigned f, @@ -1745,7 +1484,7 @@ bool value_set_fivrnst::object_map_dt::is_valid_at( { #if 0 std::cout << "IS_VALID_AT: " << inx << ", " << f << ", line " << line << - std::endl; + '\n'; #endif validity_rangest::const_iterator vrs = validity_ranges.find(inx); @@ -1769,18 +1508,6 @@ bool value_set_fivrnst::object_map_dt::is_valid_at( return false; } -/*******************************************************************\ - -Function: value_set_fivrnst::handover - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool value_set_fivrnst::handover(void) { bool changed=false; @@ -1797,10 +1524,10 @@ bool value_set_fivrnst::handover(void) if(t_it==temporary_values.end()) { -// std::cout << "OLD VALUES FOR: " << ident << std::endl; +// std::cout << "OLD VALUES FOR: " << ident << '\n'; Forall_valid_objects(o_it, state_map.write()) { -// std::cout << "STILL VALID: " << to_expr(o_it) << std::endl; +// std::cout << "STILL VALID: " << to_expr(o_it) << '\n'; if(state_map.write().set_valid_at(o_it->first, to_function, to_target_index)) changed = true; @@ -1808,7 +1535,7 @@ bool value_set_fivrnst::handover(void) } else { -// std::cout << "NEW VALUES FOR: " << ident << std::endl; +// std::cout << "NEW VALUES FOR: " << ident << '\n'; if(make_union(state_map, t_it->second.object_map)) changed = true; } diff --git a/src/pointer-analysis/value_set_fivrns.h b/src/pointer-analysis/value_set_fivrns.h index f3afc204ef2..5ce1d4464c6 100644 --- a/src/pointer-analysis/value_set_fivrns.h +++ b/src/pointer-analysis/value_set_fivrns.h @@ -7,6 +7,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Value Set (Flow Insensitive, Validity Regions) + #ifndef CPROVER_POINTER_ANALYSIS_VALUE_SET_FIVRNS_H #define CPROVER_POINTER_ANALYSIS_VALUE_SET_FIVRNS_H diff --git a/src/pointer-analysis/value_sets.h b/src/pointer-analysis/value_sets.h index 5e39997b7e1..e230f72ebe7 100644 --- a/src/pointer-analysis/value_sets.h +++ b/src/pointer-analysis/value_sets.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Value Set Propagation + #ifndef CPROVER_POINTER_ANALYSIS_VALUE_SETS_H #define CPROVER_POINTER_ANALYSIS_VALUE_SETS_H diff --git a/src/solvers/cvc/cvc_conv.cpp b/src/solvers/cvc/cvc_conv.cpp index 55c1815b182..3646a5add65 100644 --- a/src/solvers/cvc/cvc_conv.cpp +++ b/src/solvers/cvc/cvc_conv.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include @@ -22,18 +23,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "cvc_conv.h" -/*******************************************************************\ - -Function: cvc_convt::print_assignment - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cvc_convt::print_assignment(std::ostream &out) const { // Boolean stuff @@ -44,18 +33,6 @@ void cvc_convt::print_assignment(std::ostream &out) const // others } -/*******************************************************************\ - -Function: cvc_convt::l_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - tvt cvc_convt::l_get(literalt l) const { if(l.is_true()) @@ -66,18 +43,6 @@ tvt cvc_convt::l_get(literalt l) const return tvt(boolean_assignment[l.var_no()]^l.sign()); } -/*******************************************************************\ - -Function: cvc_convt::convert_binary_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cvc_convt::convert_binary_expr(const exprt &expr, const exprt &op) { unsigned to_width= @@ -159,18 +124,6 @@ void cvc_convt::convert_binary_expr(const exprt &expr, const exprt &op) } } -/*******************************************************************\ - -Function: cvc_convt::convert_constant_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cvc_convt::convert_constant_expr(const exprt &expr) { if(expr.type().id()==ID_unsignedbv || @@ -255,18 +208,6 @@ void cvc_convt::convert_constant_expr(const exprt &expr) throw "unknown constant: "+expr.type().id_string(); } -/*******************************************************************\ - -Function: cvc_convt::convert_plus_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cvc_convt::convert_plus_expr(const exprt &expr) { if(expr.operands().size()>=2) @@ -323,18 +264,6 @@ void cvc_convt::convert_plus_expr(const exprt &expr) assert(false); } -/*******************************************************************\ - -Function: cvc_convt::convert_typecast_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cvc_convt::convert_typecast_expr(const exprt &expr) { assert(expr.operands().size()==1); @@ -373,18 +302,6 @@ void cvc_convt::convert_typecast_expr(const exprt &expr) throw "todo typecast4 ? -> "+expr.type().id_string(); } -/*******************************************************************\ - -Function: cvc_convt::convert_struct_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cvc_convt::convert_struct_expr(const exprt &expr) { out << "(# "; @@ -411,18 +328,6 @@ void cvc_convt::convert_struct_expr(const exprt &expr) out << " #)"; } -/*******************************************************************\ - -Function: cvc_convt::convert_equality_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cvc_convt::convert_equality_expr(const exprt &expr) { assert(expr.operands().size()==2); @@ -453,18 +358,6 @@ void cvc_convt::convert_equality_expr(const exprt &expr) } } -/*******************************************************************\ - -Function: cvc_convt::convert_comparison_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cvc_convt::convert_comparison_expr(const exprt &expr) { assert(expr.operands().size()==2); @@ -512,18 +405,6 @@ void cvc_convt::convert_comparison_expr(const exprt &expr) } } -/*******************************************************************\ - -Function: cvc_convt::convert_minus_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cvc_convt::convert_minus_expr(const exprt &expr) { if(expr.operands().size()==2) @@ -548,18 +429,6 @@ void cvc_convt::convert_minus_expr(const exprt &expr) assert(false); } -/*******************************************************************\ - -Function: cvc_convt::convert_with_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cvc_convt::convert_with_expr(const exprt &expr) { assert(expr.operands().size()>=1); @@ -603,18 +472,6 @@ void cvc_convt::convert_with_expr(const exprt &expr) } } -/*******************************************************************\ - -Function: cvc_convt::convert_literal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cvc_convt::convert_literal(const literalt l) { if(l==const_literal(false)) @@ -631,18 +488,6 @@ void cvc_convt::convert_literal(const literalt l) out << ")"; } -/*******************************************************************\ - -Function: cvc_convt::bin_zero - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string cvc_convt::bin_zero(unsigned bits) { assert(bits!=0); @@ -655,18 +500,6 @@ std::string cvc_convt::bin_zero(unsigned bits) return result; } -/*******************************************************************\ - -Function: cvc_convt::cvc_pointer_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string cvc_convt::cvc_pointer_type() { assert(config.ansi_c.pointer_width!=0); @@ -674,36 +507,12 @@ std::string cvc_convt::cvc_pointer_type() std::to_string(config.ansi_c.pointer_width)+") #]"; } -/*******************************************************************\ - -Function: cvc_convt::array_index_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string cvc_convt::array_index_type() { return std::string("BITVECTOR(")+ std::to_string(32)+")"; } -/*******************************************************************\ - -Function: cvc_convt::gen_array_index_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet cvc_convt::gen_array_index_type() { typet t(ID_signedbv); @@ -711,35 +520,11 @@ typet cvc_convt::gen_array_index_type() return t; } -/*******************************************************************\ - -Function: cvc_convt::array_index - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string cvc_convt::array_index(unsigned i) { return "0bin"+integer2binary(i, config.ansi_c.int_width); } -/*******************************************************************\ - -Function: cvc_convt::convert_array_index - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cvc_convt::convert_array_index(const exprt &expr) { if(expr.type()==gen_array_index_type()) @@ -754,18 +539,6 @@ void cvc_convt::convert_array_index(const exprt &expr) } } -/*******************************************************************\ - -Function: cvc_convt::convert_address_of_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cvc_convt::convert_address_of_rec(const exprt &expr) { if(expr.id()==ID_symbol || @@ -835,6 +608,7 @@ void cvc_convt::convert_address_of_rec(const exprt &expr) to_struct_type(struct_op.type()), component_name, ns); + assert(offset>=0); typet index_type(ID_unsignedbv); index_type.set(ID_width, config.ansi_c.pointer_width); @@ -851,18 +625,6 @@ void cvc_convt::convert_address_of_rec(const exprt &expr) throw "don't know how to take address of: "+expr.id_string(); } -/*******************************************************************\ - -Function: cvc_convt::convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt cvc_convt::convert(const exprt &expr) { if(expr.type().id()!=ID_bool) @@ -895,23 +657,11 @@ literalt cvc_convt::convert(const exprt &expr) convert_literal(l); out << " <=> ("; convert_expr(expr); - out << ");" << std::endl << std::endl; + out << ");\n\n"; return l; } -/*******************************************************************\ - -Function: cvc_convt::convert_identifier - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cvc_convt::convert_identifier(const std::string &identifier) { for(std::string::const_iterator @@ -948,18 +698,6 @@ void cvc_convt::convert_identifier(const std::string &identifier) } } -/*******************************************************************\ - -Function: cvc_convt::convert_as_bv - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cvc_convt::convert_as_bv(const exprt &expr) { if(expr.type().id()==ID_bool) @@ -979,35 +717,11 @@ void cvc_convt::convert_as_bv(const exprt &expr) convert_expr(expr); } -/*******************************************************************\ - -Function: cvc_convt::convert_array_value - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cvc_convt::convert_array_value(const exprt &expr) { convert_as_bv(expr); } -/*******************************************************************\ - -Function: cvc_convt::convert_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cvc_convt::convert_expr(const exprt &expr) { const exprt::operandst &op=expr.operands(); @@ -1446,18 +1160,6 @@ void cvc_convt::convert_expr(const exprt &expr) throw "convert_expr: "+expr.id_string()+" is unsupported"; } -/*******************************************************************\ - -Function: cvc_convt::set_to - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cvc_convt::set_to(const exprt &expr, bool value) { if(value && expr.id()==ID_and) @@ -1467,7 +1169,7 @@ void cvc_convt::set_to(const exprt &expr, bool value) return; } - out << "%% set_to " << (value?"true":"false") << std::endl; + out << "%% set_to " << (value?"true":"false") << '\n'; if(expr.id()==ID_equal && value) { @@ -1497,7 +1199,7 @@ void cvc_convt::set_to(const exprt &expr, bool value) out << " = "; convert_expr(expr.op1()); - out << ";" << std::endl << std::endl; + out << ";\n\n"; return; } } @@ -1516,21 +1218,9 @@ void cvc_convt::set_to(const exprt &expr, bool value) if(!value) out << ")"; - out << ";" << std::endl << std::endl; + out << ";\n\n"; } -/*******************************************************************\ - -Function: cvc_convt::find_symbols - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cvc_convt::find_symbols(const exprt &expr) { find_symbols(expr.type()); @@ -1554,7 +1244,7 @@ void cvc_convt::find_symbols(const exprt &expr) convert_identifier(id2string(identifier)); out << ": "; convert_type(expr.type()); - out << ";" << std::endl; + out << ";\n"; } } else if(expr.id()==ID_nondet_symbol) @@ -1573,23 +1263,11 @@ void cvc_convt::find_symbols(const exprt &expr) convert_identifier(id2string(identifier)); out << ": "; convert_type(expr.type()); - out << ";" << std::endl; + out << ";\n"; } } } -/*******************************************************************\ - -Function: cvc_convt::convert_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cvc_convt::convert_type(const typet &type) { if(type.id()==ID_array) @@ -1662,18 +1340,6 @@ void cvc_convt::convert_type(const typet &type) throw "unsupported type: "+type.id_string(); } -/*******************************************************************\ - -Function: cvc_convt::find_symbols - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cvc_convt::find_symbols(const typet &type) { if(type.id()==ID_array) diff --git a/src/solvers/cvc/cvc_conv.h b/src/solvers/cvc/cvc_conv.h index 7f1c37b5ee2..c3fc7dbe182 100644 --- a/src/solvers/cvc/cvc_conv.h +++ b/src/solvers/cvc/cvc_conv.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_CVC_CVC_CONV_H #define CPROVER_SOLVERS_CVC_CVC_CONV_H diff --git a/src/solvers/cvc/cvc_dec.cpp b/src/solvers/cvc/cvc_dec.cpp index a30fdb2e614..e61479a2dbf 100644 --- a/src/solvers/cvc/cvc_dec.cpp +++ b/src/solvers/cvc/cvc_dec.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include // for system() @@ -29,18 +30,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "cvc_dec.h" -/*******************************************************************\ - -Function: cvc_temp_filet::cvc_temp_filet - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - cvc_temp_filet::cvc_temp_filet() { temp_out_filename="cvc_dec_out_"+std::to_string(getpid())+".tmp"; @@ -50,18 +39,6 @@ cvc_temp_filet::cvc_temp_filet() std::ios_base::out | std::ios_base::trunc); } -/*******************************************************************\ - -Function: cvc_temp_filet::~cvc_temp_filet - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - cvc_temp_filet::~cvc_temp_filet() { temp_out.close(); @@ -73,22 +50,10 @@ cvc_temp_filet::~cvc_temp_filet() unlink(temp_result_filename.c_str()); } -/*******************************************************************\ - -Function: cvc_dect::dec_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - decision_proceduret::resultt cvc_dect::dec_solve() { - out << "QUERY FALSE;" << std::endl; - out << "COUNTERMODEL;" << std::endl; + out << "QUERY FALSE;\n"; + out << "COUNTERMODEL;\n"; temp_out.close(); @@ -106,18 +71,6 @@ decision_proceduret::resultt cvc_dect::dec_solve() return read_cvcl_result(); } -/*******************************************************************\ - -Function: cvc_dect::read_assert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cvc_dect::read_assert(std::istream &in, std::string &line) { // strip ASSERT @@ -150,8 +103,7 @@ void cvc_dect::read_assert(std::istream &in, std::string &line) std::string value=std::string(line, pos, pos2-pos); #if 0 - std::cout << ">" << identifier << "< = >" << value << "<"; - std::cout << std::endl; + std::cout << ">" << identifier << "< = >" << value << "<\n"; #endif } else @@ -178,18 +130,6 @@ void cvc_dect::read_assert(std::istream &in, std::string &line) } } -/*******************************************************************\ - -Function: cvc_dect::read_cvcl_result - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - decision_proceduret::resultt cvc_dect::read_cvcl_result() { std::ifstream in(temp_result_filename.c_str()); diff --git a/src/solvers/cvc/cvc_dec.h b/src/solvers/cvc/cvc_dec.h index e819edc2755..66f5e77c43a 100644 --- a/src/solvers/cvc/cvc_dec.h +++ b/src/solvers/cvc/cvc_dec.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_CVC_CVC_DEC_H #define CPROVER_SOLVERS_CVC_CVC_DEC_H diff --git a/src/solvers/cvc/cvc_prop.cpp b/src/solvers/cvc/cvc_prop.cpp index 27c499620ea..23f51daa332 100644 --- a/src/solvers/cvc/cvc_prop.cpp +++ b/src/solvers/cvc/cvc_prop.cpp @@ -6,200 +6,81 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include "cvc_prop.h" -/*******************************************************************\ - -Function: cvc_propt::cvc_propt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - explicit cvc_propt::cvc_propt(std::ostream &_out):out(_out) { _no_variables=0; } -/*******************************************************************\ - -Function: cvc_propt::~cvc_propt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - cvc_propt::~cvc_propt() { } -/*******************************************************************\ - -Function: cvc_propt::land - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cvc_propt::land(literalt a, literalt b, literalt o) { - out << "%% land" << std::endl; + out << "%% land\n"; out << "ASSERT (" << cvc_literal(a) << " AND " << cvc_literal(b) << ") <=> " << cvc_literal(o) - << ";" << std::endl << std::endl; + << ";\n\n"; } -/*******************************************************************\ - -Function: cvc_propt::lor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cvc_propt::lor(literalt a, literalt b, literalt o) { - out << "%% lor" << std::endl; + out << "%% lor\n"; out << "ASSERT (" << cvc_literal(a) << " OR " << cvc_literal(b) << ") <=> " << cvc_literal(o) - << ";" << std::endl << std::endl; + << ";\n\n"; } -/*******************************************************************\ - -Function: cvc_propt::lxor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cvc_propt::lxor(literalt a, literalt b, literalt o) { - out << "%% lxor" << std::endl; + out << "%% lxor\n"; out << "ASSERT (" << cvc_literal(a) << " XOR " << cvc_literal(b) << ") <=> " << cvc_literal(o) - << ";" << std::endl << std::endl; + << ";\n\n"; } -/*******************************************************************\ - -Function: cvc_propt::lnand - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cvc_propt::lnand(literalt a, literalt b, literalt o) { - out << "%% lnand" << std::endl; + out << "%% lnand\n"; out << "ASSERT (NOT (" << cvc_literal(a) << " AND " << cvc_literal(b) << ")) <=> " << cvc_literal(o) - << ";" << std::endl << std::endl; + << ";\n\n"; } -/*******************************************************************\ - -Function: cvc_propt::lnor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cvc_propt::lnor(literalt a, literalt b, literalt o) { - out << "%% lnor" << std::endl; + out << "%% lnor\n"; out << "ASSERT (NOT (" << cvc_literal(a) << " OR " << cvc_literal(b) << ")) <=> " << cvc_literal(o) - << ";" << std::endl << std::endl; + << ";\n\n"; } -/*******************************************************************\ - -Function: cvc_propt::lequal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cvc_propt::lequal(literalt a, literalt b, literalt o) { - out << "%% lequal" << std::endl; + out << "%% lequal\n"; out << "ASSERT (" << cvc_literal(a) << " <=> " << cvc_literal(b) << ") <=> " << cvc_literal(o) - << ";" << std::endl << std::endl; + << ";\n\n"; } -/*******************************************************************\ - -Function: cvc_propt::limplies - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cvc_propt::limplies(literalt a, literalt b, literalt o) { - out << "%% limplies" << std::endl; + out << "%% limplies\n"; out << "ASSERT (" << cvc_literal(a) << " => " << cvc_literal(b) << ") <=> " << cvc_literal(o) - << ";" << std::endl << std::endl; + << ";\n\n"; } -/*******************************************************************\ - -Function: cvc_propt::land - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt cvc_propt::land(const bvt &bv) { - out << "%% land" << std::endl; + out << "%% land\n"; literalt literal=def_cvc_literal(); @@ -210,26 +91,14 @@ literalt cvc_propt::land(const bvt &bv) out << cvc_literal(*it); } - out << ";" << std::endl << std::endl; + out << ";\n\n"; return literal; } -/*******************************************************************\ - -Function: cvc_propt::lor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt cvc_propt::lor(const bvt &bv) { - out << "%% lor" << std::endl; + out << "%% lor\n"; literalt literal=def_cvc_literal(); @@ -240,23 +109,11 @@ literalt cvc_propt::lor(const bvt &bv) out << cvc_literal(*it); } - out << ";" << std::endl << std::endl; + out << ";\n\n"; return literal; } -/*******************************************************************\ - -Function: cvc_propt::lxor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt cvc_propt::lxor(const bvt &bv) { if(bv.empty()) @@ -274,18 +131,6 @@ literalt cvc_propt::lxor(const bvt &bv) return literal; } -/*******************************************************************\ - -Function: cvc_propt::land - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt cvc_propt::land(literalt a, literalt b) { if(a==const_literal(true)) @@ -299,28 +144,15 @@ literalt cvc_propt::land(literalt a, literalt b) if(a==b) return a; - out << "%% land" << std::endl; + out << "%% land\n"; literalt o=def_cvc_literal(); - out << cvc_literal(a) << " AND " << cvc_literal(b) << ";" - << std::endl << std::endl; + out << cvc_literal(a) << " AND " << cvc_literal(b) << ";\n\n"; return o; } -/*******************************************************************\ - -Function: cvc_propt::lor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt cvc_propt::lor(literalt a, literalt b) { if(a==const_literal(false)) @@ -334,28 +166,15 @@ literalt cvc_propt::lor(literalt a, literalt b) if(a==b) return a; - out << "%% lor" << std::endl; + out << "%% lor\n"; literalt o=def_cvc_literal(); - out << cvc_literal(a) << " OR " << cvc_literal(b) << ";" - << std::endl << std::endl; + out << cvc_literal(a) << " OR " << cvc_literal(b) << ";\n\n"; return o; } -/*******************************************************************\ - -Function: cvc_propt::lxor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt cvc_propt::lxor(literalt a, literalt b) { if(a==const_literal(false)) @@ -367,96 +186,35 @@ literalt cvc_propt::lxor(literalt a, literalt b) if(b==const_literal(true)) return !a; - out << "%% lxor" << std::endl; + out << "%% lxor\n"; literalt o=def_cvc_literal(); - out << cvc_literal(a) << " XOR " << cvc_literal(b) << ";" - << std::endl << std::endl; + out << cvc_literal(a) << " XOR " << cvc_literal(b) << ";\n\n"; return o; } -/*******************************************************************\ - -Function: cvc_propt::lnand - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt cvc_propt::lnand(literalt a, literalt b) { return !land(a, b); } -/*******************************************************************\ - -Function: cvc_propt::lnor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt cvc_propt::lnor(literalt a, literalt b) { return !lor(a, b); } -/*******************************************************************\ - -Function: cvc_propt::lequal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt cvc_propt::lequal(literalt a, literalt b) { return !lxor(a, b); } -/*******************************************************************\ - -Function: cvc_propt::limplies - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt cvc_propt::limplies(literalt a, literalt b) { return lor(!a, b); } -/*******************************************************************\ - -Function: cvc_propt::lselect - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt cvc_propt::lselect(literalt a, literalt b, literalt c) { if(a==const_literal(true)) @@ -466,51 +224,26 @@ literalt cvc_propt::lselect(literalt a, literalt b, literalt c) if(b==c) return b; - out << "%% lselect" << std::endl; + out << "%% lselect\n"; literalt o=def_cvc_literal(); out << "IF " << cvc_literal(a) << " THEN " << cvc_literal(b) << " ELSE " - << cvc_literal(c) << " ENDIF;" - << std::endl << std::endl; + << cvc_literal(c) << " ENDIF;\n\n"; return o; } -/*******************************************************************\ - -Function: cvc_propt::new_variable - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt cvc_propt::new_variable() { - out << "l" << _no_variables << ": BOOLEAN;" << std::endl; + out << "l" << _no_variables << ": BOOLEAN;\n"; literalt l; l.set(_no_variables, false); _no_variables++; return l; } -/*******************************************************************\ - -Function: cvc_propt::def_cvc_literal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt cvc_propt::def_cvc_literal() { out << "l" << _no_variables << ": BOOLEAN = "; @@ -520,18 +253,6 @@ literalt cvc_propt::def_cvc_literal() return l; } -/*******************************************************************\ - -Function: cvc_propt::lcnf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cvc_propt::lcnf(const bvt &bv) { if(bv.empty()) @@ -555,7 +276,7 @@ void cvc_propt::lcnf(const bvt &bv) assert(!new_bv.empty()); - out << "%% lcnf" << std::endl; + out << "%% lcnf\n"; out << "ASSERT "; for(bvt::const_iterator it=new_bv.begin(); it!=new_bv.end(); it++) @@ -565,21 +286,9 @@ void cvc_propt::lcnf(const bvt &bv) out << cvc_literal(*it); } - out << ";" << std::endl << std::endl; + out << ";\n\n"; } -/*******************************************************************\ - -Function: cvc_propt::cvc_literal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string cvc_propt::cvc_literal(literalt l) { if(l==const_literal(false)) @@ -593,20 +302,8 @@ std::string cvc_propt::cvc_literal(literalt l) return "l"+std::to_string(l.var_no()); } -/*******************************************************************\ - -Function: cvc_propt::prop_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - propt::resultt cvc_propt::prop_solve() { - out << "QUERY FALSE;" << std::endl; + out << "QUERY FALSE;\n"; return P_ERROR; } diff --git a/src/solvers/cvc/cvc_prop.h b/src/solvers/cvc/cvc_prop.h index cc83906a3f7..82786e0a2bb 100644 --- a/src/solvers/cvc/cvc_prop.h +++ b/src/solvers/cvc/cvc_prop.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_CVC_CVC_PROP_H #define CPROVER_SOLVERS_CVC_CVC_PROP_H diff --git a/src/solvers/dplib/dplib_conv.cpp b/src/solvers/dplib/dplib_conv.cpp index d9d7eefbb11..7d0ea0f45c4 100644 --- a/src/solvers/dplib/dplib_conv.cpp +++ b/src/solvers/dplib/dplib_conv.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -21,18 +22,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "dplib_conv.h" -/*******************************************************************\ - -Function: dplib_convt::bin_zero - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string dplib_convt::bin_zero(unsigned bits) { assert(bits!=0); @@ -41,18 +30,6 @@ std::string dplib_convt::bin_zero(unsigned bits) return result; } -/*******************************************************************\ - -Function: dplib_convt::dplib_pointer_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string dplib_convt::dplib_pointer_type() { assert(config.ansi_c.pointer_width!=0); @@ -60,35 +37,11 @@ std::string dplib_convt::dplib_pointer_type() std::to_string(config.ansi_c.pointer_width)+") #]"; } -/*******************************************************************\ - -Function: dplib_convt::array_index_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string dplib_convt::array_index_type() { return std::string("SIGNED [")+std::to_string(32)+"]"; } -/*******************************************************************\ - -Function: dplib_convt::gen_array_index_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet dplib_convt::gen_array_index_type() { typet t(ID_signedbv); @@ -96,35 +49,11 @@ typet dplib_convt::gen_array_index_type() return t; } -/*******************************************************************\ - -Function: dplib_convt::array_index - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string dplib_convt::array_index(unsigned i) { return "0bin"+integer2binary(i, config.ansi_c.int_width); } -/*******************************************************************\ - -Function: dplib_convt::convert_array_index - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dplib_convt::convert_array_index(const exprt &expr) { if(expr.type()==gen_array_index_type()) @@ -139,18 +68,6 @@ void dplib_convt::convert_array_index(const exprt &expr) } } -/*******************************************************************\ - -Function: dplib_convt::convert_address_of_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dplib_convt::convert_address_of_rec(const exprt &expr) { if(expr.id()==ID_symbol || @@ -218,6 +135,7 @@ void dplib_convt::convert_address_of_rec(const exprt &expr) mp_integer offset=member_offset(ns, to_struct_type(struct_op.type()), component_name); + assert(offset>=0); typet index_type(ID_unsignedbv); index_type.set(ID_width, config.ansi_c.pointer_width); @@ -234,21 +152,9 @@ void dplib_convt::convert_address_of_rec(const exprt &expr) throw "don't know how to take address of: "+expr.id_string(); } -/*******************************************************************\ - -Function: dplib_convt::convert_rest - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt dplib_convt::convert_rest(const exprt &expr) { - // dplib_prop.out << "%% E: " << expr << std::endl; + // dplib_prop.out << "%% E: " << expr << '\n'; literalt l=prop.new_variable(); @@ -262,24 +168,12 @@ literalt dplib_convt::convert_rest(const exprt &expr) convert_dplib_expr(expr.op0()); dplib_prop.out << ((expr.id()==ID_equal)?"=":"/="); convert_dplib_expr(expr.op1()); - dplib_prop.out << ");" << std::endl; + dplib_prop.out << ");\n"; } return l; } -/*******************************************************************\ - -Function: dplib_convt::convert_identifier - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dplib_convt::convert_identifier(const std::string &identifier) { for(std::string::const_iterator @@ -316,18 +210,6 @@ void dplib_convt::convert_identifier(const std::string &identifier) } } -/*******************************************************************\ - -Function: dplib_convt::convert_as_bv - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dplib_convt::convert_as_bv(const exprt &expr) { if(expr.type().id()==ID_bool) @@ -340,35 +222,11 @@ void dplib_convt::convert_as_bv(const exprt &expr) convert_dplib_expr(expr); } -/*******************************************************************\ - -Function: dplib_convt::convert_array_value - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dplib_convt::convert_array_value(const exprt &expr) { convert_as_bv(expr); } -/*******************************************************************\ - -Function: dplib_convt::convert_dplib_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dplib_convt::convert_dplib_expr(const exprt &expr) { if(expr.id()==ID_symbol) @@ -1105,18 +963,6 @@ void dplib_convt::convert_dplib_expr(const exprt &expr) throw "convert_dplib_expr: "+expr.id_string()+" is unsupported"; } -/*******************************************************************\ - -Function: dplib_convt::set_to - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dplib_convt::set_to(const exprt &expr, bool value) { if(value && expr.id()==ID_and) @@ -1129,7 +975,7 @@ void dplib_convt::set_to(const exprt &expr, bool value) if(value && expr.is_true()) return; - dplib_prop.out << "// set_to " << (value?"true":"false") << std::endl; + dplib_prop.out << "// set_to " << (value?"true":"false") << '\n'; if(expr.id()==ID_equal && value) { @@ -1159,7 +1005,7 @@ void dplib_convt::set_to(const exprt &expr, bool value) dplib_prop.out << " = "; convert_dplib_expr(expr.op1()); - dplib_prop.out << ";" << std::endl << std::endl; + dplib_prop.out << ";\n\n"; return; } } @@ -1178,21 +1024,9 @@ void dplib_convt::set_to(const exprt &expr, bool value) if(!value) dplib_prop.out << ")"; - dplib_prop.out << ";" << std::endl << std::endl; + dplib_prop.out << ";\n\n"; } -/*******************************************************************\ - -Function: dplib_convt::find_symbols - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dplib_convt::find_symbols(const exprt &expr) { find_symbols(expr.type()); @@ -1216,7 +1050,7 @@ void dplib_convt::find_symbols(const exprt &expr) convert_identifier(id2string(identifier)); dplib_prop.out << ": "; convert_dplib_type(expr.type()); - dplib_prop.out << ";" << std::endl; + dplib_prop.out << ";\n"; } } else if(expr.id()==ID_nondet_symbol) @@ -1235,23 +1069,11 @@ void dplib_convt::find_symbols(const exprt &expr) convert_identifier(id2string(identifier)); dplib_prop.out << ": "; convert_dplib_type(expr.type()); - dplib_prop.out << ";" << std::endl; + dplib_prop.out << ";\n"; } } } -/*******************************************************************\ - -Function: dplib_convt::convert_dplib_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dplib_convt::convert_dplib_type(const typet &type) { if(type.id()==ID_array) @@ -1335,18 +1157,6 @@ void dplib_convt::convert_dplib_type(const typet &type) throw "unsupported type: "+type.id_string(); } -/*******************************************************************\ - -Function: dplib_convt::find_symbols - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dplib_convt::find_symbols(const typet &type) { if(type.id()==ID_array) diff --git a/src/solvers/dplib/dplib_conv.h b/src/solvers/dplib/dplib_conv.h index a4f2f0558f4..74034d6c1e2 100644 --- a/src/solvers/dplib/dplib_conv.h +++ b/src/solvers/dplib/dplib_conv.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_DPLIB_DPLIB_CONV_H #define CPROVER_SOLVERS_DPLIB_DPLIB_CONV_H diff --git a/src/solvers/dplib/dplib_dec.cpp b/src/solvers/dplib/dplib_dec.cpp index 66369bdc1ff..1750e7bc6f9 100644 --- a/src/solvers/dplib/dplib_dec.cpp +++ b/src/solvers/dplib/dplib_dec.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -28,18 +29,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "dplib_dec.h" -/*******************************************************************\ - -Function: dplib_temp_filet::dplib_temp_filet - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - dplib_temp_filet::dplib_temp_filet() { temp_out_filename="dplib_dec_out_"+std::to_string(getpid())+".tmp"; @@ -49,18 +38,6 @@ dplib_temp_filet::dplib_temp_filet() std::ios_base::out | std::ios_base::trunc); } -/*******************************************************************\ - -Function: dplib_temp_filet::~dplib_temp_filet - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - dplib_temp_filet::~dplib_temp_filet() { temp_out.close(); @@ -72,22 +49,10 @@ dplib_temp_filet::~dplib_temp_filet() unlink(temp_result_filename.c_str()); } -/*******************************************************************\ - -Function: dplib_dect::dec_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - decision_proceduret::resultt dplib_dect::dec_solve() { - dplib_prop.out << "QUERY FALSE;" << std::endl; - dplib_prop.out << "COUNTERMODEL;" << std::endl; + dplib_prop.out << "QUERY FALSE;\n"; + dplib_prop.out << "COUNTERMODEL;\n"; post_process(); @@ -107,18 +72,6 @@ decision_proceduret::resultt dplib_dect::dec_solve() return read_dplib_result(); } -/*******************************************************************\ - -Function: dplib_dect::read_assert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dplib_dect::read_assert(std::istream &in, std::string &line) { // strip ASSERT @@ -151,8 +104,7 @@ void dplib_dect::read_assert(std::istream &in, std::string &line) std::string value=std::string(line, pos, pos2-pos); #if 0 - std::cout << ">" << identifier << "< = >" << value << "<"; - std::cout << std::endl; + std::cout << ">" << identifier << "< = >" << value << "<\n"; #endif } else @@ -178,18 +130,6 @@ void dplib_dect::read_assert(std::istream &in, std::string &line) } } -/*******************************************************************\ - -Function: dplib_dect::read_dplib_result - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - decision_proceduret::resultt dplib_dect::read_dplib_result() { std::ifstream in(temp_result_filename.c_str()); diff --git a/src/solvers/dplib/dplib_dec.h b/src/solvers/dplib/dplib_dec.h index 6f722569ec4..ca481518a80 100644 --- a/src/solvers/dplib/dplib_dec.h +++ b/src/solvers/dplib/dplib_dec.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_DPLIB_DPLIB_DEC_H #define CPROVER_SOLVERS_DPLIB_DPLIB_DEC_H diff --git a/src/solvers/dplib/dplib_prop.cpp b/src/solvers/dplib/dplib_prop.cpp index 5153b6874de..ccc22614198 100644 --- a/src/solvers/dplib/dplib_prop.cpp +++ b/src/solvers/dplib/dplib_prop.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -13,179 +14,71 @@ Author: Daniel Kroening, kroening@kroening.com #include "dplib_prop.h" -/*******************************************************************\ - -Function: dplib_propt::dplib_propt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - dplib_propt::dplib_propt(std::ostream &_out):out(_out) { // we skip index 0 _no_variables=1; } -/*******************************************************************\ - -Function: dplib_propt::land - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dplib_propt::land(literalt a, literalt b, literalt o) { - out << "// land" << std::endl; + out << "// land\n"; out << "AXIOM (" << dplib_literal(a) << " & " << dplib_literal(b) << ") <=> " << dplib_literal(o) - << ";" << std::endl << std::endl; + << ";\n\n"; } -/*******************************************************************\ - -Function: dplib_propt::lor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dplib_propt::lor(literalt a, literalt b, literalt o) { - out << "// lor" << std::endl; + out << "// lor\n"; out << "AXIOM (" << dplib_literal(a) << " | " << dplib_literal(b) << ") <=> " << dplib_literal(o) - << ";" << std::endl << std::endl; + << ";\n\n"; } -/*******************************************************************\ - -Function: dplib_propt::lxor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dplib_propt::lxor(literalt a, literalt b, literalt o) { - out << "// lxor" << std::endl; + out << "// lxor\n"; out << "AXIOM (" << dplib_literal(a) << " <=> " << dplib_literal(b) << ") <=> !" << dplib_literal(o) - << ";" << std::endl << std::endl; + << ";\n\n"; } -/*******************************************************************\ - -Function: dplib_propt::lnand - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dplib_propt::lnand(literalt a, literalt b, literalt o) { - out << "// lnand" << std::endl; + out << "// lnand\n"; out << "AXIOM (" << dplib_literal(a) << " & " << dplib_literal(b) << ") <=> !" << dplib_literal(o) - << ";" << std::endl << std::endl; + << ";\n\n"; } -/*******************************************************************\ - -Function: dplib_propt::lnor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dplib_propt::lnor(literalt a, literalt b, literalt o) { - out << "// lnor" << std::endl; + out << "// lnor\n"; out << "AXIOM (" << dplib_literal(a) << " | " << dplib_literal(b) << ") <=> !" << dplib_literal(o) - << ";" << std::endl << std::endl; + << ";\n\n"; } -/*******************************************************************\ - -Function: dplib_propt::lequal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dplib_propt::lequal(literalt a, literalt b, literalt o) { - out << "// lequal" << std::endl; + out << "// lequal\n"; out << "AXIOM (" << dplib_literal(a) << " <=> " << dplib_literal(b) << ") <=> " << dplib_literal(o) - << ";" << std::endl << std::endl; + << ";\n\n"; } -/*******************************************************************\ - -Function: dplib_propt::limplies - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dplib_propt::limplies(literalt a, literalt b, literalt o) { - out << "// limplies" << std::endl; + out << "// limplies\n"; out << "AXIOM (" << dplib_literal(a) << " => " << dplib_literal(b) << ") <=> " << dplib_literal(o) - << ";" << std::endl << std::endl; + << ";\n\n"; } -/*******************************************************************\ - -Function: dplib_propt::land - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt dplib_propt::land(const bvt &bv) { - out << "// land" << std::endl; + out << "// land\n"; literalt literal=def_dplib_literal(); @@ -196,26 +89,14 @@ literalt dplib_propt::land(const bvt &bv) out << dplib_literal(*it); } - out << std::endl << std::endl; + out << "\n\n"; return literal; } -/*******************************************************************\ - -Function: dplib_propt::lor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt dplib_propt::lor(const bvt &bv) { - out << "// lor" << std::endl; + out << "// lor\n"; literalt literal=def_dplib_literal(); @@ -226,23 +107,11 @@ literalt dplib_propt::lor(const bvt &bv) out << dplib_literal(*it); } - out << std::endl << std::endl; + out << "\n\n"; return literal; } -/*******************************************************************\ - -Function: dplib_propt::lxor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt dplib_propt::lxor(const bvt &bv) { if(bv.empty()) @@ -260,18 +129,6 @@ literalt dplib_propt::lxor(const bvt &bv) return literal; } -/*******************************************************************\ - -Function: dplib_propt::land - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt dplib_propt::land(literalt a, literalt b) { if(a==const_literal(true)) @@ -287,23 +144,11 @@ literalt dplib_propt::land(literalt a, literalt b) literalt o=def_dplib_literal(); out << dplib_literal(a) << " & " << dplib_literal(b) - << ";" << std::endl << std::endl; + << ";\n\n"; return o; } -/*******************************************************************\ - -Function: dplib_propt::lor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt dplib_propt::lor(literalt a, literalt b) { if(a==const_literal(false)) @@ -319,23 +164,11 @@ literalt dplib_propt::lor(literalt a, literalt b) literalt o=def_dplib_literal(); out << dplib_literal(a) << " | " << dplib_literal(b) - << ";" << std::endl << std::endl; + << ";\n\n"; return o; } -/*******************************************************************\ - -Function: dplib_propt::lxor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt dplib_propt::lxor(literalt a, literalt b) { if(a==const_literal(false)) @@ -349,91 +182,31 @@ literalt dplib_propt::lxor(literalt a, literalt b) literalt o=def_dplib_literal(); out << "!(" << dplib_literal(a) << " <-> " << dplib_literal(b) - << ");" << std::endl << std::endl; + << ");\n\n"; return o; } -/*******************************************************************\ - -Function: dplib_propt::lnand - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt dplib_propt::lnand(literalt a, literalt b) { return !land(a, b); } -/*******************************************************************\ - -Function: dplib_propt::lnor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt dplib_propt::lnor(literalt a, literalt b) { return !lor(a, b); } -/*******************************************************************\ - -Function: dplib_propt::lequal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt dplib_propt::lequal(literalt a, literalt b) { return !lxor(a, b); } -/*******************************************************************\ - -Function: dplib_propt::limplies - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt dplib_propt::limplies(literalt a, literalt b) { return lor(!a, b); } -/*******************************************************************\ - -Function: dplib_propt::lselect - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt dplib_propt::lselect(literalt a, literalt b, literalt c) { if(a==const_literal(true)) @@ -443,51 +216,26 @@ literalt dplib_propt::lselect(literalt a, literalt b, literalt c) if(b==c) return b; - out << "// lselect" << std::endl; + out << "// lselect\n"; literalt o=def_dplib_literal(); out << "IF " << dplib_literal(a) << " THEN " << dplib_literal(b) << " ELSE " - << dplib_literal(c) << " ENDIF;" - << std::endl << std::endl; + << dplib_literal(c) << " ENDIF;\n\n"; return o; } -/*******************************************************************\ - -Function: dplib_propt::new_variable - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt dplib_propt::new_variable() { _no_variables++; - out << "l" << _no_variables << ": boolean;" << std::endl; + out << "l" << _no_variables << ": boolean;\n"; literalt l; l.set(_no_variables, false); return l; } -/*******************************************************************\ - -Function: dplib_propt::def_dplib_literal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt dplib_propt::def_dplib_literal() { _no_variables++; @@ -497,18 +245,6 @@ literalt dplib_propt::def_dplib_literal() return l; } -/*******************************************************************\ - -Function: dplib_propt::lcnf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dplib_propt::lcnf(const bvt &bv) { if(bv.empty()) @@ -532,7 +268,7 @@ void dplib_propt::lcnf(const bvt &bv) assert(!new_bv.empty()); - out << "// lcnf" << std::endl; + out << "// lcnf\n"; out << "AXIOM "; for(bvt::const_iterator it=new_bv.begin(); it!=new_bv.end(); it++) @@ -542,21 +278,9 @@ void dplib_propt::lcnf(const bvt &bv) out << dplib_literal(*it); } - out << ";" << std::endl << std::endl; + out << ";\n\n"; } -/*******************************************************************\ - -Function: dplib_propt::dplib_literal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string dplib_propt::dplib_literal(literalt l) { if(l==const_literal(false)) @@ -570,36 +294,12 @@ std::string dplib_propt::dplib_literal(literalt l) return "l"+std::to_string(l.var_no()); } -/*******************************************************************\ - -Function: dplib_propt::finish - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dplib_propt::finish() { // we want satisfiability - out << "THEOREM false;" << std::endl; + out << "THEOREM false;\n"; } -/*******************************************************************\ - -Function: dplib_propt::prop_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - propt::resultt dplib_propt::prop_solve() { finish(); diff --git a/src/solvers/dplib/dplib_prop.h b/src/solvers/dplib/dplib_prop.h index 7aec9d47980..89441646093 100644 --- a/src/solvers/dplib/dplib_prop.h +++ b/src/solvers/dplib/dplib_prop.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_DPLIB_DPLIB_PROP_H #define CPROVER_SOLVERS_DPLIB_DPLIB_PROP_H diff --git a/src/solvers/flattening/arrays.cpp b/src/solvers/flattening/arrays.cpp index 10c29c2ae76..a7c92cbc277 100644 --- a/src/solvers/flattening/arrays.cpp +++ b/src/solvers/flattening/arrays.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -21,18 +22,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "arrays.h" -/*******************************************************************\ - -Function: arrayst::arrayst - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - arrayst::arrayst( const namespacet &_ns, propt &_prop):equalityt(_ns, _prop) @@ -41,18 +30,6 @@ arrayst::arrayst( incremental_cache = false; // for incremental solving } -/*******************************************************************\ - -Function: arrayst::record_array_index - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void arrayst::record_array_index(const index_exprt &index) { // we are not allowed to put the index directly in the @@ -63,18 +40,6 @@ void arrayst::record_array_index(const index_exprt &index) update_indices.insert(number); } -/*******************************************************************\ - -Function: arrayst::record_array_equality - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt arrayst::record_array_equality( const equal_exprt &equality) { @@ -84,7 +49,7 @@ literalt arrayst::record_array_equality( // check types if(!base_type_eq(op0.type(), op1.type(), ns)) { - std::cout << equality.pretty() << std::endl; + std::cout << equality.pretty() << '\n'; throw "record_array_equality got equality without matching types"; } @@ -103,18 +68,6 @@ literalt arrayst::record_array_equality( return array_equalities.back().l; } -/*******************************************************************\ - -Function: arrayst::collect_indices - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void arrayst::collect_indices() { for(std::size_t i=0; ifirst) << " = " << from_expr(ns, "", arrays[arrays.find_number(i1->first)]) << "): " - << from_expr(ns, "", *i2) << std::endl; - std::cout << "-----" << std::endl; + << from_expr(ns, "", *i2) << '\n'; + std::cout << "-----\n"; #endif } -/*******************************************************************\ - -Function: arrayst::add_array_constraints - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void arrayst::add_array_constraints( const index_sett &index_set, const array_equalityt &array_equality) @@ -569,18 +450,6 @@ void arrayst::add_array_constraints( } } -/*******************************************************************\ - -Function: arrayst::add_array_constraints - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void arrayst::add_array_constraints( const index_sett &index_set, const exprt &expr) @@ -648,18 +517,6 @@ void arrayst::add_array_constraints( expr.id_string()+"'"; } -/*******************************************************************\ - -Function: arrayst::add_array_constraints_with - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void arrayst::add_array_constraints_with( const index_sett &index_set, const with_exprt &expr) @@ -678,7 +535,7 @@ void arrayst::add_array_constraints_with( if(index_expr.type()!=value.type()) { - std::cout << expr.pretty() << std::endl; + std::cout << expr.pretty() << '\n'; assert(false); } @@ -743,18 +600,6 @@ void arrayst::add_array_constraints_with( } } -/*******************************************************************\ - -Function: arrayst::add_array_constraints_update - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void arrayst::add_array_constraints_update( const index_sett &index_set, const update_exprt &expr) @@ -774,7 +619,7 @@ void arrayst::add_array_constraints_update( if(index_expr.type()!=value.type()) { - std::cout << expr.pretty() << std::endl; + std::cout << expr.pretty() << '\n'; assert(false); } @@ -830,18 +675,6 @@ void arrayst::add_array_constraints_update( #endif } -/*******************************************************************\ - -Function: arrayst::add_array_constraints_array_of - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void arrayst::add_array_constraints_array_of( const index_sett &index_set, const array_of_exprt &expr) @@ -869,18 +702,6 @@ void arrayst::add_array_constraints_array_of( } } -/*******************************************************************\ - -Function: arrayst::add_array_constraints_if - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void arrayst::add_array_constraints_if( const index_sett &index_set, const if_exprt &expr) diff --git a/src/solvers/flattening/arrays.h b/src/solvers/flattening/arrays.h index 3277c4671ec..b0c1e45cfe4 100644 --- a/src/solvers/flattening/arrays.h +++ b/src/solvers/flattening/arrays.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Theory of Arrays with Extensionality + #ifndef CPROVER_SOLVERS_FLATTENING_ARRAYS_H #define CPROVER_SOLVERS_FLATTENING_ARRAYS_H diff --git a/src/solvers/flattening/boolbv.cpp b/src/solvers/flattening/boolbv.cpp index f261452c2b0..3c6de247d15 100644 --- a/src/solvers/flattening/boolbv.cpp +++ b/src/solvers/flattening/boolbv.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include @@ -27,18 +28,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "../floatbv/float_utils.h" -/*******************************************************************\ - -Function: boolbvt::literal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool boolbvt::literal( const exprt &expr, const std::size_t bit, @@ -123,18 +112,6 @@ bool boolbvt::literal( throw "found no literal for expression"; } -/*******************************************************************\ - -Function: boolbvt::convert_bv - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const bvt &boolbvt::convert_bv(const exprt &expr) { // check cache first @@ -165,18 +142,6 @@ const bvt &boolbvt::convert_bv(const exprt &expr) return cache_result.first->second; } -/*******************************************************************\ - -Function: boolbvt::conversion_failed - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::conversion_failed(const exprt &expr) { ignoring(expr); @@ -186,18 +151,6 @@ bvt boolbvt::conversion_failed(const exprt &expr) return prop.new_variables(width); } -/*******************************************************************\ - -Function: boolbvt::convert_bitvector - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::convert_bitvector(const exprt &expr) { if(expr.type().id()==ID_bool) @@ -354,18 +307,6 @@ bvt boolbvt::convert_bitvector(const exprt &expr) return conversion_failed(expr); } -/*******************************************************************\ - -Function: boolbvt::convert_lambda - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::convert_lambda(const exprt &expr) { std::size_t width=boolbv_width(expr.type()); @@ -413,18 +354,6 @@ bvt boolbvt::convert_lambda(const exprt &expr) return bv; } -/*******************************************************************\ - -Function: boolbvt::convert_bv_literals - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::convert_bv_literals(const exprt &expr) { std::size_t width=boolbv_width(expr.type()); @@ -446,18 +375,6 @@ bvt boolbvt::convert_bv_literals(const exprt &expr) return bv; } -/*******************************************************************\ - -Function: boolbvt::convert_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::convert_symbol(const exprt &expr) { const typet &type=expr.type(); @@ -493,18 +410,6 @@ bvt boolbvt::convert_symbol(const exprt &expr) } -/*******************************************************************\ - -Function: boolbvt::convert_function_application - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::convert_function_application( const function_application_exprt &expr) { @@ -516,18 +421,6 @@ bvt boolbvt::convert_function_application( } -/*******************************************************************\ - -Function: boolbvt::convert_rest - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt boolbvt::convert_rest(const exprt &expr) { if(expr.type().id()!=ID_bool) @@ -694,18 +587,6 @@ literalt boolbvt::convert_rest(const exprt &expr) return SUB::convert_rest(expr); } -/*******************************************************************\ - -Function: boolbvt::boolbv_set_equality_to_true - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool boolbvt::boolbv_set_equality_to_true(const equal_exprt &expr) { if(!equality_propagation) @@ -737,18 +618,6 @@ bool boolbvt::boolbv_set_equality_to_true(const equal_exprt &expr) return true; } -/*******************************************************************\ - -Function: boolbvt::set_to - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void boolbvt::set_to(const exprt &expr, bool value) { if(expr.type().id()!=ID_bool) @@ -770,18 +639,6 @@ void boolbvt::set_to(const exprt &expr, bool value) return SUB::set_to(expr, value); } -/*******************************************************************\ - -Function: boolbvt::make_bv_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void boolbvt::make_bv_expr(const typet &type, const bvt &bv, exprt &dest) { dest=exprt(ID_bv_literals, type); @@ -793,18 +650,6 @@ void boolbvt::make_bv_expr(const typet &type, const bvt &bv, exprt &dest) bv_sub[i].id(std::to_string(bv[i].get())); } -/*******************************************************************\ - -Function: boolbvt::make_bv_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void boolbvt::make_free_bv_expr(const typet &type, exprt &dest) { std::size_t width=boolbv_width(type); @@ -825,18 +670,6 @@ void boolbvt::make_free_bv_expr(const typet &type, exprt &dest) make_bv_expr(type, bv, dest); } -/*******************************************************************\ - -Function: boolbvt::is_unbounded_array - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool boolbvt::is_unbounded_array(const typet &type) const { if(type.id()==ID_symbol) @@ -861,18 +694,6 @@ bool boolbvt::is_unbounded_array(const typet &type) const return false; } -/*******************************************************************\ - -Function: boolbvt::print_assignment - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void boolbvt::print_assignment(std::ostream &out) const { for(boolbv_mapt::mappingt::const_iterator it=map.mapping.begin(); @@ -884,18 +705,6 @@ void boolbvt::print_assignment(std::ostream &out) const } } -/*******************************************************************\ - -Function: boolbvt::build_offset_map - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void boolbvt::build_offset_map(const struct_typet &src, offset_mapt &dest) { const struct_typet::componentst &components= diff --git a/src/solvers/flattening/boolbv.h b/src/solvers/flattening/boolbv.h index 578521a6e3d..f015e96097b 100644 --- a/src/solvers/flattening/boolbv.h +++ b/src/solvers/flattening/boolbv.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_FLATTENING_BOOLBV_H #define CPROVER_SOLVERS_FLATTENING_BOOLBV_H diff --git a/src/solvers/flattening/boolbv_abs.cpp b/src/solvers/flattening/boolbv_abs.cpp index 7c93353b45b..c32bca58cd9 100644 --- a/src/solvers/flattening/boolbv_abs.cpp +++ b/src/solvers/flattening/boolbv_abs.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "boolbv.h" @@ -13,18 +14,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "../floatbv/float_utils.h" -/*******************************************************************\ - -Function: boolbvt::convert_abs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::convert_abs(const exprt &expr) { std::size_t width=boolbv_width(expr.type()); diff --git a/src/solvers/flattening/boolbv_add_sub.cpp b/src/solvers/flattening/boolbv_add_sub.cpp index 9bcb6281be6..373738fe1fc 100644 --- a/src/solvers/flattening/boolbv_add_sub.cpp +++ b/src/solvers/flattening/boolbv_add_sub.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -14,18 +15,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "../floatbv/float_utils.h" -/*******************************************************************\ - -Function: boolbvt::convert_add_sub - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::convert_add_sub(const exprt &expr) { const typet &type=ns.follow(expr.type()); @@ -53,7 +42,7 @@ bvt boolbvt::convert_add_sub(const exprt &expr) if(op0.type()!=type) { - std::cerr << expr.pretty() << std::endl; + std::cerr << expr.pretty() << '\n'; throw "add/sub with mixed types"; } @@ -83,7 +72,7 @@ bvt boolbvt::convert_add_sub(const exprt &expr) { if(it->type()!=type) { - std::cerr << expr.pretty() << std::endl; + std::cerr << expr.pretty() << '\n'; throw "add/sub with mixed types"; } diff --git a/src/solvers/flattening/boolbv_array.cpp b/src/solvers/flattening/boolbv_array.cpp index e6a44279684..b96639a6d40 100644 --- a/src/solvers/flattening/boolbv_array.cpp +++ b/src/solvers/flattening/boolbv_array.cpp @@ -6,19 +6,8 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "boolbv.h" - -/*******************************************************************\ - -Function: boolbvt::convert_array - - Inputs: - Outputs: - - Purpose: - -\*******************************************************************/ +#include "boolbv.h" bvt boolbvt::convert_array(const exprt &expr) { diff --git a/src/solvers/flattening/boolbv_array_of.cpp b/src/solvers/flattening/boolbv_array_of.cpp index 74056d2df50..09fefee64e1 100644 --- a/src/solvers/flattening/boolbv_array_of.cpp +++ b/src/solvers/flattening/boolbv_array_of.cpp @@ -6,23 +6,12 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include "boolbv.h" -/*******************************************************************\ - -Function: boolbvt::convert_array_of - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::convert_array_of(const array_of_exprt &expr) { if(expr.type().id()!=ID_array) diff --git a/src/solvers/flattening/boolbv_bitwise.cpp b/src/solvers/flattening/boolbv_bitwise.cpp index 52d48b19c77..9eda6eafcd9 100644 --- a/src/solvers/flattening/boolbv_bitwise.cpp +++ b/src/solvers/flattening/boolbv_bitwise.cpp @@ -6,19 +6,8 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "boolbv.h" - -/*******************************************************************\ - -Function: boolbvt::convert_bitwise - - Inputs: - Outputs: - - Purpose: - -\*******************************************************************/ +#include "boolbv.h" bvt boolbvt::convert_bitwise(const exprt &expr) { diff --git a/src/solvers/flattening/boolbv_bv_rel.cpp b/src/solvers/flattening/boolbv_bv_rel.cpp index 8b2984e2343..7cf08127937 100644 --- a/src/solvers/flattening/boolbv_bv_rel.cpp +++ b/src/solvers/flattening/boolbv_bv_rel.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "boolbv.h" @@ -13,18 +14,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "../floatbv/float_utils.h" -/*******************************************************************\ - -Function: boolbvt::convert_bv_rel - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt boolbvt::convert_bv_rel(const exprt &expr) { const exprt::operandst &operands=expr.operands(); diff --git a/src/solvers/flattening/boolbv_byte_extract.cpp b/src/solvers/flattening/boolbv_byte_extract.cpp index 2dd32ba35f7..98a8e4b507d 100644 --- a/src/solvers/flattening/boolbv_byte_extract.cpp +++ b/src/solvers/flattening/boolbv_byte_extract.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -16,18 +17,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" #include "flatten_byte_operators.h" -/*******************************************************************\ - -Function: map_bv - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt map_bv(const endianness_mapt &map, const bvt &src) { assert(map.number_of_bits()==src.size()); @@ -45,18 +34,6 @@ bvt map_bv(const endianness_mapt &map, const bvt &src) return result; } -/*******************************************************************\ - -Function: boolbvt::convert_byte_extract - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::convert_byte_extract(const byte_extract_exprt &expr) { if(expr.operands().size()!=2) diff --git a/src/solvers/flattening/boolbv_byte_update.cpp b/src/solvers/flattening/boolbv_byte_update.cpp index 7ff0408a661..cd8851ccfcf 100644 --- a/src/solvers/flattening/boolbv_byte_update.cpp +++ b/src/solvers/flattening/boolbv_byte_update.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -15,18 +16,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" -/*******************************************************************\ - -Function: boolbvt::convert_byte_update - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::convert_byte_update(const byte_update_exprt &expr) { if(expr.operands().size()!=3) diff --git a/src/solvers/flattening/boolbv_case.cpp b/src/solvers/flattening/boolbv_case.cpp index 6a56f35fa7f..9bedb525dce 100644 --- a/src/solvers/flattening/boolbv_case.cpp +++ b/src/solvers/flattening/boolbv_case.cpp @@ -6,22 +6,11 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "boolbv.h" -/*******************************************************************\ - -Function: boolbvt::convert_case - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::convert_case(const exprt &expr) { const std::vector &operands=expr.operands(); @@ -64,10 +53,9 @@ bvt boolbvt::convert_case(const exprt &expr) if(compare_bv.size()!=op.size()) { std::cerr << "compare operand: " << compare_bv.size() - << std::endl - << "operand: " << op.size() << std::endl + << "\noperand: " << op.size() << '\n' << it->pretty() - << std::endl; + << '\n'; throw "size of compare operand does not match"; } @@ -84,10 +72,9 @@ bvt boolbvt::convert_case(const exprt &expr) if(bv.size()!=op.size()) { std::cerr << "result size: " << bv.size() - << std::endl - << "operand: " << op.size() << std::endl + << "\noperand: " << op.size() << '\n' << it->pretty() - << std::endl; + << '\n'; throw "size of value operand does not match"; } diff --git a/src/solvers/flattening/boolbv_complex.cpp b/src/solvers/flattening/boolbv_complex.cpp index 3d5407537a2..833795be842 100644 --- a/src/solvers/flattening/boolbv_complex.cpp +++ b/src/solvers/flattening/boolbv_complex.cpp @@ -6,19 +6,8 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "boolbv.h" - -/*******************************************************************\ - -Function: boolbvt::convert_complex - - Inputs: - - Outputs: - - Purpose: -\*******************************************************************/ +#include "boolbv.h" bvt boolbvt::convert_complex(const exprt &expr) { @@ -56,18 +45,6 @@ bvt boolbvt::convert_complex(const exprt &expr) return conversion_failed(expr); } -/*******************************************************************\ - -Function: boolbvt::convert_complex_real - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::convert_complex_real(const exprt &expr) { std::size_t width=boolbv_width(expr.type()); @@ -86,18 +63,6 @@ bvt boolbvt::convert_complex_real(const exprt &expr) return bv; } -/*******************************************************************\ - -Function: boolbvt::convert_complex_imag - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::convert_complex_imag(const exprt &expr) { std::size_t width=boolbv_width(expr.type()); diff --git a/src/solvers/flattening/boolbv_concatenation.cpp b/src/solvers/flattening/boolbv_concatenation.cpp index ef3896053fe..73a2a1b922b 100644 --- a/src/solvers/flattening/boolbv_concatenation.cpp +++ b/src/solvers/flattening/boolbv_concatenation.cpp @@ -6,19 +6,8 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "boolbv.h" - -/*******************************************************************\ - -Function: boolbvt::convert_concatenation - - Inputs: - Outputs: - - Purpose: - -\*******************************************************************/ +#include "boolbv.h" bvt boolbvt::convert_concatenation(const exprt &expr) { diff --git a/src/solvers/flattening/boolbv_cond.cpp b/src/solvers/flattening/boolbv_cond.cpp index 4e966a69440..0b2184a2129 100644 --- a/src/solvers/flattening/boolbv_cond.cpp +++ b/src/solvers/flattening/boolbv_cond.cpp @@ -6,22 +6,11 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "boolbv.h" -/*******************************************************************\ - -Function: boolbvt::convert_cond - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::convert_cond(const exprt &expr) { const exprt::operandst &operands=expr.operands(); @@ -66,10 +55,9 @@ bvt boolbvt::convert_cond(const exprt &expr) if(bv.size()!=op.size()) { std::cerr << "result size: " << bv.size() - << std::endl - << "operand: " << op.size() << std::endl + << "\noperand: " << op.size() << '\n' << it->pretty() - << std::endl; + << '\n'; throw "size of value operand does not match"; } diff --git a/src/solvers/flattening/boolbv_constant.cpp b/src/solvers/flattening/boolbv_constant.cpp index ebeb3a5a1db..612cee9d63c 100644 --- a/src/solvers/flattening/boolbv_constant.cpp +++ b/src/solvers/flattening/boolbv_constant.cpp @@ -6,19 +6,8 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "boolbv.h" - -/*******************************************************************\ - -Function: boolbvt::convert_constant - - Inputs: - Outputs: - - Purpose: - -\*******************************************************************/ +#include "boolbv.h" bvt boolbvt::convert_constant(const constant_exprt &expr) { diff --git a/src/solvers/flattening/boolbv_constraint_select_one.cpp b/src/solvers/flattening/boolbv_constraint_select_one.cpp index c6c9b53bd50..64ba997d395 100644 --- a/src/solvers/flattening/boolbv_constraint_select_one.cpp +++ b/src/solvers/flattening/boolbv_constraint_select_one.cpp @@ -6,19 +6,8 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "boolbv.h" - -/*******************************************************************\ - -Function: boolbvt::convert_constraint_select_one - - Inputs: - Outputs: - - Purpose: - -\*******************************************************************/ +#include "boolbv.h" bvt boolbvt::convert_constraint_select_one(const exprt &expr) { diff --git a/src/solvers/flattening/boolbv_div.cpp b/src/solvers/flattening/boolbv_div.cpp index 4689829c53f..1eacc7c64ca 100644 --- a/src/solvers/flattening/boolbv_div.cpp +++ b/src/solvers/flattening/boolbv_div.cpp @@ -6,22 +6,11 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "boolbv.h" -/*******************************************************************\ - -Function: boolbvt::convert_div - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::convert_div(const div_exprt &expr) { if(expr.type().id()!=ID_unsignedbv && diff --git a/src/solvers/flattening/boolbv_equality.cpp b/src/solvers/flattening/boolbv_equality.cpp index 53cbb624815..997f8738c97 100644 --- a/src/solvers/flattening/boolbv_equality.cpp +++ b/src/solvers/flattening/boolbv_equality.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -16,24 +17,12 @@ Author: Daniel Kroening, kroening@kroening.com #include "flatten_byte_operators.h" #include "boolbv.h" -/*******************************************************************\ - -Function: boolbvt::convert_equality - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt boolbvt::convert_equality(const equal_exprt &expr) { if(!base_type_eq(expr.lhs().type(), expr.rhs().type(), ns)) { - std::cout << "######### lhs: " << expr.lhs().pretty() << std::endl; - std::cout << "######### rhs: " << expr.rhs().pretty() << std::endl; + std::cout << "######### lhs: " << expr.lhs().pretty() << '\n'; + std::cout << "######### rhs: " << expr.rhs().pretty() << '\n'; throw "equality without matching types"; } @@ -56,10 +45,10 @@ literalt boolbvt::convert_equality(const equal_exprt &expr) if(bv0.size()!=bv1.size()) { - std::cerr << "lhs: " << expr.lhs().pretty() << std::endl; - std::cerr << "lhs size: " << bv0.size() << std::endl; - std::cerr << "rhs: " << expr.rhs().pretty() << std::endl; - std::cerr << "rhs size: " << bv1.size() << std::endl; + std::cerr << "lhs: " << expr.lhs().pretty() << '\n'; + std::cerr << "lhs size: " << bv0.size() << '\n'; + std::cerr << "rhs: " << expr.rhs().pretty() << '\n'; + std::cerr << "rhs size: " << bv1.size() << '\n'; throw "unexpected size mismatch on equality"; } @@ -73,18 +62,6 @@ literalt boolbvt::convert_equality(const equal_exprt &expr) return bv_utils.equal(bv0, bv1); } -/*******************************************************************\ - -Function: boolbvt::convert_verilog_case_equality - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt boolbvt::convert_verilog_case_equality( const binary_relation_exprt &expr) { @@ -93,8 +70,8 @@ literalt boolbvt::convert_verilog_case_equality( if(!base_type_eq(expr.lhs().type(), expr.rhs().type(), ns)) { - std::cout << "######### lhs: " << expr.lhs().pretty() << std::endl; - std::cout << "######### rhs: " << expr.rhs().pretty() << std::endl; + std::cout << "######### lhs: " << expr.lhs().pretty() << '\n'; + std::cout << "######### rhs: " << expr.rhs().pretty() << '\n'; throw "verilog_case_equality without matching types"; } @@ -103,10 +80,10 @@ literalt boolbvt::convert_verilog_case_equality( if(bv0.size()!=bv1.size()) { - std::cerr << "lhs: " << expr.lhs().pretty() << std::endl; - std::cerr << "lhs size: " << bv0.size() << std::endl; - std::cerr << "rhs: " << expr.rhs().pretty() << std::endl; - std::cerr << "rhs size: " << bv1.size() << std::endl; + std::cerr << "lhs: " << expr.lhs().pretty() << '\n'; + std::cerr << "lhs size: " << bv0.size() << '\n'; + std::cerr << "rhs: " << expr.rhs().pretty() << '\n'; + std::cerr << "rhs size: " << bv1.size() << '\n'; throw "unexpected size mismatch on verilog_case_equality"; } diff --git a/src/solvers/flattening/boolbv_extractbit.cpp b/src/solvers/flattening/boolbv_extractbit.cpp index cdccc52f578..607926550a8 100644 --- a/src/solvers/flattening/boolbv_extractbit.cpp +++ b/src/solvers/flattening/boolbv_extractbit.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -15,18 +16,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" -/*******************************************************************\ - -Function: boolbvt::convert_extractbit - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt boolbvt::convert_extractbit(const extractbit_exprt &expr) { const exprt::operandst &operands=expr.operands(); diff --git a/src/solvers/flattening/boolbv_extractbits.cpp b/src/solvers/flattening/boolbv_extractbits.cpp index 5bf2ac0f4c4..e0576b0222c 100644 --- a/src/solvers/flattening/boolbv_extractbits.cpp +++ b/src/solvers/flattening/boolbv_extractbits.cpp @@ -6,22 +6,11 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "boolbv.h" -/*******************************************************************\ - -Function: boolbvt::convert_extractbits - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::convert_extractbits(const extractbits_exprt &expr) { std::size_t width=boolbv_width(expr.type()); diff --git a/src/solvers/flattening/boolbv_floatbv_op.cpp b/src/solvers/flattening/boolbv_floatbv_op.cpp index e4926dc617e..6dbf6181c22 100644 --- a/src/solvers/flattening/boolbv_floatbv_op.cpp +++ b/src/solvers/flattening/boolbv_floatbv_op.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -15,18 +16,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "../floatbv/float_utils.h" -/*******************************************************************\ - -Function: boolbvt::convert_floatbv_typecast - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::convert_floatbv_typecast(const floatbv_typecast_exprt &expr) { const exprt &op0=expr.op(); // number to convert @@ -84,18 +73,6 @@ bvt boolbvt::convert_floatbv_typecast(const floatbv_typecast_exprt &expr) return conversion_failed(expr); } -/*******************************************************************\ - -Function: boolbvt::convert_floatbv_op - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::convert_floatbv_op(const exprt &expr) { const exprt::operandst &operands=expr.operands(); @@ -115,7 +92,7 @@ bvt boolbvt::convert_floatbv_op(const exprt &expr) if(op0.type()!=type || op1.type()!=type) { - std::cerr << expr.pretty() << std::endl; + std::cerr << expr.pretty() << '\n'; throw "float op with mixed types"; } diff --git a/src/solvers/flattening/boolbv_get.cpp b/src/solvers/flattening/boolbv_get.cpp index 4eb285a0d9c..fc166f758d3 100644 --- a/src/solvers/flattening/boolbv_get.cpp +++ b/src/solvers/flattening/boolbv_get.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -17,18 +18,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" #include "boolbv_type.h" -/*******************************************************************\ - -Function: boolbvt::get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt boolbvt::get(const exprt &expr) const { if(expr.id()==ID_symbol || @@ -76,18 +65,6 @@ exprt boolbvt::get(const exprt &expr) const return SUB::get(expr); } -/*******************************************************************\ - -Function: boolbvt::bv_get_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt boolbvt::bv_get_rec( const bvt &bv, const std::vector &unknown, @@ -300,18 +277,6 @@ exprt boolbvt::bv_get_rec( return nil_exprt(); } -/*******************************************************************\ - -Function: boolbvt::bv_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt boolbvt::bv_get(const bvt &bv, const typet &type) const { std::vector unknown; @@ -319,18 +284,6 @@ exprt boolbvt::bv_get(const bvt &bv, const typet &type) const return bv_get_rec(bv, unknown, 0, type); } -/*******************************************************************\ - -Function: boolbvt::bv_get_cache - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt boolbvt::bv_get_cache(const exprt &expr) const { if(expr.type().id()==ID_bool) // boolean? @@ -344,18 +297,6 @@ exprt boolbvt::bv_get_cache(const exprt &expr) const return bv_get(it->second, expr.type()); } -/*******************************************************************\ - -Function: boolbvt::bv_get_unbounded_array - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt boolbvt::bv_get_unbounded_array(const exprt &expr) const { // first, try to get size @@ -473,18 +414,6 @@ exprt boolbvt::bv_get_unbounded_array(const exprt &expr) const return result; } -/*******************************************************************\ - -Function: boolbvt::get_value - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - mp_integer boolbvt::get_value( const bvt &bv, std::size_t offset, diff --git a/src/solvers/flattening/boolbv_ieee_float_rel.cpp b/src/solvers/flattening/boolbv_ieee_float_rel.cpp index e97203566a8..4f5ad89436b 100644 --- a/src/solvers/flattening/boolbv_ieee_float_rel.cpp +++ b/src/solvers/flattening/boolbv_ieee_float_rel.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "boolbv.h" @@ -13,18 +14,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "../floatbv/float_utils.h" -/*******************************************************************\ - -Function: boolbvt::convert_ieee_float_rel - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt boolbvt::convert_ieee_float_rel(const exprt &expr) { const exprt::operandst &operands=expr.operands(); diff --git a/src/solvers/flattening/boolbv_if.cpp b/src/solvers/flattening/boolbv_if.cpp index 97563633c5b..a569036ff36 100644 --- a/src/solvers/flattening/boolbv_if.cpp +++ b/src/solvers/flattening/boolbv_if.cpp @@ -6,19 +6,8 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "boolbv.h" - -/*******************************************************************\ - -Function: boolbvt::convert_if - - Inputs: - Outputs: - - Purpose: - -\*******************************************************************/ +#include "boolbv.h" bvt boolbvt::convert_if(const if_exprt &expr) { diff --git a/src/solvers/flattening/boolbv_index.cpp b/src/solvers/flattening/boolbv_index.cpp index ec1ef27dd98..4be4408c792 100644 --- a/src/solvers/flattening/boolbv_index.cpp +++ b/src/solvers/flattening/boolbv_index.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -14,18 +15,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" -/*******************************************************************\ - -Function: boolbvt::convert_index - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::convert_index(const index_exprt &expr) { if(expr.id()!=ID_index) @@ -301,18 +290,7 @@ bvt boolbvt::convert_index(const index_exprt &expr) return bv; } -/*******************************************************************\ - -Function: boolbvt::convert_index - - Inputs: - - Outputs: - - Purpose: index operator with constant index - -\*******************************************************************/ - +/// index operator with constant index bvt boolbvt::convert_index( const exprt &array, const mp_integer &index) diff --git a/src/solvers/flattening/boolbv_map.cpp b/src/solvers/flattening/boolbv_map.cpp index 6c6e647a31c..37c66024ca0 100644 --- a/src/solvers/flattening/boolbv_map.cpp +++ b/src/solvers/flattening/boolbv_map.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "../prop/prop.h" @@ -17,18 +18,6 @@ Author: Daniel Kroening, kroening@kroening.com #include #endif -/*******************************************************************\ - -Function: boolbv_mapt::map_entryt::get_value - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string boolbv_mapt::map_entryt::get_value(const propt &prop) const { std::string result; @@ -57,18 +46,6 @@ std::string boolbv_mapt::map_entryt::get_value(const propt &prop) const return result; } -/*******************************************************************\ - -Function: boolbv_mapt::get_map_entry - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - boolbv_mapt::map_entryt &boolbv_mapt::get_map_entry( const irep_idt &identifier, const typet &type) @@ -95,18 +72,6 @@ boolbv_mapt::map_entryt &boolbv_mapt::get_map_entry( return map_entry; } -/*******************************************************************\ - -Function: boolbv_mapt::show - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void boolbv_mapt::show() const { for(mappingt::const_iterator it=mapping.begin(); @@ -116,18 +81,6 @@ void boolbv_mapt::show() const } } -/*******************************************************************\ - -Function: boolbv_mapt::get_literals - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void boolbv_mapt::get_literals( const irep_idt &identifier, const typet &type, @@ -160,23 +113,11 @@ void boolbv_mapt::get_literals( #ifdef DEBUG std::cout << "NEW: " << identifier << ":" << bit - << "=" << l << std::endl; + << "=" << l << '\n'; #endif } } -/*******************************************************************\ - -Function: boolbv_mapt::set_literals - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void boolbv_mapt::set_literals( const irep_idt &identifier, const typet &type, diff --git a/src/solvers/flattening/boolbv_map.h b/src/solvers/flattening/boolbv_map.h index e90863e02bc..7059da0ae78 100644 --- a/src/solvers/flattening/boolbv_map.h +++ b/src/solvers/flattening/boolbv_map.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_FLATTENING_BOOLBV_MAP_H #define CPROVER_SOLVERS_FLATTENING_BOOLBV_MAP_H diff --git a/src/solvers/flattening/boolbv_member.cpp b/src/solvers/flattening/boolbv_member.cpp index c5c0a697e1e..16d5de84ca1 100644 --- a/src/solvers/flattening/boolbv_member.cpp +++ b/src/solvers/flattening/boolbv_member.cpp @@ -6,24 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include #include "boolbv.h" -/*******************************************************************\ - -Function: boolbvt::convert_member - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::convert_member(const member_exprt &expr) { const exprt &struct_op=expr.struct_op(); diff --git a/src/solvers/flattening/boolbv_mod.cpp b/src/solvers/flattening/boolbv_mod.cpp index a81e30e0fae..1692fbc6a2f 100644 --- a/src/solvers/flattening/boolbv_mod.cpp +++ b/src/solvers/flattening/boolbv_mod.cpp @@ -6,19 +6,8 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "boolbv.h" - -/*******************************************************************\ - -Function: boolbvt::convert_mod - - Inputs: - Outputs: - - Purpose: - -\*******************************************************************/ +#include "boolbv.h" bvt boolbvt::convert_mod(const mod_exprt &expr) { diff --git a/src/solvers/flattening/boolbv_mult.cpp b/src/solvers/flattening/boolbv_mult.cpp index 4f7e91056bc..51d8f342ebe 100644 --- a/src/solvers/flattening/boolbv_mult.cpp +++ b/src/solvers/flattening/boolbv_mult.cpp @@ -6,22 +6,11 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "boolbv.h" -/*******************************************************************\ - -Function: boolbvt::convert_mult - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::convert_mult(const exprt &expr) { std::size_t width=boolbv_width(expr.type()); diff --git a/src/solvers/flattening/boolbv_not.cpp b/src/solvers/flattening/boolbv_not.cpp index a5d0b2e4468..b0f33f76b9c 100644 --- a/src/solvers/flattening/boolbv_not.cpp +++ b/src/solvers/flattening/boolbv_not.cpp @@ -6,19 +6,8 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "boolbv.h" - -/*******************************************************************\ - -Function: boolbvt::convert_not - - Inputs: - Outputs: - - Purpose: - -\*******************************************************************/ +#include "boolbv.h" bvt boolbvt::convert_not(const not_exprt &expr) { diff --git a/src/solvers/flattening/boolbv_onehot.cpp b/src/solvers/flattening/boolbv_onehot.cpp index d6af04966f8..168185e00f8 100644 --- a/src/solvers/flattening/boolbv_onehot.cpp +++ b/src/solvers/flattening/boolbv_onehot.cpp @@ -6,19 +6,8 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "boolbv.h" - -/*******************************************************************\ - -Function: boolbvt::convert_onehot - - Inputs: - Outputs: - - Purpose: - -\*******************************************************************/ +#include "boolbv.h" literalt boolbvt::convert_onehot(const unary_exprt &expr) { diff --git a/src/solvers/flattening/boolbv_overflow.cpp b/src/solvers/flattening/boolbv_overflow.cpp index 72b65dfe1a0..748975540ab 100644 --- a/src/solvers/flattening/boolbv_overflow.cpp +++ b/src/solvers/flattening/boolbv_overflow.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -13,18 +14,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" -/*******************************************************************\ - -Function: boolbvt::convert_overflow - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt boolbvt::convert_overflow(const exprt &expr) { const exprt::operandst &operands=expr.operands(); diff --git a/src/solvers/flattening/boolbv_power.cpp b/src/solvers/flattening/boolbv_power.cpp index 5b843a9fabb..e9967a46860 100644 --- a/src/solvers/flattening/boolbv_power.cpp +++ b/src/solvers/flattening/boolbv_power.cpp @@ -6,19 +6,8 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "boolbv.h" - -/*******************************************************************\ - -Function: boolbvt::convert_power - - Inputs: - Outputs: - - Purpose: - -\*******************************************************************/ +#include "boolbv.h" bvt boolbvt::convert_power(const binary_exprt &expr) { diff --git a/src/solvers/flattening/boolbv_quantifier.cpp b/src/solvers/flattening/boolbv_quantifier.cpp index 7cfc7f9e03e..0a706b41fa5 100644 --- a/src/solvers/flattening/boolbv_quantifier.cpp +++ b/src/solvers/flattening/boolbv_quantifier.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -14,19 +15,7 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" -/*******************************************************************\ - -Function: expr_eq - - Inputs: - - Outputs: - - Purpose: A method to detect equivalence between experts that can - contain typecast - -\*******************************************************************/ - +/// A method to detect equivalence between experts that can contain typecast bool expr_eq(const exprt &expr1, const exprt &expr2) { exprt e1=expr1, e2=expr2; @@ -37,20 +26,9 @@ bool expr_eq(const exprt &expr1, const exprt &expr2) return e1==e2; } -/*******************************************************************\ - -Function: get_quantifier_var_min - - Inputs: - - Outputs: - - Purpose: To obtain the min value for the quantifier variable - of the specified forall/exists operator. The min variable - is in the form of "!(var_expr > constant)". - -\*******************************************************************/ - +/// To obtain the min value for the quantifier variable of the specified +/// forall/exists operator. The min variable is in the form of "!(var_expr > +/// constant)". exprt get_quantifier_var_min( const exprt &var_expr, const exprt &quantifier_expr) @@ -97,19 +75,8 @@ exprt get_quantifier_var_min( return res; } -/*******************************************************************\ - -Function: get_quantifier_var_max - - Inputs: - - Outputs: - - Purpose: To obtain the max value for the quantifier variable - of the specified forall/exists operator. - -\*******************************************************************/ - +/// To obtain the max value for the quantifier variable of the specified +/// forall/exists operator. exprt get_quantifier_var_max( const exprt &var_expr, const exprt &quantifier_expr) @@ -171,18 +138,6 @@ exprt get_quantifier_var_max( return res; } -/*******************************************************************\ - -Function: instantiate_quantifier - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool instantiate_quantifier(exprt &expr, const namespacet &ns) { @@ -247,18 +202,6 @@ bool instantiate_quantifier(exprt &expr, return res; } -/*******************************************************************\ - -Function: boolbvt::convert_quantifier - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt boolbvt::convert_quantifier(const exprt &src) { exprt expr(src); @@ -275,18 +218,6 @@ literalt boolbvt::convert_quantifier(const exprt &src) return l; } -/*******************************************************************\ - -Function: boolbvt::post_process_quantifiers - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void boolbvt::post_process_quantifiers() { std::set instances; diff --git a/src/solvers/flattening/boolbv_reduction.cpp b/src/solvers/flattening/boolbv_reduction.cpp index e863657066b..2e2850fd2c8 100644 --- a/src/solvers/flattening/boolbv_reduction.cpp +++ b/src/solvers/flattening/boolbv_reduction.cpp @@ -6,19 +6,8 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "boolbv.h" - -/*******************************************************************\ - -Function: boolbvt::convert_reduction - - Inputs: - Outputs: - - Purpose: - -\*******************************************************************/ +#include "boolbv.h" literalt boolbvt::convert_reduction(const unary_exprt &expr) { @@ -60,18 +49,6 @@ literalt boolbvt::convert_reduction(const unary_exprt &expr) return l; } -/*******************************************************************\ - -Function: boolbvt::convert_bv_reduction - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::convert_bv_reduction(const unary_exprt &expr) { const bvt &op_bv=convert_bv(expr.op()); diff --git a/src/solvers/flattening/boolbv_replication.cpp b/src/solvers/flattening/boolbv_replication.cpp index 5983a1ae759..a9ff9087492 100644 --- a/src/solvers/flattening/boolbv_replication.cpp +++ b/src/solvers/flattening/boolbv_replication.cpp @@ -6,22 +6,11 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "boolbv.h" -/*******************************************************************\ - -Function: boolbvt::convert_replication - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::convert_replication(const replication_exprt &expr) { std::size_t width=boolbv_width(expr.type()); diff --git a/src/solvers/flattening/boolbv_shift.cpp b/src/solvers/flattening/boolbv_shift.cpp index f63be04c4a1..8c09d7d92e4 100644 --- a/src/solvers/flattening/boolbv_shift.cpp +++ b/src/solvers/flattening/boolbv_shift.cpp @@ -6,24 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include "boolbv.h" -/*******************************************************************\ - -Function: boolbvt::convert_shift - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::convert_shift(const binary_exprt &expr) { const irep_idt &type_id=expr.type().id(); diff --git a/src/solvers/flattening/boolbv_struct.cpp b/src/solvers/flattening/boolbv_struct.cpp index e1b0b29593a..f900430a6f4 100644 --- a/src/solvers/flattening/boolbv_struct.cpp +++ b/src/solvers/flattening/boolbv_struct.cpp @@ -6,23 +6,12 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include "boolbv.h" -/*******************************************************************\ - -Function: boolbvt::convert_struct - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::convert_struct(const struct_exprt &expr) { const struct_typet &struct_type=to_struct_type(ns.follow(expr.type())); diff --git a/src/solvers/flattening/boolbv_type.cpp b/src/solvers/flattening/boolbv_type.cpp index 2f0d2a43e59..fc65dde98f8 100644 --- a/src/solvers/flattening/boolbv_type.cpp +++ b/src/solvers/flattening/boolbv_type.cpp @@ -6,19 +6,8 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "boolbv_type.h" - -/*******************************************************************\ - -Function: get_bvtype - - Inputs: - Outputs: - - Purpose: - -\*******************************************************************/ +#include "boolbv_type.h" bvtypet get_bvtype(const typet &type) { diff --git a/src/solvers/flattening/boolbv_type.h b/src/solvers/flattening/boolbv_type.h index 1f8315eec6f..0c4e97b639b 100644 --- a/src/solvers/flattening/boolbv_type.h +++ b/src/solvers/flattening/boolbv_type.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_FLATTENING_BOOLBV_TYPE_H #define CPROVER_SOLVERS_FLATTENING_BOOLBV_TYPE_H diff --git a/src/solvers/flattening/boolbv_typecast.cpp b/src/solvers/flattening/boolbv_typecast.cpp index c0c2b9abb81..4f41d48330f 100644 --- a/src/solvers/flattening/boolbv_typecast.cpp +++ b/src/solvers/flattening/boolbv_typecast.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -16,18 +17,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "../floatbv/float_utils.h" -/*******************************************************************\ - -Function: boolbvt::convert_bv_typecast - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::convert_bv_typecast(const typecast_exprt &expr) { const typet &expr_type=ns.follow(expr.type()); @@ -43,18 +32,6 @@ bvt boolbvt::convert_bv_typecast(const typecast_exprt &expr) return bv; } -/*******************************************************************\ - -Function: boolbvt::type_conversion - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool boolbvt::type_conversion( const typet &src_type, const bvt &src, const typet &dest_type, bvt &dest) @@ -612,18 +589,7 @@ bool boolbvt::type_conversion( return true; } -/*******************************************************************\ - -Function: boolbvt::convert_typecast - - Inputs: - - Outputs: - - Purpose: conversion from bitvector types to boolean - -\*******************************************************************/ - +/// conversion from bitvector types to boolean literalt boolbvt::convert_typecast(const typecast_exprt &expr) { assert(expr.operands().size()==1); diff --git a/src/solvers/flattening/boolbv_unary_minus.cpp b/src/solvers/flattening/boolbv_unary_minus.cpp index 032d453a877..2cef5e38e73 100644 --- a/src/solvers/flattening/boolbv_unary_minus.cpp +++ b/src/solvers/flattening/boolbv_unary_minus.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "boolbv.h" @@ -13,18 +14,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "../floatbv/float_utils.h" -/*******************************************************************\ - -Function: boolbvt::convert_unary_minus - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::convert_unary_minus(const unary_exprt &expr) { const typet &type=ns.follow(expr.type()); diff --git a/src/solvers/flattening/boolbv_union.cpp b/src/solvers/flattening/boolbv_union.cpp index 92ac97d0c2c..f35c6b8344e 100644 --- a/src/solvers/flattening/boolbv_union.cpp +++ b/src/solvers/flattening/boolbv_union.cpp @@ -6,24 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include #include "boolbv.h" -/*******************************************************************\ - -Function: boolbvt::convert_union - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::convert_union(const union_exprt &expr) { std::size_t width=boolbv_width(expr.type()); diff --git a/src/solvers/flattening/boolbv_update.cpp b/src/solvers/flattening/boolbv_update.cpp index 2b485781f6b..96fce252259 100644 --- a/src/solvers/flattening/boolbv_update.cpp +++ b/src/solvers/flattening/boolbv_update.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include @@ -13,22 +14,10 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -#include +#include #include "boolbv.h" -/*******************************************************************\ - -Function: boolbvt::convert_update - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::convert_update(const exprt &expr) { const exprt::operandst &ops=expr.operands(); @@ -53,18 +42,6 @@ bvt boolbvt::convert_update(const exprt &expr) return bv; } -/*******************************************************************\ - -Function: boolbvt::convert_update_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void boolbvt::convert_update_rec( const exprt::operandst &designators, std::size_t d, diff --git a/src/solvers/flattening/boolbv_vector.cpp b/src/solvers/flattening/boolbv_vector.cpp index 499b79abe7b..07b5397111d 100644 --- a/src/solvers/flattening/boolbv_vector.cpp +++ b/src/solvers/flattening/boolbv_vector.cpp @@ -6,19 +6,8 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "boolbv.h" - -/*******************************************************************\ - -Function: boolbvt::convert_vector - - Inputs: - Outputs: - - Purpose: - -\*******************************************************************/ +#include "boolbv.h" bvt boolbvt::convert_vector(const exprt &expr) { diff --git a/src/solvers/flattening/boolbv_width.cpp b/src/solvers/flattening/boolbv_width.cpp index b52ea11fc8a..5d8eef01963 100644 --- a/src/solvers/flattening/boolbv_width.cpp +++ b/src/solvers/flattening/boolbv_width.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -14,50 +15,14 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv_width.h" -/*******************************************************************\ - -Function: boolbv_widtht::boolbv_widtht - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - boolbv_widtht::boolbv_widtht(const namespacet &_ns):ns(_ns) { } -/*******************************************************************\ - -Function: boolbv_widtht::~boolbv_widtht - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - boolbv_widtht::~boolbv_widtht() { } -/*******************************************************************\ - -Function: boolbv_widtht::get_entry - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const boolbv_widtht::entryt &boolbv_widtht::get_entry(const typet &type) const { // check cache first @@ -252,18 +217,6 @@ const boolbv_widtht::entryt &boolbv_widtht::get_entry(const typet &type) const return entry; } -/*******************************************************************\ - -Function: boolbv_widtht::get_member - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const boolbv_widtht::membert &boolbv_widtht::get_member( const struct_typet &type, const irep_idt &member) const diff --git a/src/solvers/flattening/boolbv_width.h b/src/solvers/flattening/boolbv_width.h index 6014dd7b198..d25115b3a83 100644 --- a/src/solvers/flattening/boolbv_width.h +++ b/src/solvers/flattening/boolbv_width.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_FLATTENING_BOOLBV_WIDTH_H #define CPROVER_SOLVERS_FLATTENING_BOOLBV_WIDTH_H diff --git a/src/solvers/flattening/boolbv_with.cpp b/src/solvers/flattening/boolbv_with.cpp index d98cd6be3b9..56984f4efbd 100644 --- a/src/solvers/flattening/boolbv_with.cpp +++ b/src/solvers/flattening/boolbv_with.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include @@ -15,18 +16,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" -/*******************************************************************\ - -Function: boolbvt::convert_with - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt boolbvt::convert_with(const exprt &expr) { if(expr.operands().size()<3) @@ -77,18 +66,6 @@ bvt boolbvt::convert_with(const exprt &expr) return bv; } -/*******************************************************************\ - -Function: boolbvt::convert_with - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void boolbvt::convert_with( const typet &type, const exprt &op1, @@ -119,18 +96,6 @@ void boolbvt::convert_with( throw 0; } -/*******************************************************************\ - -Function: boolbvt::convert_with_array - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void boolbvt::convert_with_array( const array_typet &type, const exprt &op1, @@ -200,18 +165,6 @@ void boolbvt::convert_with_array( } } -/*******************************************************************\ - -Function: boolbvt::convert_with_bv - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void boolbvt::convert_with_bv( const typet &type, const exprt &op1, @@ -244,18 +197,6 @@ void boolbvt::convert_with_bv( } } -/*******************************************************************\ - -Function: boolbvt::convert_with - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void boolbvt::convert_with_struct( const struct_typet &type, const exprt &op1, @@ -312,18 +253,6 @@ void boolbvt::convert_with_struct( } } -/*******************************************************************\ - -Function: boolbvt::convert_with_union - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void boolbvt::convert_with_union( const union_typet &type, const exprt &op1, diff --git a/src/solvers/flattening/bv_minimize.cpp b/src/solvers/flattening/bv_minimize.cpp index 9798f129ff8..263c9b4ccc0 100644 --- a/src/solvers/flattening/bv_minimize.cpp +++ b/src/solvers/flattening/bv_minimize.cpp @@ -6,24 +6,13 @@ Author: Georg Weissenbacher, georg.weissenbacher@inf.ethz.ch \*******************************************************************/ + #include #include #include "bv_minimize.h" -/*******************************************************************\ - -Function: bv_minimizet::add_objective - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bv_minimizet::add_objective( prop_minimizet &prop_minimize, const exprt &objective) @@ -66,18 +55,6 @@ void bv_minimizet::add_objective( } } -/*******************************************************************\ - -Function: bv_minimizet::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bv_minimizet::operator()(const minimization_listt &symbols) { // build bit-wise objective function diff --git a/src/solvers/flattening/bv_minimize.h b/src/solvers/flattening/bv_minimize.h index 03ba354e0d8..c6c8023501b 100644 --- a/src/solvers/flattening/bv_minimize.h +++ b/src/solvers/flattening/bv_minimize.h @@ -11,6 +11,9 @@ Purpose: Find a satisfying assignment that minimizes a given set \*******************************************************************/ +/// \file +/// SAT-optimizer for minimizing expressions + #ifndef CPROVER_SOLVERS_FLATTENING_BV_MINIMIZE_H #define CPROVER_SOLVERS_FLATTENING_BV_MINIMIZE_H diff --git a/src/solvers/flattening/bv_pointers.cpp b/src/solvers/flattening/bv_pointers.cpp index e026b6c3de7..aeecd21e2bc 100644 --- a/src/solvers/flattening/bv_pointers.cpp +++ b/src/solvers/flattening/bv_pointers.cpp @@ -6,6 +6,8 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + +#include #include #include #include @@ -15,18 +17,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "bv_pointers.h" -/*******************************************************************\ - -Function: bv_pointerst::convert_rest - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt bv_pointerst::convert_rest(const exprt &expr) { if(expr.type().id()!=ID_bool) @@ -100,18 +90,6 @@ literalt bv_pointerst::convert_rest(const exprt &expr) return SUB::convert_rest(expr); } -/*******************************************************************\ - -Function: bv_pointerst::bv_pointerst - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bv_pointerst::bv_pointerst( const namespacet &_ns, propt &_prop): @@ -123,18 +101,6 @@ bv_pointerst::bv_pointerst( bits=config.ansi_c.pointer_width; } -/*******************************************************************\ - -Function: bv_pointerst::convert_address_of_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool bv_pointerst::convert_address_of_rec( const exprt &expr, bvt &bv) @@ -185,6 +151,7 @@ bool bv_pointerst::convert_address_of_rec( // get size mp_integer size= pointer_offset_size(array_type.subtype(), ns); + assert(size>0); offset_arithmetic(bv, size, index); assert(bv.size()==bits); @@ -205,6 +172,7 @@ bool bv_pointerst::convert_address_of_rec( mp_integer offset=member_offset( to_struct_type(struct_op_type), member_expr.get_component_name(), ns); + assert(offset>=0); // add offset offset_arithmetic(bv, offset); @@ -247,23 +215,14 @@ bool bv_pointerst::convert_address_of_rec( return true; } -/*******************************************************************\ - -Function: bv_pointerst::convert_pointer_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_pointerst::convert_pointer_type(const exprt &expr) { if(!is_ptr(expr.type())) throw "convert_pointer_type got non-pointer type"; + // make sure the config hasn't been changed + assert(bits==config.ansi_c.pointer_width); + if(expr.id()==ID_symbol) { const irep_idt &identifier=to_symbol_expr(expr).get_identifier(); @@ -375,7 +334,12 @@ bvt bv_pointerst::convert_pointer_type(const exprt &expr) count++; bv=convert_bv(*it); assert(bv.size()==bits); - size=pointer_offset_size(it->type().subtype(), ns); + + typet pointer_sub_type=it->type().subtype(); + if(pointer_sub_type.id()==ID_empty) + pointer_sub_type=char_type(); + size=pointer_offset_size(pointer_sub_type, ns); + assert(size>0); } } @@ -449,6 +413,7 @@ bvt bv_pointerst::convert_pointer_type(const exprt &expr) mp_integer element_size= pointer_offset_size(expr.op0().type().subtype(), ns); + assert(element_size>0); offset_arithmetic(bv, element_size, neg_op1); @@ -478,18 +443,6 @@ bvt bv_pointerst::convert_pointer_type(const exprt &expr) return conversion_failed(expr); } -/*******************************************************************\ - -Function: bv_pointerst::convert_bitvector - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_pointerst::convert_bitvector(const exprt &expr) { if(is_ptr(expr.type())) @@ -517,6 +470,7 @@ bvt bv_pointerst::convert_bitvector(const exprt &expr) mp_integer element_size= pointer_offset_size(expr.op0().type().subtype(), ns); + assert(element_size>0); if(element_size!=1) { @@ -603,18 +557,6 @@ bvt bv_pointerst::convert_bitvector(const exprt &expr) return SUB::convert_bitvector(expr); } -/*******************************************************************\ - -Function: bv_pointerst::bv_get_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt bv_pointerst::bv_get_rec( const bvt &bv, const std::vector &unknown, @@ -669,18 +611,6 @@ exprt bv_pointerst::bv_get_rec( return result; } -/*******************************************************************\ - -Function: bv_pointerst::encode - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bv_pointerst::encode(std::size_t addr, bvt &bv) { bv.resize(bits); @@ -694,18 +624,6 @@ void bv_pointerst::encode(std::size_t addr, bvt &bv) bv[offset_bits+i]=const_literal((addr&(std::size_t(1)< #include #include "bv_utils.h" -/*******************************************************************\ - -Function: bv_utilst::build_constant - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_utilst::build_constant(const mp_integer &n, std::size_t width) { std::string n_str=integer2binary(n, width); @@ -35,18 +24,6 @@ bvt bv_utilst::build_constant(const mp_integer &n, std::size_t width) return result; } -/*******************************************************************\ - -Function: bv_utilst::is_one - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt bv_utilst::is_one(const bvt &bv) { assert(!bv.empty()); @@ -56,18 +33,6 @@ literalt bv_utilst::is_one(const bvt &bv) return prop.land(is_zero(tmp), bv[0]); } -/*******************************************************************\ - -Function: bv_utilst::set_equal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bv_utilst::set_equal(const bvt &a, const bvt &b) { assert(a.size()==b.size()); @@ -75,18 +40,6 @@ void bv_utilst::set_equal(const bvt &a, const bvt &b) prop.set_equal(a[i], b[i]); } -/*******************************************************************\ - -Function: bv_utilst::extract - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_utilst::extract(const bvt &a, std::size_t first, std::size_t last) { // preconditions @@ -103,18 +56,6 @@ bvt bv_utilst::extract(const bvt &a, std::size_t first, std::size_t last) return result; } -/*******************************************************************\ - -Function: bv_utilst::extract_msb - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_utilst::extract_msb(const bvt &a, std::size_t n) { // preconditions @@ -127,18 +68,6 @@ bvt bv_utilst::extract_msb(const bvt &a, std::size_t n) return result; } -/*******************************************************************\ - -Function: bv_utilst::extract_lsb - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_utilst::extract_lsb(const bvt &a, std::size_t n) { // preconditions @@ -149,18 +78,6 @@ bvt bv_utilst::extract_lsb(const bvt &a, std::size_t n) return result; } -/*******************************************************************\ - -Function: bv_utilst::concatenate - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_utilst::concatenate(const bvt &a, const bvt &b) const { bvt result; @@ -176,18 +93,7 @@ bvt bv_utilst::concatenate(const bvt &a, const bvt &b) const return result; } -/*******************************************************************\ - -Function: bv_utilst::select - - Inputs: - - Outputs: - - Purpose: If s is true, selects a otherwise selects b - -\*******************************************************************/ - +/// If s is true, selects a otherwise selects b bvt bv_utilst::select(literalt s, const bvt &a, const bvt &b) { assert(a.size()==b.size()); @@ -201,18 +107,6 @@ bvt bv_utilst::select(literalt s, const bvt &a, const bvt &b) return result; } -/*******************************************************************\ - -Function: bv_utilst::extension - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_utilst::extension( const bvt &bv, std::size_t new_size, @@ -235,18 +129,11 @@ bvt bv_utilst::extension( } -/*******************************************************************\ - -Function: bv_utilst::full_adder - - Inputs: a, b, carry_in are the literals representing inputs - - Outputs: return value is the literal for the sum, carry_out gets the output carry - - Purpose: Generates the encoding of a full adder. The optimal encoding is the default. - -\*******************************************************************/ - +/// Generates the encoding of a full adder. The optimal encoding is the +/// default. +/// \par parameters: a, b, carry_in are the literals representing inputs +/// \return return value is the literal for the sum, carry_out gets the output +/// carry // The optimal encoding is the default as it gives a reduction in space // and small performance gains #define OPTIMAL_FULL_ADDER @@ -339,18 +226,6 @@ literalt bv_utilst::full_adder( } } -/*******************************************************************\ - -Function: bv_utilst::carry - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - // Daniel's carry optimisation #define COMPACT_CARRY @@ -420,18 +295,6 @@ literalt bv_utilst::carry(literalt a, literalt b, literalt c) } } -/*******************************************************************\ - -Function: bv_utilst::adder - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bv_utilst::adder( bvt &sum, const bvt &op, @@ -448,18 +311,6 @@ void bv_utilst::adder( } } -/*******************************************************************\ - -Function: bv_utilst::carry_out - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt bv_utilst::carry_out( const bvt &op0, const bvt &op1, @@ -475,18 +326,6 @@ literalt bv_utilst::carry_out( return carry_out; } -/*******************************************************************\ - -Function: bv_utilst::add_sub_no_overflow - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_utilst::add_sub_no_overflow( const bvt &op0, const bvt &op1, @@ -498,18 +337,6 @@ bvt bv_utilst::add_sub_no_overflow( return sum; } -/*******************************************************************\ - -Function: bv_utilst::add_sub - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_utilst::add_sub(const bvt &op0, const bvt &op1, bool subtract) { assert(op0.size()==op1.size()); @@ -525,18 +352,6 @@ bvt bv_utilst::add_sub(const bvt &op0, const bvt &op1, bool subtract) return result; } -/*******************************************************************\ - -Function: bv_utilst::add_sub - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_utilst::add_sub(const bvt &op0, const bvt &op1, literalt subtract) { const bvt op1_sign_applied= @@ -550,18 +365,6 @@ bvt bv_utilst::add_sub(const bvt &op0, const bvt &op1, literalt subtract) return result; } -/*******************************************************************\ - -Function: bv_utilst::overflow_add - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt bv_utilst::overflow_add( const bvt &op0, const bvt &op1, representationt rep) { @@ -586,18 +389,6 @@ literalt bv_utilst::overflow_add( assert(false); } -/*******************************************************************\ - -Function: bv_utilst::overflow_sub - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt bv_utilst::overflow_sub( const bvt &op0, const bvt &op1, representationt rep) { @@ -623,18 +414,6 @@ literalt bv_utilst::overflow_sub( assert(false); } -/*******************************************************************\ - -Function: bv_utilst::adder_no_overflow - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bv_utilst::adder_no_overflow( bvt &sum, const bvt &op, @@ -669,18 +448,6 @@ void bv_utilst::adder_no_overflow( assert(false); } -/*******************************************************************\ - -Function: bv_utilst::adder_no_overflow - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bv_utilst::adder_no_overflow(bvt &sum, const bvt &op) { literalt carry_out=const_literal(false); @@ -690,18 +457,6 @@ void bv_utilst::adder_no_overflow(bvt &sum, const bvt &op) prop.l_set_to_false(carry_out); // enforce no overflow } -/*******************************************************************\ - -Function: bv_utilst::shift - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_utilst::shift(const bvt &op, const shiftt s, const bvt &dist) { std::size_t d=1, width=op.size(); @@ -723,18 +478,6 @@ bvt bv_utilst::shift(const bvt &op, const shiftt s, const bvt &dist) return result; } -/*******************************************************************\ - -Function: bv_utilst::shift - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_utilst::shift(const bvt &src, const shiftt s, std::size_t dist) { bvt result; @@ -768,18 +511,6 @@ bvt bv_utilst::shift(const bvt &src, const shiftt s, std::size_t dist) return result; } -/*******************************************************************\ - -Function: bv_utilst::negate - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_utilst::negate(const bvt &bv) { bvt result=inverted(bv); @@ -788,36 +519,12 @@ bvt bv_utilst::negate(const bvt &bv) return result; } -/*******************************************************************\ - -Function: bv_utilst::negate_no_overflow - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_utilst::negate_no_overflow(const bvt &bv) { prop.l_set_to(overflow_negate(bv), false); return negate(bv); } -/*******************************************************************\ - -Function: bv_utilst::overflow_negate - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt bv_utilst::overflow_negate(const bvt &bv) { // a overflow on unary- can only happen with the smallest @@ -829,18 +536,6 @@ literalt bv_utilst::overflow_negate(const bvt &bv) return prop.land(bv[bv.size()-1], !prop.lor(zeros)); } -/*******************************************************************\ - -Function: bv_utilst::incrementer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bv_utilst::incrementer( bvt &bv, literalt carry_in, @@ -856,18 +551,6 @@ void bv_utilst::incrementer( } } -/*******************************************************************\ - -Function: bv_utilst::incrementer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_utilst::incrementer(const bvt &bv, literalt carry_in) { bvt result=bv; @@ -876,18 +559,6 @@ bvt bv_utilst::incrementer(const bvt &bv, literalt carry_in) return result; } -/*******************************************************************\ - -Function: bv_utilst::invert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_utilst::inverted(const bvt &bv) { bvt result=bv; @@ -896,18 +567,6 @@ bvt bv_utilst::inverted(const bvt &bv) return result; } -/*******************************************************************\ - -Function: bv_utilst::wallace_tree - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_utilst::wallace_tree(const std::vector &pps) { assert(!pps.empty()); @@ -953,18 +612,6 @@ bvt bv_utilst::wallace_tree(const std::vector &pps) } } -/*******************************************************************\ - -Function: bv_utilst::unsigned_multiplier - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_utilst::unsigned_multiplier(const bvt &_op0, const bvt &_op1) { #if 1 @@ -1035,18 +682,6 @@ bvt bv_utilst::unsigned_multiplier(const bvt &_op0, const bvt &_op1) #endif } -/*******************************************************************\ - -Function: bv_utilst::unsigned_multiplier_no_overflow - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_utilst::unsigned_multiplier_no_overflow( const bvt &op0, const bvt &op1) @@ -1086,18 +721,6 @@ bvt bv_utilst::unsigned_multiplier_no_overflow( return product; } -/*******************************************************************\ - -Function: bv_utilst::signed_multiplier - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_utilst::signed_multiplier(const bvt &op0, const bvt &op1) { if(op0.empty() || op1.empty()) @@ -1116,18 +739,6 @@ bvt bv_utilst::signed_multiplier(const bvt &op0, const bvt &op1) return cond_negate(result, result_sign); } -/*******************************************************************\ - -Function: bv_utilst::cond_negate - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_utilst::cond_negate(const bvt &bv, const literalt cond) { bvt neg_bv=negate(bv); @@ -1141,36 +752,12 @@ bvt bv_utilst::cond_negate(const bvt &bv, const literalt cond) return result; } -/*******************************************************************\ - -Function: bv_utilst::absolute_value - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_utilst::absolute_value(const bvt &bv) { assert(!bv.empty()); return cond_negate(bv, bv[bv.size()-1]); } -/*******************************************************************\ - -Function: bv_utilst::cond_negate_no_overflow - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_utilst::cond_negate_no_overflow(const bvt &bv, literalt cond) { prop.l_set_to( @@ -1180,18 +767,6 @@ bvt bv_utilst::cond_negate_no_overflow(const bvt &bv, literalt cond) return cond_negate(bv, cond); } -/*******************************************************************\ - -Function: bv_utilst::signed_multiplier_no_overflow - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_utilst::signed_multiplier_no_overflow( const bvt &op0, const bvt &op1) @@ -1214,18 +789,6 @@ bvt bv_utilst::signed_multiplier_no_overflow( return cond_negate_no_overflow(result, result_sign); } -/*******************************************************************\ - -Function: bv_utilst::multiplier - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_utilst::multiplier( const bvt &op0, const bvt &op1, @@ -1239,18 +802,6 @@ bvt bv_utilst::multiplier( } } -/*******************************************************************\ - -Function: bv_utilst::multiplier_no_overflow - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_utilst::multiplier_no_overflow( const bvt &op0, const bvt &op1, @@ -1266,18 +817,6 @@ bvt bv_utilst::multiplier_no_overflow( } } -/*******************************************************************\ - -Function: bv_utilst::signed_divider - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bv_utilst::signed_divider( const bvt &op0, const bvt &op1, @@ -1313,18 +852,6 @@ void bv_utilst::signed_divider( rem[i]=prop.lselect(sign_0, neg_rem[i], rem[i]); } -/*******************************************************************\ - -Function: bv_utilst::divider - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bv_utilst::divider( const bvt &op0, const bvt &op1, @@ -1344,18 +871,6 @@ void bv_utilst::divider( } } -/*******************************************************************\ - -Function: bv_utilst::unsigned_divider - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bv_utilst::unsigned_divider( const bvt &op0, const bvt &op1, @@ -1445,18 +960,9 @@ void bv_utilst::unsigned_divider( #ifdef COMPACT_EQUAL_CONST // TODO : use for lt_or_le as well -/*******************************************************************\ - -Function: bv_utilst::equal_const_rec - - Inputs: A bit-vector of a variable that is to be registered. - - Outputs: None. - - Purpose: The equal_const optimisation will be used on this bit-vector. - -\*******************************************************************/ - +/// The equal_const optimisation will be used on this bit-vector. +/// \par parameters: A bit-vector of a variable that is to be registered. +/// \return None. void bv_utilst::equal_const_register(const bvt &var) { assert(!is_constant(var)); @@ -1465,21 +971,12 @@ void bv_utilst::equal_const_register(const bvt &var) } -/*******************************************************************\ - -Function: bv_utilst::equal_const_rec - - Inputs: Bit-vectors for a variable and a const to compare, note that - to avoid significant amounts of copying these are mutable and consumed. - - Outputs: The literal that is true if and only if all the bits in var - and const are equal. - - Purpose: The obvious recursive comparison, the interesting thing is - that it is cached so the literals are shared between constants. - -\*******************************************************************/ - +/// The obvious recursive comparison, the interesting thing is that it is cached +/// so the literals are shared between constants. +/// \param Bit:vectors for a variable and a const to compare, note that +/// to avoid significant amounts of copying these are mutable and consumed. +/// \return The literal that is true if and only if all the bits in var and +/// const are equal. literalt bv_utilst::equal_const_rec(bvt &var, bvt &constant) { std::size_t size = var.size(); @@ -1522,24 +1019,14 @@ literalt bv_utilst::equal_const_rec(bvt &var, bvt &constant) } } -/*******************************************************************\ - -Function: bv_utilst::equal_const - - Inputs: Bit-vectors for a variable and a const to compare. - - Outputs: The literal that is true if and only if they are equal. - - Purpose: An experimental encoding, aimed primarily at variable - position access to constant arrays. These generate a lot of - comparisons of the form var = small_const . It will introduce some - additional literals and for variables that have only a few - comparisons with constants this may result in a net increase in - formula size. It is hoped that a 'sufficently advanced preprocessor' - will remove these. - -\*******************************************************************/ - +/// An experimental encoding, aimed primarily at variable position access to +/// constant arrays. These generate a lot of comparisons of the form var = +/// small_const . It will introduce some additional literals and for variables +/// that have only a few comparisons with constants this may result in a net +/// increase in formula size. It is hoped that a 'sufficently advanced +/// preprocessor' will remove these. +/// \param Bit:vectors for a variable and a const to compare. +/// \return The literal that is true if and only if they are equal. literalt bv_utilst::equal_const(const bvt &var, const bvt &constant) { std::size_t size = constant.size(); @@ -1597,18 +1084,9 @@ literalt bv_utilst::equal_const(const bvt &var, const bvt &constant) #endif -/*******************************************************************\ - -Function: bv_utilst::equal - - Inputs: Bit-vectors for the two things to compare. - - Outputs: The literal that is true if and only if they are equal. - - Purpose: Bit-blasting ID_equal and use in other encodings. - -\*******************************************************************/ - +/// Bit-blasting ID_equal and use in other encodings. +/// \param Bit:vectors for the two things to compare. +/// \return The literal that is true if and only if they are equal. literalt bv_utilst::equal(const bvt &op0, const bvt &op1) { assert(op0.size()==op1.size()); @@ -1633,20 +1111,10 @@ literalt bv_utilst::equal(const bvt &op0, const bvt &op1) return prop.land(equal_bv); } -/*******************************************************************\ - -Function: bv_utilst::lt_or_le - - Inputs: bvts for each input and whether they are signed and whether - a model of < or <= is required. - - Outputs: A literalt that models the value of the comparison. - - Purpose: To provide a bitwise model of < or <=. - -\*******************************************************************/ - - +/// To provide a bitwise model of < or <=. +/// \par parameters: bvts for each input and whether they are signed and whether +/// a model of < or <= is required. +/// \return A literalt that models the value of the comparison. /* Some clauses are not needed for correctness but they remove models (effectively setting "don't care" bits) and so may be worth including.*/ @@ -1773,18 +1241,6 @@ literalt bv_utilst::lt_or_le( } } -/*******************************************************************\ - -Function: bv_utilst::unsigned_less_than - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt bv_utilst::unsigned_less_than( const bvt &op0, const bvt &op1) @@ -1797,18 +1253,6 @@ literalt bv_utilst::unsigned_less_than( #endif } -/*******************************************************************\ - -Function: bv_utilst::signed_less_than - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt bv_utilst::signed_less_than( const bvt &bv0, const bvt &bv1) @@ -1816,18 +1260,6 @@ literalt bv_utilst::signed_less_than( return lt_or_le(false, bv0, bv1, representationt::SIGNED); } -/*******************************************************************\ - -Function: bv_utilst::rel - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt bv_utilst::rel( const bvt &bv0, irep_idt id, @@ -1850,18 +1282,6 @@ literalt bv_utilst::rel( assert(false); } -/*******************************************************************\ - -Function: bv_utilst::is_constant - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool bv_utilst::is_constant(const bvt &bv) { forall_literals(it, bv) @@ -1871,18 +1291,6 @@ bool bv_utilst::is_constant(const bvt &bv) return true; } -/*******************************************************************\ - -Function: bv_utilst::cond_implies_equal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bv_utilst::cond_implies_equal( literalt cond, const bvt &a, @@ -1906,18 +1314,6 @@ void bv_utilst::cond_implies_equal( return; } -/*******************************************************************\ - -Function: bv_utilst::verilog_bv_has_x_or_z - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt bv_utilst::verilog_bv_has_x_or_z(const bvt &src) { bvt odd_bits; @@ -1933,18 +1329,6 @@ literalt bv_utilst::verilog_bv_has_x_or_z(const bvt &src) return prop.lor(odd_bits); } -/*******************************************************************\ - -Function: bv_utilst::verilog_bv_normal_bits - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_utilst::verilog_bv_normal_bits(const bvt &src) { bvt even_bits; diff --git a/src/solvers/flattening/bv_utils.h b/src/solvers/flattening/bv_utils.h index 6c415b117d0..0dc828a773d 100644 --- a/src/solvers/flattening/bv_utils.h +++ b/src/solvers/flattening/bv_utils.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_FLATTENING_BV_UTILS_H #define CPROVER_SOLVERS_FLATTENING_BV_UTILS_H diff --git a/src/solvers/flattening/c_bit_field_replacement_type.cpp b/src/solvers/flattening/c_bit_field_replacement_type.cpp index 5a81dc085d5..8e103425433 100644 --- a/src/solvers/flattening/c_bit_field_replacement_type.cpp +++ b/src/solvers/flattening/c_bit_field_replacement_type.cpp @@ -6,19 +6,8 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "c_bit_field_replacement_type.h" - -/*******************************************************************\ - -Function: c_bit_field_replacement_type - - Inputs: - Outputs: - - Purpose: - -\*******************************************************************/ +#include "c_bit_field_replacement_type.h" typet c_bit_field_replacement_type( const c_bit_field_typet &src, diff --git a/src/solvers/flattening/c_bit_field_replacement_type.h b/src/solvers/flattening/c_bit_field_replacement_type.h index 6f0f78e2c8c..cc139e96836 100644 --- a/src/solvers/flattening/c_bit_field_replacement_type.h +++ b/src/solvers/flattening/c_bit_field_replacement_type.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_FLATTENING_C_BIT_FIELD_REPLACEMENT_TYPE_H #define CPROVER_SOLVERS_FLATTENING_C_BIT_FIELD_REPLACEMENT_TYPE_H diff --git a/src/solvers/flattening/equality.cpp b/src/solvers/flattening/equality.cpp index 63ca7e2e147..547ef743054 100644 --- a/src/solvers/flattening/equality.cpp +++ b/src/solvers/flattening/equality.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifdef DEBUG #include #endif @@ -13,18 +14,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "equality.h" #include "bv_utils.h" -/*******************************************************************\ - -Function: equalityt::equality - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt equalityt::equality(const exprt &e1, const exprt &e2) { if(e1second); } -/*******************************************************************\ - -Function: equalityt::add_equality_constraints - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void equalityt::add_equality_constraints(const typestructt &typestruct) { std::size_t no_elements=typestruct.elements.size(); diff --git a/src/solvers/flattening/equality.h b/src/solvers/flattening/equality.h index 3bb1f74d8de..c4f11f4cd5c 100644 --- a/src/solvers/flattening/equality.h +++ b/src/solvers/flattening/equality.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_FLATTENING_EQUALITY_H #define CPROVER_SOLVERS_FLATTENING_EQUALITY_H diff --git a/src/solvers/flattening/flatten_byte_operators.cpp b/src/solvers/flattening/flatten_byte_operators.cpp index 68ad4b9197e..364565fe0f6 100644 --- a/src/solvers/flattening/flatten_byte_operators.cpp +++ b/src/solvers/flattening/flatten_byte_operators.cpp @@ -6,6 +6,8 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + +#include #include #include #include @@ -13,26 +15,190 @@ Author: Daniel Kroening, kroening@kroening.com #include #include #include +#include +#include #include "flatten_byte_operators.h" -/*******************************************************************\ +/// rewrite an object into its individual bytes +/// \par parameters: src object to unpack +/// little_endian true, iff assumed endianness is little-endian +/// max_bytes if not nil, use as upper bound of the number of bytes to unpack +/// ns namespace for type lookups +/// \return array of bytes in the sequence found in memory +static exprt unpack_rec( + const exprt &src, + bool little_endian, + const exprt &max_bytes, + const namespacet &ns, + bool unpack_byte_array=false) +{ + array_exprt array( + array_typet(unsignedbv_typet(8), from_integer(0, size_type()))); -Function: flatten_byte_extract + // endianness_mapt should be the point of reference for mapping out + // endianness, but we need to work on elements here instead of + // individual bits - Inputs: + const typet &type=ns.follow(src.type()); - Outputs: + if(type.id()==ID_array) + { + const array_typet &array_type=to_array_type(type); + const typet &subtype=array_type.subtype(); - Purpose: rewrite byte extraction from an array to byte extraction - from a concatenation of array index expressions + mp_integer element_width=pointer_offset_bits(subtype, ns); + // this probably doesn't really matter + #if 0 + if(element_width<=0) + throw "cannot unpack array with non-constant element width:\n"+ + type.pretty(); + else if(element_width%8!=0) + throw "cannot unpack array of non-byte aligned elements:\n"+ + type.pretty(); + #endif + + if(!unpack_byte_array && element_width==8) + return src; + + mp_integer num_elements; + if(to_integer(max_bytes, num_elements) && + to_integer(array_type.size(), num_elements)) + throw "cannot unpack array of non-const size:\n"+type.pretty(); + + // all array members will have the same structure; do this just + // once and then replace the dummy symbol by a suitable index + // expression in the loop below + symbol_exprt dummy(ID_C_incomplete, subtype); + exprt sub=unpack_rec(dummy, little_endian, max_bytes, ns, true); + + for(mp_integer i=0; i <... 8bits ...> + // + // An array {0, 1} will be encoded as bvt bv={0,1}, i.e., bv[1]==1 + // concatenation(0, 1) will yield a bvt bv={1,0}, i.e., bv[1]==0 + // + // The semantics of byte_extract(endianness, op, offset, T) is: + // interpret ((char*)&op)+offset as the endianness-ordered storage + // of an object of type T at address ((char*)&op)+offset + // For some T x, byte_extract(endianness, x, 0, T) must yield x. + // + // byte_extract for a composite type T or an array will interpret + // the individual subtypes with suitable endianness; the overall + // order of components is not affected by endianness. + // + // Examples: + // unsigned char A[4]; + // byte_extract_little_endian(A, 0, unsigned short) requests that + // A[0],A[1] be interpreted as the storage of an unsigned short with + // A[1] being the most-significant byte; byte_extract_big_endian for + // the same operands will select A[0] as the most-significant byte. + // + // int A[2] = {0x01020304,0xDEADBEEF} + // byte_extract_big_endian(A, 0, short) should yield 0x0102 + // byte_extract_little_endian(A, 0, short) should yield 0x0304 + // To obtain this we first compute byte arrays while taking into + // account endianness: + // big-endian byte representation: {01,02,03,04,DE,AB,BE,EF} + // little-endian byte representation: {04,03,02,01,EF,BE,AB,DE} + // We extract the relevant bytes starting from ((char*)A)+0: + // big-endian: {01,02}; little-endian: {04,03} + // Finally we place them in the appropriate byte order as indicated + // by endianness: + // big-endian: (short)concatenation(01,02)=0x0102 + // little-endian: (short)concatenation(03,04)=0x0304 + assert(src.operands().size()==2); bool little_endian; @@ -44,149 +210,135 @@ exprt flatten_byte_extract( else assert(false); - mp_integer size_bits=pointer_offset_bits(src.type(), ns); - if(size_bits<0) - throw "byte_extract flatting with non-constant size: "+src.pretty(); + // determine an upper bound of the number of bytes we might need + exprt upper_bound=size_of_expr(src.type(), ns); + if(upper_bound.is_not_nil()) + upper_bound= + simplify_expr( + plus_exprt( + upper_bound, + typecast_exprt(src.offset(), upper_bound.type())), + ns); - if(src.op0().type().id()==ID_array) - { - const exprt &root=src.op0(); - const exprt &offset=src.op1(); + byte_extract_exprt unpacked(src); + unpacked.op()= + unpack_rec(src.op(), little_endian, upper_bound, ns); + + const typet &type=ns.follow(src.type()); - const array_typet &array_type=to_array_type(root.type()); + if(type.id()==ID_array) + { + const array_typet &array_type=to_array_type(type); const typet &subtype=array_type.subtype(); mp_integer element_width=pointer_offset_bits(subtype, ns); - if(element_width<0) // failed - throw "failed to flatten array with unknown element width"; - - mp_integer num_elements= - size_bits/element_width+((size_bits%element_width==0)?0:1); - - const typet &offset_type=ns.follow(offset.type()); - - // byte-array? - if(element_width==8) + mp_integer num_elements; + // TODO: consider ways of dealing with arrays of unknown subtype + // size or with a subtype size that does not fit byte boundaries + if(element_width>0 && element_width%8==0 && + to_integer(array_type.size(), num_elements)) { - // get 'width'-many bytes, and concatenate - std::size_t width_bytes=integer2unsigned(num_elements); - exprt::operandst op; - op.reserve(width_bytes); + array_exprt array(array_type); - for(std::size_t i=0; i=2 - { - concatenation_exprt concatenation(src.type()); - concatenation.operands().swap(op); - return concatenation; + array.copy_to_operands(flatten_byte_extract(tmp, ns)); } - } - else // non-byte array - { - // add an extra element as the access need not be aligned with - // element boundaries and could thus stretch over extra elements - ++num_elements; - assert(element_width!=0); + return array; + } + } + else if(type.id()==ID_struct) + { + const struct_typet &struct_type=to_struct_type(type); + const struct_typet::componentst &components=struct_type.components(); - // compute new root and offset - concatenation_exprt concat( - unsignedbv_typet(integer2unsigned(element_width*num_elements))); + bool failed=false; + struct_exprt s(struct_type); - assert(element_width%8==0); - exprt first_index= - div_exprt(offset, from_integer(element_width/8, offset_type)); + for(const auto &comp : components) + { + mp_integer element_width=pointer_offset_bits(comp.type(), ns); - // byte extract will do the appropriate mapping, thus MSB comes - // last here (as opposed to the above, where no further byte - // extract is involved) - for(mp_integer i=0; i=2 + { + concatenation_exprt concatenation(src.type()); + concatenation.operands().swap(op); + return concatenation; + } +} exprt flatten_byte_update( const byte_update_exprt &src, @@ -197,6 +349,8 @@ exprt flatten_byte_update( mp_integer element_size= pointer_offset_size(src.op2().type(), ns); + if(element_size<0) + throw "byte_update of unknown width:\n"+src.pretty(); const typet &t=ns.follow(src.op0().type()); @@ -378,9 +532,9 @@ exprt flatten_byte_update( t.id()==ID_pointer) { // do a shift, mask and OR - std::size_t width=integer2size_t(pointer_offset_size(t, ns)*8); - - assert(width!=0); + mp_integer type_width=pointer_offset_bits(t, ns); + assert(type_width>0); + std::size_t width=integer2size_t(type_width); if(element_size*8>width) throw "flatten_byte_update to update element that is too large"; @@ -441,18 +595,6 @@ exprt flatten_byte_update( } } -/*******************************************************************\ - -Function: flatten_byte_update - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt flatten_byte_update( const byte_update_exprt &src, const namespacet &ns) @@ -460,18 +602,6 @@ exprt flatten_byte_update( return flatten_byte_update(src, ns, false); } -/*******************************************************************\ - -Function: has_byte_operators - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool has_byte_operator(const exprt &src) { if(src.id()==ID_byte_update_little_endian || @@ -487,18 +617,6 @@ bool has_byte_operator(const exprt &src) return false; } -/*******************************************************************\ - -Function: flatten_byte_operators - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt flatten_byte_operators( const exprt &src, const namespacet &ns) diff --git a/src/solvers/flattening/flatten_byte_operators.h b/src/solvers/flattening/flatten_byte_operators.h index 03bdd47f357..678827905a5 100644 --- a/src/solvers/flattening/flatten_byte_operators.h +++ b/src/solvers/flattening/flatten_byte_operators.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_FLATTENING_FLATTEN_BYTE_OPERATORS_H #define CPROVER_SOLVERS_FLATTENING_FLATTEN_BYTE_OPERATORS_H diff --git a/src/solvers/flattening/functions.cpp b/src/solvers/flattening/functions.cpp index 6b23229c958..1f2ed42be9c 100644 --- a/src/solvers/flattening/functions.cpp +++ b/src/solvers/flattening/functions.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -13,18 +14,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "functions.h" -/*******************************************************************\ - -Function: functionst::record - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void functionst::record( const function_application_exprt &function_application) { @@ -32,18 +21,6 @@ void functionst::record( insert(function_application); } -/*******************************************************************\ - -Function: functionst::add_function_constraints - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void functionst::add_function_constraints() { for(function_mapt::const_iterator it= @@ -53,18 +30,6 @@ void functionst::add_function_constraints() add_function_constraints(it->second); } -/*******************************************************************\ - -Function: functionst::add_function_constraints - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt functionst::arguments_equal(const exprt::operandst &o1, const exprt::operandst &o2) { @@ -91,18 +56,6 @@ exprt functionst::arguments_equal(const exprt::operandst &o1, return and_expr; } -/*******************************************************************\ - -Function: functionst::add_function_constraints - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void functionst::add_function_constraints(const function_infot &info) { // Do Ackermann's function reduction. diff --git a/src/solvers/flattening/functions.h b/src/solvers/flattening/functions.h index 1708862e946..0403e34189f 100644 --- a/src/solvers/flattening/functions.h +++ b/src/solvers/flattening/functions.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Uninterpreted Functions + #ifndef CPROVER_SOLVERS_FLATTENING_FUNCTIONS_H #define CPROVER_SOLVERS_FLATTENING_FUNCTIONS_H diff --git a/src/solvers/flattening/pointer_logic.cpp b/src/solvers/flattening/pointer_logic.cpp index c2b9d1175d0..5086e62bbf4 100644 --- a/src/solvers/flattening/pointer_logic.cpp +++ b/src/solvers/flattening/pointer_logic.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Pointer Logic + #include #include @@ -15,18 +18,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "pointer_logic.h" -/*******************************************************************\ - -Function: pointer_logict::is_dynamic_object - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool pointer_logict::is_dynamic_object(const exprt &expr) const { if(expr.type().get_bool("#dynamic")) @@ -40,18 +31,6 @@ bool pointer_logict::is_dynamic_object(const exprt &expr) const return false; } -/*******************************************************************\ - -Function: pointer_logict::get_dynamic_objects - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void pointer_logict::get_dynamic_objects(std::vector &o) const { o.clear(); @@ -65,18 +44,6 @@ void pointer_logict::get_dynamic_objects(std::vector &o) const o.push_back(nr); } -/*******************************************************************\ - -Function: pointer_logict::add_object - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::size_t pointer_logict::add_object(const exprt &expr) { // remove any index/member @@ -95,18 +62,6 @@ std::size_t pointer_logict::add_object(const exprt &expr) return objects.number(expr); } -/*******************************************************************\ - -Function: pointer_logict::pointer_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt pointer_logict::pointer_expr( std::size_t object, const typet &type) const @@ -115,18 +70,6 @@ exprt pointer_logict::pointer_expr( return pointer_expr(pointer, type); } -/*******************************************************************\ - -Function: pointer_logict::pointer_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt pointer_logict::pointer_expr( const pointert &pointer, const typet &type) const @@ -178,18 +121,6 @@ exprt pointer_logict::pointer_expr( return result; } -/*******************************************************************\ - -Function: pointer_logict::object_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt pointer_logict::object_rec( const mp_integer &offset, const typet &pointer_type, @@ -200,7 +131,7 @@ exprt pointer_logict::object_rec( mp_integer size= pointer_offset_size(src.type().subtype(), ns); - if(size==0) + if(size<=0) return src; mp_integer index=offset/size; @@ -234,6 +165,7 @@ exprt pointer_logict::object_rec( const typet &subtype=it->type(); mp_integer sub_size=pointer_offset_size(subtype, ns); + assert(sub_size>0); mp_integer new_offset=current_offset+sub_size; if(new_offset>offset) @@ -260,18 +192,6 @@ exprt pointer_logict::object_rec( return src; } -/*******************************************************************\ - -Function: pointer_logict::pointer_logict - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - pointer_logict::pointer_logict(const namespacet &_ns):ns(_ns) { // add NULL @@ -282,18 +202,6 @@ pointer_logict::pointer_logict(const namespacet &_ns):ns(_ns) invalid_object=objects.number(exprt("INVALID")); } -/*******************************************************************\ - -Function: pointer_logict::~pointer_logict - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - pointer_logict::~pointer_logict() { } diff --git a/src/solvers/flattening/pointer_logic.h b/src/solvers/flattening/pointer_logic.h index bcf18ca69f7..a0dc8b7fb50 100644 --- a/src/solvers/flattening/pointer_logic.h +++ b/src/solvers/flattening/pointer_logic.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Pointer Logic + #ifndef CPROVER_SOLVERS_FLATTENING_POINTER_LOGIC_H #define CPROVER_SOLVERS_FLATTENING_POINTER_LOGIC_H diff --git a/src/solvers/floatbv/float_approximation.cpp b/src/solvers/floatbv/float_approximation.cpp index 08e65162647..799efcbb4a1 100644 --- a/src/solvers/floatbv/float_approximation.cpp +++ b/src/solvers/floatbv/float_approximation.cpp @@ -6,38 +6,15 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "float_approximation.h" -/*******************************************************************\ - -Function: float_approximationt::~float_approximationt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - float_approximationt::~float_approximationt() { } -/*******************************************************************\ - -Function: float_approximationt::round_fraction - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void float_approximationt::normalization_shift(bvt &fraction, bvt &exponent) { // this thing is quadratic! @@ -87,18 +64,6 @@ void float_approximationt::normalization_shift(bvt &fraction, bvt &exponent) exponent=new_exponent; } -/*******************************************************************\ - -Function: float_approximationt::overapproximating_left_shift - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt float_approximationt::overapproximating_left_shift( const bvt &src, unsigned dist) { diff --git a/src/solvers/floatbv/float_approximation.h b/src/solvers/floatbv/float_approximation.h index c0a266b8fb6..daaaac8c7f3 100644 --- a/src/solvers/floatbv/float_approximation.h +++ b/src/solvers/floatbv/float_approximation.h @@ -6,6 +6,9 @@ Module: Floating Point with under/over-approximation \*******************************************************************/ +/// \file +/// Floating Point with under/over-approximation + #ifndef CPROVER_SOLVERS_FLOATBV_FLOAT_APPROXIMATION_H #define CPROVER_SOLVERS_FLOATBV_FLOAT_APPROXIMATION_H diff --git a/src/solvers/floatbv/float_bv.cpp b/src/solvers/floatbv/float_bv.cpp index 0d07a9d8ee9..b346b40dfcc 100644 --- a/src/solvers/floatbv/float_bv.cpp +++ b/src/solvers/floatbv/float_bv.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -14,18 +15,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "float_bv.h" -/*******************************************************************\ - -Function: float_bvt::convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt float_bvt::convert(const exprt &expr) { if(expr.id()==ID_abs) @@ -107,36 +96,12 @@ exprt float_bvt::convert(const exprt &expr) return nil_exprt(); } -/*******************************************************************\ - -Function: float_bvt::get_spec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - ieee_float_spect float_bvt::get_spec(const exprt &expr) { const floatbv_typet &type=to_floatbv_type(expr.type()); return ieee_float_spect(type); } -/*******************************************************************\ - -Function: float_bvt::abs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt float_bvt::abs(const exprt &op, const ieee_float_spect &spec) { // we mask away the sign bit, which is the most significand bit @@ -148,18 +113,6 @@ exprt float_bvt::abs(const exprt &op, const ieee_float_spect &spec) return bitand_exprt(op, mask); } -/*******************************************************************\ - -Function: float_bvt::negation - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt float_bvt::negation(const exprt &op, const ieee_float_spect &spec) { // we flip the sign bit with an xor @@ -171,18 +124,6 @@ exprt float_bvt::negation(const exprt &op, const ieee_float_spect &spec) return bitxor_exprt(op, mask); } -/*******************************************************************\ - -Function: float_bvt::is_equal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt float_bvt::is_equal( const exprt &src0, const exprt &src1, @@ -205,18 +146,6 @@ exprt float_bvt::is_equal( not_exprt(nan)); } -/*******************************************************************\ - -Function: float_bvt::is_zero - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt float_bvt::is_zero( const exprt &src, const ieee_float_spect &spec) @@ -236,18 +165,6 @@ exprt float_bvt::is_zero( return equal_exprt(bitand_exprt(src, mask), z.to_expr()); } -/*******************************************************************\ - -Function: float_bvt::exponent_all_ones - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt float_bvt::exponent_all_ones( const exprt &src, const ieee_float_spect &spec) @@ -257,18 +174,6 @@ exprt float_bvt::exponent_all_ones( return equal_exprt(exponent, all_ones); } -/*******************************************************************\ - -Function: float_bvt::exponent_all_zeros - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt float_bvt::exponent_all_zeros( const exprt &src, const ieee_float_spect &spec) @@ -278,18 +183,6 @@ exprt float_bvt::exponent_all_zeros( return equal_exprt(exponent, all_zeros); } -/*******************************************************************\ - -Function: float_bvt::fraction_all_zeros - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt float_bvt::fraction_all_zeros( const exprt &src, const ieee_float_spect &spec) @@ -300,18 +193,6 @@ exprt float_bvt::fraction_all_zeros( return equal_exprt(fraction, all_zeros); } -/*******************************************************************\ - -Function: float_bvt::rounding_mode_bitst::get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void float_bvt::rounding_mode_bitst::get(const exprt &rm) { exprt round_to_even_const=from_integer(ieee_floatt::ROUND_TO_EVEN, rm.type()); @@ -327,18 +208,6 @@ void float_bvt::rounding_mode_bitst::get(const exprt &rm) round_to_zero=equal_exprt(rm, round_to_zero_const); } -/*******************************************************************\ - -Function: float_bvt::sign_bit - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt float_bvt::sign_bit(const exprt &op) { const bitvector_typet &bv_type=to_bitvector_type(op.type()); @@ -346,18 +215,6 @@ exprt float_bvt::sign_bit(const exprt &op) return extractbit_exprt(op, width-1); } -/*******************************************************************\ - -Function: float_bvt::from_signed_integer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt float_bvt::from_signed_integer( const exprt &src, const exprt &rm, @@ -382,18 +239,6 @@ exprt float_bvt::from_signed_integer( return rounder(result, rm, spec); } -/*******************************************************************\ - -Function: float_bvt::from_unsigned_integer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt float_bvt::from_unsigned_integer( const exprt &src, const exprt &rm, @@ -416,18 +261,6 @@ exprt float_bvt::from_unsigned_integer( return rounder(result, rm, spec); } -/*******************************************************************\ - -Function: float_bvt::to_signed_integer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt float_bvt::to_signed_integer( const exprt &src, std::size_t dest_width, @@ -437,18 +270,6 @@ exprt float_bvt::to_signed_integer( return to_integer(src, dest_width, true, rm, spec); } -/*******************************************************************\ - -Function: float_bvt::to_unsigned_integer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt float_bvt::to_unsigned_integer( const exprt &src, std::size_t dest_width, @@ -458,18 +279,6 @@ exprt float_bvt::to_unsigned_integer( return to_integer(src, dest_width, false, rm, spec); } -/*******************************************************************\ - -Function: float_bvt::to_integer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt float_bvt::to_integer( const exprt &src, std::size_t dest_width, @@ -518,18 +327,6 @@ exprt float_bvt::to_integer( return result; } -/*******************************************************************\ - -Function: float_bvt::conversion - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt float_bvt::conversion( const exprt &src, const exprt &rm, @@ -595,18 +392,6 @@ exprt float_bvt::conversion( } } -/*******************************************************************\ - -Function: float_bvt::isnormal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt float_bvt::isnormal( const exprt &src, const ieee_float_spect &spec) @@ -616,18 +401,7 @@ exprt float_bvt::isnormal( not_exprt(exponent_all_ones(src, spec))); } -/*******************************************************************\ - -Function: float_bvt::subtract_exponents - - Inputs: - - Outputs: - - Purpose: Subtracts the exponents - -\*******************************************************************/ - +/// Subtracts the exponents exprt float_bvt::subtract_exponents( const unbiased_floatt &src1, const unbiased_floatt &src2) @@ -648,18 +422,6 @@ exprt float_bvt::subtract_exponents( return minus_exprt(extended_exponent1, extended_exponent2); } -/*******************************************************************\ - -Function: float_bvt::add_sub - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt float_bvt::add_sub( bool subtract, const exprt &op0, @@ -807,18 +569,7 @@ exprt float_bvt::add_sub( return rounder(result, rm, spec); } -/*******************************************************************\ - -Function: float_bvt::limit_distance - - Inputs: - - Outputs: - - Purpose: Limits the shift distance - -\*******************************************************************/ - +/// Limits the shift distance exprt float_bvt::limit_distance( const exprt &dist, mp_integer limit) @@ -845,18 +596,6 @@ exprt float_bvt::limit_distance( unsignedbv_typet(nb_bits).largest_expr()); } -/*******************************************************************\ - -Function: float_bvt::mul - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt float_bvt::mul( const exprt &src1, const exprt &src2, @@ -912,18 +651,6 @@ exprt float_bvt::mul( return rounder(result, rm, spec); } -/*******************************************************************\ - -Function: float_bvt::div - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt float_bvt::div( const exprt &src1, const exprt &src2, @@ -1016,18 +743,6 @@ exprt float_bvt::div( return rounder(result, rm, spec); } -/*******************************************************************\ - -Function: float_bvt::relation - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt float_bvt::relation( const exprt &src1, relt rel, @@ -1119,18 +834,6 @@ exprt float_bvt::relation( return false_exprt(); } -/*******************************************************************\ - -Function: float_bvt::isinf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt float_bvt::isinf( const exprt &src, const ieee_float_spect &spec) @@ -1140,18 +843,6 @@ exprt float_bvt::isinf( fraction_all_zeros(src, spec)); } -/*******************************************************************\ - -Function: float_bvt::isfinite - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt float_bvt::isfinite( const exprt &src, const ieee_float_spect &spec) @@ -1159,18 +850,7 @@ exprt float_bvt::isfinite( return not_exprt(or_exprt(isinf(src, spec), isnan(src, spec))); } -/*******************************************************************\ - -Function: float_bvt::get_exponent - - Inputs: - - Outputs: - - Purpose: Gets the unbiased exponent in a floating-point bit-vector - -\*******************************************************************/ - +/// Gets the unbiased exponent in a floating-point bit-vector exprt float_bvt::get_exponent( const exprt &src, const ieee_float_spect &spec) @@ -1180,19 +860,7 @@ exprt float_bvt::get_exponent( unsignedbv_typet(spec.e)); } -/*******************************************************************\ - -Function: float_bvt::get_fraction - - Inputs: - - Outputs: - - Purpose: Gets the fraction without hidden bit in a floating-point - bit-vector src - -\*******************************************************************/ - +/// Gets the fraction without hidden bit in a floating-point bit-vector src exprt float_bvt::get_fraction( const exprt &src, const ieee_float_spect &spec) @@ -1202,18 +870,6 @@ exprt float_bvt::get_fraction( unsignedbv_typet(spec.f)); } -/*******************************************************************\ - -Function: float_bvt::isnan - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt float_bvt::isnan( const exprt &src, const ieee_float_spect &spec) @@ -1222,19 +878,7 @@ exprt float_bvt::isnan( not_exprt(fraction_all_zeros(src, spec))); } -/*******************************************************************\ - -Function: float_bvt::normalization_shift - - Inputs: - - Outputs: - - Purpose: normalize fraction/exponent pair - returns 'zero' if fraction is zero - -\*******************************************************************/ - +/// normalize fraction/exponent pair returns 'zero' if fraction is zero void float_bvt::normalization_shift( exprt &fraction, exprt &exponent) @@ -1283,19 +927,7 @@ void float_bvt::normalization_shift( exponent=minus_exprt(exponent, exponent_delta); } -/*******************************************************************\ - -Function: float_bvt::denormalization_shift - - Inputs: - - Outputs: - - Purpose: make sure exponent is not too small; - the exponent is unbiased - -\*******************************************************************/ - +/// make sure exponent is not too small; the exponent is unbiased void float_bvt::denormalization_shift( exprt &fraction, exprt &exponent, @@ -1375,18 +1007,6 @@ void float_bvt::denormalization_shift( exponent); } -/*******************************************************************\ - -Function: float_bvt::rounder - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt float_bvt::rounder( const unbiased_floatt &src, const exprt &rm, @@ -1431,18 +1051,7 @@ exprt float_bvt::rounder( return pack(bias(result, spec), spec); } -/*******************************************************************\ - -Function: float_bvt::fraction_rounding_decision - - Inputs: - - Outputs: - - Purpose: rounding decision for fraction using sticky bit - -\*******************************************************************/ - +/// rounding decision for fraction using sticky bit exprt float_bvt::fraction_rounding_decision( const std::size_t dest_bits, const exprt sign, @@ -1506,18 +1115,6 @@ exprt float_bvt::fraction_rounding_decision( false_exprt())))); // otherwise zero } -/*******************************************************************\ - -Function: float_bvt::round_fraction - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void float_bvt::round_fraction( unbiased_floatt &result, const rounding_mode_bitst &rounding_mode_bits, @@ -1628,18 +1225,6 @@ void float_bvt::round_fraction( } } -/*******************************************************************\ - -Function: float_bvt::round_exponent - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void float_bvt::round_exponent( unbiased_floatt &result, const rounding_mode_bitst &rounding_mode_bits, @@ -1714,18 +1299,7 @@ void float_bvt::round_exponent( } } -/*******************************************************************\ - -Function: float_bvt::bias - - Inputs: - - Outputs: - - Purpose: takes an unbiased float, and applies the bias - -\*******************************************************************/ - +/// takes an unbiased float, and applies the bias float_bvt::biased_floatt float_bvt::bias( const unbiased_floatt &src, const ieee_float_spect &spec) @@ -1759,18 +1333,6 @@ float_bvt::biased_floatt float_bvt::bias( return result; } -/*******************************************************************\ - -Function: float_bvt::add_bias - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt float_bvt::add_bias( const exprt &src, const ieee_float_spect &spec) @@ -1781,18 +1343,6 @@ exprt float_bvt::add_bias( from_integer(spec.bias(), t)); } -/*******************************************************************\ - -Function: float_bvt::sub_bias - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt float_bvt::sub_bias( const exprt &src, const ieee_float_spect &spec) @@ -1803,18 +1353,6 @@ exprt float_bvt::sub_bias( from_integer(spec.bias(), t)); } -/*******************************************************************\ - -Function: float_bvt::unpack - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - float_bvt::unbiased_floatt float_bvt::unpack( const exprt &src, const ieee_float_spect &spec) @@ -1848,18 +1386,6 @@ float_bvt::unbiased_floatt float_bvt::unpack( return result; } -/*******************************************************************\ - -Function: float_bvt::pack - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt float_bvt::pack( const biased_floatt &src, const ieee_float_spect &spec) @@ -1895,18 +1421,6 @@ exprt float_bvt::pack( spec.to_type()); } -/*******************************************************************\ - -Function: float_bvt::sticky_right_shift - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt float_bvt::sticky_right_shift( const exprt &op, const exprt &dist, diff --git a/src/solvers/floatbv/float_bv.h b/src/solvers/floatbv/float_bv.h index 1ae6a63ffe2..f9a58ba2695 100644 --- a/src/solvers/floatbv/float_bv.h +++ b/src/solvers/floatbv/float_bv.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_FLOATBV_FLOAT_BV_H #define CPROVER_SOLVERS_FLOATBV_FLOAT_BV_H diff --git a/src/solvers/floatbv/float_utils.cpp b/src/solvers/floatbv/float_utils.cpp index 3660aced265..c2752a29e1a 100644 --- a/src/solvers/floatbv/float_utils.cpp +++ b/src/solvers/floatbv/float_utils.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -13,18 +14,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "float_utils.h" -/*******************************************************************\ - -Function: float_utilst::set_rounding_mode - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void float_utilst::set_rounding_mode(const bvt &src) { bvt round_to_even= @@ -42,18 +31,6 @@ void float_utilst::set_rounding_mode(const bvt &src) rounding_mode_bits.round_to_zero=bv_utils.equal(src, round_to_zero); } -/*******************************************************************\ - -Function: float_utilst::from_signed_integer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt float_utilst::from_signed_integer(const bvt &src) { unbiased_floatt result; @@ -72,18 +49,6 @@ bvt float_utilst::from_signed_integer(const bvt &src) return rounder(result); } -/*******************************************************************\ - -Function: float_utilst::from_unsigned_integer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt float_utilst::from_unsigned_integer(const bvt &src) { unbiased_floatt result; @@ -101,18 +66,6 @@ bvt float_utilst::from_unsigned_integer(const bvt &src) return rounder(result); } -/*******************************************************************\ - -Function: float_utilst::to_signed_integer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt float_utilst::to_signed_integer( const bvt &src, std::size_t dest_width) @@ -120,18 +73,6 @@ bvt float_utilst::to_signed_integer( return to_integer(src, dest_width, true); } -/*******************************************************************\ - -Function: float_utilst::to_unsigned_integer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt float_utilst::to_unsigned_integer( const bvt &src, std::size_t dest_width) @@ -139,18 +80,6 @@ bvt float_utilst::to_unsigned_integer( return to_integer(src, dest_width, false); } -/*******************************************************************\ - -Function: float_utilst::to_integer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt float_utilst::to_integer( const bvt &src, std::size_t dest_width, @@ -210,18 +139,6 @@ bvt float_utilst::to_integer( throw "unsupported rounding mode"; } -/*******************************************************************\ - -Function: float_utilst::build_constant - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt float_utilst::build_constant(const ieee_floatt &src) { unbiased_floatt result; @@ -235,18 +152,6 @@ bvt float_utilst::build_constant(const ieee_floatt &src) return pack(bias(result)); } -/*******************************************************************\ - -Function: float_utilst::conversion - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt float_utilst::conversion( const bvt &src, const ieee_float_spect &dest_spec) @@ -314,18 +219,6 @@ bvt float_utilst::conversion( } } -/*******************************************************************\ - -Function: float_utilst::is_normal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt float_utilst::is_normal(const bvt &src) { return prop.land( @@ -333,18 +226,7 @@ literalt float_utilst::is_normal(const bvt &src) !exponent_all_ones(src)); } -/*******************************************************************\ - -Function: float_utilst::subtract_exponents - - Inputs: - - Outputs: - - Purpose: Subtracts the exponents - -\*******************************************************************/ - +/// Subtracts the exponents bvt float_utilst::subtract_exponents( const unbiased_floatt &src1, const unbiased_floatt &src2) @@ -361,18 +243,6 @@ bvt float_utilst::subtract_exponents( return bv_utils.sub(extended_exponent1, extended_exponent2); } -/*******************************************************************\ - -Function: float_utilst::add_sub - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt float_utilst::add_sub( const bvt &src1, const bvt &src2, @@ -514,18 +384,7 @@ bvt float_utilst::add_sub( return rounder(result); } -/*******************************************************************\ - -Function: float_utilst::limit_distance - - Inputs: - - Outputs: - - Purpose: Limits the shift distance - -\*******************************************************************/ - +/// Limits the shift distance bvt float_utilst::limit_distance( const bvt &dist, mp_integer limit) @@ -549,18 +408,6 @@ bvt float_utilst::limit_distance( return result; } -/*******************************************************************\ - -Function: float_utilst::mul - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt float_utilst::mul(const bvt &src1, const bvt &src2) { // unpack @@ -613,18 +460,6 @@ bvt float_utilst::mul(const bvt &src1, const bvt &src2) return rounder(result); } -/*******************************************************************\ - -Function: float_utilst::div - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt float_utilst::div(const bvt &src1, const bvt &src2) { // unpack @@ -704,18 +539,6 @@ bvt float_utilst::div(const bvt &src1, const bvt &src2) return rounder(result); } -/*******************************************************************\ - -Function: float_utilst::rem - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt float_utilst::rem(const bvt &src1, const bvt &src2) { /* The semantics of floating-point remainder implemented as below @@ -731,18 +554,6 @@ bvt float_utilst::rem(const bvt &src1, const bvt &src2) return sub(src1, mul(div(src1, src2), src2)); } -/*******************************************************************\ - -Function: float_utilst::negate - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt float_utilst::negate(const bvt &src) { bvt result=src; @@ -752,18 +563,6 @@ bvt float_utilst::negate(const bvt &src) return result; } -/*******************************************************************\ - -Function: float_utilst::abs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt float_utilst::abs(const bvt &src) { bvt result=src; @@ -772,18 +571,6 @@ bvt float_utilst::abs(const bvt &src) return result; } -/*******************************************************************\ - -Function: float_utilst::relation - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt float_utilst::relation( const bvt &src1, relt rel, @@ -866,18 +653,6 @@ literalt float_utilst::relation( return const_literal(false); } -/*******************************************************************\ - -Function: float_utilst::is_zero - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt float_utilst::is_zero(const bvt &src) { assert(!src.empty()); @@ -887,18 +662,6 @@ literalt float_utilst::is_zero(const bvt &src) return bv_utils.is_zero(all_but_sign); } -/*******************************************************************\ - -Function: float_utilst::is_plus_inf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt float_utilst::is_plus_inf(const bvt &src) { bvt and_bv; @@ -908,18 +671,6 @@ literalt float_utilst::is_plus_inf(const bvt &src) return prop.land(and_bv); } -/*******************************************************************\ - -Function: float_utilst::infinity - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt float_utilst::is_infinity(const bvt &src) { return prop.land( @@ -927,53 +678,18 @@ literalt float_utilst::is_infinity(const bvt &src) fraction_all_zeros(src)); } -/*******************************************************************\ - -Function: float_utilst::get_exponent - - Inputs: - - Outputs: - - Purpose: Gets the unbiased exponent in a floating-point bit-vector - -\*******************************************************************/ - +/// Gets the unbiased exponent in a floating-point bit-vector bvt float_utilst::get_exponent(const bvt &src) { return bv_utils.extract(src, spec.f, spec.f+spec.e-1); } -/*******************************************************************\ - -Function: float_utilst::get_fraction - - Inputs: - - Outputs: - - Purpose: Gets the fraction without hidden bit in a floating-point - bit-vector src - -\*******************************************************************/ - +/// Gets the fraction without hidden bit in a floating-point bit-vector src bvt float_utilst::get_fraction(const bvt &src) { return bv_utils.extract(src, 0, spec.f-1); } -/*******************************************************************\ - -Function: float_utilst::is_minus_inf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt float_utilst::is_minus_inf(const bvt &src) { bvt and_bv; @@ -983,36 +699,12 @@ literalt float_utilst::is_minus_inf(const bvt &src) return prop.land(and_bv); } -/*******************************************************************\ - -Function: float_utilst::is_NaN - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt float_utilst::is_NaN(const bvt &src) { return prop.land(exponent_all_ones(src), !fraction_all_zeros(src)); } -/*******************************************************************\ - -Function: float_utilst::exponent_all_ones - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt float_utilst::exponent_all_ones(const bvt &src) { bvt exponent=src; @@ -1026,18 +718,6 @@ literalt float_utilst::exponent_all_ones(const bvt &src) return bv_utils.is_all_ones(exponent); } -/*******************************************************************\ - -Function: float_utilst::exponent_all_zeros - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt float_utilst::exponent_all_zeros(const bvt &src) { bvt exponent=src; @@ -1051,18 +731,6 @@ literalt float_utilst::exponent_all_zeros(const bvt &src) return bv_utils.is_zero(exponent); } -/*******************************************************************\ - -Function: float_utilst::fraction_all_zeros - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt float_utilst::fraction_all_zeros(const bvt &src) { // does not include hidden bit @@ -1072,19 +740,7 @@ literalt float_utilst::fraction_all_zeros(const bvt &src) return bv_utils.is_zero(tmp); } -/*******************************************************************\ - -Function: float_utilst::normalization_shift - - Inputs: - - Outputs: - - Purpose: normalize fraction/exponent pair - returns 'zero' if fraction is zero - -\*******************************************************************/ - +/// normalize fraction/exponent pair returns 'zero' if fraction is zero void float_utilst::normalization_shift(bvt &fraction, bvt &exponent) { #if 0 @@ -1169,19 +825,7 @@ void float_utilst::normalization_shift(bvt &fraction, bvt &exponent) #endif } -/*******************************************************************\ - -Function: float_utilst::denormalization_shift - - Inputs: - - Outputs: - - Purpose: make sure exponent is not too small; - the exponent is unbiased - -\*******************************************************************/ - +/// make sure exponent is not too small; the exponent is unbiased void float_utilst::denormalization_shift(bvt &fraction, bvt &exponent) { mp_integer bias=spec.bias(); @@ -1250,18 +894,6 @@ void float_utilst::denormalization_shift(bvt &fraction, bvt &exponent) exponent); } -/*******************************************************************\ - -Function: float_utilst::rounder - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt float_utilst::rounder(const unbiased_floatt &src) { // incoming: some fraction (with explicit 1), @@ -1302,18 +934,7 @@ bvt float_utilst::rounder(const unbiased_floatt &src) return pack(bias(result)); } -/*******************************************************************\ - -Function: float_utilst::fraction_rounding_decision - - Inputs: - - Outputs: - - Purpose: rounding decision for fraction using sticky bit - -\*******************************************************************/ - +/// rounding decision for fraction using sticky bit literalt float_utilst::fraction_rounding_decision( const std::size_t dest_bits, const literalt sign, @@ -1371,18 +992,6 @@ literalt float_utilst::fraction_rounding_decision( prop.new_variable())))); // otherwise non-det } -/*******************************************************************\ - -Function: float_utilst::round_fraction - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void float_utilst::round_fraction(unbiased_floatt &result) { std::size_t fraction_size=spec.f+1; @@ -1475,18 +1084,6 @@ void float_utilst::round_fraction(unbiased_floatt &result) } } -/*******************************************************************\ - -Function: float_utilst::round_exponent - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void float_utilst::round_exponent(unbiased_floatt &result) { // do we need to enlarge the exponent? @@ -1552,18 +1149,7 @@ void float_utilst::round_exponent(unbiased_floatt &result) } } -/*******************************************************************\ - -Function: float_utilst::bias - - Inputs: - - Outputs: - - Purpose: takes an unbiased float, and applies the bias - -\*******************************************************************/ - +/// takes an unbiased float, and applies the bias float_utilst::biased_floatt float_utilst::bias(const unbiased_floatt &src) { biased_floatt result; @@ -1593,18 +1179,6 @@ float_utilst::biased_floatt float_utilst::bias(const unbiased_floatt &src) return result; } -/*******************************************************************\ - -Function: float_utilst::add_bias - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt float_utilst::add_bias(const bvt &src) { assert(src.size()==spec.e); @@ -1614,18 +1188,6 @@ bvt float_utilst::add_bias(const bvt &src) bv_utils.build_constant(spec.bias(), spec.e)); } -/*******************************************************************\ - -Function: float_utilst::sub_bias - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt float_utilst::sub_bias(const bvt &src) { assert(src.size()==spec.e); @@ -1635,18 +1197,6 @@ bvt float_utilst::sub_bias(const bvt &src) bv_utils.build_constant(spec.bias(), spec.e)); } -/*******************************************************************\ - -Function: float_utilst::unpack - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - float_utilst::unbiased_floatt float_utilst::unpack(const bvt &src) { assert(src.size()==spec.width()); @@ -1676,18 +1226,6 @@ float_utilst::unbiased_floatt float_utilst::unpack(const bvt &src) return result; } -/*******************************************************************\ - -Function: float_utilst::pack - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt float_utilst::pack(const biased_floatt &src) { assert(src.fraction.size()==spec.f); @@ -1719,18 +1257,6 @@ bvt float_utilst::pack(const biased_floatt &src) return result; } -/*******************************************************************\ - -Function: float_utilst::get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - ieee_floatt float_utilst::get(const bvt &src) const { mp_integer int_value=0; @@ -1745,18 +1271,6 @@ ieee_floatt float_utilst::get(const bvt &src) const return result; } -/*******************************************************************\ - -Function: float_utilst::sticky_right_shift - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt float_utilst::sticky_right_shift( const bvt &op, const bvt &dist, @@ -1792,18 +1306,6 @@ bvt float_utilst::sticky_right_shift( return result; } -/*******************************************************************\ - -Function: float_utilst::debug1 - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt float_utilst::debug1( const bvt &src1, const bvt &src2) @@ -1811,18 +1313,6 @@ bvt float_utilst::debug1( return src1; } -/*******************************************************************\ - -Function: float_utilst::debug1 - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt float_utilst::debug2( const bvt &op0, const bvt &op1) diff --git a/src/solvers/floatbv/float_utils.h b/src/solvers/floatbv/float_utils.h index 0396700f193..8d5e935b21a 100644 --- a/src/solvers/floatbv/float_utils.h +++ b/src/solvers/floatbv/float_utils.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_FLOATBV_FLOAT_UTILS_H #define CPROVER_SOLVERS_FLOATBV_FLOAT_UTILS_H diff --git a/src/solvers/miniBDD/example.cpp b/src/solvers/miniBDD/example.cpp index 2dddc990d5a..4918b89a601 100644 --- a/src/solvers/miniBDD/example.cpp +++ b/src/solvers/miniBDD/example.cpp @@ -7,6 +7,10 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// A minimalistic BDD library, following Bryant's original paper and Andersen's +/// lecture notes + #include #include "miniBDD.h" diff --git a/src/solvers/miniBDD/miniBDD.cpp b/src/solvers/miniBDD/miniBDD.cpp index 756a9dc6e52..2b337c2ec15 100644 --- a/src/solvers/miniBDD/miniBDD.cpp +++ b/src/solvers/miniBDD/miniBDD.cpp @@ -7,6 +7,10 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// A minimalistic BDD library, following Bryant's original paper and Andersen's +/// lecture notes + #include #include diff --git a/src/solvers/miniBDD/miniBDD.h b/src/solvers/miniBDD/miniBDD.h index aab378edbae..f7dde020fe6 100644 --- a/src/solvers/miniBDD/miniBDD.h +++ b/src/solvers/miniBDD/miniBDD.h @@ -7,6 +7,10 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// A minimalistic BDD library, following Bryant's original paper and Andersen's +/// lecture notes + #ifndef CPROVER_SOLVERS_MINIBDD_MINIBDD_H #define CPROVER_SOLVERS_MINIBDD_MINIBDD_H diff --git a/src/solvers/prop/aig.cpp b/src/solvers/prop/aig.cpp index 791436646f9..a6f3886539c 100644 --- a/src/solvers/prop/aig.cpp +++ b/src/solvers/prop/aig.cpp @@ -6,76 +6,29 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include #include "aig.h" -/*******************************************************************\ - -Function: aigt::label - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string aigt::label(nodest::size_type v) const { return "var("+std::to_string(v)+")"; } -/*******************************************************************\ - -Function: aigt::dot_label - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string aigt::dot_label(nodest::size_type v) const { return "var("+std::to_string(v)+")"; } -/*******************************************************************\ - -Function: aigt::get_terminals - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void aigt::get_terminals(terminalst &terminals) const { for(nodest::size_type n=0; n #include @@ -19,18 +20,6 @@ Author: Daniel Kroening, kroening@kroening.com // native CNF back-end. #define USE_PG -/*******************************************************************\ - -Function: aig_prop_baset::land - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt aig_prop_baset::land(const bvt &bv) { literalt literal=const_literal(true); @@ -43,18 +32,6 @@ literalt aig_prop_baset::land(const bvt &bv) return literal; } -/*******************************************************************\ - -Function: aig_prop_baset::lor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt aig_prop_baset::lor(const bvt &bv) { literalt literal=const_literal(true); @@ -67,18 +44,6 @@ literalt aig_prop_baset::lor(const bvt &bv) return neg(literal); } -/*******************************************************************\ - -Function: aig_prop_baset::lxor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt aig_prop_baset::lxor(const bvt &bv) { literalt literal=const_literal(false); @@ -89,18 +54,6 @@ literalt aig_prop_baset::lxor(const bvt &bv) return literal; } -/*******************************************************************\ - -Function: aig_prop_baset::land - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt aig_prop_baset::land(literalt a, literalt b) { if(a.is_true() || b.is_false()) @@ -116,35 +69,11 @@ literalt aig_prop_baset::land(literalt a, literalt b) return dest.new_and_node(a, b); } -/*******************************************************************\ - -Function: aig_prop_baset::lor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt aig_prop_baset::lor(literalt a, literalt b) { return neg(land(neg(a), neg(b))); // De Morgan's } -/*******************************************************************\ - -Function: aig_prop_baset::lxor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt aig_prop_baset::lxor(literalt a, literalt b) { if(a.is_false()) @@ -166,86 +95,26 @@ literalt aig_prop_baset::lxor(literalt a, literalt b) return lor(land(a, neg(b)), land(neg(a), b)); } -/*******************************************************************\ - -Function: aig_prop_baset::lnand - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt aig_prop_baset::lnand(literalt a, literalt b) { return !land(a, b); } -/*******************************************************************\ - -Function: aig_prop_baset::lnor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt aig_prop_baset::lnor(literalt a, literalt b) { return !lor(a, b); } -/*******************************************************************\ - -Function: aig_prop_baset::lequal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt aig_prop_baset::lequal(literalt a, literalt b) { return !lxor(a, b); } -/*******************************************************************\ - -Function: aig_prop_baset::limplies - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt aig_prop_baset::limplies(literalt a, literalt b) { return lor(neg(a), b); } -/*******************************************************************\ - -Function: aig_prop_baset::lselect - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt aig_prop_baset::lselect(literalt a, literalt b, literalt c) { // a?b:c=(a AND b) OR (/a AND c) if(a.is_true()) @@ -261,18 +130,6 @@ literalt aig_prop_baset::lselect(literalt a, literalt b, literalt c) return lor(land(a, b), land(neg(a), c)); } -/*******************************************************************\ - -Function: aig_prop_baset::set_equal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void aig_prop_baset::set_equal(literalt a, literalt b) { #ifdef USE_AIG_COMPACT @@ -288,35 +145,11 @@ void aig_prop_baset::set_equal(literalt a, literalt b) #endif } -/*******************************************************************\ - -Function: aig_prop_solvert::l_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - tvt aig_prop_solvert::l_get(literalt a) const { return solver.l_get(a); } -/*******************************************************************\ - -Function: aig_prop_solvert::prop_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - propt::resultt aig_prop_solvert::prop_solve() { status() << "converting AIG, " @@ -326,18 +159,9 @@ propt::resultt aig_prop_solvert::prop_solve() return solver.prop_solve(); } -/*******************************************************************\ - -Function: aig_prop_solvert::compute_phase - - Inputs: Two vectors of bools of size aig.nodes.size() - - Outputs: These vectors filled in with per node phase information - - Purpose: Compute the phase information needed for Plaisted-Greenbaum encoding - -\*******************************************************************/ - +/// Compute the phase information needed for Plaisted-Greenbaum encoding +/// \par parameters: Two vectors of bools of size aig.nodes.size() +/// \return These vectors filled in with per node phase information void aig_prop_solvert::compute_phase( std::vector &n_pos, std::vector &n_neg) @@ -400,18 +224,9 @@ void aig_prop_solvert::compute_phase( } -/*******************************************************************\ - -Function: aig_prop_solvert::usage_count - - Inputs: Two vectors of unsigned of size aig.nodes.size() - - Outputs: These vectors filled in with per node usage information - - Purpose: Compact encoding for single usage variable - -\*******************************************************************/ - +/// Compact encoding for single usage variable +/// \par parameters: Two vectors of unsigned of size aig.nodes.size() +/// \return These vectors filled in with per node usage information void aig_prop_solvert::usage_count( std::vector &p_usage_count, std::vector &n_usage_count) @@ -519,18 +334,10 @@ void aig_prop_solvert::usage_count( #endif } -/*******************************************************************\ - -Function: aig_prop_solvert::convert_node - - Inputs: The node to convert, the phases required and the usage counts. - - Outputs: The node converted to CNF in the solver object. - - Purpose: Convert one AIG node, including special handling of a couple of cases - -\*******************************************************************/ - +/// Convert one AIG node, including special handling of a couple of cases +/// \par parameters: The node to convert, the phases required and the usage +/// counts. +/// \return The node converted to CNF in the solver object. void aig_prop_solvert::convert_node( unsigned n, const aigt::nodet &node, @@ -742,18 +549,6 @@ void aig_prop_solvert::convert_node( } } -/*******************************************************************\ - -Function: aig_prop_solvert::convert_aig - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void aig_prop_solvert::convert_aig() { // 1. Do variables diff --git a/src/solvers/prop/aig_prop.h b/src/solvers/prop/aig_prop.h index 7c5ecf6bba2..335f224747c 100644 --- a/src/solvers/prop/aig_prop.h +++ b/src/solvers/prop/aig_prop.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_PROP_AIG_PROP_H #define CPROVER_SOLVERS_PROP_AIG_PROP_H diff --git a/src/solvers/prop/bdd_expr.cpp b/src/solvers/prop/bdd_expr.cpp index 91e06dfb08a..9a885c031b7 100644 --- a/src/solvers/prop/bdd_expr.cpp +++ b/src/solvers/prop/bdd_expr.cpp @@ -6,6 +6,9 @@ Author: Michael Tautschnig, michael.tautschnig@qmul.ac.uk \*******************************************************************/ +/// \file +/// Conversion between exprt and miniBDD + #include #include @@ -13,18 +16,6 @@ Author: Michael Tautschnig, michael.tautschnig@qmul.ac.uk #include "bdd_expr.h" -/*******************************************************************\ - -Function: bdd_exprt::from_expr_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - mini_bddt bdd_exprt::from_expr_rec(const exprt &expr) { assert(expr.type().id()==ID_bool); @@ -103,35 +94,11 @@ mini_bddt bdd_exprt::from_expr_rec(const exprt &expr) } } -/*******************************************************************\ - -Function: bdd_exprt::from_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bdd_exprt::from_expr(const exprt &expr) { root=from_expr_rec(expr); } -/*******************************************************************\ - -Function: bdd_exprt::as_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt bdd_exprt::as_expr(const mini_bddt &r) const { if(r.is_constant()) @@ -168,18 +135,6 @@ exprt bdd_exprt::as_expr(const mini_bddt &r) const return if_exprt(n_expr, as_expr(r.high()), as_expr(r.low())); } -/*******************************************************************\ - -Function: bdd_exprt::as_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt bdd_exprt::as_expr() const { if(!root.is_initialized()) diff --git a/src/solvers/prop/bdd_expr.h b/src/solvers/prop/bdd_expr.h index 3c35aa5dc21..c462a17e669 100644 --- a/src/solvers/prop/bdd_expr.h +++ b/src/solvers/prop/bdd_expr.h @@ -6,6 +6,9 @@ Author: Michael Tautschnig, michael.tautschnig@qmul.ac.uk \*******************************************************************/ +/// \file +/// Conversion between exprt and miniBDD + #ifndef CPROVER_SOLVERS_PROP_BDD_EXPR_H #define CPROVER_SOLVERS_PROP_BDD_EXPR_H diff --git a/src/solvers/prop/cover_goals.cpp b/src/solvers/prop/cover_goals.cpp index b4f2e614bf3..1783983ccf9 100644 --- a/src/solvers/prop/cover_goals.cpp +++ b/src/solvers/prop/cover_goals.cpp @@ -6,39 +6,19 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Cover a set of goals incrementally + #include #include "literal_expr.h" #include "cover_goals.h" -/*******************************************************************\ - -Function: cover_goalst::~cover_goalst - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - cover_goalst::~cover_goalst() { } -/*******************************************************************\ - -Function: cover_goalst::mark - - Inputs: - - Outputs: - - Purpose: Mark goals that are covered - -\*******************************************************************/ - +/// Mark goals that are covered void cover_goalst::mark() { // notify observers @@ -58,18 +38,7 @@ void cover_goalst::mark() } } -/*******************************************************************\ - -Function: cover_goalst::constaint - - Inputs: - - Outputs: - - Purpose: Build clause - -\*******************************************************************/ - +/// Build clause void cover_goalst::constraint() { exprt::operandst disjuncts; @@ -88,18 +57,7 @@ void cover_goalst::constraint() prop_conv.set_to_true(disjunction(disjuncts)); } -/*******************************************************************\ - -Function: cover_goalst::freeze_goal_variables - - Inputs: - - Outputs: - - Purpose: Build clause - -\*******************************************************************/ - +/// Build clause void cover_goalst::freeze_goal_variables() { for(std::list::const_iterator @@ -110,18 +68,7 @@ void cover_goalst::freeze_goal_variables() prop_conv.set_frozen(g_it->condition); } -/*******************************************************************\ - -Function: cover_goalst::operator() - - Inputs: - - Outputs: - - Purpose: Try to cover all goals - -\*******************************************************************/ - +/// Try to cover all goals decision_proceduret::resultt cover_goalst::operator()() { _iterations=_number_covered=0; diff --git a/src/solvers/prop/cover_goals.h b/src/solvers/prop/cover_goals.h index afb93c9e534..8851e188347 100644 --- a/src/solvers/prop/cover_goals.h +++ b/src/solvers/prop/cover_goals.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Cover a set of goals incrementally + #ifndef CPROVER_SOLVERS_PROP_COVER_GOALS_H #define CPROVER_SOLVERS_PROP_COVER_GOALS_H @@ -13,16 +16,8 @@ Author: Daniel Kroening, kroening@kroening.com #include "prop_conv.h" -/*******************************************************************\ - - Class: cover_gooalst - - Purpose: Try to cover some given set of goals incrementally. - This can be seen as a heuristic variant of - SAT-based set-cover. No minimality guarantee. - -\*******************************************************************/ - +/// Try to cover some given set of goals incrementally. This can be seen as a +/// heuristic variant of SAT-based set-cover. No minimality guarantee. class cover_goalst:public messaget { public: diff --git a/src/solvers/prop/literal.cpp b/src/solvers/prop/literal.cpp index d57da3e91a3..e00f3bb37be 100644 --- a/src/solvers/prop/literal.cpp +++ b/src/solvers/prop/literal.cpp @@ -6,22 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Literals + #include #include "literal.h" -/*******************************************************************\ - -Function: operator << - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::ostream &operator << (std::ostream &out, literalt l) { if(l.is_constant()) diff --git a/src/solvers/prop/literal.h b/src/solvers/prop/literal.h index 694f5701a12..24e62ba599a 100644 --- a/src/solvers/prop/literal.h +++ b/src/solvers/prop/literal.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_PROP_LITERAL_H #define CPROVER_SOLVERS_PROP_LITERAL_H diff --git a/src/solvers/prop/literal_expr.h b/src/solvers/prop/literal_expr.h index b76c23b0ba5..c37553615d0 100644 --- a/src/solvers/prop/literal_expr.h +++ b/src/solvers/prop/literal_expr.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_PROP_LITERAL_EXPR_H #define CPROVER_SOLVERS_PROP_LITERAL_EXPR_H diff --git a/src/solvers/prop/minimize.cpp b/src/solvers/prop/minimize.cpp index bdbc6661159..8ae18a1787c 100644 --- a/src/solvers/prop/minimize.cpp +++ b/src/solvers/prop/minimize.cpp @@ -6,23 +6,15 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Minimize some target function incrementally + #include #include "literal_expr.h" #include "minimize.h" -/*******************************************************************\ - -Function: prop_minimizet::objective - - Inputs: - - Outputs: - - Purpose: Add an objective - -\*******************************************************************/ - +/// Add an objective void prop_minimizet::objective( const literalt condition, const weightt weight) @@ -39,18 +31,7 @@ void prop_minimizet::objective( } } -/*******************************************************************\ - -Function: prop_minimizet::fix - - Inputs: - - Outputs: - - Purpose: Fix objectives that are satisfied - -\*******************************************************************/ - +/// Fix objectives that are satisfied void prop_minimizet::fix_objectives() { std::vector &entry=current->second; @@ -75,19 +56,7 @@ void prop_minimizet::fix_objectives() assert(found); } -/*******************************************************************\ - -Function: prop_minimizet::constaint - - Inputs: - - Outputs: - - Purpose: Build constraints that require us to improve on - at least one goal, greedily. - -\*******************************************************************/ - +/// Build constraints that require us to improve on at least one goal, greedily. literalt prop_minimizet::constraint() { std::vector &entry=current->second; @@ -119,18 +88,7 @@ literalt prop_minimizet::constraint() } } -/*******************************************************************\ - -Function: prop_minimizet::operator() - - Inputs: - - Outputs: - - Purpose: Try to cover all objectives - -\*******************************************************************/ - +/// Try to cover all objectives void prop_minimizet::operator()() { // we need to use assumptions diff --git a/src/solvers/prop/minimize.h b/src/solvers/prop/minimize.h index f546f8442ee..3818a76b114 100644 --- a/src/solvers/prop/minimize.h +++ b/src/solvers/prop/minimize.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// SAT Minimizer + #ifndef CPROVER_SOLVERS_PROP_MINIMIZE_H #define CPROVER_SOLVERS_PROP_MINIMIZE_H @@ -15,15 +18,8 @@ Author: Daniel Kroening, kroening@kroening.com #include "prop_conv.h" -/*******************************************************************\ - - Class: prop_minimizet - - Purpose: Computes a satisfying assignment of minimal cost - according to a const function using incremental SAT - -\*******************************************************************/ - +/// Computes a satisfying assignment of minimal cost according to a const +/// function using incremental SAT class prop_minimizet:public messaget { public: diff --git a/src/solvers/prop/prop.cpp b/src/solvers/prop/prop.cpp index cb17cc9ce11..6810ca4fef6 100644 --- a/src/solvers/prop/prop.cpp +++ b/src/solvers/prop/prop.cpp @@ -6,92 +6,37 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "prop.h" -/*******************************************************************\ - -Function: propt::set_equal - - Inputs: - - Outputs: - - Purpose: asserts a==b in the propositional formula - -\*******************************************************************/ - +/// asserts a==b in the propositional formula void propt::set_equal(literalt a, literalt b) { lcnf(a, !b); lcnf(!a, b); } -/*******************************************************************\ - -Function: propt::set_assignment - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void propt::set_assignment(literalt a, bool value) { assert(false); } -/*******************************************************************\ - -Function: propt::copy_assignment_from - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void propt::copy_assignment_from(const propt &src) { assert(false); } -/*******************************************************************\ - -Function: propt::is_in_conflict - - Inputs: - - Outputs: true iff the given literal is part of the final conflict - - Purpose: - -\*******************************************************************/ - +/// \return true iff the given literal is part of the final conflict bool propt::is_in_conflict(literalt l) const { assert(false); return false; } -/*******************************************************************\ - -Function: propt::new_variables - - Inputs: width - - Outputs: bitvector - - Purpose: generates a bitvector of given width with new variables - -\*******************************************************************/ - +/// generates a bitvector of given width with new variables +/// \return bitvector bvt propt::new_variables(std::size_t width) { bvt result; diff --git a/src/solvers/prop/prop.h b/src/solvers/prop/prop.h index ce6fe54051c..e48674d5c57 100644 --- a/src/solvers/prop/prop.h +++ b/src/solvers/prop/prop.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_PROP_PROP_H #define CPROVER_SOLVERS_PROP_PROP_H diff --git a/src/solvers/prop/prop_assignment.cpp b/src/solvers/prop/prop_assignment.cpp index f191a4c6c55..31eb4089559 100644 --- a/src/solvers/prop/prop_assignment.cpp +++ b/src/solvers/prop/prop_assignment.cpp @@ -6,19 +6,8 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "prop_assignment.h" - -/*******************************************************************\ - -Function: prop_assignmentt::~prop_assignmentt - - Inputs: - Outputs: - - Purpose: - -\*******************************************************************/ +#include "prop_assignment.h" prop_assignmentt::~prop_assignmentt() { diff --git a/src/solvers/prop/prop_assignment.h b/src/solvers/prop/prop_assignment.h index 0de6dcdc4ef..63c32d4bda4 100644 --- a/src/solvers/prop/prop_assignment.h +++ b/src/solvers/prop/prop_assignment.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_PROP_PROP_ASSIGNMENT_H #define CPROVER_SOLVERS_PROP_PROP_ASSIGNMENT_H diff --git a/src/solvers/prop/prop_conv.cpp b/src/solvers/prop/prop_conv.cpp index eac517bf2b6..f7274994d16 100644 --- a/src/solvers/prop/prop_conv.cpp +++ b/src/solvers/prop/prop_conv.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include @@ -18,70 +19,23 @@ Author: Daniel Kroening, kroening@kroening.com #include "prop_conv.h" #include "literal_expr.h" -/*******************************************************************\ - -Function: prop_convt::is_in_conflict - - Inputs: - - Outputs: - - Purpose: determine whether a variable is in the final conflict - -\*******************************************************************/ - +/// determine whether a variable is in the final conflict bool prop_convt::is_in_conflict(literalt l) const { assert(false); return false; } -/*******************************************************************\ - -Function: prop_convt::set_assumptions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void prop_convt::set_assumptions(const bvt &) { assert(false); } -/*******************************************************************\ - -Function: prop_convt::set_frozen - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void prop_convt::set_frozen(const literalt) { assert(false); } -/*******************************************************************\ - -Function: prop_convt::set_frozen - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void prop_convt::set_frozen(const bvt &bv) { for(unsigned i=0; i result= @@ -153,18 +83,7 @@ literalt prop_conv_solvert::get_literal(const irep_idt &identifier) return literal; } -/*******************************************************************\ - -Function: prop_conv_solvert::get_bool - - Inputs: - - Outputs: - - Purpose: get a boolean value from counter example if not valid - -\*******************************************************************/ - +/// get a boolean value from counter example if not valid bool prop_conv_solvert::get_bool(const exprt &expr, tvt &value) const { // trivial cases @@ -253,18 +172,6 @@ bool prop_conv_solvert::get_bool(const exprt &expr, tvt &value) const return false; } -/*******************************************************************\ - -Function: prop_conv_solvert::convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt prop_conv_solvert::convert(const exprt &expr) { if(!use_cache || @@ -293,24 +200,12 @@ literalt prop_conv_solvert::convert(const exprt &expr) prop.set_frozen(literal); #if 0 - std::cout << literal << "=" << expr << std::endl; + std::cout << literal << "=" << expr << '\n'; #endif return literal; } -/*******************************************************************\ - -Function: prop_conv_solvert::convert_bool - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt prop_conv_solvert::convert_bool(const exprt &expr) { if(expr.type().id()!=ID_bool) @@ -439,18 +334,6 @@ literalt prop_conv_solvert::convert_bool(const exprt &expr) return convert_rest(expr); } -/*******************************************************************\ - -Function: prop_conv_solvert::convert_rest - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt prop_conv_solvert::convert_rest(const exprt &expr) { // fall through @@ -458,18 +341,6 @@ literalt prop_conv_solvert::convert_rest(const exprt &expr) return prop.new_variable(); } -/*******************************************************************\ - -Function: prop_conv_solvert::set_equality_to_true - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool prop_conv_solvert::set_equality_to_true(const equal_exprt &expr) { if(!equality_propagation) @@ -497,18 +368,6 @@ bool prop_conv_solvert::set_equality_to_true(const equal_exprt &expr) return true; } -/*******************************************************************\ - -Function: prop_conv_solvert::set_to - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void prop_conv_solvert::set_to(const exprt &expr, bool value) { if(expr.type().id()!=ID_bool) @@ -608,66 +467,28 @@ void prop_conv_solvert::set_to(const exprt &expr, bool value) prop.l_set_to(convert(expr), value); } -/*******************************************************************\ - -Function: prop_conv_solvert::ignoring - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void prop_conv_solvert::ignoring(const exprt &expr) { // fall through - std::string msg="warning: ignoring "+expr.pretty(); - - print(2, msg); + warning() << "warning: ignoring " << expr.pretty() << eom; } -/*******************************************************************\ - -Function: prop_conv_solvert::post_process - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void prop_conv_solvert::post_process() { } -/*******************************************************************\ - -Function: prop_conv_solvert::solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - decision_proceduret::resultt prop_conv_solvert::dec_solve() { // post-processing isn't incremental yet if(!post_processing_done) { - print(8, "Post-processing"); + statistics() << "Post-processing" << eom; post_process(); post_processing_done=true; } - print(7, "Solving with "+prop.solver_text()); + statistics() << "Solving with " << prop.solver_text() << eom; propt::resultt result=prop.prop_solve(); @@ -681,18 +502,6 @@ decision_proceduret::resultt prop_conv_solvert::dec_solve() return resultt::D_ERROR; } -/*******************************************************************\ - -Function: prop_conv_solvert::get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt prop_conv_solvert::get(const exprt &expr) const { tvt value; @@ -719,18 +528,6 @@ exprt prop_conv_solvert::get(const exprt &expr) const return tmp; } -/*******************************************************************\ - -Function: prop_conv_solvert::print_assignment - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void prop_conv_solvert::print_assignment(std::ostream &out) const { for(symbolst::const_iterator it=symbols.begin(); diff --git a/src/solvers/prop/prop_conv.h b/src/solvers/prop/prop_conv.h index 5f3cf35c2c8..9d59fb06cf5 100644 --- a/src/solvers/prop/prop_conv.h +++ b/src/solvers/prop/prop_conv.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_PROP_PROP_CONV_H #define CPROVER_SOLVERS_PROP_PROP_CONV_H diff --git a/src/solvers/prop/prop_conv_store.cpp b/src/solvers/prop/prop_conv_store.cpp index 9fb2c09a414..109c2f0cee7 100644 --- a/src/solvers/prop/prop_conv_store.cpp +++ b/src/solvers/prop/prop_conv_store.cpp @@ -6,22 +6,11 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "prop_conv_store.h" -/*******************************************************************\ - -Function: prop_conv_storet::set_to - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void prop_conv_storet::set_to(const exprt &expr, bool value) { constraintt &constraint=constraints.add_constraint(); @@ -30,18 +19,6 @@ void prop_conv_storet::set_to(const exprt &expr, bool value) constraint.value=value; } -/*******************************************************************\ - -Function: prop_conv_storet::convert_rest - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt prop_conv_storet::convert(const exprt &expr) { constraintt &constraint=constraints.add_constraint(); @@ -53,18 +30,6 @@ literalt prop_conv_storet::convert(const exprt &expr) return constraint.literal; } -/*******************************************************************\ - -Function: prop_conv_storet::constraintst::replay - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void prop_conv_storet::constraintst::replay(prop_convt &dest) const { for(constraint_listt::const_iterator @@ -74,18 +39,6 @@ void prop_conv_storet::constraintst::replay(prop_convt &dest) const it->replay(dest); } -/*******************************************************************\ - -Function: prop_conv_storet::constraintst::print - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void prop_conv_storet::constraintst::print(std::ostream &out) const { for(constraint_listt::const_iterator @@ -95,18 +48,6 @@ void prop_conv_storet::constraintst::print(std::ostream &out) const it->print(out); } -/*******************************************************************\ - -Function: prop_conv_storet::constraintt::replay - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void prop_conv_storet::constraintt::replay(prop_convt &dest) const { switch(type) @@ -124,18 +65,6 @@ void prop_conv_storet::constraintt::replay(prop_convt &dest) const } } -/*******************************************************************\ - -Function: prop_conv_storet::constraintt::print - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void prop_conv_storet::constraintt::print(std::ostream &out) const { switch(type) diff --git a/src/solvers/prop/prop_conv_store.h b/src/solvers/prop/prop_conv_store.h index f146600e77b..334b191949c 100644 --- a/src/solvers/prop/prop_conv_store.h +++ b/src/solvers/prop/prop_conv_store.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_PROP_PROP_CONV_STORE_H #define CPROVER_SOLVERS_PROP_PROP_CONV_STORE_H diff --git a/src/solvers/prop/prop_wrapper.h b/src/solvers/prop/prop_wrapper.h index d21b2e85a4e..3cbff0b0835 100644 --- a/src/solvers/prop/prop_wrapper.h +++ b/src/solvers/prop/prop_wrapper.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_PROP_PROP_WRAPPER_H #define CPROVER_SOLVERS_PROP_PROP_WRAPPER_H diff --git a/src/solvers/qbf/qbf_bdd_core.cpp b/src/solvers/qbf/qbf_bdd_core.cpp index 9fa58639ad0..03779c3b7d1 100644 --- a/src/solvers/qbf/qbf_bdd_core.cpp +++ b/src/solvers/qbf/qbf_bdd_core.cpp @@ -6,6 +6,7 @@ Author: CM Wintersteiger \*******************************************************************/ + #include #include @@ -21,18 +22,6 @@ Author: CM Wintersteiger /*! \cond */ // FIX FOR THE CUDD LIBRARY -/*******************************************************************\ - -Function: DD::getNode - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - inline DdNode *DD::getNode() const { return node; @@ -42,35 +31,11 @@ inline DdNode *DD::getNode() const #include "qbf_bdd_core.h" -/*******************************************************************\ - -Function: qbf_bdd_certificatet::qbf_bdd_certificatet - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - qbf_bdd_certificatet::qbf_bdd_certificatet(void) : qdimacs_coret() { bdd_manager=new Cudd(0, 0); } -/*******************************************************************\ - -Function: qbf_bdd_certificatet::~qbf_bdd_certificatet - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - qbf_bdd_certificatet::~qbf_bdd_certificatet(void) { for(const BDD* model : model_bdds) @@ -84,18 +49,6 @@ qbf_bdd_certificatet::~qbf_bdd_certificatet(void) bdd_manager=NULL; } -/*******************************************************************\ - -Function: qbf_bdd_certificatet::new_variable - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt qbf_bdd_certificatet::new_variable(void) { literalt l=qdimacs_coret::new_variable(); @@ -106,36 +59,12 @@ literalt qbf_bdd_certificatet::new_variable(void) return l; } -/*******************************************************************\ - -Function: qbf_bdd_coret::qbf_bdd_coret - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - qbf_bdd_coret::qbf_bdd_coret() : qbf_bdd_certificatet() { matrix=new BDD(); *matrix=bdd_manager->bddOne(); } -/*******************************************************************\ - -Function: qbf_bdd_coret::~qbf_bdd_coret - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - qbf_bdd_coret::~qbf_bdd_coret() { for(const BDD* variable : bdd_variable_map) @@ -152,53 +81,17 @@ qbf_bdd_coret::~qbf_bdd_coret() } } -/*******************************************************************\ - -Function: qbf_bdd_coret::l_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - tvt qbf_bdd_coret::l_get(literalt a) const { assert(false); return tvt(false); } -/*******************************************************************\ - -Function: qbf_bdd_coret::solver_text - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const std::string qbf_bdd_coret::solver_text() { return "QBF/BDD/CORE"; } -/*******************************************************************\ - -Function: qbf_bdd_coret::prop_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - propt::resultt qbf_bdd_coret::prop_solve() { { @@ -220,7 +113,7 @@ propt::resultt qbf_bdd_coret::prop_solve() { #if 0 std::cout << "BDD E: " << var << ", " << - matrix->nodeCount() << " nodes" << std::endl; + matrix->nodeCount() << " nodes\n"; #endif BDD *model=new BDD(); @@ -236,7 +129,7 @@ propt::resultt qbf_bdd_coret::prop_solve() { #if 0 std::cout << "BDD A: " << var << ", " << - matrix->nodeCount() << " nodes" << std::endl; + matrix->nodeCount() << " nodes\n"; #endif *matrix=matrix->UnivAbstract(*bdd_variable_map[var]); @@ -259,52 +152,16 @@ propt::resultt qbf_bdd_coret::prop_solve() return P_ERROR; } -/*******************************************************************\ - -Function: qbf_bdd_coret::is_in_core - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool qbf_bdd_coret::is_in_core(literalt l) const { throw "nyi"; } -/*******************************************************************\ - -Function: qbf_bdd_coret::m_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - qdimacs_coret::modeltypet qbf_bdd_coret::m_get(literalt a) const { throw "nyi"; } -/*******************************************************************\ - -Function: qbf_bdd_coret::new_variable - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt qbf_bdd_coret::new_variable() { literalt res=qbf_bdd_certificatet::new_variable(); @@ -317,18 +174,6 @@ literalt qbf_bdd_coret::new_variable() return res; } -/*******************************************************************\ - -Function: qbf_bdd_coret::lcnf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void qbf_bdd_coret::lcnf(const bvt &bv) { bvt new_bv; @@ -351,18 +196,6 @@ void qbf_bdd_coret::lcnf(const bvt &bv) *matrix&=clause; } -/*******************************************************************\ - -Function: qbf_bdd_coret::lor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt qbf_bdd_coret::lor(literalt a, literalt b) { literalt nl=new_variable(); @@ -380,18 +213,6 @@ literalt qbf_bdd_coret::lor(literalt a, literalt b) return nl; } -/*******************************************************************\ - -Function: qbf_bdd_coret::lor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt qbf_bdd_coret::lor(const bvt &bv) { for(const literalt &literal : bv) @@ -419,18 +240,6 @@ literalt qbf_bdd_coret::lor(const bvt &bv) return nl; } -/*******************************************************************\ - -Function: qbf_bdd_coret::compress_certificate - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void qbf_bdd_coret::compress_certificate(void) { status() << "Compressing Certificate" << eom; @@ -459,18 +268,6 @@ void qbf_bdd_coret::compress_certificate(void) } } -/*******************************************************************\ - -Function: qbf_bdd_certificatet::f_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const exprt qbf_bdd_certificatet::f_get(literalt l) { quantifiert q; @@ -510,7 +307,7 @@ const exprt qbf_bdd_certificatet::f_get(literalt l) if(it!=function_cache.end()) { #if 0 - std::cout << "CACHE HIT for " << l.dimacs() << std::endl; + std::cout << "CACHE HIT for " << l.dimacs() << '\n'; #endif if(l.sign()) @@ -525,7 +322,7 @@ const exprt qbf_bdd_certificatet::f_get(literalt l) BDD &model=*model_bdds[l.var_no()]; #if 0 - std::cout << "Model " << l.var_no() << std::endl; + std::cout << "Model " << l.var_no() << '\n'; model.PrintMinterm(); #endif @@ -547,7 +344,7 @@ const exprt qbf_bdd_certificatet::f_get(literalt l) std::cout << "CUBE: "; for(signed i=0; iReadSize(); i++) std::cout << cube[i]; - std::cout << std::endl; + std::cout << '\n'; #endif for(signed i=0; iReadSize(); i++) @@ -592,18 +389,6 @@ const exprt qbf_bdd_certificatet::f_get(literalt l) } } -/*******************************************************************\ - -Function: qbf_bdd_certificatet::l_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - tvt qbf_bdd_certificatet::l_get(literalt a) const { const BDD &model=*model_bdds[a.var_no()]; diff --git a/src/solvers/qbf/qbf_bdd_core.h b/src/solvers/qbf/qbf_bdd_core.h index 4c9d3e6fd2d..d309bf143c2 100644 --- a/src/solvers/qbf/qbf_bdd_core.h +++ b/src/solvers/qbf/qbf_bdd_core.h @@ -6,6 +6,7 @@ Author: CM Wintersteiger \*******************************************************************/ + #ifndef CPROVER_SOLVERS_QBF_QBF_BDD_CORE_H #define CPROVER_SOLVERS_QBF_QBF_BDD_CORE_H diff --git a/src/solvers/qbf/qbf_core.h b/src/solvers/qbf/qbf_core.h index 79758f83daa..9a214441a77 100644 --- a/src/solvers/qbf/qbf_core.h +++ b/src/solvers/qbf/qbf_core.h @@ -7,6 +7,7 @@ Author: Daniel Kroening, kroening@kroening.com, \*******************************************************************/ + #ifndef CPROVER_SOLVERS_QBF_QBF_CORE_H #define CPROVER_SOLVERS_QBF_QBF_CORE_H diff --git a/src/solvers/qbf/qbf_quantor.cpp b/src/solvers/qbf/qbf_quantor.cpp index a1ed0fa70e5..fef41a7e892 100644 --- a/src/solvers/qbf/qbf_quantor.cpp +++ b/src/solvers/qbf/qbf_quantor.cpp @@ -6,91 +6,32 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include #include "qbf_quantor.h" -/*******************************************************************\ - -Function: qbf_quantort::qbf_quantort - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - qbf_quantort::qbf_quantort() { } -/*******************************************************************\ - -Function: qbf_quantort::~qbf_quantort - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - qbf_quantort::~qbf_quantort() { } -/*******************************************************************\ - -Function: qbf_quantort::l_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - tvt qbf_quantort::l_get(literalt a) const { assert(false); return tvt::unknown(); } -/*******************************************************************\ - -Function: qbf_quantort::solver_text - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const std::string qbf_quantort::solver_text() { return "Quantor"; } -/*******************************************************************\ - -Function: qbf_quantort::prop_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - propt::resultt qbf_quantort::prop_solve() { { diff --git a/src/solvers/qbf/qbf_quantor.h b/src/solvers/qbf/qbf_quantor.h index e5f302fbea8..a6b8ec05d66 100644 --- a/src/solvers/qbf/qbf_quantor.h +++ b/src/solvers/qbf/qbf_quantor.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_QBF_QBF_QUANTOR_H #define CPROVER_SOLVERS_QBF_QBF_QUANTOR_H diff --git a/src/solvers/qbf/qbf_qube.cpp b/src/solvers/qbf/qbf_qube.cpp index a52c99bac33..eb3b73ddbfd 100644 --- a/src/solvers/qbf/qbf_qube.cpp +++ b/src/solvers/qbf/qbf_qube.cpp @@ -6,93 +6,34 @@ Author: CM Wintersteiger \*******************************************************************/ + #include #include #include #include "qbf_qube.h" -/*******************************************************************\ - -Function: qbf_qubet::qbf_qubet - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - qbf_qubet::qbf_qubet() { // skizzo crashes on broken lines break_lines=false; } -/*******************************************************************\ - -Function: qbf_qubet::~qbf_qubet - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - qbf_qubet::~qbf_qubet() { } -/*******************************************************************\ - -Function: qbf_qubet::l_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - tvt qbf_qubet::l_get(literalt a) const { assert(false); return tvt(false); } -/*******************************************************************\ - -Function: qbf_qubet::solver_text - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const std::string qbf_qubet::solver_text() { return "QuBE"; } -/*******************************************************************\ - -Function: qbf_qubet::prop_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - propt::resultt qbf_qubet::prop_solve() { // sKizzo crashes on empty instances diff --git a/src/solvers/qbf/qbf_qube.h b/src/solvers/qbf/qbf_qube.h index 10331e09fee..062e664cb48 100644 --- a/src/solvers/qbf/qbf_qube.h +++ b/src/solvers/qbf/qbf_qube.h @@ -6,6 +6,7 @@ Author: CM Wintersteiger \*******************************************************************/ + #ifndef CPROVER_SOLVERS_QBF_QBF_QUBE_H #define CPROVER_SOLVERS_QBF_QBF_QUBE_H diff --git a/src/solvers/qbf/qbf_qube_core.cpp b/src/solvers/qbf/qbf_qube_core.cpp index f5ea1d76610..1315ef4a591 100644 --- a/src/solvers/qbf/qbf_qube_core.cpp +++ b/src/solvers/qbf/qbf_qube_core.cpp @@ -6,6 +6,7 @@ Author: CM Wintersteiger \*******************************************************************/ + #include #include #include @@ -14,69 +15,21 @@ Author: CM Wintersteiger #include "qbf_qube_core.h" -/*******************************************************************\ - -Function: qbf_qube_coret::qbf_qube_coret - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - qbf_qube_coret::qbf_qube_coret() : qdimacs_coret() { break_lines=false; qbf_tmp_file="qube.qdimacs"; } -/*******************************************************************\ - -Function: qbf_qube_coret::~qbf_qube_coret - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - qbf_qube_coret::~qbf_qube_coret() { } -/*******************************************************************\ - -Function: qbf_qube_coret::solver_text - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const std::string qbf_qube_coret::solver_text() { return "QuBE w/ toplevel assignments"; } -/*******************************************************************\ - -Function: qbf_qube_coret::prop_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - propt::resultt qbf_qube_coret::prop_solve() { if(no_clauses()==0) @@ -165,35 +118,11 @@ propt::resultt qbf_qube_coret::prop_solve() } } -/*******************************************************************\ - -Function: qbf_qube_coret::is_in_core - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool qbf_qube_coret::is_in_core(literalt l) const { throw "not supported"; } -/*******************************************************************\ - -Function: qbf_qube_coret::m_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - qdimacs_coret::modeltypet qbf_qube_coret::m_get(literalt a) const { throw "not supported"; diff --git a/src/solvers/qbf/qbf_qube_core.h b/src/solvers/qbf/qbf_qube_core.h index 348d9492015..29d68088e5c 100644 --- a/src/solvers/qbf/qbf_qube_core.h +++ b/src/solvers/qbf/qbf_qube_core.h @@ -6,6 +6,7 @@ Author: CM Wintersteiger \*******************************************************************/ + #ifndef CPROVER_SOLVERS_QBF_QBF_QUBE_CORE_H #define CPROVER_SOLVERS_QBF_QBF_QUBE_CORE_H diff --git a/src/solvers/qbf/qbf_skizzo.cpp b/src/solvers/qbf/qbf_skizzo.cpp index 1b665567323..c26132f70bf 100644 --- a/src/solvers/qbf/qbf_skizzo.cpp +++ b/src/solvers/qbf/qbf_skizzo.cpp @@ -6,93 +6,34 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include #include "qbf_skizzo.h" -/*******************************************************************\ - -Function: qbf_skizzot::qbf_skizzot - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - qbf_skizzot::qbf_skizzot() { // skizzo crashes on broken lines break_lines=false; } -/*******************************************************************\ - -Function: qbf_skizzot::~qbf_skizzot - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - qbf_skizzot::~qbf_skizzot() { } -/*******************************************************************\ - -Function: qbf_skizzot::l_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - tvt qbf_skizzot::l_get(literalt a) const { assert(false); return tvt(false); } -/*******************************************************************\ - -Function: qbf_skizzot::solver_text - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const std::string qbf_skizzot::solver_text() { return "Skizzo"; } -/*******************************************************************\ - -Function: qbf_skizzot::prop_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - propt::resultt qbf_skizzot::prop_solve() { // sKizzo crashes on empty instances diff --git a/src/solvers/qbf/qbf_skizzo.h b/src/solvers/qbf/qbf_skizzo.h index bfc21ca4d43..62bf604582e 100644 --- a/src/solvers/qbf/qbf_skizzo.h +++ b/src/solvers/qbf/qbf_skizzo.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_QBF_QBF_SKIZZO_H #define CPROVER_SOLVERS_QBF_QBF_SKIZZO_H diff --git a/src/solvers/qbf/qbf_skizzo_core.cpp b/src/solvers/qbf/qbf_skizzo_core.cpp index 0b79ca216a6..5940347d43a 100644 --- a/src/solvers/qbf/qbf_skizzo_core.cpp +++ b/src/solvers/qbf/qbf_skizzo_core.cpp @@ -6,6 +6,7 @@ Author: CM Wintersteiger \*******************************************************************/ + #include #include @@ -16,18 +17,6 @@ Author: CM Wintersteiger /*! \cond */ // FIX FOR THE CUDD LIBRARY -/*******************************************************************\ - -Function: DD::getNode - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - inline DdNode *DD::getNode() const { return node; @@ -38,18 +27,6 @@ inline DdNode *DD::getNode() const #include "qbf_skizzo_core.h" -/*******************************************************************\ - -Function: qbf_skizzo_coret::qbf_skizzo_coret - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - qbf_skizzo_coret::qbf_skizzo_coret(): qbf_bdd_certificatet() { @@ -58,51 +35,15 @@ qbf_skizzo_coret::qbf_skizzo_coret(): qbf_tmp_file="sKizzo.qdimacs"; } -/*******************************************************************\ - -Function: qbf_skizzo_coret::~qbf_skizzo_coret - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - qbf_skizzo_coret::~qbf_skizzo_coret() { } -/*******************************************************************\ - -Function: qbf_skizzo_coret::solver_text - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const std::string qbf_skizzo_coret::solver_text() { return "Skizzo/Core"; } -/*******************************************************************\ - -Function: qbf_skizzo_coret::prop_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - propt::resultt qbf_skizzo_coret::prop_solve() { // sKizzo crashes on empty instances @@ -189,52 +130,16 @@ propt::resultt qbf_skizzo_coret::prop_solve() } } -/*******************************************************************\ - -Function: qbf_skizzo_coret::is_in_core - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool qbf_skizzo_coret::is_in_core(literalt l) const { throw "nyi"; } -/*******************************************************************\ - -Function: qbf_skizzo_coret::m_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - qdimacs_coret::modeltypet qbf_skizzo_coret::m_get(literalt a) const { throw "nyi"; } -/*******************************************************************\ - -Function: qbf_skizzo_coret::get_certificate - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool qbf_skizzo_coret::get_certificate(void) { std::string result_tmp_file="ozziKs.out"; diff --git a/src/solvers/qbf/qbf_skizzo_core.h b/src/solvers/qbf/qbf_skizzo_core.h index 6ffa06c9c84..28a42d5f5d6 100644 --- a/src/solvers/qbf/qbf_skizzo_core.h +++ b/src/solvers/qbf/qbf_skizzo_core.h @@ -6,6 +6,7 @@ Author: CM Wintersteiger \*******************************************************************/ + #ifndef CPROVER_SOLVERS_QBF_QBF_SKIZZO_CORE_H #define CPROVER_SOLVERS_QBF_QBF_SKIZZO_CORE_H diff --git a/src/solvers/qbf/qbf_squolem.cpp b/src/solvers/qbf/qbf_squolem.cpp index a869603a737..6724a3f189e 100644 --- a/src/solvers/qbf/qbf_squolem.cpp +++ b/src/solvers/qbf/qbf_squolem.cpp @@ -7,88 +7,31 @@ Author: CM Wintersteiger \*******************************************************************/ -#include "qbf_squolem.h" - -/*******************************************************************\ - -Function: qbf_squolemt::qbf_squolemt - - Inputs: +/// \file +/// Squolem Backend - Outputs: - - Purpose: - -\*******************************************************************/ +#include "qbf_squolem.h" qbf_squolemt::qbf_squolemt(): early_decision(false) { } -/*******************************************************************\ - -Function: qbf_squolemt::~qbf_squolemt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - qbf_squolemt::~qbf_squolemt() { squolem.reset(); } -/*******************************************************************\ - -Function: qbf_squolemt::l_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - tvt qbf_squolemt::l_get(literalt a) const { assert(false); } -/*******************************************************************\ - -Function: qbf_squolemt::solver_text - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const std::string qbf_squolemt::solver_text() { return "Squolem"; } -/*******************************************************************\ - -Function: qbf_squolemt::prop_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - propt::resultt qbf_squolemt::prop_solve() { { @@ -126,18 +69,6 @@ propt::resultt qbf_squolemt::prop_solve() return P_ERROR; } -/*******************************************************************\ - -Function: qbf_squolemt::lcnf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void qbf_squolemt::lcnf(const bvt &bv) { if(early_decision) @@ -167,18 +98,6 @@ void qbf_squolemt::lcnf(const bvt &bv) early_decision=true; } -/*******************************************************************\ - -Function: qbf_squolemt::add_quantifier - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void qbf_squolemt::add_quantifier(const quantifiert &quantifier) { squolem.quantifyVariableInner( @@ -188,36 +107,12 @@ void qbf_squolemt::add_quantifier(const quantifiert &quantifier) qdimacs_cnft::add_quantifier(quantifier); // necessary? } -/*******************************************************************\ - -Function: qbf_squolemt::set_no_variables - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void qbf_squolemt::set_no_variables(unsigned no) { squolem.setLastVariable(no+1); cnft::set_no_variables(no); } -/*******************************************************************\ - -Function: qbf_squolemt::set_quantifier - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void qbf_squolemt::set_quantifier( const quantifiert::typet type, const literalt l) diff --git a/src/solvers/qbf/qbf_squolem.h b/src/solvers/qbf/qbf_squolem.h index 1780528fb32..7210436fd4c 100644 --- a/src/solvers/qbf/qbf_squolem.h +++ b/src/solvers/qbf/qbf_squolem.h @@ -6,6 +6,9 @@ Author: CM Wintersteiger \*******************************************************************/ +/// \file +/// Squolem Backend + #ifndef CPROVER_SOLVERS_QBF_QBF_SQUOLEM_H #define CPROVER_SOLVERS_QBF_QBF_SQUOLEM_H diff --git a/src/solvers/qbf/qbf_squolem_core.cpp b/src/solvers/qbf/qbf_squolem_core.cpp index 00229cd8fee..f927117b22e 100644 --- a/src/solvers/qbf/qbf_squolem_core.cpp +++ b/src/solvers/qbf/qbf_squolem_core.cpp @@ -6,44 +6,23 @@ Author: CM Wintersteiger \*******************************************************************/ +/// \file +/// Squolem Backend (with proofs) + #include #include #include -#include // uint type for indices +#include // uint type for indices #include "qbf_squolem_core.h" -/*******************************************************************\ - -Function: qbf_squolem_coret::qbf_squolem_coret - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - qbf_squolem_coret::qbf_squolem_coret() : squolem(NULL) { setup(); } -/*******************************************************************\ - -Function: qbf_squolem_coret::setup - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void qbf_squolem_coret::setup(void) { quantifiers.clear(); @@ -65,18 +44,6 @@ void qbf_squolem_coret::setup(void) // squolem->options.set_predictOnLiteralBound(true); } -/*******************************************************************\ - -Function: qbf_squolem_coret::reset - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void qbf_squolem_coret::reset(void) { squolem->reset(); @@ -85,18 +52,6 @@ void qbf_squolem_coret::reset(void) setup(); } -/*******************************************************************\ - -Function: qbf_squolem_coret::~qbf_squolem_coret - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - qbf_squolem_coret::~qbf_squolem_coret() { squolem->reset(); @@ -104,18 +59,6 @@ qbf_squolem_coret::~qbf_squolem_coret() squolem=NULL; } -/*******************************************************************\ - -Function: qbf_squolem_coret::l_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - tvt qbf_squolem_coret::l_get(literalt a) const { if(a.is_true()) @@ -131,35 +74,11 @@ tvt qbf_squolem_coret::l_get(literalt a) const return tvt(tvt::tv_enumt::TV_UNKNOWN); } -/*******************************************************************\ - -Function: qbf_squolem_coret::solver_text - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const std::string qbf_squolem_coret::solver_text() { return "Squolem (Certifying)"; } -/*******************************************************************\ - -Function: qbf_squolem_coret::prop_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - propt::resultt qbf_squolem_coret::prop_solve() { { @@ -187,35 +106,11 @@ propt::resultt qbf_squolem_coret::prop_solve() return P_ERROR; } -/*******************************************************************\ - -Function: qbf_squolem_coret::is_in_core - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool qbf_squolem_coret::is_in_core(literalt l) const { return squolem->inCore(l.var_no()); } -/*******************************************************************\ - -Function: qbf_squolem_coret::m_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - qbf_squolem_coret::modeltypet qbf_squolem_coret::m_get(literalt a) const { if(squolem->modelIsTrue(a.var_no())) @@ -228,18 +123,6 @@ qbf_squolem_coret::modeltypet qbf_squolem_coret::m_get(literalt a) const return M_DONTCARE; } -/*******************************************************************\ - -Function: qbf_squolem_coret::lcnf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void qbf_squolem_coret::lcnf(const bvt &bv) { if(early_decision) @@ -269,18 +152,6 @@ void qbf_squolem_coret::lcnf(const bvt &bv) early_decision=true; } -/*******************************************************************\ - -Function: qbf_squolem_coret::add_quantifier - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void qbf_squolem_coret::add_quantifier(const quantifiert &quantifier) { squolem->quantifyVariableInner( @@ -290,36 +161,12 @@ void qbf_squolem_coret::add_quantifier(const quantifiert &quantifier) qdimacs_cnft::add_quantifier(quantifier); // necessary? } -/*******************************************************************\ - -Function: qbf_squolem_coret::set_no_variables - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void qbf_squolem_coret::set_no_variables(unsigned no) { squolem->setLastVariable(no+1); cnft::set_no_variables(no); } -/*******************************************************************\ - -Function: qbf_squolem_coret::set_quantifier - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void qbf_squolem_coret::set_quantifier( const quantifiert::typet type, const literalt l) @@ -328,52 +175,16 @@ void qbf_squolem_coret::set_quantifier( squolem->requantifyVariable(l.var_no(), type==quantifiert::UNIVERSAL); } -/*******************************************************************\ - -Function: qbf_squolem_coret::set_debug_filename - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void qbf_squolem_coret::set_debug_filename(const std::string &str) { squolem->options.set_debugFilename(str.c_str()); } -/*******************************************************************\ - -Function: qbf_squolem_coret::write_qdimacs_cnf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void qbf_squolem_coret::write_qdimacs_cnf(std::ostream &out) { squolem->saveQCNF(out); } -/*******************************************************************\ - -Function: qbf_squolem_coret::f_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const exprt qbf_squolem_coret::f_get(literalt l) { if(squolem->isUniversal(l.var_no())) @@ -403,7 +214,7 @@ const exprt qbf_squolem_coret::f_get(literalt l) if(it!=function_cache.end()) { #if 0 - std::cout << "CACHE HIT for " << l.dimacs() << std::endl; + std::cout << "CACHE HIT for " << l.dimacs() << '\n'; #endif if(l.sign()) @@ -435,18 +246,6 @@ const exprt qbf_squolem_coret::f_get(literalt l) } } -/*******************************************************************\ - -Function: qbf_squolem_coret::f_get_cnf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const exprt qbf_squolem_coret::f_get_cnf(WitnessStack *wsp) { Clause *p=wsp->negWits; @@ -478,7 +277,7 @@ const exprt qbf_squolem_coret::f_get_cnf(WitnessStack *wsp) } #if 0 - std::cout << "CLAUSE: " << clause << std::endl; + std::cout << "CLAUSE: " << clause << '\n'; #endif operands.push_back(clause); @@ -489,18 +288,6 @@ const exprt qbf_squolem_coret::f_get_cnf(WitnessStack *wsp) return and_exprt(operands); } -/*******************************************************************\ - -Function: qbf_squolem_coret::f_get_dnf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const exprt qbf_squolem_coret::f_get_dnf(WitnessStack *wsp) { Clause *p=wsp->posWits; @@ -534,7 +321,7 @@ const exprt qbf_squolem_coret::f_get_dnf(WitnessStack *wsp) } #if 0 - std::cout << "CUBE: " << cube << std::endl; + std::cout << "CUBE: " << cube << '\n'; #endif operands.push_back(cube); diff --git a/src/solvers/qbf/qbf_squolem_core.h b/src/solvers/qbf/qbf_squolem_core.h index 3c6e96252b4..f00e00a79ac 100644 --- a/src/solvers/qbf/qbf_squolem_core.h +++ b/src/solvers/qbf/qbf_squolem_core.h @@ -6,6 +6,9 @@ Author: CM Wintersteiger \*******************************************************************/ +/// \file +/// Squolem Backend (with Proofs) + #ifndef CPROVER_SOLVERS_QBF_QBF_SQUOLEM_CORE_H #define CPROVER_SOLVERS_QBF_QBF_SQUOLEM_CORE_H diff --git a/src/solvers/qbf/qdimacs_cnf.cpp b/src/solvers/qbf/qdimacs_cnf.cpp index 41e5484c369..e0333c569cb 100644 --- a/src/solvers/qbf/qdimacs_cnf.cpp +++ b/src/solvers/qbf/qdimacs_cnf.cpp @@ -6,23 +6,12 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include "qdimacs_cnf.h" -/*******************************************************************\ - -Function: qdimacs_cnft::write_qdimacs_cnf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void qdimacs_cnft::write_qdimacs_cnf(std::ostream &out) { write_problem_line(out); @@ -30,18 +19,6 @@ void qdimacs_cnft::write_qdimacs_cnf(std::ostream &out) write_clauses(out); } -/*******************************************************************\ - -Function: qdimacs_cnft::write_prefix - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void qdimacs_cnft::write_prefix(std::ostream &out) const { std::vector quantified; @@ -74,7 +51,7 @@ void qdimacs_cnft::write_prefix(std::ostream &out) const assert(false); } - out << " " << quantifier.var_no << " 0" << std::endl; + out << " " << quantifier.var_no << " 0\n"; } // variables that are not quantified @@ -82,38 +59,14 @@ void qdimacs_cnft::write_prefix(std::ostream &out) const for(std::size_t i=1; i #include #include "qdimacs_core.h" -/*******************************************************************\ - -Function: qdimacs_coret::simplify_extractbits - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void qdimacs_coret::simplify_extractbits(exprt &expr) const { if(expr.id()==ID_and) @@ -75,7 +64,7 @@ void qdimacs_coret::simplify_extractbits(exprt &expr) const value_string[value.to_ulong()]='1'; #if 0 - std::cout << "[" << value << "]=1" << std::endl; + std::cout << "[" << value << "]=1\n"; #endif continue; @@ -100,7 +89,7 @@ void qdimacs_coret::simplify_extractbits(exprt &expr) const new_operands.push_back(equality_exprt(it->first, new_value)); #if 0 - std::cout << "FINAL: " << value_string << std::endl; + std::cout << "FINAL: " << value_string << '\n'; #endif expr.operands()=new_operands; diff --git a/src/solvers/qbf/qdimacs_core.h b/src/solvers/qbf/qdimacs_core.h index fd1684b2ac3..5cb144585f2 100644 --- a/src/solvers/qbf/qdimacs_core.h +++ b/src/solvers/qbf/qdimacs_core.h @@ -6,6 +6,7 @@ Author: CM Wintersteiger \*******************************************************************/ + #ifndef CPROVER_SOLVERS_QBF_QDIMACS_CORE_H #define CPROVER_SOLVERS_QBF_QDIMACS_CORE_H diff --git a/src/solvers/refinement/bv_refinement.h b/src/solvers/refinement/bv_refinement.h index cc96bfccf45..cbfef19d3a8 100644 --- a/src/solvers/refinement/bv_refinement.h +++ b/src/solvers/refinement/bv_refinement.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Abstraction Refinement Loop + #ifndef CPROVER_SOLVERS_REFINEMENT_BV_REFINEMENT_H #define CPROVER_SOLVERS_REFINEMENT_BV_REFINEMENT_H diff --git a/src/solvers/refinement/bv_refinement_loop.cpp b/src/solvers/refinement/bv_refinement_loop.cpp index 3d39c16ac80..cf21409ee8b 100644 --- a/src/solvers/refinement/bv_refinement_loop.cpp +++ b/src/solvers/refinement/bv_refinement_loop.cpp @@ -6,24 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include "bv_refinement.h" -/*******************************************************************\ - -Function: bv_refinementt::bv_refinementt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bv_refinementt::bv_refinementt( const namespacet &_ns, propt &_prop): bv_pointerst(_ns, _prop), @@ -37,34 +26,10 @@ bv_refinementt::bv_refinementt( assert(prop.has_is_in_conflict()); } -/*******************************************************************\ - -Function: bv_refinementt::~bv_refinementt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bv_refinementt::~bv_refinementt() { } -/*******************************************************************\ - -Function: bv_refinementt::dec_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - decision_proceduret::resultt bv_refinementt::dec_solve() { // do the usual post-processing @@ -125,18 +90,6 @@ decision_proceduret::resultt bv_refinementt::dec_solve() } } -/*******************************************************************\ - -Function: bv_refinementt::prop_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - decision_proceduret::resultt bv_refinementt::prop_solve() { // this puts the underapproximations into effect @@ -167,18 +120,6 @@ decision_proceduret::resultt bv_refinementt::prop_solve() } } -/*******************************************************************\ - -Function: bv_refinementt::check_SAT - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bv_refinementt::check_SAT() { progress=false; @@ -192,18 +133,6 @@ void bv_refinementt::check_SAT() check_SAT(*a_it); } -/*******************************************************************\ - -Function: bv_refinementt::check_UNSAT - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bv_refinementt::check_UNSAT() { progress=false; @@ -215,18 +144,6 @@ void bv_refinementt::check_UNSAT() check_UNSAT(*a_it); } -/*******************************************************************\ - -Function: bv_refinementt::set_to - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bv_refinementt::set_to(const exprt &expr, bool value) { #if 0 @@ -239,24 +156,12 @@ void bv_refinementt::set_to(const exprt &expr, bool value) if(expr.id()=="=" && expr.operands().size()==2) forall_operands(it, expr.op1()) std::cout << " " << it->id() << "@" << it->type().id(); - std::cout << std::endl; + std::cout << '\n'; #else SUB::set_to(expr, value); #endif } -/*******************************************************************\ - -Function: bv_refinementt::set_assumptions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bv_refinementt::set_assumptions(const bvt &_assumptions) { parent_assumptions=_assumptions; diff --git a/src/solvers/refinement/refine_arithmetic.cpp b/src/solvers/refinement/refine_arithmetic.cpp index 1f08874abfa..70faf0e600d 100644 --- a/src/solvers/refinement/refine_arithmetic.cpp +++ b/src/solvers/refinement/refine_arithmetic.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include @@ -21,18 +22,6 @@ Author: Daniel Kroening, kroening@kroening.com #define MAX_INTEGER_UNDERAPPROX 3 #define MAX_FLOAT_UNDERAPPROX 10 -/*******************************************************************\ - -Function: bv_refinementt::approximationt::add_over_assumption - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bv_refinementt::approximationt::add_over_assumption(literalt l) { // if it's a constant already, give up @@ -40,18 +29,6 @@ void bv_refinementt::approximationt::add_over_assumption(literalt l) over_assumptions.push_back(l); } -/*******************************************************************\ - -Function: bv_refinementt::approximationt::add_under_assumption - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bv_refinementt::approximationt::add_under_assumption(literalt l) { // if it's a constant already, give up @@ -59,18 +36,6 @@ void bv_refinementt::approximationt::add_under_assumption(literalt l) under_assumptions.push_back(l); } -/*******************************************************************\ - -Function: bv_refinementt::convert_floatbv_op - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_refinementt::convert_floatbv_op(const exprt &expr) { if(!do_arithmetic_refinement) @@ -85,18 +50,6 @@ bvt bv_refinementt::convert_floatbv_op(const exprt &expr) return bv; } -/*******************************************************************\ - -Function: bv_refinementt::convert_mult - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_refinementt::convert_mult(const exprt &expr) { if(!do_arithmetic_refinement || expr.type().id()==ID_fixedbv) @@ -145,18 +98,6 @@ bvt bv_refinementt::convert_mult(const exprt &expr) return bv; } -/*******************************************************************\ - -Function: bv_refinementt::convert_div - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_refinementt::convert_div(const div_exprt &expr) { if(!do_arithmetic_refinement || expr.type().id()==ID_fixedbv) @@ -175,18 +116,6 @@ bvt bv_refinementt::convert_div(const div_exprt &expr) return bv; } -/*******************************************************************\ - -Function: bv_refinementt::convert_mod - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bvt bv_refinementt::convert_mod(const mod_exprt &expr) { if(!do_arithmetic_refinement || expr.type().id()==ID_fixedbv) @@ -205,18 +134,6 @@ bvt bv_refinementt::convert_mod(const mod_exprt &expr) return bv; } -/*******************************************************************\ - -Function: bv_refinementt::get_values - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bv_refinementt::get_values(approximationt &a) { std::size_t o=a.expr.operands().size(); @@ -240,19 +157,8 @@ void bv_refinementt::get_values(approximationt &a) a.result_value=get_value(a.result_bv); } -/*******************************************************************\ - -Function: bv_refinementt::check_SAT - - Inputs: - - Outputs: - - Purpose: inspect if satisfying assignment extends to original - formula, otherwise refine overapproximation - -\*******************************************************************/ - +/// inspect if satisfying assignment extends to original formula, otherwise +/// refine overapproximation void bv_refinementt::check_SAT(approximationt &a) { // get values @@ -458,19 +364,8 @@ void bv_refinementt::check_SAT(approximationt &a) a.over_state++; } -/*******************************************************************\ - -Function: bv_refinementt::check_UNSAT - - Inputs: - - Outputs: - - Purpose: inspect if proof holds on original formula, - otherwise refine underapproximation - -\*******************************************************************/ - +/// inspect if proof holds on original formula, otherwise refine +/// underapproximation void bv_refinementt::check_UNSAT(approximationt &a) { // part of the conflict? @@ -558,18 +453,7 @@ void bv_refinementt::check_UNSAT(approximationt &a) progress=true; } -/*******************************************************************\ - -Function: bv_refinementt::is_in_conflict - - Inputs: - - Outputs: - - Purpose: check if an under-approximation is part of the conflict - -\*******************************************************************/ - +/// check if an under-approximation is part of the conflict bool bv_refinementt::is_in_conflict(approximationt &a) { for(std::size_t i=0; i #include @@ -17,18 +18,7 @@ Author: Daniel Kroening, kroening@kroening.com #include "bv_refinement.h" #include -/*******************************************************************\ - -Function: bv_refinementt::post_process_arrays - - Inputs: - - Outputs: - - Purpose: generate array constraints - -\*******************************************************************/ - +/// generate array constraints void bv_refinementt::post_process_arrays() { collect_indices(); @@ -43,18 +33,7 @@ void bv_refinementt::post_process_arrays() freeze_lazy_constraints(); } -/*******************************************************************\ - -Function: bv_refinementt::arrays_overapproximated - - Inputs: - - Outputs: - - Purpose: check whether counterexample is spurious - -\*******************************************************************/ - +/// check whether counterexample is spurious void bv_refinementt::arrays_overapproximated() { if(!do_array_refinement) @@ -125,18 +104,7 @@ void bv_refinementt::arrays_overapproximated() } -/*******************************************************************\ - -Function: bv_refinementt::freeze_lazy_constraints - - Inputs: - - Outputs: - - Purpose: freeze symbols for incremental solving - -\*******************************************************************/ - +/// freeze symbols for incremental solving void bv_refinementt::freeze_lazy_constraints() { if(!lazy_arrays) diff --git a/src/solvers/refinement/string_constraint.h b/src/solvers/refinement/string_constraint.h index 1bb460349b7..c83d63cc69a 100644 --- a/src/solvers/refinement/string_constraint.h +++ b/src/solvers/refinement/string_constraint.h @@ -10,6 +10,13 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com \*******************************************************************/ +/// \file +/// Defines string constraints. These are formulas talking about strings. We +/// implemented two forms of constraints: `string_constraintt` are formulas +/// of the form $\forall univ_var \in [lb,ub[. prem => body$, and +/// not_contains_constraintt of the form: $\forall x in [lb,ub[. p(x) => +/// \exists y in [lb,ub[. s1[x+y] != s2[y]$. + #ifndef CPROVER_SOLVERS_REFINEMENT_STRING_CONSTRAINT_H #define CPROVER_SOLVERS_REFINEMENT_STRING_CONSTRAINT_H diff --git a/src/solvers/refinement/string_constraint_generator.h b/src/solvers/refinement/string_constraint_generator.h index 94234b810de..533e41a4212 100644 --- a/src/solvers/refinement/string_constraint_generator.h +++ b/src/solvers/refinement/string_constraint_generator.h @@ -10,6 +10,13 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com \*******************************************************************/ +/// \file +/// Generates string constraints to link results from string functions with +/// their arguments. This is inspired by the PASS paper at HVC'13: "PASS: +/// String Solving with Parameterized Array and Interval Automaton" by Guodong +/// Li and Indradeep Ghosh, which gives examples of constraints for several +/// functions. + #ifndef CPROVER_SOLVERS_REFINEMENT_STRING_CONSTRAINT_GENERATOR_H #define CPROVER_SOLVERS_REFINEMENT_STRING_CONSTRAINT_GENERATOR_H diff --git a/src/solvers/refinement/string_constraint_generator_code_points.cpp b/src/solvers/refinement/string_constraint_generator_code_points.cpp index 16763dfc97c..ad44469d51e 100644 --- a/src/solvers/refinement/string_constraint_generator_code_points.cpp +++ b/src/solvers/refinement/string_constraint_generator_code_points.cpp @@ -7,6 +7,9 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com \*******************************************************************/ +/// \file +/// Generates string constraints for Java functions dealing with code points + #include /******************************************************************* \ @@ -70,21 +73,12 @@ string_exprt string_constraint_generatort::add_axioms_for_code_point( return res; } -/*******************************************************************\ - -Function: string_constraint_generatort::is_high_surrogate - - Inputs: a character expression - - Outputs: a Boolean expression - - Purpose: the output is true when the character is a high surrogate for - UTF-16 encoding, see https://en.wikipedia.org/wiki/UTF-16 for - more explenation about the encoding; - this is true when the character is in the range 0xD800..0xDBFF - -\*******************************************************************/ - +/// the output is true when the character is a high surrogate for UTF-16 +/// encoding, see https://en.wikipedia.org/wiki/UTF-16 for more explenation +/// about the encoding; this is true when the character is in the range +/// 0xD800..0xDBFF +/// \par parameters: a character expression +/// \return a Boolean expression exprt string_constraint_generatort::is_high_surrogate(const exprt &chr) const { return and_exprt( @@ -92,21 +86,12 @@ exprt string_constraint_generatort::is_high_surrogate(const exprt &chr) const binary_relation_exprt(chr, ID_le, constant_char(0xDBFF, chr.type()))); } -/*******************************************************************\ - -Function: string_constraint_generatort::is_low_surrogate - - Inputs: a character expression - - Outputs: a Boolean expression - - Purpose: the output is true when the character is a low surrogate for - UTF-16 encoding, see https://en.wikipedia.org/wiki/UTF-16 for - more explenation about the encoding; - this is true when the character is in the range 0xDC00..0xDFFF - -\*******************************************************************/ - +/// the output is true when the character is a low surrogate for UTF-16 +/// encoding, see https://en.wikipedia.org/wiki/UTF-16 for more explenation +/// about the encoding; this is true when the character is in the range +/// 0xDC00..0xDFFF +/// \par parameters: a character expression +/// \return a Boolean expression exprt string_constraint_generatort::is_low_surrogate(const exprt &chr) const { return and_exprt( @@ -114,24 +99,14 @@ exprt string_constraint_generatort::is_low_surrogate(const exprt &chr) const binary_relation_exprt(chr, ID_le, constant_char(0xDFFF, chr.type()))); } -/*******************************************************************\ - -Function: string_constraint_generatort::pair_value - - Inputs: two character expressions and a return type - char1 and char2 should be of type return_type - - Outputs: an integer expression of type return_type - - Purpose: the output corresponds to the unicode character given by the - pair of characters of inputs assuming it has been encoded in - UTF-16, see https://en.wikipedia.org/wiki/UTF-16 for - more explenation about the encoding; - the operation we perform is: - pair_value=0x10000+(((char1%0x0800)*0x0400)+char2%0x0400) - -\*******************************************************************/ - +/// the output corresponds to the unicode character given by the pair of +/// characters of inputs assuming it has been encoded in UTF-16, see +/// https://en.wikipedia.org/wiki/UTF-16 for more explenation about the +/// encoding; the operation we perform is: +/// pair_value=0x10000+(((char1%0x0800)*0x0400)+char2%0x0400) +/// \par parameters: two character expressions and a return type +/// char1 and char2 should be of type return_type +/// \return an integer expression of type return_type exprt pair_value(exprt char1, exprt char2, typet return_type) { exprt hex010000=from_integer(0x010000, return_type); @@ -143,18 +118,10 @@ exprt pair_value(exprt char1, exprt char2, typet return_type) return pair_value; } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_code_point_at - - Inputs: function application with two arguments: a string and an index - - Outputs: a integer expression corresponding to a code point - - Purpose: add axioms corresponding to the String.codePointAt java function - -\*******************************************************************/ - +/// add axioms corresponding to the String.codePointAt java function +/// \par parameters: function application with two arguments: a string and an +/// index +/// \return a integer expression corresponding to a code point exprt string_constraint_generatort::add_axioms_for_code_point_at( const function_application_exprt &f) { @@ -180,18 +147,10 @@ exprt string_constraint_generatort::add_axioms_for_code_point_at( return result; } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_code_point_before - - Inputs: function application with two arguments: a string and an index - - Outputs: a integer expression corresponding to a code point - - Purpose: add axioms corresponding to the String.codePointBefore java function - -\*******************************************************************/ - +/// add axioms corresponding to the String.codePointBefore java function +/// \par parameters: function application with two arguments: a string and an +/// index +/// \return a integer expression corresponding to a code point exprt string_constraint_generatort::add_axioms_for_code_point_before( const function_application_exprt &f) { @@ -219,19 +178,11 @@ exprt string_constraint_generatort::add_axioms_for_code_point_before( return result; } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_code_point_count - - Inputs: function application with three arguments: a string and two indexes - - Outputs: an integer expression - - Purpose: add axioms giving approximate bounds on the result of the - String.codePointCount java function - -\*******************************************************************/ - +/// add axioms giving approximate bounds on the result of the +/// String.codePointCount java function +/// \par parameters: function application with three arguments: a string and two +/// indexes +/// \return an integer expression exprt string_constraint_generatort::add_axioms_for_code_point_count( const function_application_exprt &f) { @@ -248,21 +199,12 @@ exprt string_constraint_generatort::add_axioms_for_code_point_count( return result; } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_offset_by_code_point - - Inputs: function application with three arguments: a string and two indexes - - Outputs: a new string expression - - Purpose: add axioms giving approximate bounds on the result of the - String.offsetByCodePointCount java function. - We approximate the result by saying the result is - between index + offset and index + 2 * offset - -\*******************************************************************/ - +/// add axioms giving approximate bounds on the result of the +/// String.offsetByCodePointCount java function. We approximate the result by +/// saying the result is between index + offset and index + 2 * offset +/// \par parameters: function application with three arguments: a string and two +/// indexes +/// \return a new string expression exprt string_constraint_generatort::add_axioms_for_offset_by_code_point( const function_application_exprt &f) { diff --git a/src/solvers/refinement/string_constraint_generator_comparison.cpp b/src/solvers/refinement/string_constraint_generator_comparison.cpp index a51e2abe3cd..f926147d1d4 100644 --- a/src/solvers/refinement/string_constraint_generator_comparison.cpp +++ b/src/solvers/refinement/string_constraint_generator_comparison.cpp @@ -7,23 +7,18 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com \*******************************************************************/ -#include - -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_equals - - Inputs: function application with two string arguments - - Outputs: a expression of Boolean type - - Purpose: add axioms stating that the result is true exactly when the strings - represented by the arguments are equal. - the variable ending in `witness_unequal` is -1 if the length differs - or an index at which the strings are different +/// \file +/// Generates string constraints for function comparing strings, such as: +/// equals, equalsIgnoreCase, compareTo, hashCode, intern -\*******************************************************************/ +#include +/// add axioms stating that the result is true exactly when the strings +/// represented by the arguments are equal. the variable ending in +/// `witness_unequal` is -1 if the length differs or an index at which the +/// strings are different +/// \par parameters: function application with two string arguments +/// \return a expression of Boolean type exprt string_constraint_generatort::add_axioms_for_equals( const function_application_exprt &f) { @@ -65,20 +60,12 @@ exprt string_constraint_generatort::add_axioms_for_equals( return tc_eq; } -/*******************************************************************\ - -Function: string_constraint_generatort::character_equals_ignore_case - - Inputs: two character expressions and constant character expressions - representing 'a', 'A' and 'Z' - - Outputs: a expression of Boolean type - - Purpose: returns an expression which is true when the two given - characters are equal when ignoring case for ASCII - -\*******************************************************************/ - +/// returns an expression which is true when the two given characters are equal +/// when ignoring case for ASCII +/// \par parameters: two character expressions and constant character +/// expressions +/// representing 'a', 'A' and 'Z' +/// \return a expression of Boolean type exprt string_constraint_generatort::character_equals_ignore_case( exprt char1, exprt char2, exprt char_a, exprt char_A, exprt char_Z) { @@ -105,18 +92,9 @@ exprt string_constraint_generatort::character_equals_ignore_case( return or_exprt(or_exprt(p1, p2), p3); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_equals_ignore_case - - Inputs: function application with two string arguments - - Outputs: a Boolean expression - - Purpose: add axioms corresponding to the String.equalsIgnoreCase java function - -\*******************************************************************/ - +/// add axioms corresponding to the String.equalsIgnoreCase java function +/// \par parameters: function application with two string arguments +/// \return a Boolean expression exprt string_constraint_generatort::add_axioms_for_equals_ignore_case( const function_application_exprt &f) { @@ -166,19 +144,10 @@ exprt string_constraint_generatort::add_axioms_for_equals_ignore_case( return tc_eq; } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_hash_code - - Inputs: function application with a string argument - - Outputs: a integer expression corresponding to the hash code of the string - - Purpose: add axioms stating that if two strings are equal then their hash - codes are equals - -\*******************************************************************/ - +/// add axioms stating that if two strings are equal then their hash codes are +/// equals +/// \par parameters: function application with a string argument +/// \return a integer expression corresponding to the hash code of the string exprt string_constraint_generatort::add_axioms_for_hash_code( const function_application_exprt &f) { @@ -213,18 +182,9 @@ exprt string_constraint_generatort::add_axioms_for_hash_code( return hash; } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_compare_to - - Inputs: function application with two string arguments - - Outputs: a integer expression - - Purpose: add axioms corresponding to the String.compareTo java function - -\*******************************************************************/ - +/// add axioms corresponding to the String.compareTo java function +/// \par parameters: function application with two string arguments +/// \return a integer expression exprt string_constraint_generatort::add_axioms_for_compare_to( const function_application_exprt &f) { @@ -296,19 +256,10 @@ exprt string_constraint_generatort::add_axioms_for_compare_to( return res; } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_intern - - Inputs: function application with one string argument - - Outputs: a string expression - - Purpose: add axioms stating that the return value for two equal string - should be the same - -\*******************************************************************/ - +/// add axioms stating that the return value for two equal string should be the +/// same +/// \par parameters: function application with one string argument +/// \return a string expression symbol_exprt string_constraint_generatort::add_axioms_for_intern( const function_application_exprt &f) { diff --git a/src/solvers/refinement/string_constraint_generator_concat.cpp b/src/solvers/refinement/string_constraint_generator_concat.cpp index e6f360585bb..311427ec771 100644 --- a/src/solvers/refinement/string_constraint_generator_concat.cpp +++ b/src/solvers/refinement/string_constraint_generator_concat.cpp @@ -7,21 +7,16 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com \*******************************************************************/ -#include - -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_concat - - Inputs: two string expressions +/// \file +/// Generates string constraints for functions adding content add the end of +/// strings - Outputs: a new string expression - - Purpose: add axioms to say that the returned string expression is equal to - the concatenation of the two string expressions given as input - -\*******************************************************************/ +#include +/// add axioms to say that the returned string expression is equal to the +/// concatenation of the two string expressions given as input +/// \par parameters: two string expressions +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_concat( const string_exprt &s1, const string_exprt &s2) { @@ -53,20 +48,10 @@ string_exprt string_constraint_generatort::add_axioms_for_concat( return res; } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_concat - - Inputs: function application with two arguments which are strings - - Outputs: a new string expression - - Purpose: add axioms to say that the returned string expression is equal to - the concatenation of the two string arguments of - the function application - -\*******************************************************************/ - +/// add axioms to say that the returned string expression is equal to the +/// concatenation of the two string arguments of the function application +/// \par parameters: function application with two arguments which are strings +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_concat( const function_application_exprt &f) { @@ -79,18 +64,10 @@ string_exprt string_constraint_generatort::add_axioms_for_concat( return add_axioms_for_concat(s1, s2); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_concat_int - - Inputs: function application with two arguments: a string and an integer - - Outputs: a new string expression - - Purpose: add axioms corresponding to the StringBuilder.append(I) java function - -\*******************************************************************/ - +/// add axioms corresponding to the StringBuilder.append(I) java function +/// \par parameters: function application with two arguments: a string and an +/// integer +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_concat_int( const function_application_exprt &f) { @@ -101,19 +78,10 @@ string_exprt string_constraint_generatort::add_axioms_for_concat_int( return add_axioms_for_concat(s1, s2); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_long - - Inputs: function application with two arguments: a string and a - integer of type long - - Outputs: a new string expression - - Purpose: Add axioms corresponding to the StringBuilder.append(J) java function - -\*******************************************************************/ - +/// Add axioms corresponding to the StringBuilder.append(J) java function +/// \par parameters: function application with two arguments: a string and a +/// integer of type long +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_concat_long( const function_application_exprt &f) { @@ -123,18 +91,9 @@ string_exprt string_constraint_generatort::add_axioms_for_concat_long( return add_axioms_for_concat(s1, s2); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_concat_bool - - Inputs: function application two arguments: a string and a bool - - Outputs: a new string expression - - Purpose: add axioms corresponding to the StringBuilder.append(Z) java function - -\*******************************************************************/ - +/// add axioms corresponding to the StringBuilder.append(Z) java function +/// \par parameters: function application two arguments: a string and a bool +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_concat_bool( const function_application_exprt &f) { @@ -144,18 +103,10 @@ string_exprt string_constraint_generatort::add_axioms_for_concat_bool( return add_axioms_for_concat(s1, s2); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_concat_char - - Inputs: function application with two arguments: a string and a char - - Outputs: a new string expression - - Purpose: add axioms corresponding to the StringBuilder.append(C) java function - -\*******************************************************************/ - +/// add axioms corresponding to the StringBuilder.append(C) java function +/// \par parameters: function application with two arguments: a string and a +/// char +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_concat_char( const function_application_exprt &f) { @@ -165,18 +116,10 @@ string_exprt string_constraint_generatort::add_axioms_for_concat_char( return add_axioms_for_concat(s1, s2); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_concat_double - - Inputs: function application with two arguments: a string and a double - - Outputs: a new string expression - - Purpose: add axioms corresponding to the StringBuilder.append(D) java function - -\*******************************************************************/ - +/// add axioms corresponding to the StringBuilder.append(D) java function +/// \par parameters: function application with two arguments: a string and a +/// double +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_concat_double( const function_application_exprt &f) { @@ -187,18 +130,10 @@ string_exprt string_constraint_generatort::add_axioms_for_concat_double( return add_axioms_for_concat(s1, s2); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_concat_float - - Inputs: function application with two arguments: a string and a float - - Outputs: a new string expression - - Purpose: add axioms corresponding to the StringBuilder.append(F) java function - -\*******************************************************************/ - +/// add axioms corresponding to the StringBuilder.append(F) java function +/// \par parameters: function application with two arguments: a string and a +/// float +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_concat_float( const function_application_exprt &f) { @@ -209,19 +144,10 @@ string_exprt string_constraint_generatort::add_axioms_for_concat_float( return add_axioms_for_concat(s1, s2); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_concat_code_point - - Inputs: function application with two arguments: a string and a code point - - Outputs: a new string expression - - Purpose: Add axioms corresponding to the StringBuilder.appendCodePoint(I) - function - -\*******************************************************************/ - +/// Add axioms corresponding to the StringBuilder.appendCodePoint(I) function +/// \par parameters: function application with two arguments: a string and a +/// code point +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_concat_code_point( const function_application_exprt &f) { diff --git a/src/solvers/refinement/string_constraint_generator_constants.cpp b/src/solvers/refinement/string_constraint_generator_constants.cpp index b423b4adc0c..7225a0aad00 100644 --- a/src/solvers/refinement/string_constraint_generator_constants.cpp +++ b/src/solvers/refinement/string_constraint_generator_constants.cpp @@ -6,24 +6,18 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com \*******************************************************************/ +/// \file +/// Generates string constraints for constant strings + #include #include #include #include -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_constant - - Inputs: a string constant - - Outputs: a string expression - - Purpose: add axioms saying the returned string expression should be equal - to the string constant - -\*******************************************************************/ - +/// add axioms saying the returned string expression should be equal to the +/// string constant +/// \par parameters: a string constant +/// \return a string expression string_exprt string_constraint_generatort::add_axioms_for_constant( irep_idt sval, const refined_string_typet &ref_type) { @@ -54,18 +48,9 @@ string_exprt string_constraint_generatort::add_axioms_for_constant( return res; } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_empty_string - - Inputs: function application without argument - - Outputs: string expression - - Purpose: add axioms to say that the returned string expression is empty - -\*******************************************************************/ - +/// add axioms to say that the returned string expression is empty +/// \par parameters: function application without argument +/// \return string expression string_exprt string_constraint_generatort::add_axioms_for_empty_string( const function_application_exprt &f) { @@ -80,21 +65,11 @@ string_exprt string_constraint_generatort::add_axioms_for_empty_string( return res; } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_from_literal - - Inputs: - f - function application with an argument which is a string literal - that is a constant with a string value. - - Outputs: string expression - - Purpose: add axioms to say that the returned string expression is equal to - the string literal - -\*******************************************************************/ - +/// add axioms to say that the returned string expression is equal to the string +/// literal +/// \param f: function application with an argument which is a string literal +/// that is a constant with a string value. +/// \return string expression string_exprt string_constraint_generatort::add_axioms_from_literal( const function_application_exprt &f) { diff --git a/src/solvers/refinement/string_constraint_generator_indexof.cpp b/src/solvers/refinement/string_constraint_generator_indexof.cpp index 9386639e594..2e3e6424c36 100644 --- a/src/solvers/refinement/string_constraint_generator_indexof.cpp +++ b/src/solvers/refinement/string_constraint_generator_indexof.cpp @@ -7,25 +7,19 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com \*******************************************************************/ -#include - -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_index_of - - Inputs: - str - a string expression - c - an expression representing a character - from_index - an expression representing an index in the string - - Outputs: a integer expression - - Purpose: Add axioms stating that the returned value is the index within - str of the first occurence of c starting the search at from_index, - or -1 if no such character occurs at or after position from_index. +/// \file +/// Generates string constraints for the family of indexOf and lastIndexOf java +/// functions -\*******************************************************************/ +#include +/// Add axioms stating that the returned value is the index within str of the +/// first occurence of c starting the search at from_index, or -1 if no such +/// character occurs at or after position from_index. +/// \param str: a string expression +/// \param c: an expression representing a character +/// \param from_index: an expression representing an index in the string +/// \return a integer expression exprt string_constraint_generatort::add_axioms_for_index_of( const string_exprt &str, const exprt &c, const exprt &from_index) { @@ -73,25 +67,14 @@ exprt string_constraint_generatort::add_axioms_for_index_of( return index; } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_index_of_string - - Inputs: - haystack - a string expression - needle - a string expression - from_index - an expression representing an index in strings - - Outputs: an integer expression representing the first index of needle in - haystack after from_index, or -1 if there is none - - Purpose: Add axioms stating that the returned value is the index within - haystack of the first occurence of needle starting the search at - from_index, or -1 if needle does not occur at or after position - from_index. - -\*******************************************************************/ - +/// Add axioms stating that the returned value is the index within haystack of +/// the first occurence of needle starting the search at from_index, or -1 if +/// needle does not occur at or after position from_index. +/// \param haystack: a string expression +/// \param needle: a string expression +/// \param from_index: an expression representing an index in strings +/// \return an integer expression representing the first index of needle in +/// haystack after from_index, or -1 if there is none exprt string_constraint_generatort::add_axioms_for_index_of_string( const string_exprt &haystack, const string_exprt &needle, @@ -191,25 +174,15 @@ exprt string_constraint_generatort::add_axioms_for_index_of_string( return offset; } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_last_index_of_string - - Inputs: - haystack - a string expression - needle - a string expression - from_index - an expression representing an index in strings - - Outputs: an integer expression representing the last index of needle in - haystack before or at from_index, or -1 if there is none - - Purpose: Add axioms stating that the returned value is the index within - haystack of the last occurence of needle starting the search - backward at from_index (ie the index is smaller or equal to - from_index), or -1 if needle does not occur before from_index. - -\*******************************************************************/ - +/// Add axioms stating that the returned value is the index within haystack of +/// the last occurence of needle starting the search backward at from_index (ie +/// the index is smaller or equal to from_index), or -1 if needle does not occur +/// before from_index. +/// \param haystack: a string expression +/// \param needle: a string expression +/// \param from_index: an expression representing an index in strings +/// \return an integer expression representing the last index of needle in +/// haystack before or at from_index, or -1 if there is none exprt string_constraint_generatort::add_axioms_for_last_index_of_string( const string_exprt &haystack, const string_exprt &needle, @@ -312,20 +285,10 @@ exprt string_constraint_generatort::add_axioms_for_last_index_of_string( return offset; } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_index_of - - Inputs: function application with 2 or 3 arguments - - Outputs: a integer expression - - Purpose: add axioms corresponding to the String.indexOf:(C), - String.indexOf:(CI), String.indexOf:(String), and - String.indexOf:(String,I) java functions - -\*******************************************************************/ - +/// add axioms corresponding to the String.indexOf:(C), String.indexOf:(CI), +/// String.indexOf:(String), and String.indexOf:(String,I) java functions +/// \par parameters: function application with 2 or 3 arguments +/// \return a integer expression exprt string_constraint_generatort::add_axioms_for_index_of( const function_application_exprt &f) { @@ -356,25 +319,14 @@ exprt string_constraint_generatort::add_axioms_for_index_of( } } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_last_index_of - - Inputs: - str - a string expression - c - an expression representing a character - from_index - an expression representing an index in the string - - Outputs: an integer expression representing the last index of c in - str before or at from_index, or -1 if there is none - - Purpose: Add axioms stating that the returned value is the index within - str of the last occurence of c starting the search backward at - from_index, or -1 if no such character occurs at or before - position from_index. - -\*******************************************************************/ - +/// Add axioms stating that the returned value is the index within str of the +/// last occurence of c starting the search backward at from_index, or -1 if no +/// such character occurs at or before position from_index. +/// \param str: a string expression +/// \param c: an expression representing a character +/// \param from_index: an expression representing an index in the string +/// \return an integer expression representing the last index of c in str before +/// or at from_index, or -1 if there is none exprt string_constraint_generatort::add_axioms_for_last_index_of( const string_exprt &str, const exprt &c, const exprt &from_index) { @@ -428,20 +380,11 @@ exprt string_constraint_generatort::add_axioms_for_last_index_of( return index; } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_last_index_of - - Inputs: function application with 2 or 3 arguments - - Outputs: a integer expression - - Purpose: add axioms corresponding to the String.lastIndexOf:(C), - String.lastIndexOf:(CI), String.lastIndexOf:(String), and - String.lastIndexOf:(String,I) java functions - -\*******************************************************************/ - +/// add axioms corresponding to the String.lastIndexOf:(C), +/// String.lastIndexOf:(CI), String.lastIndexOf:(String), and +/// String.lastIndexOf:(String,I) java functions +/// \par parameters: function application with 2 or 3 arguments +/// \return a integer expression exprt string_constraint_generatort::add_axioms_for_last_index_of( const function_application_exprt &f) { diff --git a/src/solvers/refinement/string_constraint_generator_insert.cpp b/src/solvers/refinement/string_constraint_generator_insert.cpp index 7a63279699e..0fb39e8a658 100644 --- a/src/solvers/refinement/string_constraint_generator_insert.cpp +++ b/src/solvers/refinement/string_constraint_generator_insert.cpp @@ -6,21 +6,15 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com \*******************************************************************/ -#include - -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_insert - - Inputs: two string expression and an integer offset +/// \file +/// Generates string constraints for the family of insert Java functions - Outputs: a new string expression - - Purpose: add axioms stating that the result correspond to the first string - where we inserted the second one at possition offset - -\*******************************************************************/ +#include +/// add axioms stating that the result correspond to the first string where we +/// inserted the second one at possition offset +/// \par parameters: two string expression and an integer offset +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_insert( const string_exprt &s1, const string_exprt &s2, const exprt &offset) { @@ -32,21 +26,11 @@ string_exprt string_constraint_generatort::add_axioms_for_insert( return add_axioms_for_concat(concat1, suf); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_insert - - Inputs: function application with three arguments: two strings and an index - - Outputs: a new string expression - - Purpose: add axioms corresponding to the - StringBuilder.insert(int, CharSequence) - and StringBuilder.insert(int, CharSequence, int, int) - java functions - -\*******************************************************************/ - +/// add axioms corresponding to the StringBuilder.insert(int, CharSequence) and +/// StringBuilder.insert(int, CharSequence, int, int) java functions +/// \par parameters: function application with three arguments: two strings and +/// an index +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_insert( const function_application_exprt &f) { @@ -68,19 +52,11 @@ string_exprt string_constraint_generatort::add_axioms_for_insert( } } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_insert_int - - Inputs: function application with three arguments: a string, an integer - offset, and an integer - - Outputs: a new string expression - - Purpose: add axioms corresponding to the StringBuilder.insert(I) java function - -\*******************************************************************/ - +/// add axioms corresponding to the StringBuilder.insert(I) java function +/// \par parameters: function application with three arguments: a string, an +/// integer +/// offset, and an integer +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_insert_int( const function_application_exprt &f) { @@ -91,19 +67,11 @@ string_exprt string_constraint_generatort::add_axioms_for_insert_int( return add_axioms_for_insert(s1, s2, args(f, 3)[1]); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_insert_long - - Inputs: function application with three arguments: a string, an integer - offset and a long - - Outputs: a new string expression - - Purpose: add axioms corresponding to the StringBuilder.insert(J) java function - -\*******************************************************************/ - +/// add axioms corresponding to the StringBuilder.insert(J) java function +/// \par parameters: function application with three arguments: a string, an +/// integer +/// offset and a long +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_insert_long( const function_application_exprt &f) { @@ -113,19 +81,11 @@ string_exprt string_constraint_generatort::add_axioms_for_insert_long( return add_axioms_for_insert(s1, s2, args(f, 3)[1]); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_insert_bool - - Inputs: function application with three arguments: a string, an integer - offset, and a Boolean - - Outputs: a new string expression - - Purpose: add axioms corresponding to the StringBuilder.insert(Z) java function - -\*******************************************************************/ - +/// add axioms corresponding to the StringBuilder.insert(Z) java function +/// \par parameters: function application with three arguments: a string, an +/// integer +/// offset, and a Boolean +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_insert_bool( const function_application_exprt &f) { @@ -135,19 +95,11 @@ string_exprt string_constraint_generatort::add_axioms_for_insert_bool( return add_axioms_for_insert(s1, s2, args(f, 3)[1]); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_insert_char - - Inputs: function application with three arguments: a string, an integer - offset, and a character - - Outputs: a new string expression - - Purpose: add axioms corresponding to the StringBuilder.insert(C) java function - -\*******************************************************************/ - +/// add axioms corresponding to the StringBuilder.insert(C) java function +/// \par parameters: function application with three arguments: a string, an +/// integer +/// offset, and a character +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_insert_char( const function_application_exprt &f) { @@ -157,19 +109,11 @@ string_exprt string_constraint_generatort::add_axioms_for_insert_char( return add_axioms_for_insert(s1, s2, args(f, 3)[1]); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_insert_double - - Inputs: function application with three arguments: a string, an integer - offset, and a double - - Outputs: a new string expression - - Purpose: add axioms corresponding to the StringBuilder.insert(D) java function - -\*******************************************************************/ - +/// add axioms corresponding to the StringBuilder.insert(D) java function +/// \par parameters: function application with three arguments: a string, an +/// integer +/// offset, and a double +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_insert_double( const function_application_exprt &f) { @@ -179,19 +123,11 @@ string_exprt string_constraint_generatort::add_axioms_for_insert_double( return add_axioms_for_insert(s1, s2, args(f, 3)[1]); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_insert_float - - Inputs: function application with three arguments: a string, an integer - offset, and a float - - Outputs: a new string expression - - Purpose: add axioms corresponding to the StringBuilder.insert(F) java function - -\*******************************************************************/ - +/// add axioms corresponding to the StringBuilder.insert(F) java function +/// \par parameters: function application with three arguments: a string, an +/// integer +/// offset, and a float +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_insert_float( const function_application_exprt &f) { @@ -201,21 +137,13 @@ string_exprt string_constraint_generatort::add_axioms_for_insert_float( return add_axioms_for_insert(s1, s2, args(f, 3)[1]); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_insert_char_array - - Inputs: function application with 4 arguments plus two optional arguments: - a string, an offset index, a length, data array, an offset and a - count - - Outputs: a new string expression - - Purpose: add axioms corresponding to the StringBuilder.insert:(I[CII) - and StringBuilder.insert:(I[C) java functions - -\*******************************************************************/ - +/// add axioms corresponding to the StringBuilder.insert:(I[CII) and +/// StringBuilder.insert:(I[C) java functions +/// \par parameters: function application with 4 arguments plus two optional +/// arguments: +/// a string, an offset index, a length, data array, an offset and a +/// count +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_insert_char_array( const function_application_exprt &f) { diff --git a/src/solvers/refinement/string_constraint_generator_main.cpp b/src/solvers/refinement/string_constraint_generator_main.cpp index 796b0554696..b7d8ad878e3 100644 --- a/src/solvers/refinement/string_constraint_generator_main.cpp +++ b/src/solvers/refinement/string_constraint_generator_main.cpp @@ -10,6 +10,13 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com \*******************************************************************/ +/// \file +/// Generates string constraints to link results from string functions with +/// their arguments. This is inspired by the PASS paper at HVC'13: "PASS: +/// String Solving with Parameterized Array and Interval Automaton" by Guodong +/// Li and Indradeep Ghosh, which gives examples of constraints for several +/// functions. + #include #include #include @@ -20,39 +27,22 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com unsigned string_constraint_generatort::next_symbol_id=1; -/*******************************************************************\ - -Function: string_constraint_generatort::constant_char - - Inputs: integer representing a character, and a type for characters; - we do not use char type here because in some languages - (for instance java) characters use more than 8 bits. - - Outputs: constant expression corresponding to the character. - - Purpose: generate constant character expression with character type. - -\*******************************************************************/ - +/// generate constant character expression with character type. +/// \par parameters: integer representing a character, and a type for +/// characters; +/// we do not use char type here because in some languages +/// (for instance java) characters use more than 8 bits. +/// \return constant expression corresponding to the character. constant_exprt string_constraint_generatort::constant_char( int i, const typet &char_type) { return from_integer(i, char_type); } -/*******************************************************************\ - -Function: string_constraint_generator::fresh_symbol - - Inputs: a prefix and a type - - Outputs: a symbol of type tp whose name starts with - "string_refinement#" followed by prefix - - Purpose: generate a new symbol expression of the given type with some prefix - -\*******************************************************************/ - +/// generate a new symbol expression of the given type with some prefix +/// \par parameters: a prefix and a type +/// \return a symbol of type tp whose name starts with "string_refinement#" +/// followed by prefix symbol_exprt string_constraint_generatort::fresh_symbol( const irep_idt &prefix, const typet &type) { @@ -62,37 +52,18 @@ symbol_exprt string_constraint_generatort::fresh_symbol( return symbol_exprt(name, type); } -/*******************************************************************\ - -Function: string_constraint_generatort::fresh_univ_index - - Inputs: a prefix - - Outputs: a symbol of index type whose name starts with the prefix - - Purpose: generate an index symbol to be used as an universaly quantified - variable - -\*******************************************************************/ - +/// generate an index symbol to be used as an universaly quantified variable +/// \par parameters: a prefix +/// \return a symbol of index type whose name starts with the prefix symbol_exprt string_constraint_generatort::fresh_univ_index( const irep_idt &prefix, const typet &type) { return fresh_symbol(prefix, type); } -/*******************************************************************\ - -Function: string_constraint_generatort::fresh_exist_index - - Inputs: a prefix - - Outputs: a symbol of index type whose name starts with the prefix - - Purpose: generate an index symbol which is existentially quantified - -\*******************************************************************/ - +/// generate an index symbol which is existentially quantified +/// \par parameters: a prefix +/// \return a symbol of index type whose name starts with the prefix symbol_exprt string_constraint_generatort::fresh_exist_index( const irep_idt &prefix, const typet &type) { @@ -101,18 +72,9 @@ symbol_exprt string_constraint_generatort::fresh_exist_index( return s; } -/*******************************************************************\ - -Function: string_constraint_generatort::fresh_boolean - - Inputs: a prefix - - Outputs: a symbol of index type whose name starts with the prefix - - Purpose: generate a Boolean symbol which is existentially quantified - -\*******************************************************************/ - +/// generate a Boolean symbol which is existentially quantified +/// \par parameters: a prefix +/// \return a symbol of index type whose name starts with the prefix symbol_exprt string_constraint_generatort::fresh_boolean( const irep_idt &prefix) { @@ -121,20 +83,11 @@ symbol_exprt string_constraint_generatort::fresh_boolean( return b; } -/*******************************************************************\ - -Function: string_constraint_generatort::plus_exprt_with_overflow_check - - Inputs: - op1 - First term of the sum - op2 - Second term of the sum - - Outputs: A plus expression representing the sum of the arguments - - Purpose: Create a plus expression while adding extra constraints to - axioms in order to prevent overflows. - -\*******************************************************************/ +/// Create a plus expression while adding extra constraints to axioms in order +/// to prevent overflows. +/// \param op1: First term of the sum +/// \param op2: Second term of the sum +/// \return A plus expression representing the sum of the arguments plus_exprt string_constraint_generatort::plus_exprt_with_overflow_check( const exprt &op1, const exprt &op2) { @@ -157,19 +110,9 @@ plus_exprt string_constraint_generatort::plus_exprt_with_overflow_check( return sum; } -/*******************************************************************\ - -Function: string_constraint_generatort::fresh_string - - Inputs: a type for string - - Outputs: a string expression - - Purpose: construct a string expression whose length and content are new - variables - -\*******************************************************************/ - +/// construct a string expression whose length and content are new variables +/// \par parameters: a type for string +/// \return a string expression string_exprt string_constraint_generatort::fresh_string( const refined_string_typet &type) { @@ -181,19 +124,10 @@ string_exprt string_constraint_generatort::fresh_string( return str; } -/*******************************************************************\ - -Function: string_constraint_generatort::get_string_expr - - Inputs: an expression of refined string type - - Outputs: a string expression - - Purpose: casts an expression to a string expression, or fetches the - actual string_exprt in the case of a symbol. - -\*******************************************************************/ - +/// casts an expression to a string expression, or fetches the actual +/// string_exprt in the case of a symbol. +/// \par parameters: an expression of refined string type +/// \return a string expression string_exprt string_constraint_generatort::get_string_expr(const exprt &expr) { assert(refined_string_typet::is_refined_string_type(expr.type())); @@ -210,18 +144,9 @@ string_exprt string_constraint_generatort::get_string_expr(const exprt &expr) } } -/*******************************************************************\ - -Function: string_constraint_generatort::convert_java_string_to_string_exprt - - Inputs: a java string - - Outputs: a string expression - - Purpose: create a new string_exprt as a conversion of a java string - -\*******************************************************************/ - +/// create a new string_exprt as a conversion of a java string +/// \par parameters: a java string +/// \return a string expression string_exprt string_constraint_generatort::convert_java_string_to_string_exprt( const exprt &jls) { @@ -245,26 +170,13 @@ string_exprt string_constraint_generatort::convert_java_string_to_string_exprt( return string_exprt(length, java_content, type); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_default_axioms - - Inputs: - s - a string expression - - Outputs: a string expression that is linked to the argument through - axioms that are added to the list - - Purpose: adds standard axioms about the length of the string and - its content: - * its length should be positive - * it should not exceed max_string_length - * if force_printable_characters is true then all characters - should belong to the range of ASCII characters between ' ' and '~' - - -\*******************************************************************/ - +/// adds standard axioms about the length of the string and its content: * its +/// length should be positive * it should not exceed max_string_length * if +/// force_printable_characters is true then all characters should belong to the +/// range of ASCII characters between ' ' and '~' +/// \param s: a string expression +/// \return a string expression that is linked to the argument through axioms +/// that are added to the list void string_constraint_generatort::add_default_axioms( const string_exprt &s) { @@ -285,20 +197,11 @@ void string_constraint_generatort::add_default_axioms( } } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_refined_string - - Inputs: an expression of refined string type - - Outputs: a string expression that is linked to the argument through - axioms that are added to the list - - Purpose: obtain a refined string expression corresponding to a expression - of type string - -\*******************************************************************/ - +/// obtain a refined string expression corresponding to a expression of type +/// string +/// \par parameters: an expression of refined string type +/// \return a string expression that is linked to the argument through axioms +/// that are added to the list string_exprt string_constraint_generatort::add_axioms_for_refined_string( const exprt &string) { @@ -339,18 +242,9 @@ string_exprt string_constraint_generatort::add_axioms_for_refined_string( } } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_if - - Inputs: an if expression - - Outputs: a string expression - - Purpose: add axioms for an if expression which should return a string - -\*******************************************************************/ - +/// add axioms for an if expression which should return a string +/// \par parameters: an if expression +/// \return a string expression string_exprt string_constraint_generatort::add_axioms_for_if( const if_exprt &expr) { @@ -378,21 +272,12 @@ string_exprt string_constraint_generatort::add_axioms_for_if( return res; } -/*******************************************************************\ - -Function: string_constraint_generatort::find_or_add_string_of_symbol - - Inputs: a symbol expression - - Outputs: a string expression - - Purpose: if a symbol representing a string is present in the symbol_to_string - table, returns the corresponding string, if the symbol is not yet - present, creates a new string with the correct type depending on - whether the mode is java or c, adds it to the table and returns it. - -\*******************************************************************/ - +/// if a symbol representing a string is present in the symbol_to_string table, +/// returns the corresponding string, if the symbol is not yet present, creates +/// a new string with the correct type depending on whether the mode is java or +/// c, adds it to the table and returns it. +/// \par parameters: a symbol expression +/// \return a string expression string_exprt string_constraint_generatort::find_or_add_string_of_symbol( const symbol_exprt &sym, const refined_string_typet &ref_type) { @@ -402,20 +287,11 @@ string_exprt string_constraint_generatort::find_or_add_string_of_symbol( return entry.first->second; } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_function_application - - Inputs: an expression containing a function application - - Outputs: expression corresponding to the result of the function application - - Purpose: strings contained in this call are converted to objects of type - `string_exprt`, through adding axioms. Axioms are then added to - enforce that the result corresponds to the function application. - -\*******************************************************************/ - +/// strings contained in this call are converted to objects of type +/// `string_exprt`, through adding axioms. Axioms are then added to enforce that +/// the result corresponds to the function application. +/// \par parameters: an expression containing a function application +/// \return expression corresponding to the result of the function application exprt string_constraint_generatort::add_axioms_for_function_application( const function_application_exprt &expr) { @@ -609,20 +485,11 @@ exprt string_constraint_generatort::add_axioms_for_function_application( return res; } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_copy - - Inputs: function application with one argument, which is a string, - or three arguments: string, integer offset and count - - Outputs: a new string expression - - Purpose: add axioms to say that the returned string expression is equal to - the argument of the function application - -\*******************************************************************/ - +/// add axioms to say that the returned string expression is equal to the +/// argument of the function application +/// \par parameters: function application with one argument, which is a string, +/// or three arguments: string, integer offset and count +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_copy( const function_application_exprt &f) { @@ -642,18 +509,10 @@ string_exprt string_constraint_generatort::add_axioms_for_copy( } } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_java_char_array - - Inputs: an expression corresponding to a java object of type char array - - Outputs: a new string expression - - Purpose: add axioms corresponding to the String.valueOf([C) java function - -\*******************************************************************/ - +/// add axioms corresponding to the String.valueOf([C) java function +/// \par parameters: an expression corresponding to a java object of type char +/// array +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_java_char_array( const exprt &char_array) { @@ -667,18 +526,9 @@ string_exprt string_constraint_generatort::add_axioms_for_java_char_array( return res; } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_char_pointer - - Inputs: an expression of type char - - Outputs: an array expression - - Purpose: for an expression of the form `array[0]` returns `array` - -\*******************************************************************/ - +/// for an expression of the form `array[0]` returns `array` +/// \par parameters: an expression of type char +/// \return an array expression exprt string_constraint_generatort::add_axioms_for_char_pointer( const function_application_exprt &fun) { @@ -690,18 +540,9 @@ exprt string_constraint_generatort::add_axioms_for_char_pointer( return exprt(); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_length - - Inputs: function application with one string argument - - Outputs: a string expression of index type - - Purpose: add axioms corresponding to the String.length java function - -\*******************************************************************/ - +/// add axioms corresponding to the String.length java function +/// \par parameters: function application with one string argument +/// \return a string expression of index type exprt string_constraint_generatort::add_axioms_for_length( const function_application_exprt &f) { @@ -709,21 +550,13 @@ exprt string_constraint_generatort::add_axioms_for_length( return str.length(); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_from_char_array - - Inputs: a length expression, an array expression, a offset index, and a - count index - - Outputs: a new string expression - - Purpose: add axioms stating that the content of the returned string - equals to the content of the array argument, starting at offset and - with `count` characters - -\*******************************************************************/ - +/// add axioms stating that the content of the returned string equals to the +/// content of the array argument, starting at offset and with `count` +/// characters +/// \par parameters: a length expression, an array expression, a offset index, +/// and a +/// count index +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_from_char_array( const exprt &length, const exprt &data, @@ -752,20 +585,11 @@ string_exprt string_constraint_generatort::add_axioms_from_char_array( return str; } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_from_char_array - - Inputs: function application with 2 arguments and 2 additional optional - arguments: length, char array, offset and count - - Outputs: a new string expression - - Purpose: add axioms corresponding to the String.:(I[CII) - and String.:(I[C) java functions - -\*******************************************************************/ - +/// add axioms corresponding to the String.:(I[CII) and +/// String.:(I[C) java functions +/// function application with 2 arguments and 2 additional optional +/// \param arguments: length, char array, offset and count +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_from_char_array( const function_application_exprt &f) { @@ -788,36 +612,18 @@ string_exprt string_constraint_generatort::add_axioms_from_char_array( return add_axioms_from_char_array(tab_length, data, offset, count); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_is_positive_index - - Inputs: an index expression - - Outputs: a Boolean expression - - Purpose: expression true exactly when the index is positive - -\*******************************************************************/ - +/// expression true exactly when the index is positive +/// \par parameters: an index expression +/// \return a Boolean expression exprt string_constraint_generatort::axiom_for_is_positive_index(const exprt &x) { return binary_relation_exprt( x, ID_ge, from_integer(0, x.type())); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_char_literal - - Inputs: function application with one character argument - - Outputs: a new character expression - - Purpose: add axioms stating that the returned value is equal to the argument - -\*******************************************************************/ - +/// add axioms stating that the returned value is equal to the argument +/// \par parameters: function application with one character argument +/// \return a new character expression exprt string_constraint_generatort::add_axioms_for_char_literal( const function_application_exprt &f) { @@ -843,19 +649,11 @@ exprt string_constraint_generatort::add_axioms_for_char_literal( } } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_char_at - - Inputs: function application with two arguments: a string and an integer - - Outputs: a character expression - - Purpose: add axioms stating that the character of the string at the given - position is equal to the returned value - -\*******************************************************************/ - +/// add axioms stating that the character of the string at the given position is +/// equal to the returned value +/// \par parameters: function application with two arguments: a string and an +/// integer +/// \return a character expression exprt string_constraint_generatort::add_axioms_for_char_at( const function_application_exprt &f) { @@ -866,18 +664,9 @@ exprt string_constraint_generatort::add_axioms_for_char_at( return char_sym; } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_to_char_array - - Inputs: function application with one string argument - - Outputs: a char array expression - - Purpose: add axioms corresponding to the String.toCharArray java function - -\*******************************************************************/ - +/// add axioms corresponding to the String.toCharArray java function +/// \par parameters: function application with one string argument +/// \return a char array expression exprt string_constraint_generatort::add_axioms_for_to_char_array( const function_application_exprt &f) { diff --git a/src/solvers/refinement/string_constraint_generator_testing.cpp b/src/solvers/refinement/string_constraint_generator_testing.cpp index 55a6f45f4f7..878441cd0d1 100644 --- a/src/solvers/refinement/string_constraint_generator_testing.cpp +++ b/src/solvers/refinement/string_constraint_generator_testing.cpp @@ -7,22 +7,15 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com \*******************************************************************/ -#include - -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_is_prefix - - Inputs: a prefix string, a string and an integer offset - - Outputs: a Boolean expression - - Purpose: add axioms stating that the returned expression is true exactly - when the first string is a prefix of the second one, starting at - position offset +/// \file +/// Generates string constraints for string functions that return Boolean values -\*******************************************************************/ +#include +/// add axioms stating that the returned expression is true exactly when the +/// first string is a prefix of the second one, starting at position offset +/// \par parameters: a prefix string, a string and an integer offset +/// \return a Boolean expression exprt string_constraint_generatort::add_axioms_for_is_prefix( const string_exprt &prefix, const string_exprt &str, const exprt &offset) { @@ -69,20 +62,12 @@ exprt string_constraint_generatort::add_axioms_for_is_prefix( return isprefix; } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_is_prefix - - Inputs: a function application with 2 or 3 arguments and a Boolean telling - whether the prefix is the second argument (when swap_arguments is - true) or the first argument - - Outputs: a Boolean expression - - Purpose: add axioms corresponding to the String.isPrefix java function - -\*******************************************************************/ - +/// add axioms corresponding to the String.isPrefix java function +/// \par parameters: a function application with 2 or 3 arguments and a Boolean +/// telling +/// whether the prefix is the second argument (when swap_arguments is +/// true) or the first argument +/// \return a Boolean expression exprt string_constraint_generatort::add_axioms_for_is_prefix( const function_application_exprt &f, bool swap_arguments) { @@ -98,19 +83,10 @@ exprt string_constraint_generatort::add_axioms_for_is_prefix( return typecast_exprt(add_axioms_for_is_prefix(s0, s1, offset), f.type()); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_is_empty - - Inputs: function application with a string argument - - Outputs: a Boolean expression - - Purpose: add axioms stating that the returned value is true exactly when - the argument string is empty - -\*******************************************************************/ - +/// add axioms stating that the returned value is true exactly when the argument +/// string is empty +/// \par parameters: function application with a string argument +/// \return a Boolean expression exprt string_constraint_generatort::add_axioms_for_is_empty( const function_application_exprt &f) { @@ -127,20 +103,12 @@ exprt string_constraint_generatort::add_axioms_for_is_empty( return typecast_exprt(is_empty, f.type()); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_is_suffix - - Inputs: a function application with 2 or 3 arguments and a Boolean telling - whether the suffix is the second argument (when swap_arguments is - true) or the first argument - - Outputs: a Boolean expression - - Purpose: add axioms corresponding to the String.isSuffix java function - -\*******************************************************************/ - +/// add axioms corresponding to the String.isSuffix java function +/// \par parameters: a function application with 2 or 3 arguments and a Boolean +/// telling +/// whether the suffix is the second argument (when swap_arguments is +/// true) or the first argument +/// \return a Boolean expression exprt string_constraint_generatort::add_axioms_for_is_suffix( const function_application_exprt &f, bool swap_arguments) { @@ -190,19 +158,9 @@ exprt string_constraint_generatort::add_axioms_for_is_suffix( return tc_issuffix; } -/*******************************************************************\ - -Function: string_constraint_generatort::is_constant_string - - Inputs: - expr - a string expression - - Outputs: a Boolean - - Purpose: tells whether the given string is a constant - -\*******************************************************************/ - +/// tells whether the given string is a constant +/// \param expr: a string expression +/// \return a Boolean bool string_constraint_generatort::is_constant_string( const string_exprt &expr) const { @@ -219,18 +177,9 @@ bool string_constraint_generatort::is_constant_string( return true; } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_contains - - Inputs: function application with two string arguments - - Outputs: a Boolean expression - - Purpose: add axioms corresponding to the String.contains java function - -\*******************************************************************/ - +/// add axioms corresponding to the String.contains java function +/// \par parameters: function application with two string arguments +/// \return a Boolean expression exprt string_constraint_generatort::add_axioms_for_contains( const function_application_exprt &f) { diff --git a/src/solvers/refinement/string_constraint_generator_transformation.cpp b/src/solvers/refinement/string_constraint_generator_transformation.cpp index c110f636c43..599ae3af9dd 100644 --- a/src/solvers/refinement/string_constraint_generator_transformation.cpp +++ b/src/solvers/refinement/string_constraint_generator_transformation.cpp @@ -7,25 +7,20 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com \*******************************************************************/ -#include - -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_set_length - - Inputs: function application with two arguments, the first of which is - a string and the second an integer which should have same type has - return by get_index_type() - - Outputs: a new string expression +/// \file +/// Generates string constraints for string transformations, that is, functions +/// taking one string and returning another - Purpose: add axioms to say that the returned string expression has length - given by the second argument and whose characters are equal to - those of the first argument for the positions which are defined in - both strings - -\*******************************************************************/ +#include +/// add axioms to say that the returned string expression has length given by +/// the second argument and whose characters are equal to those of the first +/// argument for the positions which are defined in both strings +/// \par parameters: function application with two arguments, the first of which +/// is +/// a string and the second an integer which should have same type has +/// return by get_index_type() +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_set_length( const function_application_exprt &f) { @@ -63,21 +58,13 @@ string_exprt string_constraint_generatort::add_axioms_for_set_length( } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_substring - - Inputs: function application with one string argument, one start index - argument and an optional end index argument - - Outputs: a new string expression - - Purpose: add axioms corresponding to the String.substring java function - Warning: the specification may not be correct for the case where the - string is shorter than the end index - -\*******************************************************************/ - +/// add axioms corresponding to the String.substring java function Warning: the +/// specification may not be correct for the case where the string is shorter +/// than the end index +/// \par parameters: function application with one string argument, one start +/// index +/// argument and an optional end index argument +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_substring( const function_application_exprt &f) { @@ -98,20 +85,12 @@ string_exprt string_constraint_generatort::add_axioms_for_substring( return add_axioms_for_substring(str, i, j); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_substring - - Inputs: a string expression, an expression for the start index, and an - expression for the end index - - Outputs: a new string expression - - Purpose: add axioms stating that the returned string expression is equal - to the input one starting at `start` and ending before `end` - -\*******************************************************************/ - +/// add axioms stating that the returned string expression is equal to the input +/// one starting at `start` and ending before `end` +/// \par parameters: a string expression, an expression for the start index, and +/// an +/// expression for the end index +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_substring( const string_exprt &str, const exprt &start, const exprt &end) { @@ -148,18 +127,9 @@ string_exprt string_constraint_generatort::add_axioms_for_substring( return res; } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_trim - - Inputs: function application with one string argument - - Outputs: a new string expression - - Purpose: add axioms corresponding to the String.trim java function - -\*******************************************************************/ - +/// add axioms corresponding to the String.trim java function +/// \par parameters: function application with one string argument +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_trim( const function_application_exprt &expr) { @@ -233,18 +203,9 @@ string_exprt string_constraint_generatort::add_axioms_for_trim( return res; } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_to_lower_case - - Inputs: function application with one string argument - - Outputs: a new string expression - - Purpose: add axioms corresponding to the String.toLowerCase java function - -\*******************************************************************/ - +/// add axioms corresponding to the String.toLowerCase java function +/// \par parameters: function application with one string argument +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_to_lower_case( const function_application_exprt &expr) { @@ -286,18 +247,9 @@ string_exprt string_constraint_generatort::add_axioms_for_to_lower_case( return res; } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_to_upper_case - - Inputs: function application with one string argument - - Outputs: a new string expression - - Purpose: add axioms corresponding to the String.toUpperCase java function - -\*******************************************************************/ - +/// add axioms corresponding to the String.toUpperCase java function +/// \par parameters: function application with one string argument +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_to_upper_case( const function_application_exprt &expr) { @@ -338,22 +290,13 @@ string_exprt string_constraint_generatort::add_axioms_for_to_upper_case( } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_char_set - - Inputs: function application with three arguments, the first is a string - the second an index and the third a character - - Outputs: a new string expression - - Purpose: add axioms corresponding stating that the result is similar to - that of the StringBuilder.setCharAt java function - Warning: this may be underspecified in the case wher the index exceed - the length of the string - -\*******************************************************************/ - +/// add axioms corresponding stating that the result is similar to that of the +/// StringBuilder.setCharAt java function Warning: this may be underspecified in +/// the case wher the index exceed the length of the string +/// \par parameters: function application with three arguments, the first is a +/// string +/// the second an index and the third a character +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_char_set( const function_application_exprt &f) { @@ -374,19 +317,11 @@ string_exprt string_constraint_generatort::add_axioms_for_char_set( return res; } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_replace - - Inputs: function application with three arguments, the first is a string, - the second and the third are characters - - Outputs: a new string expression - - Purpose: add axioms corresponding to the String.replace java function - -\*******************************************************************/ - +/// add axioms corresponding to the String.replace java function +/// \par parameters: function application with three arguments, the first is a +/// string, +/// the second and the third are characters +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_replace( const function_application_exprt &f) { @@ -416,20 +351,11 @@ string_exprt string_constraint_generatort::add_axioms_for_replace( return res; } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_delete_char_at - - Inputs: function application with two arguments, the first is a string - and the second is an index - - Outputs: a new string expression - - Purpose: add axioms corresponding to the StringBuilder.deleteCharAt java - function - -\*******************************************************************/ - +/// add axioms corresponding to the StringBuilder.deleteCharAt java function +/// \par parameters: function application with two arguments, the first is a +/// string +/// and the second is an index +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_delete_char_at( const function_application_exprt &f) { @@ -441,20 +367,11 @@ string_exprt string_constraint_generatort::add_axioms_for_delete_char_at( plus_exprt_with_overflow_check(args(f, 2)[1], index_one)); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_delete - - Inputs: a string expression, a start index and an end index - - Outputs: a new string expression - - Purpose: add axioms stating that the returned string corresponds to the input - one where we removed characters between the positions - start (included) and end (not included) - -\*******************************************************************/ - +/// add axioms stating that the returned string corresponds to the input one +/// where we removed characters between the positions start (included) and end +/// (not included) +/// \par parameters: a string expression, a start index and an end index +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_delete( const string_exprt &str, const exprt &start, const exprt &end) { @@ -466,19 +383,10 @@ string_exprt string_constraint_generatort::add_axioms_for_delete( return add_axioms_for_concat(str1, str2); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_delete - - Inputs: function application with three arguments: a string - expression, a start index and an end index - - Outputs: a new string expression - - Purpose: add axioms corresponding to the StringBuilder.delete java function - -\*******************************************************************/ - +/// add axioms corresponding to the StringBuilder.delete java function +/// \par parameters: function application with three arguments: a string +/// expression, a start index and an end index +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_delete( const function_application_exprt &f) { diff --git a/src/solvers/refinement/string_constraint_generator_valueof.cpp b/src/solvers/refinement/string_constraint_generator_valueof.cpp index d967e5bb820..9ad1845c9d0 100644 --- a/src/solvers/refinement/string_constraint_generator_valueof.cpp +++ b/src/solvers/refinement/string_constraint_generator_valueof.cpp @@ -7,21 +7,16 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com \*******************************************************************/ +/// \file +/// Generates string constraints for functions generating strings from other +/// types, in particular int, long, float, double, char, bool + #include #include -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_from_int - - Inputs: function application with one integer argument - - Outputs: a new string expression - - Purpose: add axioms corresponding to the String.valueOf(I) java function - -\*******************************************************************/ - +/// add axioms corresponding to the String.valueOf(I) java function +/// \par parameters: function application with one integer argument +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_from_int( const function_application_exprt &expr) { @@ -29,18 +24,9 @@ string_exprt string_constraint_generatort::add_axioms_from_int( return add_axioms_from_int(args(expr, 1)[0], MAX_INTEGER_LENGTH, ref_type); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_from_long - - Inputs: function application with one long argument - - Outputs: a new string expression - - Purpose: add axioms corresponding to the String.valueOf(J) java function - -\*******************************************************************/ - +/// add axioms corresponding to the String.valueOf(J) java function +/// \par parameters: function application with one long argument +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_from_long( const function_application_exprt &expr) { @@ -48,18 +34,9 @@ string_exprt string_constraint_generatort::add_axioms_from_long( return add_axioms_from_int(args(expr, 1)[0], MAX_LONG_LENGTH, ref_type); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_from_float - - Inputs: function application with one float argument - - Outputs: a new string expression - - Purpose: add axioms corresponding to the String.valueOf(F) java function - -\*******************************************************************/ - +/// add axioms corresponding to the String.valueOf(F) java function +/// \par parameters: function application with one float argument +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_from_float( const function_application_exprt &f) { @@ -67,18 +44,9 @@ string_exprt string_constraint_generatort::add_axioms_from_float( return add_axioms_from_float(args(f, 1)[0], ref_type, false); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_from_double - - Inputs: function application with one double argument - - Outputs: a new string expression - - Purpose: add axioms corresponding to the String.valueOf(D) java function - -\*******************************************************************/ - +/// add axioms corresponding to the String.valueOf(D) java function +/// \par parameters: function application with one double argument +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_from_double( const function_application_exprt &f) { @@ -86,20 +54,12 @@ string_exprt string_constraint_generatort::add_axioms_from_double( return add_axioms_from_float(args(f, 1)[0], ref_type, true); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_from_float - - Inputs: float expression and Boolean signaling that the argument has - double precision - - Outputs: a new string expression - - Purpose: add axioms corresponding to the String.valueOf(F) java function - Warning: we currently only have partial specification - -\*******************************************************************/ - +/// add axioms corresponding to the String.valueOf(F) java function Warning: we +/// currently only have partial specification +/// \par parameters: float expression and Boolean signaling that the argument +/// has +/// double precision +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_from_float( const exprt &f, const refined_string_typet &ref_type, bool double_precision) { @@ -191,18 +151,9 @@ string_exprt string_constraint_generatort::add_axioms_from_float( } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_from_bool - - Inputs: function application with on Boolean argument - - Outputs: a new string expression - - Purpose: add axioms corresponding to the String.valueOf(Z) java function - -\*******************************************************************/ - +/// add axioms corresponding to the String.valueOf(Z) java function +/// \par parameters: function application with on Boolean argument +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_from_bool( const function_application_exprt &f) { @@ -211,19 +162,10 @@ string_exprt string_constraint_generatort::add_axioms_from_bool( } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_from_bool - - Inputs: Boolean expression - - Outputs: a new string expression - - Purpose: add axioms stating that the returned string equals "true" when - the Boolean expression is true and "false" when it is false - -\*******************************************************************/ - +/// add axioms stating that the returned string equals "true" when the Boolean +/// expression is true and "false" when it is false +/// \par parameters: Boolean expression +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_from_bool( const exprt &b, const refined_string_typet &ref_type) { @@ -265,21 +207,12 @@ string_exprt string_constraint_generatort::add_axioms_from_bool( return res; } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_from_int - - Inputs: a signed integer expression, and a maximal size for the string - representation - - Outputs: a string expression - - Purpose: add axioms to say the string corresponds to the result of - String.valueOf(I) or String.valueOf(J) java functions applied on the - integer expression - -\*******************************************************************/ - +/// add axioms to say the string corresponds to the result of String.valueOf(I) +/// or String.valueOf(J) java functions applied on the integer expression +/// \par parameters: a signed integer expression, and a maximal size for the +/// string +/// representation +/// \return a string expression string_exprt string_constraint_generatort::add_axioms_from_int( const exprt &i, size_t max_size, const refined_string_typet &ref_type) { @@ -383,18 +316,10 @@ string_exprt string_constraint_generatort::add_axioms_from_int( return res; } -/*******************************************************************\ - -Function: string_constraint_generatort::int_of_hex_char - - Inputs: a character expression in the following set: 0123456789abcdef - - Outputs: an integer expression - - Purpose: returns the value represented by the character - -\*******************************************************************/ - +/// returns the value represented by the character +/// \par parameters: a character expression in the following set: +/// 0123456789abcdef +/// \return an integer expression exprt string_constraint_generatort::int_of_hex_char(const exprt &chr) const { exprt zero_char=constant_char('0', chr.type()); @@ -406,19 +331,10 @@ exprt string_constraint_generatort::int_of_hex_char(const exprt &chr) const minus_exprt(chr, zero_char)); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_from_int_hex - - Inputs: one integer argument - - Outputs: a new string expression - - Purpose: add axioms stating that the returned string corresponds to the - integer argument written in hexadecimal - -\*******************************************************************/ - +/// add axioms stating that the returned string corresponds to the integer +/// argument written in hexadecimal +/// \par parameters: one integer argument +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_from_int_hex( const exprt &i, const refined_string_typet &ref_type) { @@ -472,18 +388,9 @@ string_exprt string_constraint_generatort::add_axioms_from_int_hex( return res; } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_int_hex - - Inputs: function application with integer argument - - Outputs: a new string expression - - Purpose: add axioms corresponding to the Integer.toHexString(I) java function - -\*******************************************************************/ - +/// add axioms corresponding to the Integer.toHexString(I) java function +/// \par parameters: function application with integer argument +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_from_int_hex( const function_application_exprt &f) { @@ -491,18 +398,9 @@ string_exprt string_constraint_generatort::add_axioms_from_int_hex( return add_axioms_from_int_hex(args(f, 1)[0], ref_type); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_from_char - - Inputs: function application one char argument - - Outputs: a new string expression - - Purpose: add axioms corresponding to the String.valueOf(C) java function - -\*******************************************************************/ - +/// add axioms corresponding to the String.valueOf(C) java function +/// \par parameters: function application one char argument +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_from_char( const function_application_exprt &f) { @@ -510,19 +408,10 @@ string_exprt string_constraint_generatort::add_axioms_from_char( return add_axioms_from_char(args(f, 1)[0], ref_type); } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_from_char - - Inputs: one expression of type char - - Outputs: a new string expression - - Purpose: add axioms stating that the returned string has length 1 and - the character it contains correspond to the input expression - -\*******************************************************************/ - +/// add axioms stating that the returned string has length 1 and the character +/// it contains correspond to the input expression +/// \par parameters: one expression of type char +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_from_char( const exprt &c, const refined_string_typet &ref_type) { @@ -532,19 +421,10 @@ string_exprt string_constraint_generatort::add_axioms_from_char( return res; } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_value_of - - Inputs: function application with one or three arguments - - Outputs: a new string expression - - Purpose: add axioms corresponding to the String.valueOf([C) and - String.valueOf([CII) functions - -\*******************************************************************/ - +/// add axioms corresponding to the String.valueOf([C) and String.valueOf([CII) +/// functions +/// \par parameters: function application with one or three arguments +/// \return a new string expression string_exprt string_constraint_generatort::add_axioms_for_value_of( const function_application_exprt &f) { @@ -578,19 +458,10 @@ string_exprt string_constraint_generatort::add_axioms_for_value_of( } } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_correct_number_format - - Inputs: function application with one string expression - - Outputs: an boolean expression - - Purpose: add axioms making the return value true if the given string is - a correct number - -\*******************************************************************/ - +/// add axioms making the return value true if the given string is a correct +/// number +/// \par parameters: function application with one string expression +/// \return an boolean expression exprt string_constraint_generatort::add_axioms_for_correct_number_format( const string_exprt &str, std::size_t max_size) { @@ -642,18 +513,9 @@ exprt string_constraint_generatort::add_axioms_for_correct_number_format( return correct; } -/*******************************************************************\ - -Function: string_constraint_generatort::add_axioms_for_parse_int - - Inputs: function application with one string expression - - Outputs: an integer expression - - Purpose: add axioms corresponding to the Integer.parseInt java function - -\*******************************************************************/ - +/// add axioms corresponding to the Integer.parseInt java function +/// \par parameters: function application with one string expression +/// \return an integer expression exprt string_constraint_generatort::add_axioms_for_parse_int( const function_application_exprt &f) { diff --git a/src/solvers/refinement/string_refinement.cpp b/src/solvers/refinement/string_refinement.cpp index 3c28e6f8fa3..257fbf51e48 100644 --- a/src/solvers/refinement/string_refinement.cpp +++ b/src/solvers/refinement/string_refinement.cpp @@ -10,6 +10,13 @@ Author: Alberto Griggio, alberto.griggio@gmail.com \*******************************************************************/ +/// \file +/// String support via creating string constraints and progressively +/// instantiating the universal constraints as needed. The procedure is +/// described in the PASS paper at HVC'13: "PASS: String Solving with +/// Parameterized Array and Interval Automaton" by Guodong Li and Indradeep +/// Ghosh. + #include #include #include @@ -22,19 +29,6 @@ Author: Alberto Griggio, alberto.griggio@gmail.com #include #include -/*******************************************************************\ - -Constructor: string_refinementt - - Inputs: - _ns - a namespace - _prop - a decision procedure - refinement_bound - a bound on the number of refinements - - Purpose: refinement_bound is a bound on the number of refinement allowed. - -\*******************************************************************/ - string_refinementt::string_refinementt( const namespacet &_ns, propt &_prop, @@ -46,62 +40,31 @@ string_refinementt::string_refinementt( non_empty_string(false) { } -/*******************************************************************\ - -Function: string_refinementt::set_max_string_length - - Inputs: - i - maximum length which is allowed for strings. - by default the strings length has no other limit - than the maximal integer according to the type of their - length, for instance 2^31-1 for Java. - - Purpose: Add constraints on the size of strings used in the - program. - -\*******************************************************************/ - +/// Add constraints on the size of strings used in the program. +/// \param i: maximum length which is allowed for strings. +/// by default the strings length has no other limit +/// than the maximal integer according to the type of their +/// length, for instance 2^31-1 for Java. void string_refinementt::set_max_string_length(size_t i) { generator.max_string_length=i; } -/*******************************************************************\ - -Function: string_refinementt::set_max_string_length - - Purpose: Add constraints on the size of nondet character arrays - to ensure they have length at least 1 - -\*******************************************************************/ - +/// Add constraints on the size of nondet character arrays to ensure they have +/// length at least 1 void string_refinementt::enforce_non_empty_string() { non_empty_string=true; } -/*******************************************************************\ - -Function: string_refinementt::enforce_printable_characters - - Purpose: Add constraints on characters used in the program - to ensure they are printable - -\*******************************************************************/ - +/// Add constraints on characters used in the program to ensure they are +/// printable void string_refinementt::enforce_printable_characters() { generator.force_printable_characters=true; } -/*******************************************************************\ - -Function: string_refinementt::display_index_set - - Purpose: display the current index set, for debugging - -\*******************************************************************/ - +/// display the current index set, for debugging void string_refinementt::display_index_set() { std::size_t count=0; @@ -127,15 +90,8 @@ void string_refinementt::display_index_set() << " newly added)" << eom; } -/*******************************************************************\ - -Function: string_refinementt::add_instantiations - - Purpose: compute the index set for all formulas, instantiate the formulas - with the found indexes, and add them as lemmas. - -\*******************************************************************/ - +/// compute the index set for all formulas, instantiate the formulas with the +/// found indexes, and add them as lemmas. void string_refinementt::add_instantiations() { debug() << "string_constraint_generatort::add_instantiations: " @@ -162,19 +118,10 @@ void string_refinementt::add_instantiations() } } -/*******************************************************************\ - -Function: string_refinementt::add_symbol_to_symbol_map() - - Inputs: - lhs - a symbol expression - rhs - an expression to map it to - - Purpose: keeps a map of symbols to expressions, such as none of the - mapped values exist as a key - -\*******************************************************************/ - +/// keeps a map of symbols to expressions, such as none of the mapped values +/// exist as a key +/// \param lhs: a symbol expression +/// \param rhs: an expression to map it to void string_refinementt::add_symbol_to_symbol_map( const exprt &lhs, const exprt &rhs) { @@ -196,16 +143,8 @@ void string_refinementt::add_symbol_to_symbol_map( } } -/*******************************************************************\ - -Function: string_refinementt::set_char_array_equality() - - Inputs: the rhs and lhs of an equality over character arrays - - Purpose: add axioms if the rhs is a character array - -\*******************************************************************/ - +/// add axioms if the rhs is a character array +/// \par parameters: the rhs and lhs of an equality over character arrays void string_refinementt::set_char_array_equality( const exprt &lhs, const exprt &rhs) { @@ -230,19 +169,9 @@ void string_refinementt::set_char_array_equality( // equality. Note that this might not be the case for other languages. } -/*******************************************************************\ - -Function: string_refinementt::substitute_function_applications() - - Inputs: an expression containing function applications - - Outputs: an epression containing no function application - - Purpose: remove functions applications and create the necessary - axioms - -\*******************************************************************/ - +/// remove functions applications and create the necessary axioms +/// \par parameters: an expression containing function applications +/// \return an epression containing no function application exprt string_refinementt::substitute_function_applications(exprt expr) { for(size_t i=0; i 2, y -> -1. - -\*******************************************************************/ - +/// \par parameters: an expression with only addition and substraction +/// \return a map where each leaf of the input is mapped to the number of times +/// it is added. For instance, expression $x + x - y$ would give the map x -> +/// 2, y -> -1. std::map string_refinementt::map_representation_of_sum( const exprt &f) const { @@ -1336,18 +1099,10 @@ std::map string_refinementt::map_representation_of_sum( return elems; } -/*******************************************************************\ - -Function: string_refinementt::sum_over_map - - Inputs: a map from expressions to integers - - Outputs: a expression for the sum of each element in the map a number of - times given by the corresponding integer in the map. - For a map x -> 2, y -> -1 would give an expression $x + x - y$. - -\*******************************************************************/ - +/// \par parameters: a map from expressions to integers +/// \return a expression for the sum of each element in the map a number of +/// times given by the corresponding integer in the map. For a map x -> 2, y +/// -> -1 would give an expression $x + x - y$. exprt string_refinementt::sum_over_map( std::map &m, const typet &type, bool negated) const { @@ -1417,37 +1172,21 @@ exprt string_refinementt::sum_over_map( return index_const; } -/*******************************************************************\ - -Function: string_refinementt::simplify_sum - - Inputs: an expression with only plus and minus expr - - Outputs: an equivalent expression in a cannonical form - -\*******************************************************************/ - +/// \par parameters: an expression with only plus and minus expr +/// \return an equivalent expression in a cannonical form exprt string_refinementt::simplify_sum(const exprt &f) const { std::map map=map_representation_of_sum(f); return sum_over_map(map, f.type()); } -/*******************************************************************\ - -Function: string_refinementt::compute_inverse_function - - Inputs: a symbol qvar, an expression val, an expression f containing + and − - operations in which qvar should appear exactly once. - - Outputs: an expression corresponding of $f^{−1}(val)$ where $f$ is seen as a - function of $qvar$, i.e. the value that is necessary for qvar for f - to be equal to val. For instance, if `f` corresponds to the expression - $q + x$, `compute_inverse_function(q,v,f)` returns an expression for - $v - x$. - -\*******************************************************************/ - +/// \par parameters: a symbol qvar, an expression val, an expression f +/// containing + and − +/// operations in which qvar should appear exactly once. +/// \return an expression corresponding of $f^{−1}(val)$ where $f$ is seen as +/// a function of $qvar$, i.e. the value that is necessary for qvar for f to +/// be equal to val. For instance, if `f` corresponds to the expression $q + +/// x$, `compute_inverse_function(q,v,f)` returns an expression for $v - x$. exprt string_refinementt::compute_inverse_function( const exprt &qvar, const exprt &val, const exprt &f) { @@ -1497,18 +1236,9 @@ class find_qvar_visitort: public const_expr_visitort } }; -/*******************************************************************\ - -Function: find_qvar - - Inputs: an index expression and a symbol qvar - - Outputs: a Boolean - - Purpose: look for the symbol and return true if it is found - -\*******************************************************************/ - +/// look for the symbol and return true if it is found +/// \par parameters: an index expression and a symbol qvar +/// \return a Boolean static bool find_qvar(const exprt index, const symbol_exprt &qvar) { find_qvar_visitort v2(qvar); @@ -1516,17 +1246,9 @@ static bool find_qvar(const exprt index, const symbol_exprt &qvar) return v2.found; } -/*******************************************************************\ - -Function: string_refinementt::initial_index_set - - Inputs: a list of string constraints - - Purpose: add to the index set all the indices that appear in the formulas - and the upper bound minus one - -\*******************************************************************/ - +/// add to the index set all the indices that appear in the formulas and the +/// upper bound minus one +/// \par parameters: a list of string constraints void string_refinementt::initial_index_set( const std::vector &string_axioms) { @@ -1534,32 +1256,17 @@ void string_refinementt::initial_index_set( initial_index_set(axiom); } -/*******************************************************************\ - -Function: string_refinementt::update_index_set - - Inputs: a list of string constraints - - Purpose: add to the index set all the indices that appear in the formulas - -\*******************************************************************/ - +/// add to the index set all the indices that appear in the formulas +/// \par parameters: a list of string constraints void string_refinementt::update_index_set(const std::vector &cur) { for(const auto &axiom : cur) update_index_set(axiom); } -/*******************************************************************\ - -Function: string_refinementt::initial_index_set - - Inputs: a string constraint - - Purpose: add to the index set all the indices that appear in the formula - and the upper bound minus one - -\*******************************************************************/ +/// add to the index set all the indices that appear in the formula and the +/// upper bound minus one +/// \par parameters: a string constraint void string_refinementt::add_to_index_set(const exprt &s, exprt i) { simplify(i, ns); @@ -1620,16 +1327,8 @@ void string_refinementt::initial_index_set(const string_constraintt &axiom) } } -/*******************************************************************\ - -Function: string_refinementt::update_index_set - - Inputs: a string constraint - - Purpose: add to the index set all the indices that appear in the formula - -\*******************************************************************/ - +/// add to the index set all the indices that appear in the formula +/// \par parameters: a string constraint void string_refinementt::update_index_set(const exprt &formula) { std::list to_process; @@ -1677,20 +1376,10 @@ class find_index_visitort: public const_expr_visitort } }; -/*******************************************************************\ - -Function: string_refinementt::update_index_set - - Inputs: a formula expr and a char array str - - Outputs: an index expression - - Purpose: find an index used in the expression for str, for instance - with arguments (str[k] == 'a') and str, the function should - return k - -\*******************************************************************/ - +/// find an index used in the expression for str, for instance with arguments +/// (str[k] == 'a') and str, the function should return k +/// \par parameters: a formula expr and a char array str +/// \return an index expression exprt find_index(const exprt &expr, const exprt &str) { find_index_visitort v1(str); @@ -1702,21 +1391,13 @@ exprt find_index(const exprt &expr, const exprt &str) catch (exprt i) { return i; } } -/*******************************************************************\ - -Function: string_refinementt::instantiate - - Inputs: a universally quantified formula `axiom`, an array of char - variable `str`, and an index expression `val`. - - Outputs: substitute `qvar` the universally quantified variable of `axiom`, by - an index `val`, in `axiom`, so that the index used for `str` equals - `val`. For instance, if `axiom` corresponds to - $\forall q. s[q+x]='a' && t[q]='b'$, `instantiate(axom,s,v)` - would return an expression for $s[v]='a' && t[v-x]='b'$. - -\*******************************************************************/ - +/// \par parameters: a universally quantified formula `axiom`, an array of char +/// variable `str`, and an index expression `val`. +/// \return substitute `qvar` the universally quantified variable of `axiom`, by +/// an index `val`, in `axiom`, so that the index used for `str` equals `val`. +/// For instance, if `axiom` corresponds to $\forall q. s[q+x]='a' && +/// t[q]='b'$, `instantiate(axom,s,v)` would return an expression for +/// $s[v]='a' && t[v-x]='b'$. exprt string_refinementt::instantiate( const string_constraintt &axiom, const exprt &str, const exprt &val) { @@ -1738,18 +1419,10 @@ exprt string_refinementt::instantiate( return implies_exprt(bounds, instance); } -/*******************************************************************\ - -Function: string_refinementt::instantiate_not_contains - - Inputs: a quantified formula representing `not_contains`, and a - list to which to add the created lemmas to - - Purpose: instantiate a quantified formula representing `not_contains` - by substituting the quantifiers and generating axioms - -\*******************************************************************/ - +/// instantiate a quantified formula representing `not_contains` by substituting +/// the quantifiers and generating axioms +/// \par parameters: a quantified formula representing `not_contains`, and a +/// list to which to add the created lemmas to void string_refinementt::instantiate_not_contains( const string_not_contains_constraintt &axiom, std::list &new_lemmas) { @@ -1801,18 +1474,9 @@ void string_refinementt::instantiate_not_contains( } } -/*******************************************************************\ - -Function: string_refinementt::substitute_array_lists() - - Inputs: an expression containing array-list expressions - - Outputs: an epression containing no array-list - - Purpose: replace array-lists by 'with' expressions - -\*******************************************************************/ - +/// replace array-lists by 'with' expressions +/// \par parameters: an expression containing array-list expressions +/// \return an epression containing no array-list exprt string_refinementt::substitute_array_lists(exprt expr) const { for(size_t i=0; i void string_refinementt::pad_vector( std::vector &concrete_array, diff --git a/src/solvers/sat/cnf.cpp b/src/solvers/sat/cnf.cpp index a69947df8f4..7ff2fc1c520 100644 --- a/src/solvers/sat/cnf.cpp +++ b/src/solvers/sat/cnf.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// CNF Generation, via Tseitin + #include #include #include @@ -14,19 +17,10 @@ Author: Daniel Kroening, kroening@kroening.com #include "cnf.h" // #define VERBOSE -/*******************************************************************\ - -Function: cnft::gate_and - - Inputs: Two input signals to the AND gate, one output - - Outputs: Side effect: add clauses that encodes relation between - inputs/output via lcnf - - Purpose: Tseitin encoding of conjunction of two literals - -\*******************************************************************/ - +/// Tseitin encoding of conjunction of two literals +/// \par parameters: Two input signals to the AND gate, one output +/// \return Side effect: add clauses that encodes relation between inputs/output +/// via lcnf void cnft::gate_and(literalt a, literalt b, literalt o) { // a*b=c <==> (a + o')( b + o')(a'+b'+o) @@ -48,18 +42,8 @@ void cnft::gate_and(literalt a, literalt b, literalt o) lcnf(lits); } -/*******************************************************************\ - -Function: cnft::gate_or - - Inputs: Two input signals to the OR gate, one output - - Outputs: - - Purpose: Tseitin encoding of disjunction of two literals - -\*******************************************************************/ - +/// Tseitin encoding of disjunction of two literals +/// \par parameters: Two input signals to the OR gate, one output void cnft::gate_or(literalt a, literalt b, literalt o) { // a+b=c <==> (a' + c)( b' + c)(a + b + c') @@ -80,18 +64,8 @@ void cnft::gate_or(literalt a, literalt b, literalt o) lcnf(lits); } -/*******************************************************************\ - -Function: cnft::gate_xor - - Inputs: Two input signals to the XOR gate, one output - - Outputs: - - Purpose: Tseitin encoding of XOR of two literals - -\*******************************************************************/ - +/// Tseitin encoding of XOR of two literals +/// \par parameters: Two input signals to the XOR gate, one output void cnft::gate_xor(literalt a, literalt b, literalt o) { // a xor b = o <==> (a' + b' + o') @@ -121,18 +95,8 @@ void cnft::gate_xor(literalt a, literalt b, literalt o) lcnf(lits); } -/*******************************************************************\ - -Function: cnft::gate_nand - - Inputs: Two input signals to the NAND gate, one output - - Outputs: - - Purpose: Tseitin encoding of NAND of two literals - -\*******************************************************************/ - +/// Tseitin encoding of NAND of two literals +/// \par parameters: Two input signals to the NAND gate, one output void cnft::gate_nand(literalt a, literalt b, literalt o) { // a Nand b = o <==> (a + o)( b + o)(a' + b' + o') @@ -153,18 +117,8 @@ void cnft::gate_nand(literalt a, literalt b, literalt o) lcnf(lits); } -/*******************************************************************\ - -Function: cnft::gate_nor - - Inputs: Two input signals to the NOR gate, one output - - Outputs: - - Purpose: Tseitin encoding of NOR of two literals - -\*******************************************************************/ - +/// Tseitin encoding of NOR of two literals +/// \par parameters: Two input signals to the NOR gate, one output void cnft::gate_nor(literalt a, literalt b, literalt o) { // a Nor b = o <==> (a' + o')( b' + o')(a + b + o) @@ -185,52 +139,23 @@ void cnft::gate_nor(literalt a, literalt b, literalt o) lcnf(lits); } -/*******************************************************************\ - -Function: cnft::gate_equal - - Inputs: Two input signals to the EQUAL gate, one output - - Outputs: - - Purpose: Tseitin encoding of equality between two literals - -\*******************************************************************/ - +/// Tseitin encoding of equality between two literals +/// \par parameters: Two input signals to the EQUAL gate, one output void cnft::gate_equal(literalt a, literalt b, literalt o) { gate_xor(a, b, !o); } -/*******************************************************************\ - -Function: cnft::gate_implies - - Inputs: Two input signals to the IMPLIES gate, one output - - Outputs: - - Purpose: Tseitin encoding of implication between two literals - -\*******************************************************************/ - +/// Tseitin encoding of implication between two literals +/// \par parameters: Two input signals to the IMPLIES gate, one output void cnft::gate_implies(literalt a, literalt b, literalt o) { gate_or(!a, b, o); } -/*******************************************************************\ - -Function: cnft::land - - Inputs: Any number of inputs to the AND gate - - Outputs: Output signal of the AND gate as literal - - Purpose: Tseitin encoding of conjunction between multiple literals - -\*******************************************************************/ - +/// Tseitin encoding of conjunction between multiple literals +/// \par parameters: Any number of inputs to the AND gate +/// \return Output signal of the AND gate as literal literalt cnft::land(const bvt &bv) { if(bv.empty()) @@ -271,18 +196,9 @@ literalt cnft::land(const bvt &bv) return literal; } -/*******************************************************************\ - -Function: cnft::lor - - Inputs: Any number of inputs to the OR gate - - Outputs: Output signal of the OR gate as literal - - Purpose: Tseitin encoding of disjunction between multiple literals - -\*******************************************************************/ - +/// Tseitin encoding of disjunction between multiple literals +/// \par parameters: Any number of inputs to the OR gate +/// \return Output signal of the OR gate as literal literalt cnft::lor(const bvt &bv) { if(bv.empty()) @@ -323,18 +239,9 @@ literalt cnft::lor(const bvt &bv) return literal; } -/*******************************************************************\ - -Function: cnft::lxor - - Inputs: Any number of inputs to the XOR gate - - Outputs: Output signal of the XOR gate as literal - - Purpose: Tseitin encoding of XOR between multiple literals - -\*******************************************************************/ - +/// Tseitin encoding of XOR between multiple literals +/// \par parameters: Any number of inputs to the XOR gate +/// \return Output signal of the XOR gate as literal literalt cnft::lxor(const bvt &bv) { if(bv.empty()) @@ -352,18 +259,8 @@ literalt cnft::lxor(const bvt &bv) return literal; } -/*******************************************************************\ - -Function: cnft::land - - Inputs: Two inputs to the AND gate - - Outputs: Output signal of the AND gate as literal - - Purpose: - -\*******************************************************************/ - +/// \par parameters: Two inputs to the AND gate +/// \return Output signal of the AND gate as literal literalt cnft::land(literalt a, literalt b) { if(a.is_true() || b.is_false()) @@ -378,18 +275,8 @@ literalt cnft::land(literalt a, literalt b) return o; } -/*******************************************************************\ - -Function: cnft::lor - - Inputs: Two inputs to the OR gate - - Outputs: Output signal of the OR gate as literal - - Purpose: - -\*******************************************************************/ - +/// \par parameters: Two inputs to the OR gate +/// \return Output signal of the OR gate as literal literalt cnft::lor(literalt a, literalt b) { if(a.is_false() || b.is_true()) @@ -404,18 +291,8 @@ literalt cnft::lor(literalt a, literalt b) return o; } -/*******************************************************************\ - -Function: cnft::lxor - - Inputs: Two inputs to the XOR gate - - Outputs: Output signal of the XOR gate as literal - - Purpose: - -\*******************************************************************/ - +/// \par parameters: Two inputs to the XOR gate +/// \return Output signal of the XOR gate as literal literalt cnft::lxor(literalt a, literalt b) { if(a.is_false()) @@ -436,86 +313,30 @@ literalt cnft::lxor(literalt a, literalt b) return o; } -/*******************************************************************\ - -Function: cnft::lnand - - Inputs: Two inputs to the NAND gate - - Outputs: Output signal of the NAND gate as literal - - Purpose: - -\*******************************************************************/ - +/// \par parameters: Two inputs to the NAND gate +/// \return Output signal of the NAND gate as literal literalt cnft::lnand(literalt a, literalt b) { return !land(a, b); } -/*******************************************************************\ - -Function: cnft::lnor - - Inputs: Two inputs to the NOR gate - - Outputs: Output signal of the NOR gate as literal - - Purpose: - -\*******************************************************************/ - +/// \par parameters: Two inputs to the NOR gate +/// \return Output signal of the NOR gate as literal literalt cnft::lnor(literalt a, literalt b) { return !lor(a, b); } -/*******************************************************************\ - -Function: cnft::lequal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt cnft::lequal(literalt a, literalt b) { return !lxor(a, b); } -/*******************************************************************\ - -Function: cnft::limplies - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt cnft::limplies(literalt a, literalt b) { return lor(!a, b); } -/*******************************************************************\ - -Function: cnft::lselect - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - // Tino observed slow-downs up to 50% with OPTIMAL_COMPACT_ITE. #define COMPACT_ITE @@ -560,18 +381,8 @@ literalt cnft::lselect(literalt a, literalt b, literalt c) #endif } -/*******************************************************************\ - -Function: cnft::new_variable - - Inputs: - - Outputs: New variable as literal - - Purpose: Generate a new variable and return it as a literal - -\*******************************************************************/ - +/// Generate a new variable and return it as a literal +/// \return New variable as literal literalt cnft::new_variable() { literalt l; @@ -582,18 +393,9 @@ literalt cnft::new_variable() return l; } -/*******************************************************************\ - -Function: cnft::eliminate_duplicates - - Inputs: set of literals given as vector - - Outputs: set of literals, duplicates removed - - Purpose: eliminate duplicates from given vector of literals - -\*******************************************************************/ - +/// eliminate duplicates from given vector of literals +/// \par parameters: set of literals given as vector +/// \return set of literals, duplicates removed bvt cnft::eliminate_duplicates(const bvt &bv) { std::set s; @@ -608,19 +410,8 @@ bvt cnft::eliminate_duplicates(const bvt &bv) return dest; } -/*******************************************************************\ - -Function: cnft::process_clause - - Inputs: - - Outputs: - - Purpose: filter 'true' from clause, eliminate duplicates, - recognise trivially satisfied clauses - -\*******************************************************************/ - +/// filter 'true' from clause, eliminate duplicates, recognise trivially +/// satisfied clauses bool cnft::process_clause(const bvt &bv, bvt &dest) { dest.clear(); @@ -647,7 +438,7 @@ bool cnft::process_clause(const bvt &bv, bvt &dest) if(l.var_no()>=_no_variables) std::cout << "l.var_no()=" << l.var_no() - << " _no_variables=" << _no_variables << std::endl; + << " _no_variables=" << _no_variables << '\n'; assert(l.var_no()<_no_variables); } diff --git a/src/solvers/sat/cnf.h b/src/solvers/sat/cnf.h index 644d62999e4..236de673374 100644 --- a/src/solvers/sat/cnf.h +++ b/src/solvers/sat/cnf.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// CNF Generation, via Tseitin + #ifndef CPROVER_SOLVERS_SAT_CNF_H #define CPROVER_SOLVERS_SAT_CNF_H diff --git a/src/solvers/sat/cnf_clause_list.cpp b/src/solvers/sat/cnf_clause_list.cpp index 629a7363795..cb68ddad24b 100644 --- a/src/solvers/sat/cnf_clause_list.cpp +++ b/src/solvers/sat/cnf_clause_list.cpp @@ -6,23 +6,14 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// CNF Generation + #include #include #include "cnf_clause_list.h" -/*******************************************************************\ - -Function: cnf_clause_listt::lcnf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cnf_clause_listt::lcnf(const bvt &bv) { bvt new_bv; @@ -33,36 +24,12 @@ void cnf_clause_listt::lcnf(const bvt &bv) clauses.push_back(new_bv); } -/*******************************************************************\ - -Function: cnf_clause_list_assignmentt::print_assignment - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cnf_clause_list_assignmentt::print_assignment(std::ostream &out) const { for(unsigned v=1; v -/*******************************************************************\ - -Function: dimacs_cnft::dimacs_cnft - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - dimacs_cnft::dimacs_cnft():break_lines(false) { } -/*******************************************************************\ - -Function: dimacs_cnf_dumpt::dimacs_cnf_dumpt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - dimacs_cnf_dumpt::dimacs_cnf_dumpt(std::ostream &_out):out(_out) { } -/*******************************************************************\ - -Function: dimacs_cnft::write_dimacs_cnf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dimacs_cnft::write_dimacs_cnf(std::ostream &out) { write_problem_line(out); write_clauses(out); } -/*******************************************************************\ - -Function: dimacs_cnft::write_problem_line - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dimacs_cnft::write_problem_line(std::ostream &out) { // We start counting at 1, thus there is one variable fewer. @@ -79,18 +32,6 @@ void dimacs_cnft::write_problem_line(std::ostream &out) << clauses.size() << "\n"; } -/*******************************************************************\ - -Function: write_dimacs_clause - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static void write_dimacs_clause( const bvt &clause, std::ostream &out, @@ -117,18 +58,6 @@ static void write_dimacs_clause( out << "0" << "\n"; } -/*******************************************************************\ - -Function: dimacs_cnft::write_clauses - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dimacs_cnft::write_clauses(std::ostream &out) { for(clausest::const_iterator it=clauses.begin(); @@ -136,18 +65,6 @@ void dimacs_cnft::write_clauses(std::ostream &out) write_dimacs_clause(*it, out, break_lines); } -/*******************************************************************\ - -Function: dimacs_cnf_dumpt::lcnf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void dimacs_cnf_dumpt::lcnf(const bvt &bv) { write_dimacs_clause(bv, out, true); diff --git a/src/solvers/sat/dimacs_cnf.h b/src/solvers/sat/dimacs_cnf.h index de8763c4c29..302fee4e36b 100644 --- a/src/solvers/sat/dimacs_cnf.h +++ b/src/solvers/sat/dimacs_cnf.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_SAT_DIMACS_CNF_H #define CPROVER_SOLVERS_SAT_DIMACS_CNF_H diff --git a/src/solvers/sat/pbs_dimacs_cnf.cpp b/src/solvers/sat/pbs_dimacs_cnf.cpp index 5c45f8e0a09..d8bfa283398 100644 --- a/src/solvers/sat/pbs_dimacs_cnf.cpp +++ b/src/solvers/sat/pbs_dimacs_cnf.cpp @@ -6,6 +6,7 @@ Author: Alex Groce \*******************************************************************/ + #include #include #include @@ -13,18 +14,6 @@ Author: Alex Groce #include "pbs_dimacs_cnf.h" -/*******************************************************************\ - -Function: pbs_dimacs_cnft::write_dimacs_cnf_pb - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void pbs_dimacs_cnft::write_dimacs_pb(std::ostream &out) { double d_sum=0; @@ -64,18 +53,6 @@ void pbs_dimacs_cnft::write_dimacs_pb(std::ostream &out) // std::cout << "exit: No Lit.=" << no_variables () << "\n"; } -/*******************************************************************\ - -Function: pbs_dimacs_cnft::pbs_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool pbs_dimacs_cnft::pbs_solve() { // std::cout << "solve: No Lit.=" << no_variables () << "\n"; @@ -190,7 +167,8 @@ bool pbs_dimacs_cnft::pbs_solve() // print(line); if(strstr(line.c_str(), "time out")!=NULL) { - print(6, "WARNING: TIMED OUT. SOLUTION MAY BE INCORRECT.\n"); + status() << "WARNING: TIMED OUT. SOLUTION MAY BE INCORRECT." + << eom; return satisfied; } sscanf(line.c_str(), "%*s %*s %*s %d", &opt_sum); @@ -200,18 +178,6 @@ bool pbs_dimacs_cnft::pbs_solve() return satisfied; } -/*******************************************************************\ - -Function: pbs_dimacs_cnft::prop_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - propt::resultt pbs_dimacs_cnft::prop_solve() { std::ofstream file("temp.cnf"); @@ -252,18 +218,6 @@ propt::resultt pbs_dimacs_cnft::prop_solve() return resultt::P_UNSATISFIABLE; } -/*******************************************************************\ - -Function: pbs_dimacs_cnft::l_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - tvt pbs_dimacs_cnft::l_get(literalt a) const { int dimacs_lit=a.dimacs(); diff --git a/src/solvers/sat/pbs_dimacs_cnf.h b/src/solvers/sat/pbs_dimacs_cnf.h index 8d2b04bae24..f257746b8c4 100644 --- a/src/solvers/sat/pbs_dimacs_cnf.h +++ b/src/solvers/sat/pbs_dimacs_cnf.h @@ -6,6 +6,7 @@ Author: Alex Groce \*******************************************************************/ + #ifndef CPROVER_SOLVERS_SAT_PBS_DIMACS_CNF_H #define CPROVER_SOLVERS_SAT_PBS_DIMACS_CNF_H diff --git a/src/solvers/sat/read_dimacs_cnf.cpp b/src/solvers/sat/read_dimacs_cnf.cpp index 42e63a5e9e2..5a12e16b5ef 100644 --- a/src/solvers/sat/read_dimacs_cnf.cpp +++ b/src/solvers/sat/read_dimacs_cnf.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Reading DIMACS CNF + #include #include // for abs() @@ -15,18 +18,6 @@ Author: Daniel Kroening, kroening@kroening.com // #define VERBOSE -/*******************************************************************\ - -Function: cnft::read_dimacs_cnf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void read_dimacs_cnf(std::istream &in, cnft &dest) { #define DELIMITERS "\t\n\v\f\r " @@ -45,11 +36,11 @@ void read_dimacs_cnf(std::istream &in, cnft &dest) break; #ifdef VERBOSE - std::cout << "begin line " << line << std::endl; + std::cout << "begin line " << line << '\n'; #endif size_t pos = line.find_first_of(DELIMITERS, 0); #ifdef VERBOSE - std::cout << "pos " << pos << std::endl; + std::cout << "pos " << pos << '\n'; #endif size_t pos_char = line.find_first_of(CHAR_DELIMITERS, 0); @@ -59,13 +50,13 @@ void read_dimacs_cnf(std::istream &in, cnft &dest) line.erase(0, pos+1); #ifdef VERBOSE std::cout << "i am here\n"; - std::cout << decision << std::endl; - std::cout << "line" << line << std::endl; + std::cout << decision << '\n'; + std::cout << "line" << line << '\n'; #endif if(!decision.compare(std::string("c"))) { #ifdef VERBOSE - std::cout << "c " << std::endl; + std::cout << "c \n"; #endif break; } @@ -73,7 +64,7 @@ void read_dimacs_cnf(std::istream &in, cnft &dest) if(!decision.compare(std::string("p"))) { #ifdef VERBOSE - std::cout << "p " << std::endl; + std::cout << "p \n"; #endif break; } @@ -82,13 +73,13 @@ void read_dimacs_cnf(std::istream &in, cnft &dest) { int parsed_lit = unsafe_string2int(decision); #ifdef VERBOSE - std::cout << "parsed_lit " << parsed_lit << " " << std::endl; + std::cout << "parsed_lit " << parsed_lit << " \n"; #endif if(parsed_lit == 0) { bvt no_dup=cnft::eliminate_duplicates(new_bv); #ifdef VERBOSE - std::cout << "calling lcnf " << new_bv.size() << std::endl; + std::cout << "calling lcnf " << new_bv.size() << '\n'; #endif dest.lcnf(no_dup); new_bv.clear(); @@ -101,7 +92,7 @@ void read_dimacs_cnf(std::istream &in, cnft &dest) bool sign = (parsed_lit > 0) ? false : true; l.set(var, sign); #ifdef VERBOSE - std::cout << "setting l to " << l.get() << std::endl; + std::cout << "setting l to " << l.get() << '\n'; #endif new_bv.push_back(l); if(dest.no_variables() <= var) diff --git a/src/solvers/sat/read_dimacs_cnf.h b/src/solvers/sat/read_dimacs_cnf.h index 2a0c0cb3950..96bb752867a 100644 --- a/src/solvers/sat/read_dimacs_cnf.h +++ b/src/solvers/sat/read_dimacs_cnf.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Reading DIMACS CNF + #ifndef CPROVER_SOLVERS_SAT_READ_DIMACS_CNF_H #define CPROVER_SOLVERS_SAT_READ_DIMACS_CNF_H diff --git a/src/solvers/sat/resolution_proof.cpp b/src/solvers/sat/resolution_proof.cpp index 20c10498a96..061e9d2cf15 100644 --- a/src/solvers/sat/resolution_proof.cpp +++ b/src/solvers/sat/resolution_proof.cpp @@ -6,23 +6,12 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include "resolution_proof.h" -/*******************************************************************\ - -Function: resolution_prooft::build_core - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void resolution_prooft::build_core(std::vector &in_core) { diff --git a/src/solvers/sat/resolution_proof.h b/src/solvers/sat/resolution_proof.h index dc810620aaf..04ceb489a12 100644 --- a/src/solvers/sat/resolution_proof.h +++ b/src/solvers/sat/resolution_proof.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_SAT_RESOLUTION_PROOF_H #define CPROVER_SOLVERS_SAT_RESOLUTION_PROOF_H diff --git a/src/solvers/sat/satcheck.cpp b/src/solvers/sat/satcheck.cpp index 48daf8f6399..27cdb5d79a6 100644 --- a/src/solvers/sat/satcheck.cpp +++ b/src/solvers/sat/satcheck.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include "satcheck.h" // Sanity check diff --git a/src/solvers/sat/satcheck.h b/src/solvers/sat/satcheck.h index 19fc7759f69..ada65d253e8 100644 --- a/src/solvers/sat/satcheck.h +++ b/src/solvers/sat/satcheck.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_SAT_SATCHECK_H #define CPROVER_SOLVERS_SAT_SATCHECK_H diff --git a/src/solvers/sat/satcheck_booleforce.cpp b/src/solvers/sat/satcheck_booleforce.cpp index 16a23f152f9..51e8684a2f2 100644 --- a/src/solvers/sat/satcheck_booleforce.cpp +++ b/src/solvers/sat/satcheck_booleforce.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include @@ -16,69 +17,21 @@ extern "C" #include "booleforce.h" } -/*******************************************************************\ - -Function: satcheck_booleforcet::satcheck_booleforcet - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - satcheck_booleforcet::satcheck_booleforcet() { booleforce_set_trace(false); } -/*******************************************************************\ - -Function: satcheck_booleforce_coret::satcheck_booleforce_coret - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - satcheck_booleforce_coret::satcheck_booleforce_coret() { booleforce_set_trace(true); } -/*******************************************************************\ - -Function: satcheck_booleforce_baset::~satcheck_booleforce_baset - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - satcheck_booleforce_baset::~satcheck_booleforce_baset() { booleforce_reset(); } -/*******************************************************************\ - -Function: satcheck_booleforce_baset::l_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - tvt satcheck_booleforce_baset::l_get(literalt a) const { assert(status==SAT); @@ -108,35 +61,11 @@ tvt satcheck_booleforce_baset::l_get(literalt a) const return result; } -/*******************************************************************\ - -Function: satcheck_booleforce_Baset::solver_text - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const std::string satcheck_booleforce_baset::solver_text() { return std::string("Booleforce version ")+booleforce_version(); } -/*******************************************************************\ - -Function: satcheck_booleforce_baset::lcnf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void satcheck_booleforce_baset::lcnf(const bvt &bv) { bvt tmp; @@ -153,18 +82,6 @@ void satcheck_booleforce_baset::lcnf(const bvt &bv) clause_counter++; } -/*******************************************************************\ - -Function: satcheck_booleforce_baset::prop_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - propt::resultt satcheck_booleforce_baset::prop_solve() { assert(status==SAT || status==INIT); @@ -209,18 +126,6 @@ propt::resultt satcheck_booleforce_baset::prop_solve() return P_ERROR; } -/*******************************************************************\ - -Function: satcheck_booleforce_coret::in_core - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool satcheck_booleforce_coret::is_in_core(literalt l) const { return booleforce_var_in_core(l.var_no()); diff --git a/src/solvers/sat/satcheck_booleforce.h b/src/solvers/sat/satcheck_booleforce.h index 6dd3ac69ffd..e52dc1b0883 100644 --- a/src/solvers/sat/satcheck_booleforce.h +++ b/src/solvers/sat/satcheck_booleforce.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_SAT_SATCHECK_BOOLEFORCE_H #define CPROVER_SOLVERS_SAT_SATCHECK_BOOLEFORCE_H diff --git a/src/solvers/sat/satcheck_core.h b/src/solvers/sat/satcheck_core.h index 65ad61bab83..17b44c79402 100644 --- a/src/solvers/sat/satcheck_core.h +++ b/src/solvers/sat/satcheck_core.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_SAT_SATCHECK_CORE_H #define CPROVER_SOLVERS_SAT_SATCHECK_CORE_H diff --git a/src/solvers/sat/satcheck_glucose.cpp b/src/solvers/sat/satcheck_glucose.cpp index 152716d8157..adcfbded617 100644 --- a/src/solvers/sat/satcheck_glucose.cpp +++ b/src/solvers/sat/satcheck_glucose.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef _MSC_VER #include #endif @@ -24,18 +25,6 @@ Author: Daniel Kroening, kroening@kroening.com #error "Expected HAVE_GLUCOSE" #endif -/*******************************************************************\ - -Function: convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void convert(const bvt &bv, Glucose::vec &dest) { dest.capacity(bv.size()); @@ -45,18 +34,6 @@ void convert(const bvt &bv, Glucose::vec &dest) dest.push(Glucose::mkLit(it->var_no(), it->sign())); } -/*******************************************************************\ - -Function: satcheck_glucose_baset::l_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template tvt satcheck_glucose_baset::l_get(literalt a) const { @@ -85,18 +62,6 @@ tvt satcheck_glucose_baset::l_get(literalt a) const return result; } -/*******************************************************************\ - -Function: satcheck_glucose_baset::set_polarity - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void satcheck_glucose_baset::set_polarity(literalt a, bool value) { @@ -105,52 +70,16 @@ void satcheck_glucose_baset::set_polarity(literalt a, bool value) solver->setPolarity(a.var_no(), value); } -/*******************************************************************\ - -Function: satcheck_glucose_no_simplifiert::solver_text - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const std::string satcheck_glucose_no_simplifiert::solver_text() { return "Glucose Syrup without simplifier"; } -/*******************************************************************\ - -Function: satcheck_glucose_simplifiert::solver_text - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const std::string satcheck_glucose_simplifiert::solver_text() { return "Glucose Syrup with simplifier"; } -/*******************************************************************\ - -Function: satcheck_glucose_baset::add_variables - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void satcheck_glucose_baset::add_variables() { @@ -158,18 +87,6 @@ void satcheck_glucose_baset::add_variables() solver->newVar(); } -/*******************************************************************\ - -Function: satcheck_glucose_baset::lcnf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void satcheck_glucose_baset::lcnf(const bvt &bv) { @@ -195,18 +112,6 @@ void satcheck_glucose_baset::lcnf(const bvt &bv) clause_counter++; } -/*******************************************************************\ - -Function: satcheck_glucose_baset::prop_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template propt::resultt satcheck_glucose_baset::prop_solve() { @@ -265,18 +170,6 @@ propt::resultt satcheck_glucose_baset::prop_solve() return P_UNSATISFIABLE; } -/*******************************************************************\ - -Function: satcheck_glucose_baset::set_assignment - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void satcheck_glucose_baset::set_assignment(literalt a, bool value) { @@ -291,36 +184,12 @@ void satcheck_glucose_baset::set_assignment(literalt a, bool value) solver->model[v]=Glucose::lbool(value); } -/*******************************************************************\ - -Function: satcheck_glucose_baset::satcheck_glucose_baset - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template satcheck_glucose_baset::satcheck_glucose_baset(T *_solver): solver(_solver) { } -/*******************************************************************\ - -Function: satcheck_glucose_baset::~satcheck_glucose_baset - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template<> satcheck_glucose_baset::~satcheck_glucose_baset() { @@ -333,18 +202,6 @@ satcheck_glucose_baset::~satcheck_glucose_baset() delete solver; } -/*******************************************************************\ - -Function: satcheck_glucose_baset::is_in_conflict - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template bool satcheck_glucose_baset::is_in_conflict(literalt a) const { @@ -357,18 +214,6 @@ bool satcheck_glucose_baset::is_in_conflict(literalt a) const return false; } -/*******************************************************************\ - -Function: satcheck_glucose_baset::set_assumptions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void satcheck_glucose_baset::set_assumptions(const bvt &bv) { @@ -378,52 +223,16 @@ void satcheck_glucose_baset::set_assumptions(const bvt &bv) assert(!it->is_constant()); } -/*******************************************************************\ - -Function: satcheck_glucose_no_simplifiert::satcheck_glucose_no_simplifiert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - satcheck_glucose_no_simplifiert::satcheck_glucose_no_simplifiert(): satcheck_glucose_baset(new Glucose::Solver) { } -/*******************************************************************\ - -Function: satcheck_glucose_simplifiert::satcheck_glucose_simplifiert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - satcheck_glucose_simplifiert::satcheck_glucose_simplifiert(): satcheck_glucose_baset(new Glucose::SimpSolver) { } -/*******************************************************************\ - -Function: satcheck_glucose_simplifiert::set_frozen - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void satcheck_glucose_simplifiert::set_frozen(literalt a) { if(!a.is_constant()) @@ -433,18 +242,6 @@ void satcheck_glucose_simplifiert::set_frozen(literalt a) } } -/*******************************************************************\ - -Function: satcheck_glucose_simplifiert::is_eliminated - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool satcheck_glucose_simplifiert::is_eliminated(literalt a) const { assert(!a.is_constant()); diff --git a/src/solvers/sat/satcheck_glucose.h b/src/solvers/sat/satcheck_glucose.h index 100a514e601..8f849630db5 100644 --- a/src/solvers/sat/satcheck_glucose.h +++ b/src/solvers/sat/satcheck_glucose.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_SAT_SATCHECK_GLUCOSE_H #define CPROVER_SOLVERS_SAT_SATCHECK_GLUCOSE_H diff --git a/src/solvers/sat/satcheck_limmat.cpp b/src/solvers/sat/satcheck_limmat.cpp index a8393cf30e8..1ff47403ec4 100644 --- a/src/solvers/sat/satcheck_limmat.cpp +++ b/src/solvers/sat/satcheck_limmat.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include @@ -16,53 +17,17 @@ extern "C" #include "limmat.h" } -/*******************************************************************\ - -Function: satcheck_limmatt::satcheck_limmatt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - satcheck_limmatt::satcheck_limmatt() { solver=new_Limmat(NULL); } -/*******************************************************************\ - -Function: satcheck_limmatt::~satcheck_limmatt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - satcheck_limmatt::~satcheck_limmatt() { if(solver!=NULL) delete_Limmat(solver); } -/*******************************************************************\ - -Function: satcheck_limmatt::l_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - tvt satcheck_limmatt::l_get(literalt a) const { if(a.is_true()) @@ -88,35 +53,11 @@ tvt satcheck_limmatt::l_get(literalt a) const return result; } -/*******************************************************************\ - -Function: satcheck_limmatt::solver_text - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const std::string satcheck_limmatt::solver_text() { return std::string("Limmat version ")+version_Limmat(); } -/*******************************************************************\ - -Function: satcheck_limmatt::copy_cnf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void satcheck_limmatt::copy_cnf() { for(clausest::iterator it=clauses.begin(); @@ -138,18 +79,6 @@ void satcheck_limmatt::copy_cnf() } } -/*******************************************************************\ - -Function: satcheck_limmatt::prop_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - propt::resultt satcheck_limmatt::prop_solve() { copy_cnf(); diff --git a/src/solvers/sat/satcheck_limmat.h b/src/solvers/sat/satcheck_limmat.h index 1ef88177176..91e8e3d9df8 100644 --- a/src/solvers/sat/satcheck_limmat.h +++ b/src/solvers/sat/satcheck_limmat.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_SAT_SATCHECK_LIMMAT_H #define CPROVER_SOLVERS_SAT_SATCHECK_LIMMAT_H diff --git a/src/solvers/sat/satcheck_lingeling.cpp b/src/solvers/sat/satcheck_lingeling.cpp index 18237a903ab..8d74a7706a5 100644 --- a/src/solvers/sat/satcheck_lingeling.cpp +++ b/src/solvers/sat/satcheck_lingeling.cpp @@ -6,6 +6,7 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk \*******************************************************************/ + #include #include @@ -21,18 +22,6 @@ extern "C" #error "Expected HAVE_LINGELING" #endif -/*******************************************************************\ - -Function: satcheck_lingelingt::l_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - tvt satcheck_lingelingt::l_get(literalt a) const { if(a.is_constant()) @@ -54,35 +43,11 @@ tvt satcheck_lingelingt::l_get(literalt a) const return result; } -/*******************************************************************\ - -Function: satcheck_lingelingt::solver_text - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const std::string satcheck_lingelingt::solver_text() { return "Lingeling"; } -/*******************************************************************\ - -Function: satcheck_lingelingt::lcnf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void satcheck_lingelingt::lcnf(const bvt &bv) { bvt new_bv; @@ -98,18 +63,6 @@ void satcheck_lingelingt::lcnf(const bvt &bv) clause_counter++; } -/*******************************************************************\ - -Function: satcheck_lingelingt::prop_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - propt::resultt satcheck_lingelingt::prop_solve() { assert(status!=ERROR); @@ -146,70 +99,22 @@ propt::resultt satcheck_lingelingt::prop_solve() return P_UNSATISFIABLE; } -/*******************************************************************\ - -Function: satcheck_lingelingt::set_assignment - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void satcheck_lingelingt::set_assignment(literalt a, bool value) { assert(false); } -/*******************************************************************\ - -Function: satcheck_lingelingt::satcheck_lingelingt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - satcheck_lingelingt::satcheck_lingelingt() : solver(lglinit()) { } -/*******************************************************************\ - -Function: satcheck_lingelingt::satcheck_lingelingt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - satcheck_lingelingt::~satcheck_lingelingt() { lglrelease(solver); solver=0; } -/*******************************************************************\ - -Function: satcheck_lingelingt::set_assumptions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void satcheck_lingelingt::set_assumptions(const bvt &bv) { assumptions=bv; @@ -218,40 +123,16 @@ void satcheck_lingelingt::set_assumptions(const bvt &bv) assert(!it->is_constant()); } -/*******************************************************************\ - -Function: satcheck_lingelingt::set_frozen - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void satcheck_lingelingt::set_frozen(literalt a) { if(!a.is_constant()) lglfreeze(solver, a.dimacs()); } -/*******************************************************************\ - -Function: satcheck_lingelingt::is_in_conflict - - Inputs: - - Outputs: - - Purpose: Returns true if an assumed literal is in conflict if the - formula is UNSAT. - - NOTE: if the literal is not in the assumption it causes an - assertion failure in lingeling. - -\*******************************************************************/ - +/// Returns true if an assumed literal is in conflict if the formula is UNSAT. +/// +/// NOTE: if the literal is not in the assumption it causes an +/// assertion failure in lingeling. bool satcheck_lingelingt::is_in_conflict(literalt a) const { assert(!a.is_constant()); diff --git a/src/solvers/sat/satcheck_lingeling.h b/src/solvers/sat/satcheck_lingeling.h index bc9a9198f77..ddc9388407c 100644 --- a/src/solvers/sat/satcheck_lingeling.h +++ b/src/solvers/sat/satcheck_lingeling.h @@ -6,6 +6,7 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk \*******************************************************************/ + #ifndef CPROVER_SOLVERS_SAT_SATCHECK_LINGELING_H #define CPROVER_SOLVERS_SAT_SATCHECK_LINGELING_H diff --git a/src/solvers/sat/satcheck_minisat.cpp b/src/solvers/sat/satcheck_minisat.cpp index b615d04e112..4e61f2d33da 100644 --- a/src/solvers/sat/satcheck_minisat.cpp +++ b/src/solvers/sat/satcheck_minisat.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -20,18 +21,6 @@ Author: Daniel Kroening, kroening@kroening.com #error "Expected HAVE_MINISAT" #endif -/*******************************************************************\ - -Function: convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void convert(const bvt &bv, vec &dest) { dest.growTo(bv.size()); @@ -40,14 +29,6 @@ void convert(const bvt &bv, vec &dest) dest[i]=Lit(bv[i].var_no(), bv[i].sign()); } -/*******************************************************************\ - - Class: minisat_prooft - - Purpose: - -\*******************************************************************/ - class minisat_prooft:public ProofTraverser { public: @@ -76,18 +57,6 @@ class minisat_prooft:public ProofTraverser simple_prooft resolution_proof; }; -/*******************************************************************\ - -Function: minisat_prooft::chain - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void minisat_prooft::chain(const vec &cs, const vec &xs) { assert(cs.size()==xs.size()+1); @@ -112,18 +81,6 @@ void minisat_prooft::chain(const vec &cs, const vec &xs) } } -/*******************************************************************\ - -Function: satcheck_minisat1_baset::l_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - tvt satcheck_minisat1_baset::l_get(literalt a) const { if(a.is_true()) @@ -149,53 +106,17 @@ tvt satcheck_minisat1_baset::l_get(literalt a) const return result; } -/*******************************************************************\ - -Function: satcheck_minisat1_baset::solver_text - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const std::string satcheck_minisat1_baset::solver_text() { return "MiniSAT 1.14p"; } -/*******************************************************************\ - -Function: satcheck_minisat1_baset::add_variables - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void satcheck_minisat1_baset::add_variables() { while((unsigned)solver->nVars()newVar(); } -/*******************************************************************\ - -Function: satcheck_minisat1_baset::lcnf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void satcheck_minisat1_baset::lcnf(const bvt &bv) { bvt new_bv; @@ -223,18 +144,6 @@ void satcheck_minisat1_baset::lcnf(const bvt &bv) clause_counter++; } -/*******************************************************************\ - -Function: satcheck_minisat1_baset::prop_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - propt::resultt satcheck_minisat1_baset::prop_solve() { assert(status!=ERROR); @@ -280,18 +189,6 @@ propt::resultt satcheck_minisat1_baset::prop_solve() return P_UNSATISFIABLE; } -/*******************************************************************\ - -Function: satcheck_minisat1_baset::set_assignment - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void satcheck_minisat1_baset::set_assignment(literalt a, bool value) { unsigned v=a.var_no(); @@ -301,18 +198,6 @@ void satcheck_minisat1_baset::set_assignment(literalt a, bool value) solver->model[v]=lbool(value); } -/*******************************************************************\ - -Function: satcheck_minisat1_baset::is_in_conflict - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool satcheck_minisat1_baset::is_in_conflict(literalt a) const { int v=a.var_no(); @@ -326,18 +211,6 @@ bool satcheck_minisat1_baset::is_in_conflict(literalt a) const return false; } -/*******************************************************************\ - -Function: satcheck_minisat1_baset::set_assumptions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void satcheck_minisat1_baset::set_assumptions(const bvt &bv) { assumptions=bv; @@ -348,36 +221,12 @@ void satcheck_minisat1_baset::set_assumptions(const bvt &bv) assert(!it->is_constant()); } -/*******************************************************************\ - -Function: satcheck_minisat1t::satcheck_minisat1t - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - satcheck_minisat1t::satcheck_minisat1t() { empty_clause_added=false; solver=new Solver; } -/*******************************************************************\ - -Function: satcheck_minisat1_prooft::satcheck_minisat1_prooft - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - satcheck_minisat1_prooft::satcheck_minisat1_prooft():satcheck_minisat1t() { minisat_proof=new minisat_prooft; @@ -386,102 +235,30 @@ satcheck_minisat1_prooft::satcheck_minisat1_prooft():satcheck_minisat1t() solver->proof=proof; } -/*******************************************************************\ - -Function: satcheck_minisat1_prooft::~satcheck_minisat1_prooft - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - satcheck_minisat1_prooft::~satcheck_minisat1_prooft() { delete proof; delete minisat_proof; } -/*******************************************************************\ - -Function: satcheck_minisat1_coret::satcheck_minisat1_coret - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - satcheck_minisat1_coret::satcheck_minisat1_coret() { } -/*******************************************************************\ - -Function: satcheck_minisat1_coret::~satcheck_minisat1_coret - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - satcheck_minisat1_coret::~satcheck_minisat1_coret() { } -/*******************************************************************\ - -Function: satcheck_minisat1_baset::~satcheck_minisat1_baset - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - satcheck_minisat1_baset::~satcheck_minisat1_baset() { delete solver; } -/*******************************************************************\ - -Function: satcheck_minisat1_prooft::solver_text - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const std::string satcheck_minisat1_prooft::solver_text() { return "MiniSAT + Proof"; } -/*******************************************************************\ - -Function: satcheck_minisat1_coret::prop_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - propt::resultt satcheck_minisat1_coret::prop_solve() { propt::resultt r; @@ -497,35 +274,11 @@ propt::resultt satcheck_minisat1_coret::prop_solve() return r; } -/*******************************************************************\ - -Function: satcheck_minisat1_coret::solver_text - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const std::string satcheck_minisat1_coret::solver_text() { return "MiniSAT + Core"; } -/*******************************************************************\ - -Function: satcheck_minisat1_prooft::get_resolution_proof - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - simple_prooft &satcheck_minisat1_prooft::get_resolution_proof() { return minisat_proof->resolution_proof; diff --git a/src/solvers/sat/satcheck_minisat.h b/src/solvers/sat/satcheck_minisat.h index 3924d26b816..88dbe864a4e 100644 --- a/src/solvers/sat/satcheck_minisat.h +++ b/src/solvers/sat/satcheck_minisat.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_SAT_SATCHECK_MINISAT_H #define CPROVER_SOLVERS_SAT_SATCHECK_MINISAT_H diff --git a/src/solvers/sat/satcheck_minisat2.cpp b/src/solvers/sat/satcheck_minisat2.cpp index eaccd29db64..cab952930f6 100644 --- a/src/solvers/sat/satcheck_minisat2.cpp +++ b/src/solvers/sat/satcheck_minisat2.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef _MSC_VER #include #endif @@ -24,18 +25,6 @@ Author: Daniel Kroening, kroening@kroening.com #error "Expected HAVE_MINISAT2" #endif -/*******************************************************************\ - -Function: convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void convert(const bvt &bv, Minisat::vec &dest) { dest.capacity(bv.size()); @@ -45,18 +34,6 @@ void convert(const bvt &bv, Minisat::vec &dest) dest.push(Minisat::mkLit(it->var_no(), it->sign())); } -/*******************************************************************\ - -Function: satcheck_minisat2_baset::l_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template tvt satcheck_minisat2_baset::l_get(literalt a) const { @@ -85,18 +62,6 @@ tvt satcheck_minisat2_baset::l_get(literalt a) const return result; } -/*******************************************************************\ - -Function: satcheck_minisat2_baset::set_polarity - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void satcheck_minisat2_baset::set_polarity(literalt a, bool value) { @@ -105,52 +70,16 @@ void satcheck_minisat2_baset::set_polarity(literalt a, bool value) solver->setPolarity(a.var_no(), value); } -/*******************************************************************\ - -Function: satcheck_minisat_no_simplifiert::solver_text - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const std::string satcheck_minisat_no_simplifiert::solver_text() { return "MiniSAT 2.2.1 without simplifier"; } -/*******************************************************************\ - -Function: satcheck_minisat_simplifiert::solver_text - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const std::string satcheck_minisat_simplifiert::solver_text() { return "MiniSAT 2.2.1 with simplifier"; } -/*******************************************************************\ - -Function: satcheck_minisat2_baset::add_variables - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void satcheck_minisat2_baset::add_variables() { @@ -158,18 +87,6 @@ void satcheck_minisat2_baset::add_variables() solver->newVar(); } -/*******************************************************************\ - -Function: satcheck_minisat2_baset::lcnf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void satcheck_minisat2_baset::lcnf(const bvt &bv) { @@ -195,18 +112,6 @@ void satcheck_minisat2_baset::lcnf(const bvt &bv) clause_counter++; } -/*******************************************************************\ - -Function: satcheck_minisat2_baset::prop_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template propt::resultt satcheck_minisat2_baset::prop_solve() { @@ -274,18 +179,6 @@ propt::resultt satcheck_minisat2_baset::prop_solve() } } -/*******************************************************************\ - -Function: satcheck_minisat2_baset::set_assignment - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void satcheck_minisat2_baset::set_assignment(literalt a, bool value) { @@ -300,36 +193,12 @@ void satcheck_minisat2_baset::set_assignment(literalt a, bool value) solver->model[v]=Minisat::lbool(value); } -/*******************************************************************\ - -Function: satcheck_minisat2_baset::satcheck_minisat2_baset - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template satcheck_minisat2_baset::satcheck_minisat2_baset(T *_solver): solver(_solver) { } -/*******************************************************************\ - -Function: satcheck_minisat2_baset::~satcheck_minisat2_baset - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template<> satcheck_minisat2_baset::~satcheck_minisat2_baset() { @@ -342,18 +211,6 @@ satcheck_minisat2_baset::~satcheck_minisat2_baset() delete solver; } -/*******************************************************************\ - -Function: satcheck_minisat2_baset::is_in_conflict - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template bool satcheck_minisat2_baset::is_in_conflict(literalt a) const { @@ -366,18 +223,6 @@ bool satcheck_minisat2_baset::is_in_conflict(literalt a) const return false; } -/*******************************************************************\ - -Function: satcheck_minisat2_baset::set_assumptions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void satcheck_minisat2_baset::set_assumptions(const bvt &bv) { @@ -391,52 +236,16 @@ void satcheck_minisat2_baset::set_assumptions(const bvt &bv) } } -/*******************************************************************\ - -Function: satcheck_minisat_no_simplifiert::satcheck_minisat_no_simplifiert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - satcheck_minisat_no_simplifiert::satcheck_minisat_no_simplifiert(): satcheck_minisat2_baset(new Minisat::Solver) { } -/*******************************************************************\ - -Function: satcheck_minisat_simplifiert::satcheck_minisat_simplifiert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - satcheck_minisat_simplifiert::satcheck_minisat_simplifiert(): satcheck_minisat2_baset(new Minisat::SimpSolver) { } -/*******************************************************************\ - -Function: satcheck_minisat_simplifiert::set_frozen - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void satcheck_minisat_simplifiert::set_frozen(literalt a) { if(!a.is_constant()) @@ -446,18 +255,6 @@ void satcheck_minisat_simplifiert::set_frozen(literalt a) } } -/*******************************************************************\ - -Function: satcheck_minisat_simplifiert::is_eliminated - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool satcheck_minisat_simplifiert::is_eliminated(literalt a) const { assert(!a.is_constant()); diff --git a/src/solvers/sat/satcheck_minisat2.h b/src/solvers/sat/satcheck_minisat2.h index f31018d7125..22026e27d85 100644 --- a/src/solvers/sat/satcheck_minisat2.h +++ b/src/solvers/sat/satcheck_minisat2.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_SAT_SATCHECK_MINISAT2_H #define CPROVER_SOLVERS_SAT_SATCHECK_MINISAT2_H diff --git a/src/solvers/sat/satcheck_picosat.cpp b/src/solvers/sat/satcheck_picosat.cpp index 7c3417592a3..6c69d0ab0b5 100644 --- a/src/solvers/sat/satcheck_picosat.cpp +++ b/src/solvers/sat/satcheck_picosat.cpp @@ -6,6 +6,7 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk \*******************************************************************/ + #include #include @@ -21,18 +22,6 @@ extern "C" #error "Expected HAVE_PICOSAT" #endif -/*******************************************************************\ - -Function: satcheck_picosatt::l_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - tvt satcheck_picosatt::l_get(literalt a) const { if(a.is_constant()) @@ -54,35 +43,11 @@ tvt satcheck_picosatt::l_get(literalt a) const return result; } -/*******************************************************************\ - -Function: satcheck_picosatt::solver_text - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const std::string satcheck_picosatt::solver_text() { return "PicoSAT"; } -/*******************************************************************\ - -Function: satcheck_picosatt::lcnf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void satcheck_picosatt::lcnf(const bvt &bv) { bvt new_bv; @@ -100,18 +65,6 @@ void satcheck_picosatt::lcnf(const bvt &bv) clause_counter++; } -/*******************************************************************\ - -Function: satcheck_picosatt::prop_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - propt::resultt satcheck_picosatt::prop_solve() { assert(status!=ERROR); @@ -147,69 +100,21 @@ propt::resultt satcheck_picosatt::prop_solve() return P_UNSATISFIABLE; } -/*******************************************************************\ - -Function: satcheck_picosatt::set_assignment - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void satcheck_picosatt::set_assignment(literalt a, bool value) { assert(false); } -/*******************************************************************\ - -Function: satcheck_picosatt::satcheck_picosatt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - satcheck_picosatt::satcheck_picosatt() { picosat = picosat_init(); } -/*******************************************************************\ - -Function: satcheck_picosatt::~satcheck_picosatt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - satcheck_picosatt::~satcheck_picosatt() { picosat_reset(picosat); } -/*******************************************************************\ - -Function: satcheck_picosatt::is_in_conflict - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool satcheck_picosatt::is_in_conflict(literalt a) const { assert(!a.is_constant()); @@ -217,18 +122,6 @@ bool satcheck_picosatt::is_in_conflict(literalt a) const return picosat_failed_assumption(picosat, a.dimacs())!=0; } -/*******************************************************************\ - -Function: satcheck_picosatt::set_assumptions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void satcheck_picosatt::set_assumptions(const bvt &bv) { assumptions=bv; diff --git a/src/solvers/sat/satcheck_picosat.h b/src/solvers/sat/satcheck_picosat.h index 43e4b7f356d..5380c186ee9 100644 --- a/src/solvers/sat/satcheck_picosat.h +++ b/src/solvers/sat/satcheck_picosat.h @@ -6,6 +6,7 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk \*******************************************************************/ + #ifndef CPROVER_SOLVERS_SAT_SATCHECK_PICOSAT_H #define CPROVER_SOLVERS_SAT_SATCHECK_PICOSAT_H diff --git a/src/solvers/sat/satcheck_precosat.cpp b/src/solvers/sat/satcheck_precosat.cpp index 7589d085678..ec60b64927c 100644 --- a/src/solvers/sat/satcheck_precosat.cpp +++ b/src/solvers/sat/satcheck_precosat.cpp @@ -6,6 +6,7 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk \*******************************************************************/ + #include #include @@ -20,18 +21,6 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk #define precosat_lit(a) ((a).var_no()*2 + !(a).sign()) -/*******************************************************************\ - -Function: satcheck_precosatt::l_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - tvt satcheck_precosatt::l_get(literalt a) const { if(a.is_constant()) @@ -53,35 +42,11 @@ tvt satcheck_precosatt::l_get(literalt a) const return result; } -/*******************************************************************\ - -Function: satcheck_precosatt::solver_text - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const std::string satcheck_precosatt::solver_text() { return "PrecoSAT"; } -/*******************************************************************\ - -Function: satcheck_precosatt::lcnf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void satcheck_precosatt::lcnf(const bvt &bv) { bvt new_bv; @@ -97,18 +62,6 @@ void satcheck_precosatt::lcnf(const bvt &bv) clause_counter++; } -/*******************************************************************\ - -Function: satcheck_precosatt::prop_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - propt::resultt satcheck_precosatt::prop_solve() { assert(status!=ERROR); @@ -142,70 +95,22 @@ propt::resultt satcheck_precosatt::prop_solve() return P_UNSATISFIABLE; } -/*******************************************************************\ - -Function: satcheck_precosatt::set_assignment - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void satcheck_precosatt::set_assignment(literalt a, bool value) { assert(false); } -/*******************************************************************\ - -Function: satcheck_precosatt::satcheck_precosatt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - satcheck_precosatt::satcheck_precosatt() : solver(new PrecoSat::Solver()) { solver->init(); } -/*******************************************************************\ - -Function: satcheck_precosatt::~satcheck_precosatt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - satcheck_precosatt::~satcheck_precosatt() { delete solver; } -/*******************************************************************\ - -Function: satcheck_precosatt::set_assumptions - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - /* void satcheck_precosatt::set_assumptions(const bvt &bv) { diff --git a/src/solvers/sat/satcheck_precosat.h b/src/solvers/sat/satcheck_precosat.h index c2cf053ac49..78caad55d7d 100644 --- a/src/solvers/sat/satcheck_precosat.h +++ b/src/solvers/sat/satcheck_precosat.h @@ -6,6 +6,7 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk \*******************************************************************/ + #ifndef CPROVER_SOLVERS_SAT_SATCHECK_PRECOSAT_H #define CPROVER_SOLVERS_SAT_SATCHECK_PRECOSAT_H diff --git a/src/solvers/sat/satcheck_smvsat.cpp b/src/solvers/sat/satcheck_smvsat.cpp index 8064900735d..21c9f8b5160 100644 --- a/src/solvers/sat/satcheck_smvsat.cpp +++ b/src/solvers/sat/satcheck_smvsat.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -15,18 +16,6 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -/*******************************************************************\ - -Function: satcheck_smvsatt::satcheck_smvsatt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - satcheck_smvsatt::satcheck_smvsatt() { satsolver= @@ -36,50 +25,14 @@ satcheck_smvsatt::satcheck_smvsatt() init_const(); } -/*******************************************************************\ - -Function: satcheck_smvsat_coret::satcheck_smvsat_coret - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - satcheck_smvsat_coret::satcheck_smvsat_coret() { } -/*******************************************************************\ - -Function: satcheck_smvsatt::~satcheck_smvsatt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - satcheck_smvsatt::~satcheck_smvsatt() { } -/*******************************************************************\ - -Function: satcheck_smvsatt::l_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - tvt satcheck_smvsatt::l_get(literalt a) const { assert(status==SAT); @@ -105,35 +58,11 @@ tvt satcheck_smvsatt::l_get(literalt a) const return result; } -/*******************************************************************\ - -Function: satcheck_smvsatt::solver_text - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const std::string satcheck_smvsatt::solver_text() { return std::string("SMVSAT"); } -/*******************************************************************\ - -Function: satcheck_smvsatt::lcnf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void satcheck_smvsatt::lcnf(const bvt &bv) { bvt tmp; @@ -156,18 +85,6 @@ void satcheck_smvsatt::lcnf(const bvt &bv) delete[] lits; } -/*******************************************************************\ - -Function: satcheck_smvsatt::prop_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - propt::resultt satcheck_smvsatt::prop_solve() { int result=sat_instance_solve(satsolver); @@ -210,18 +127,6 @@ propt::resultt satcheck_smvsatt::prop_solve() return P_ERROR; } -/*******************************************************************\ - -Function: satcheck_smvsat_coret::prop_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - propt::resultt satcheck_smvsat_coret::prop_solve() { propt::resultt result=satcheck_smvsatt::prop_solve(); @@ -234,18 +139,6 @@ propt::resultt satcheck_smvsat_coret::prop_solve() return result; } -/*******************************************************************\ - -Function: satcheck_smvsat_interpolatort::lcnf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void satcheck_smvsat_interpolatort::lcnf(const bvt &bv) { bvt tmp; @@ -271,18 +164,6 @@ void satcheck_smvsat_interpolatort::lcnf(const bvt &bv) delete[] lits; } -/*******************************************************************\ - -Function: satcheck_smvsat_interpolatort::interpolate - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void satcheck_smvsat_interpolatort::interpolate(exprt &dest) { // crate instance @@ -307,18 +188,6 @@ void satcheck_smvsat_interpolatort::interpolate(exprt &dest) delete interpolator_satsolver; } -/*******************************************************************\ - -Function: satcheck_smvsat_interpolatort::build_aig - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void satcheck_smvsat_interpolatort::build_aig( // NOLINTNEXTLINE(readability/identifiers) struct interpolator &interpolator_satsolver, diff --git a/src/solvers/sat/satcheck_smvsat.h b/src/solvers/sat/satcheck_smvsat.h index fa347ca2fad..c9d13c1d000 100644 --- a/src/solvers/sat/satcheck_smvsat.h +++ b/src/solvers/sat/satcheck_smvsat.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_SAT_SATCHECK_SMVSAT_H #define CPROVER_SOLVERS_SAT_SATCHECK_SMVSAT_H diff --git a/src/solvers/sat/satcheck_zchaff.cpp b/src/solvers/sat/satcheck_zchaff.cpp index 6697d6b3c6c..548bb04ff8b 100644 --- a/src/solvers/sat/satcheck_zchaff.cpp +++ b/src/solvers/sat/satcheck_zchaff.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include @@ -13,18 +14,6 @@ Author: Daniel Kroening, kroening@kroening.com #include -/*******************************************************************\ - -Function: satcheck_zchaff_baset::satcheck_zchaff_baset - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - satcheck_zchaff_baset::satcheck_zchaff_baset(CSolver *_solver):solver(_solver) { status=INIT; @@ -32,34 +21,10 @@ satcheck_zchaff_baset::satcheck_zchaff_baset(CSolver *_solver):solver(_solver) solver->set_variable_number(0); } -/*******************************************************************\ - -Function: satcheck_zchaff_baset::~satcheck_zchaff_baset - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - satcheck_zchaff_baset::~satcheck_zchaff_baset() { } -/*******************************************************************\ - -Function: satcheck_zchaff_baset::l_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - tvt satcheck_zchaff_baset::l_get(literalt a) const { assert(status==SAT); @@ -86,35 +51,11 @@ tvt satcheck_zchaff_baset::l_get(literalt a) const return result; } -/*******************************************************************\ - -Function: satcheck_zchaff_baset::solver_text - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const std::string satcheck_zchaff_baset::solver_text() { return solver->version(); } -/*******************************************************************\ - -Function: satcheck_zchaff_baset::copy_cnf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void satcheck_zchaff_baset::copy_cnf() { assert(status==INIT); @@ -129,18 +70,6 @@ void satcheck_zchaff_baset::copy_cnf() reinterpret_cast(&((*it)[0])), it->size()); } -/*******************************************************************\ - -Function: satcheck_zchaff_baset::prop_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - propt::resultt satcheck_zchaff_baset::prop_solve() { // this is *not* incremental @@ -206,7 +135,7 @@ propt::resultt satcheck_zchaff_baset::prop_solve() if(result==SATISFIABLE) { for(unsigned i=2; i<(_no_variables*2); i+=2) - cout << "DEBUG L" << i << ":" << get(i) << endl; + cout << "DEBUG L" << i << ":" << get(i) << '\n'; } #endif @@ -227,18 +156,6 @@ propt::resultt satcheck_zchaff_baset::prop_solve() return P_ERROR; } -/*******************************************************************\ - -Function: satcheck_zchaff_baset::set_assignment - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void satcheck_zchaff_baset::set_assignment(literalt a, bool value) { unsigned v=a.var_no(); @@ -247,35 +164,11 @@ void satcheck_zchaff_baset::set_assignment(literalt a, bool value) solver->variables()[v].set_value(value); } -/*******************************************************************\ - -Function: satcheck_zchafft::satcheck_zchafft - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - satcheck_zchafft::satcheck_zchafft(): satcheck_zchaff_baset(new CSolver) { } -/*******************************************************************\ - -Function: satcheck_zchafft::~satcheck_zchafft - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - satcheck_zchafft::~satcheck_zchafft() { delete solver; diff --git a/src/solvers/sat/satcheck_zchaff.h b/src/solvers/sat/satcheck_zchaff.h index 78a0d595740..a25846fecff 100644 --- a/src/solvers/sat/satcheck_zchaff.h +++ b/src/solvers/sat/satcheck_zchaff.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_SAT_SATCHECK_ZCHAFF_H #define CPROVER_SOLVERS_SAT_SATCHECK_ZCHAFF_H diff --git a/src/solvers/sat/satcheck_zcore.cpp b/src/solvers/sat/satcheck_zcore.cpp index 5079259d6cf..6886ab1b6c5 100644 --- a/src/solvers/sat/satcheck_zcore.cpp +++ b/src/solvers/sat/satcheck_zcore.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -15,85 +16,25 @@ Author: Daniel Kroening, kroening@kroening.com #include -/*******************************************************************\ - -Function: satcheck_zcoret::satcheck_zcoret - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - satcheck_zcoret::satcheck_zcoret() { } -/*******************************************************************\ - -Function: satcheck_zcoret::~satcheck_zcoret - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - satcheck_zcoret::~satcheck_zcoret() { } -/*******************************************************************\ - -Function: satcheck_zcoret::l_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - tvt satcheck_zcoret::l_get(literalt a) const { assert(false); return tvt(tvt::tv_enumt::TV_UNKNOWN); } -/*******************************************************************\ - -Function: satcheck_zcoret::solver_text - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const std::string satcheck_zcoret::solver_text() { return "ZCore"; } -/*******************************************************************\ - -Function: satcheck_zcoret::prop_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - propt::resultt satcheck_zcoret::prop_solve() { // We start counting at 1, thus there is one variable fewer. diff --git a/src/solvers/sat/satcheck_zcore.h b/src/solvers/sat/satcheck_zcore.h index fdd152bfdc9..e643f86e67f 100644 --- a/src/solvers/sat/satcheck_zcore.h +++ b/src/solvers/sat/satcheck_zcore.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_SAT_SATCHECK_ZCORE_H #define CPROVER_SOLVERS_SAT_SATCHECK_ZCORE_H diff --git a/src/solvers/smt1/smt1_conv.cpp b/src/solvers/smt1/smt1_conv.cpp index e9b71d87956..ac2326fbc07 100644 --- a/src/solvers/smt1/smt1_conv.cpp +++ b/src/solvers/smt1/smt1_conv.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// SMT Version 1 Backend + #include #include @@ -28,18 +31,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "smt1_conv.h" -/*******************************************************************\ - -Function: smt1_convt::print_assignment - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::print_assignment(std::ostream &out) const { // Boolean stuff @@ -50,18 +41,6 @@ void smt1_convt::print_assignment(std::ostream &out) const // others } -/*******************************************************************\ - -Function: smt1_convt::l_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - tvt smt1_convt::l_get(literalt l) const { if(l.is_true()) @@ -72,18 +51,6 @@ tvt smt1_convt::l_get(literalt l) const return tvt(boolean_assignment[l.var_no()]^l.sign()); } -/*******************************************************************\ - -Function: smt1_convt::dec_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - decision_proceduret::resultt smt1_convt::dec_solve() { write_footer(); @@ -91,18 +58,6 @@ decision_proceduret::resultt smt1_convt::dec_solve() return decision_proceduret::resultt::D_ERROR; } -/*******************************************************************\ - -Function: smt1_convt::write_header - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::write_header() { out << "(benchmark " << benchmark << "\n"; @@ -111,18 +66,6 @@ void smt1_convt::write_header() out << ":logic " << logic << " ; SMT1" << "\n"; } -/*******************************************************************\ - -Function: smt1_convt::write_footer() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::write_footer() { out << "\n"; @@ -130,18 +73,6 @@ void smt1_convt::write_footer() out << ") ; benchmark" << "\n"; } -/*******************************************************************\ - -Function: smt1_convt::get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt smt1_convt::get(const exprt &expr) const { if(expr.id()==ID_symbol) @@ -183,18 +114,6 @@ exprt smt1_convt::get(const exprt &expr) const return nil_exprt(); } -/*******************************************************************\ - -Function: smt1_convt::ce_value - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt smt1_convt::ce_value( const typet &type, const std::string &index, @@ -309,18 +228,6 @@ exprt smt1_convt::ce_value( return nil_exprt(); } -/*******************************************************************\ - -Function: smt1_convt::array_index_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet smt1_convt::array_index_type() const { signedbv_typet t; @@ -328,18 +235,6 @@ typet smt1_convt::array_index_type() const return t; } -/*******************************************************************\ - -Function: smt1_convt::array_index - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::array_index(const exprt &expr) { if(expr.type().id()==ID_integer) @@ -353,18 +248,6 @@ void smt1_convt::array_index(const exprt &expr) convert_expr(tmp, true); } -/*******************************************************************\ - -Function: smt1_convt::convert_address_of_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::convert_address_of_rec( const exprt &expr, const pointer_typet &result_type) @@ -432,6 +315,7 @@ void smt1_convt::convert_address_of_rec( member_expr.get_component_name(); mp_integer offset=member_offset(struct_type, component_name, ns); + assert(offset>=0); typet index_type(ID_unsignedbv); index_type.set(ID_width, boolbv_width(result_type)); @@ -466,18 +350,6 @@ void smt1_convt::convert_address_of_rec( throw "don't know how to take address of: "+expr.id_string(); } -/*******************************************************************\ - -Function: smt1_convt::convert_byte_extract - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::convert_byte_extract( const byte_extract_exprt &expr, bool bool_as_bv) @@ -487,18 +359,6 @@ void smt1_convt::convert_byte_extract( convert_expr(flattened_expr, bool_as_bv); } -/*******************************************************************\ - -Function: smt1_convt::convert_byte_update - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::convert_byte_update( const exprt &expr, bool bool_as_bv) @@ -576,18 +436,6 @@ void smt1_convt::convert_byte_update( } } -/*******************************************************************\ - -Function: smt1_convt::convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt smt1_convt::convert(const exprt &expr) { assert(expr.type().id()==ID_bool); @@ -624,18 +472,6 @@ literalt smt1_convt::convert(const exprt &expr) return l; } -/*******************************************************************\ - -Function: smt1_convt::convert_identifier - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string smt1_convt::convert_identifier(const irep_idt &identifier) { std::string s=id2string(identifier), dest; @@ -689,18 +525,6 @@ std::string smt1_convt::convert_identifier(const irep_idt &identifier) return dest; } -/*******************************************************************\ - -Function: smt1_convt::convert_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::convert_expr(const exprt &expr, bool bool_as_bv) { if(expr.id()==ID_symbol) @@ -1510,18 +1334,6 @@ void smt1_convt::convert_expr(const exprt &expr, bool bool_as_bv) expr.id_string()+"' is unsupported"; } -/*******************************************************************\ - -Function: smt1_convt::convert_typecast - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::convert_typecast( const typecast_exprt &expr, bool bool_as_bv) @@ -1903,18 +1715,6 @@ void smt1_convt::convert_typecast( throw "TODO typecast4 ? -> "+dest_type.id_string(); } -/*******************************************************************\ - -Function: smt1_convt::convert_struct - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::convert_struct(const exprt &expr) { const struct_typet &struct_type=to_struct_type(expr.type()); @@ -1969,18 +1769,6 @@ void smt1_convt::convert_struct(const exprt &expr) } } -/*******************************************************************\ - -Function: smt1_convt::convert_union - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::convert_union(const exprt &expr) { const union_typet &union_type=to_union_type(expr.type()); @@ -2010,18 +1798,6 @@ void smt1_convt::convert_union(const exprt &expr) } } -/*******************************************************************\ - -Function: smt1_convt::convert_constant - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::convert_constant( const constant_exprt &expr, bool bool_as_bv) @@ -2123,18 +1899,6 @@ void smt1_convt::convert_constant( throw "unknown constant: "+expr.type().id_string(); } -/*******************************************************************\ - -Function: smt1_convt::convert_mod - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::convert_mod(const mod_exprt &expr) { assert(expr.operands().size()==2); @@ -2156,18 +1920,6 @@ void smt1_convt::convert_mod(const mod_exprt &expr) throw "unsupported type for mod: "+expr.type().id_string(); } -/*******************************************************************\ - -Function: smt1_convt::convert_is_dynamic_object - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::convert_is_dynamic_object( const exprt &expr, bool bool_as_bv) @@ -2217,18 +1969,6 @@ void smt1_convt::convert_is_dynamic_object( from_bool_end(expr.type(), bool_as_bv); } -/*******************************************************************\ - -Function: smt1_convt::convert_relation - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::convert_relation(const exprt &expr, bool bool_as_bv) { assert(expr.operands().size()==2); @@ -2294,18 +2034,6 @@ void smt1_convt::convert_relation(const exprt &expr, bool bool_as_bv) from_bool_end(expr.type(), bool_as_bv); } -/*******************************************************************\ - -Function: smt1_convt::convert_plus - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::convert_plus(const plus_exprt &expr) { assert(expr.operands().size()>=2); @@ -2333,6 +2061,7 @@ void smt1_convt::convert_plus(const plus_exprt &expr) mp_integer element_size= pointer_offset_size(expr.type().subtype(), ns); + assert(element_size>0); // adjust width if needed if(boolbv_width(i.type())!=boolbv_width(expr.type())) @@ -2386,18 +2115,6 @@ void smt1_convt::convert_plus(const plus_exprt &expr) throw "unsupported type for +: "+expr.type().id_string(); } -/*******************************************************************\ - -Function: smt1_convt::convert_floatbv_plus - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::convert_floatbv_plus(const exprt &expr) { assert(expr.operands().size()==3); @@ -2406,18 +2123,6 @@ void smt1_convt::convert_floatbv_plus(const exprt &expr) throw "todo: floatbv_plus"; } -/*******************************************************************\ - -Function: smt1_convt::convert_minus - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::convert_minus(const minus_exprt &expr) { assert(expr.operands().size()==2); @@ -2457,18 +2162,6 @@ void smt1_convt::convert_minus(const minus_exprt &expr) throw "unsupported type for -: "+expr.type().id_string(); } -/*******************************************************************\ - -Function: smt1_convt::convert_floatbv_minus - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::convert_floatbv_minus(const exprt &expr) { assert(expr.operands().size()==3); @@ -2477,18 +2170,6 @@ void smt1_convt::convert_floatbv_minus(const exprt &expr) throw "todo: floatbv_minus"; } -/*******************************************************************\ - -Function: smt1_convt::convert_div - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::convert_div(const div_exprt &expr) { assert(expr.operands().size()==2); @@ -2528,18 +2209,6 @@ void smt1_convt::convert_div(const div_exprt &expr) throw "unsupported type for /: "+expr.type().id_string(); } -/*******************************************************************\ - -Function: smt1_convt::convert_floatbv_div - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::convert_floatbv_div(const exprt &expr) { assert(expr.operands().size()==3); @@ -2548,18 +2217,6 @@ void smt1_convt::convert_floatbv_div(const exprt &expr) throw "todo: floatbv_div"; } -/*******************************************************************\ - -Function: smt1_convt::convert_mult - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::convert_mult(const mult_exprt &expr) { assert(expr.operands().size()>=2); @@ -2623,18 +2280,6 @@ void smt1_convt::convert_mult(const mult_exprt &expr) throw "unsupported type for *: "+expr.type().id_string(); } -/*******************************************************************\ - -Function: smt1_convt::convert_floatbv_mult - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::convert_floatbv_mult(const exprt &expr) { assert(expr.operands().size()==3); @@ -2643,18 +2288,6 @@ void smt1_convt::convert_floatbv_mult(const exprt &expr) throw "todo: floatbv_mult"; } -/*******************************************************************\ - -Function: smt1_convt::convert_with - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::convert_with(const exprt &expr) { // get rid of "with" that has more than three operands @@ -2995,18 +2628,6 @@ void smt1_convt::convert_with(const exprt &expr) } } -/*******************************************************************\ - -Function: smt1_convt::convert_update - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::convert_update(const exprt &expr) { assert(expr.operands().size()==3); @@ -3015,18 +2636,6 @@ void smt1_convt::convert_update(const exprt &expr) throw "smt1_convt::convert_update to be implemented"; } -/*******************************************************************\ - -Function: smt1_convt::convert_index - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::convert_index(const index_exprt &expr, bool bool_as_bv) { assert(expr.operands().size()==2); @@ -3078,18 +2687,6 @@ void smt1_convt::convert_index(const index_exprt &expr, bool bool_as_bv) } } -/*******************************************************************\ - -Function: smt1_convt::convert_member - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::convert_member(const member_exprt &expr, bool bool_as_bv) { assert(expr.operands().size()==1); @@ -3140,34 +2737,10 @@ void smt1_convt::convert_member(const member_exprt &expr, bool bool_as_bv) from_bv_end(expr.type(), bool_as_bv); } -/*******************************************************************\ - -Function: smt1_convt::convert_overflow - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::convert_overflow(const exprt &expr) { } -/*******************************************************************\ - -Function: smt1_convt::set_to - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::set_to(const exprt &expr, bool value) { if(expr.id()==ID_and && value) @@ -3210,18 +2783,6 @@ void smt1_convt::set_to(const exprt &expr, bool value) out << "\n"; } -/*******************************************************************\ - -Function: smt1_convt::find_symbols - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::find_symbols(const exprt &expr) { const typet &type=expr.type(); @@ -3349,18 +2910,6 @@ void smt1_convt::find_symbols(const exprt &expr) } } -/*******************************************************************\ - -Function: smt1_convt::convert_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::convert_type(const typet &type) { if(type.id()==ID_array) @@ -3423,18 +2972,6 @@ void smt1_convt::convert_type(const typet &type) throw "unsupported type: "+type.id_string(); } -/*******************************************************************\ - -Function: smt1_convt::convert_literal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::convert_literal(const literalt l) { if(l==const_literal(false)) @@ -3453,18 +2990,6 @@ void smt1_convt::convert_literal(const literalt l) } } -/*******************************************************************\ - -Function: smt1_convt::from_bv_begin - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::from_bv_begin(const typet &type, bool bool_as_bv) { // this turns bv[1] into a predicate if needed @@ -3472,18 +2997,6 @@ void smt1_convt::from_bv_begin(const typet &type, bool bool_as_bv) out << "(= "; } -/*******************************************************************\ - -Function: smt1_convt::from_bv_end - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::from_bv_end(const typet &type, bool bool_as_bv) { // this turns bv[1] into a predicate if needed @@ -3491,18 +3004,6 @@ void smt1_convt::from_bv_end(const typet &type, bool bool_as_bv) out << " bv1[1])"; } -/*******************************************************************\ - -Function: smt1_convt::from_bool_begin - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::from_bool_begin(const typet &type, bool bool_as_bv) { // this turns a predicate into bv[1] if needed @@ -3510,18 +3011,6 @@ void smt1_convt::from_bool_begin(const typet &type, bool bool_as_bv) out << "(ite "; } -/*******************************************************************\ - -Function: smt1_convt::from_bool_end - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::from_bool_end(const typet &type, bool bool_as_bv) { // this turns a predicate into bv[1] if needed @@ -3529,36 +3018,12 @@ void smt1_convt::from_bool_end(const typet &type, bool bool_as_bv) out << " bv1[1] bv0[1])"; } -/*******************************************************************\ - -Function: smt1_convt::find_symbols - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::find_symbols(const typet &type) { std::set rec_stack; find_symbols_rec(type, rec_stack); } -/*******************************************************************\ - -Function: smt1_convt::find_symbols_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::find_symbols_rec( const typet &type, std::set &recstack) @@ -3609,18 +3074,6 @@ void smt1_convt::find_symbols_rec( } } -/*******************************************************************\ - -Function: smt1_convt::binary2struct - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt smt1_convt::binary2struct( const struct_typet &type, const std::string &binary) const @@ -3655,18 +3108,6 @@ exprt smt1_convt::binary2struct( return e; } -/*******************************************************************\ - -Function: smt1_convt::binary2union - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt smt1_convt::binary2union( const union_typet &type, const std::string &binary) const @@ -3697,18 +3138,6 @@ exprt smt1_convt::binary2union( return e; } -/*******************************************************************\ - -Function: smt1_convt::flatten_array - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::flatten_array(const exprt &op) { const array_typet array_type=to_array_type(op.type()); @@ -3756,18 +3185,6 @@ void smt1_convt::flatten_array(const exprt &op) #endif } -/*******************************************************************\ - -Function: smt1_convt::convert_nary - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_convt::convert_nary( const exprt &expr, const irep_idt op_string, diff --git a/src/solvers/smt1/smt1_conv.h b/src/solvers/smt1/smt1_conv.h index 4a078a0d772..f152423df1c 100644 --- a/src/solvers/smt1/smt1_conv.h +++ b/src/solvers/smt1/smt1_conv.h @@ -7,6 +7,9 @@ Revision: Roberto Bruttomesso, roberto.bruttomesso@unisi.ch \*******************************************************************/ +/// \file +/// SMT Version 1 Backend + #ifndef CPROVER_SOLVERS_SMT1_SMT1_CONV_H #define CPROVER_SOLVERS_SMT1_SMT1_CONV_H diff --git a/src/solvers/smt1/smt1_dec.cpp b/src/solvers/smt1/smt1_dec.cpp index fc01925d883..be1001c2ca2 100644 --- a/src/solvers/smt1/smt1_dec.cpp +++ b/src/solvers/smt1/smt1_dec.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #if defined(__linux__) || \ @@ -26,18 +27,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "smt1_dec.h" -/*******************************************************************\ - -Function: smt1_dect::decision_procedure_text - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string smt1_dect::decision_procedure_text() const { return "SMT1 "+logic+" using "+ @@ -52,18 +41,6 @@ std::string smt1_dect::decision_procedure_text() const "(unknown)"); } -/*******************************************************************\ - -Function: smt1_temp_filet::smt1_temp_filet - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - smt1_temp_filet::smt1_temp_filet() { temp_out_filename=get_temporary_file("smt1_dec_out_", ""); @@ -73,18 +50,6 @@ smt1_temp_filet::smt1_temp_filet() std::ios_base::out | std::ios_base::trunc); } -/*******************************************************************\ - -Function: smt1_temp_filet::~smt1_temp_filet - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - smt1_temp_filet::~smt1_temp_filet() { temp_out.close(); @@ -96,18 +61,6 @@ smt1_temp_filet::~smt1_temp_filet() unlink(temp_result_filename.c_str()); } -/*******************************************************************\ - -Function: smt1_dect::dec_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - decision_proceduret::resultt smt1_dect::dec_solve() { // SMT1 is really not incremental @@ -226,18 +179,7 @@ decision_proceduret::resultt smt1_dect::dec_solve() } } -/*******************************************************************\ - -Function: smt1_dect::read_result_boolector - - Inputs: - - Outputs: - - Purpose: read model produced by Boolector - -\*******************************************************************/ - +/// read model produced by Boolector decision_proceduret::resultt smt1_dect::read_result_boolector(std::istream &in) { std::string line; @@ -321,35 +263,11 @@ decision_proceduret::resultt smt1_dect::read_result_boolector(std::istream &in) return resultt::D_ERROR; } -/*******************************************************************\ - -Function: smt1_dect::read_result_opensmt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - decision_proceduret::resultt smt1_dect::read_result_opensmt(std::istream &in) { return resultt::D_ERROR; } -/*******************************************************************\ - -Function: smt1_dect::read_result_yices - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - decision_proceduret::resultt smt1_dect::read_result_yices(std::istream &in) { std::string line; @@ -370,18 +288,6 @@ decision_proceduret::resultt smt1_dect::read_result_yices(std::istream &in) return resultt::D_ERROR; } -/*******************************************************************\ - -Function: smt1_dect::mathsat_value - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string smt1_dect::mathsat_value(const std::string &src) { std::size_t pos=src.find('['); @@ -399,18 +305,6 @@ std::string smt1_dect::mathsat_value(const std::string &src) return ""; } -/*******************************************************************\ - -Function: smt1_dect::read_result_mathsat - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - decision_proceduret::resultt smt1_dect::read_result_mathsat(std::istream &in) { std::string line; @@ -481,18 +375,6 @@ decision_proceduret::resultt smt1_dect::read_result_mathsat(std::istream &in) return res; } -/*******************************************************************\ - -Function: smt1_dect::read_result_z3 - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - decision_proceduret::resultt smt1_dect::read_result_z3(std::istream &in) { std::string line; @@ -549,18 +431,6 @@ decision_proceduret::resultt smt1_dect::read_result_z3(std::istream &in) return res; } -/*******************************************************************\ - -Function: smt1_dect::string_to_expr_z3 - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool smt1_dect::string_to_expr_z3( const typet &type, const std::string &value, @@ -677,18 +547,6 @@ bool smt1_dect::string_to_expr_z3( return false; } -/*******************************************************************\ - -Function: smt1_dect::read_result_cvc3 - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - decision_proceduret::resultt smt1_dect::read_result_cvc3(std::istream &in) { std::string line; diff --git a/src/solvers/smt1/smt1_dec.h b/src/solvers/smt1/smt1_dec.h index 3cc6de03d46..1eb20115fcf 100644 --- a/src/solvers/smt1/smt1_dec.h +++ b/src/solvers/smt1/smt1_dec.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_SMT1_SMT1_DEC_H #define CPROVER_SOLVERS_SMT1_SMT1_DEC_H diff --git a/src/solvers/smt1/smt1_prop.cpp b/src/solvers/smt1/smt1_prop.cpp index e39dfedde80..3f3c33dbf50 100644 --- a/src/solvers/smt1/smt1_prop.cpp +++ b/src/solvers/smt1/smt1_prop.cpp @@ -8,23 +8,12 @@ Revisions: Roberto Bruttomesso, roberto.bruttomesso@unisi.ch \*******************************************************************/ + #include #include "smt1_prop.h" -/*******************************************************************\ - -Function: smt1_propt::smt1_propt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - smt1_propt::smt1_propt( const std::string &benchmark, const std::string &source, @@ -38,34 +27,10 @@ smt1_propt::smt1_propt( _no_variables=0; } -/*******************************************************************\ - -Function: smt1_propt::~smt1_propt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - smt1_propt::~smt1_propt() { } -/*******************************************************************\ - -Function: smt1_propt::finalize - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_propt::finalize() { out << "\n"; @@ -73,18 +38,6 @@ void smt1_propt::finalize() out << ") ; benchmark" << "\n"; } -/*******************************************************************\ - -Function: smt1_propt::land - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt smt1_propt::land(const bvt &bv) { out << "\n"; @@ -102,18 +55,6 @@ literalt smt1_propt::land(const bvt &bv) return l; } -/*******************************************************************\ - -Function: smt1_propt::lor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt smt1_propt::lor(const bvt &bv) { out << "\n"; @@ -131,18 +72,6 @@ literalt smt1_propt::lor(const bvt &bv) return l; } -/*******************************************************************\ - -Function: smt1_propt::lxor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt smt1_propt::lxor(const bvt &bv) { if(bv.empty()) @@ -165,18 +94,6 @@ literalt smt1_propt::lxor(const bvt &bv) return l; } -/*******************************************************************\ - -Function: smt1_propt::land - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt smt1_propt::land(literalt a, literalt b) { if(a==const_literal(true)) @@ -203,18 +120,6 @@ literalt smt1_propt::land(literalt a, literalt b) return l; } -/*******************************************************************\ - -Function: smt1_propt::lor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt smt1_propt::lor(literalt a, literalt b) { if(a==const_literal(false)) @@ -241,18 +146,6 @@ literalt smt1_propt::lor(literalt a, literalt b) return l; } -/*******************************************************************\ - -Function: smt1_propt::lxor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt smt1_propt::lxor(literalt a, literalt b) { if(a==const_literal(false)) @@ -277,86 +170,26 @@ literalt smt1_propt::lxor(literalt a, literalt b) return l; } -/*******************************************************************\ - -Function: smt1_propt::lnand - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt smt1_propt::lnand(literalt a, literalt b) { return !land(a, b); } -/*******************************************************************\ - -Function: smt1_propt::lnor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt smt1_propt::lnor(literalt a, literalt b) { return !lor(a, b); } -/*******************************************************************\ - -Function: smt1_propt::lequal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt smt1_propt::lequal(literalt a, literalt b) { return !lxor(a, b); } -/*******************************************************************\ - -Function: smt1_propt::limplies - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt smt1_propt::limplies(literalt a, literalt b) { return lor(!a, b); } -/*******************************************************************\ - -Function: smt1_propt::lselect - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt smt1_propt::lselect(literalt a, literalt b, literalt c) { if(a==const_literal(true)) @@ -387,18 +220,6 @@ literalt smt1_propt::lselect(literalt a, literalt b, literalt c) return l; } -/*******************************************************************\ - -Function: smt1_propt::new_variable - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt smt1_propt::new_variable() { literalt l; @@ -410,18 +231,6 @@ literalt smt1_propt::new_variable() return l; } -/*******************************************************************\ - -Function: smt1_propt::lcnf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_propt::lcnf(const bvt &bv) { out << "\n"; @@ -445,18 +254,6 @@ void smt1_propt::lcnf(const bvt &bv) out << "\n"; } -/*******************************************************************\ - -Function: smt1_propt::smt1_literal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string smt1_propt::smt1_literal(literalt l) { if(l==const_literal(false)) @@ -472,18 +269,6 @@ std::string smt1_propt::smt1_literal(literalt l) return v; } -/*******************************************************************\ - -Function: smt1_propt::l_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - tvt smt1_propt::l_get(literalt literal) const { if(literal.is_true()) @@ -498,18 +283,6 @@ tvt smt1_propt::l_get(literalt literal) const return literal.sign()?!r:r; } -/*******************************************************************\ - -Function: smt1_propt::set_assignment - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt1_propt::set_assignment(literalt literal, bool value) { if(literal.is_true() || literal.is_false()) @@ -520,18 +293,6 @@ void smt1_propt::set_assignment(literalt literal, bool value) assignment[v]=tvt(value); } -/*******************************************************************\ - -Function: smt1_propt::prop_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - propt::resultt smt1_propt::prop_solve() { return P_ERROR; diff --git a/src/solvers/smt1/smt1_prop.h b/src/solvers/smt1/smt1_prop.h index 1a7a5b86ddf..18fd9da1099 100644 --- a/src/solvers/smt1/smt1_prop.h +++ b/src/solvers/smt1/smt1_prop.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_SMT1_SMT1_PROP_H #define CPROVER_SOLVERS_SMT1_SMT1_PROP_H diff --git a/src/solvers/smt2/smt2_conv.cpp b/src/solvers/smt2/smt2_conv.cpp index 37a3647ed71..11f6b4c5dd1 100644 --- a/src/solvers/smt2/smt2_conv.cpp +++ b/src/solvers/smt2/smt2_conv.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// SMT Backend + #include #include @@ -17,6 +20,7 @@ Author: Daniel Kroening, kroening@kroening.com #include #include #include +#include #include @@ -31,7 +35,6 @@ Author: Daniel Kroening, kroening@kroening.com // Mark different kinds of error condition // General -#define UNREACHABLE throw "Supposidly unreachable location reached" #define PARSERERROR(S) throw S // Error checking the expression type @@ -42,19 +45,7 @@ Author: Daniel Kroening, kroening@kroening.com #define UNEXPECTEDCASE(S) throw "Unexpected case: " S // General todos -#define TODO(S) throw "TODO: " S - -/*******************************************************************\ - -Function: smt2_convt::print_assignment - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ +#define SMT2_TODO(S) throw "TODO: " S void smt2_convt::print_assignment(std::ostream &out) const { @@ -66,18 +57,6 @@ void smt2_convt::print_assignment(std::ostream &out) const // others } -/*******************************************************************\ - -Function: smt2_convt::l_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - tvt smt2_convt::l_get(literalt l) const { if(l.is_true()) @@ -88,18 +67,6 @@ tvt smt2_convt::l_get(literalt l) const return tvt(boolean_assignment[l.var_no()]^l.sign()); } -/*******************************************************************\ - -Function: smt2_convt::write_header - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::write_header() { out << "; SMT 2" << "\n"; @@ -127,18 +94,6 @@ void smt2_convt::write_header() out << "(set-logic " << logic << ")" << "\n"; } -/*******************************************************************\ - -Function: smt2_convt::write_footer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::write_footer(std::ostream &out) { out << "\n"; @@ -176,18 +131,6 @@ void smt2_convt::write_footer(std::ostream &out) out << "; end of SMT2 file" << "\n"; } -/*******************************************************************\ - -Function: smt2_convt::define_object_size - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::define_object_size( const irep_idt &id, const exprt &expr) @@ -225,18 +168,6 @@ void smt2_convt::define_object_size( } } -/*******************************************************************\ - -Function: smt2_convt::dec_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - decision_proceduret::resultt smt2_convt::dec_solve() { write_footer(out); @@ -244,18 +175,6 @@ decision_proceduret::resultt smt2_convt::dec_solve() return decision_proceduret::resultt::D_ERROR; } -/*******************************************************************\ - -Function: smt2_convt::get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt smt2_convt::get(const exprt &expr) const { if(expr.id()==ID_symbol) @@ -279,18 +198,6 @@ exprt smt2_convt::get(const exprt &expr) const return nil_exprt(); } -/*******************************************************************\ - -Function: smt2_convt::parse_literal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - constant_exprt smt2_convt::parse_literal( const irept &src, const typet &type) @@ -411,18 +318,6 @@ constant_exprt smt2_convt::parse_literal( UNEXPECTEDCASE("smt2_convt::parse_literal can't do type "+type.id_string()); } -/*******************************************************************\ - -Function: smt2_convt::parse_array - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt smt2_convt::parse_array( const irept &src, const array_typet &type) @@ -453,18 +348,6 @@ exprt smt2_convt::parse_array( return nil_exprt(); } -/*******************************************************************\ - -Function: smt2_convt::parse_union - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt smt2_convt::parse_union( const irept &src, const union_typet &type) @@ -480,18 +363,6 @@ exprt smt2_convt::parse_union( return union_exprt(first.get_name(), converted, type); } -/*******************************************************************\ - -Function: smt2_convt::parse_struct - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt smt2_convt::parse_struct( const irept &src, const struct_typet &type) @@ -553,18 +424,6 @@ exprt smt2_convt::parse_struct( return result; } -/*******************************************************************\ - -Function: smt2_convt::parse_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt smt2_convt::parse_rec(const irept &src, const typet &_type) { const typet &type=ns.follow(_type); @@ -616,18 +475,6 @@ exprt smt2_convt::parse_rec(const irept &src, const typet &_type) return nil_exprt(); } -/*******************************************************************\ - -Function: smt2_convt::convert_address_of_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::convert_address_of_rec( const exprt &expr, const pointer_typet &result_type) @@ -694,6 +541,7 @@ void smt2_convt::convert_address_of_rec( member_expr.get_component_name(); mp_integer offset=member_offset(struct_type, component_name, ns); + assert(offset>=0); unsignedbv_typet index_type; index_type.set_width(boolbv_width(result_type)); @@ -723,18 +571,6 @@ void smt2_convt::convert_address_of_rec( UNEXPECTEDCASE("don't know how to take address of: "+expr.id_string()); } -/*******************************************************************\ - -Function: smt2_convt::convert_byte_extract - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::convert_byte_extract(const byte_extract_exprt &expr) { // we just run the flattener @@ -744,18 +580,6 @@ void smt2_convt::convert_byte_extract(const byte_extract_exprt &expr) unflatten(wheret::END, expr.type()); } -/*******************************************************************\ - -Function: smt2_convt::convert_byte_update - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::convert_byte_update(const byte_update_exprt &expr) { assert(expr.operands().size()==3); @@ -860,18 +684,6 @@ void smt2_convt::convert_byte_update(const byte_update_exprt &expr) #endif } -/*******************************************************************\ - -Function: smt2_convt::convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt smt2_convt::convert(const exprt &expr) { assert(expr.type().id()==ID_bool); @@ -904,18 +716,6 @@ literalt smt2_convt::convert(const exprt &expr) return l; } -/*******************************************************************\ - -Function: smt2_convt::convert_literal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::convert_literal(const literalt l) { if(l==const_literal(false)) @@ -936,18 +736,6 @@ void smt2_convt::convert_literal(const literalt l) } } -/*******************************************************************\ - -Function: smt2_convt::convert_identifier - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string smt2_convt::convert_identifier(const irep_idt &identifier) { // Backslashes are disallowed in quoted symbols just for simplicity. @@ -979,18 +767,6 @@ std::string smt2_convt::convert_identifier(const irep_idt &identifier) return result; } -/*******************************************************************\ - -Function: smt2_convt::type2id - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string smt2_convt::type2id(const typet &type) const { if(type.id()==ID_floatbv) @@ -1025,36 +801,12 @@ std::string smt2_convt::type2id(const typet &type) const } } -/*******************************************************************\ - -Function: smt2_convt::floatbv_suffix - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string smt2_convt::floatbv_suffix(const exprt &expr) const { assert(!expr.operands().empty()); return "_"+type2id(expr.op0().type())+"->"+type2id(expr.type()); } -/*******************************************************************\ - -Function: smt2_convt::convert_floatbv - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::convert_floatbv(const exprt &expr) { assert(!use_FPA_theory); @@ -1088,18 +840,6 @@ void smt2_convt::convert_floatbv(const exprt &expr) out << ')'; } -/*******************************************************************\ - -Function: smt2_convt::convert_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::convert_expr(const exprt &expr) { // huge monster case split over expression id @@ -1212,7 +952,7 @@ void smt2_convt::convert_expr(const exprt &expr) out << "))"; // mk-, let } else - TODO("bitnot for vectors"); + SMT2_TODO("bitnot for vectors"); } else { @@ -1277,7 +1017,7 @@ void smt2_convt::convert_expr(const exprt &expr) out << "))"; // mk-, let } else - TODO("unary minus for vector"); + SMT2_TODO("unary minus for vector"); } else { @@ -1623,7 +1363,7 @@ void smt2_convt::convert_expr(const exprt &expr) assert(expr.operands().size()==1); out << "false"; // TODO - TODO("pointer_object_has_type not implemented"); + SMT2_TODO("pointer_object_has_type not implemented"); } else if(expr.id()==ID_string_constant) { @@ -1692,7 +1432,7 @@ void smt2_convt::convert_expr(const exprt &expr) convert_expr(tmp); out << ")) bin1)"; // bvlshr, extract, = #endif - TODO("smt2: extractbits with non-constant index"); + SMT2_TODO("smt2: extractbits with non-constant index"); } } else if(expr.id()==ID_replication) @@ -2050,18 +1790,6 @@ void smt2_convt::convert_expr(const exprt &expr) "smt2_convt::convert_expr: `"+expr.id_string()+"' is unsupported"); } -/*******************************************************************\ - -Function: smt2_convt::convert_typecast - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::convert_typecast(const typecast_exprt &expr) { assert(expr.operands().size()==1); @@ -2216,7 +1944,7 @@ void smt2_convt::convert_typecast(const typecast_exprt &expr) // This conversion is non-trivial as it requires creating a // new bit-vector variable and then asserting that it converts // to the required floating-point number. - TODO("bit-wise floatbv to bv"); + SMT2_TODO("bit-wise floatbv to bv"); } else { @@ -2289,7 +2017,7 @@ void smt2_convt::convert_typecast(const typecast_exprt &expr) out << "(_ bv" << i << " " << to_width << ")"; } else - TODO("can't convert non-constant integer to bitvector"); + SMT2_TODO("can't convert non-constant integer to bitvector"); } else if(src_type.id()==ID_struct) // flatten a struct to a bit-vector { @@ -2479,7 +2207,7 @@ void smt2_convt::convert_typecast(const typecast_exprt &expr) } else if(dest_type.id()==ID_range) { - TODO("range typecast"); + SMT2_TODO("range typecast"); } else if(dest_type.id()==ID_floatbv) { @@ -2546,18 +2274,6 @@ void smt2_convt::convert_typecast(const typecast_exprt &expr) "TODO typecast8 "+src_type.id_string()+" -> "+dest_type.id_string()); } -/*******************************************************************\ - -Function: smt2_convt::convert_floatbv_typecast - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::convert_floatbv_typecast(const floatbv_typecast_exprt &expr) { const exprt &src=expr.op(); @@ -2704,18 +2420,6 @@ void smt2_convt::convert_floatbv_typecast(const floatbv_typecast_exprt &expr) } } -/*******************************************************************\ - -Function: smt2_convt::convert_struct - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::convert_struct(const struct_exprt &expr) { const struct_typet &struct_type=to_struct_type(expr.type()); @@ -2778,18 +2482,7 @@ void smt2_convt::convert_struct(const struct_exprt &expr) } } -/*******************************************************************\ - -Function: smt2_convt::flatten_array - - Inputs: - - Outputs: - - Purpose: produce a flat bit-vector for a given array of fixed size - -\*******************************************************************/ - +/// produce a flat bit-vector for a given array of fixed size void smt2_convt::flatten_array(const exprt &expr) { const array_typet &array_type= @@ -2824,18 +2517,6 @@ void smt2_convt::flatten_array(const exprt &expr) out << ")"; // let } -/*******************************************************************\ - -Function: smt2_convt::convert_union - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::convert_union(const union_exprt &expr) { const union_typet &union_type=to_union_type(expr.type()); @@ -2869,18 +2550,6 @@ void smt2_convt::convert_union(const union_exprt &expr) } } -/*******************************************************************\ - -Function: smt2_convt::convert_constant - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::convert_constant(const constant_exprt &expr) { const typet &expr_type=expr.type(); @@ -3017,18 +2686,6 @@ void smt2_convt::convert_constant(const constant_exprt &expr) UNEXPECTEDCASE("unknown constant: "+expr_type.id_string()); } -/*******************************************************************\ - -Function: smt2_convt::convert_mod - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::convert_mod(const mod_exprt &expr) { assert(expr.operands().size()==2); @@ -3050,18 +2707,6 @@ void smt2_convt::convert_mod(const mod_exprt &expr) UNEXPECTEDCASE("unsupported type for mod: "+expr.type().id_string()); } -/*******************************************************************\ - -Function: smt2_convt::convert_is_dynamic_object - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::convert_is_dynamic_object(const exprt &expr) { std::vector dynamic_objects; @@ -3101,18 +2746,6 @@ void smt2_convt::convert_is_dynamic_object(const exprt &expr) } } -/*******************************************************************\ - -Function: smt2_convt::convert_relation - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::convert_relation(const exprt &expr) { assert(expr.operands().size()==2); @@ -3198,18 +2831,6 @@ void smt2_convt::convert_relation(const exprt &expr) "unsupported type for "+expr.id_string()+": "+op_type.id_string()); } -/*******************************************************************\ - -Function: smt2_convt::convert_plus - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::convert_plus(const plus_exprt &expr) { if(expr.operands().size()==0) @@ -3253,6 +2874,7 @@ void smt2_convt::convert_plus(const plus_exprt &expr) mp_integer element_size= pointer_offset_size(expr.type().subtype(), ns); + assert(element_size>0); out << "(bvadd "; convert_expr(p); @@ -3326,19 +2948,10 @@ void smt2_convt::convert_plus(const plus_exprt &expr) } } -/*******************************************************************\ - -Function: smt2_convt::convert_rounding_mode_FPA - - Inputs: The expression representing the rounding mode. - - Outputs: SMT-LIB output to out. - - Purpose: Converting a constant or symbolic rounding mode to SMT-LIB. - Only called when use_FPA_theory is enabled - -\*******************************************************************/ - +/// Converting a constant or symbolic rounding mode to SMT-LIB. Only called when +/// use_FPA_theory is enabled +/// \par parameters: The expression representing the rounding mode. +/// \return SMT-LIB output to out. void smt2_convt::convert_rounding_mode_FPA(const exprt &expr) { assert(use_FPA_theory); @@ -3395,18 +3008,6 @@ void smt2_convt::convert_rounding_mode_FPA(const exprt &expr) } } -/*******************************************************************\ - -Function: smt2_convt::convert_floatbv_plus - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::convert_floatbv_plus(const ieee_float_op_exprt &expr) { const typet &type=expr.type(); @@ -3430,11 +3031,11 @@ void smt2_convt::convert_floatbv_plus(const ieee_float_op_exprt &expr) } else if(type.id()==ID_complex) { - TODO("+ for floatbv complex"); + SMT2_TODO("+ for floatbv complex"); } else if(type.id()==ID_vector) { - TODO("+ for floatbv vector"); + SMT2_TODO("+ for floatbv vector"); } else UNEXPECTEDCASE("unsupported type for +: "+type.id_string()); @@ -3443,18 +3044,6 @@ void smt2_convt::convert_floatbv_plus(const ieee_float_op_exprt &expr) convert_floatbv(expr); } -/*******************************************************************\ - -Function: smt2_convt::convert_minus - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::convert_minus(const minus_exprt &expr) { assert(expr.operands().size()==2); @@ -3469,6 +3058,7 @@ void smt2_convt::convert_minus(const minus_exprt &expr) // Pointer difference. mp_integer element_size= pointer_offset_size(expr.op0().type().subtype(), ns); + assert(element_size>0); if(element_size>=2) out << "(bvsdiv "; @@ -3503,7 +3093,7 @@ void smt2_convt::convert_minus(const minus_exprt &expr) } else if(expr.type().id()==ID_pointer) { - TODO("pointer subtraction"); + SMT2_TODO("pointer subtraction"); } else if(expr.type().id()==ID_vector) { @@ -3548,18 +3138,6 @@ void smt2_convt::convert_minus(const minus_exprt &expr) UNEXPECTEDCASE("unsupported type for -: "+expr.type().id_string()); } -/*******************************************************************\ - -Function: smt2_convt::convert_floatbv_minus - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::convert_floatbv_minus(const ieee_float_op_exprt &expr) { assert(expr.operands().size()==3); @@ -3579,18 +3157,6 @@ void smt2_convt::convert_floatbv_minus(const ieee_float_op_exprt &expr) convert_floatbv(expr); } -/*******************************************************************\ - -Function: smt2_convt::convert_div - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::convert_div(const div_exprt &expr) { assert(expr.operands().size()==2); @@ -3637,18 +3203,6 @@ void smt2_convt::convert_div(const div_exprt &expr) UNEXPECTEDCASE("unsupported type for /: "+expr.type().id_string()); } -/*******************************************************************\ - -Function: smt2_convt::convert_floatbv_div - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::convert_floatbv_div(const ieee_float_op_exprt &expr) { assert(expr.operands().size()==3); @@ -3668,18 +3222,6 @@ void smt2_convt::convert_floatbv_div(const ieee_float_op_exprt &expr) convert_floatbv(expr); } -/*******************************************************************\ - -Function: smt2_convt::convert_mult - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::convert_mult(const mult_exprt &expr) { assert(expr.operands().size()>=2); @@ -3753,18 +3295,6 @@ void smt2_convt::convert_mult(const mult_exprt &expr) UNEXPECTEDCASE("unsupported type for *: "+expr.type().id_string()); } -/*******************************************************************\ - -Function: smt2_convt::convert_floatbv_mult - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::convert_floatbv_mult(const ieee_float_op_exprt &expr) { assert(expr.operands().size()==3); @@ -3784,18 +3314,6 @@ void smt2_convt::convert_floatbv_mult(const ieee_float_op_exprt &expr) convert_floatbv(expr); } -/*******************************************************************\ - -Function: smt2_convt::convert_with - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::convert_with(const with_exprt &expr) { // get rid of "with" that has more than three operands @@ -4009,7 +3527,7 @@ void smt2_convt::convert_with(const with_exprt &expr) typecast_exprt index_tc(index, expr_type); // TODO: SMT2-ify - TODO("SMT2-ify"); + SMT2_TODO("SMT2-ify"); out << "(bvor "; out << "(band "; @@ -4043,37 +3561,13 @@ void smt2_convt::convert_with(const with_exprt &expr) expr.type().id_string()); } -/*******************************************************************\ - -Function: smt2_convt::convert_update - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::convert_update(const exprt &expr) { assert(expr.operands().size()==3); - TODO("smt2_convt::convert_update to be implemented"); + SMT2_TODO("smt2_convt::convert_update to be implemented"); } -/*******************************************************************\ - -Function: smt2_convt::convert_index - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::convert_index(const index_exprt &expr) { assert(expr.operands().size()==2); @@ -4157,7 +3651,7 @@ void smt2_convt::convert_index(const index_exprt &expr) mp_integer index_int; if(to_integer(expr.index(), index_int)) { - TODO("non-constant index on vectors"); + SMT2_TODO("non-constant index on vectors"); } else { @@ -4168,7 +3662,7 @@ void smt2_convt::convert_index(const index_exprt &expr) } else { - TODO("index on vectors"); + SMT2_TODO("index on vectors"); } } else @@ -4176,18 +3670,6 @@ void smt2_convt::convert_index(const index_exprt &expr) "index with unsupported array type: "+array_op_type.id_string()); } -/*******************************************************************\ - -Function: smt2_convt::convert_member - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::convert_member(const member_exprt &expr) { assert(expr.operands().size()==1); @@ -4253,18 +3735,6 @@ void smt2_convt::convert_member(const member_exprt &expr) "convert_member on an unexpected type "+struct_op_type.id_string()); } -/*******************************************************************\ - -Function: smt2_convt::flatten2bv - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::flatten2bv(const exprt &expr) { const typet &type=ns.follow(expr.type()); @@ -4361,18 +3831,6 @@ void smt2_convt::flatten2bv(const exprt &expr) convert_expr(expr); } -/*******************************************************************\ - -Function: smt2_convt::unflatten - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::unflatten( wheret where, const typet &type, @@ -4488,35 +3946,11 @@ void smt2_convt::unflatten( } } -/*******************************************************************\ - -Function: smt2_convt::convert_overflow - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::convert_overflow(const exprt &expr) { UNREACHABLE; } -/*******************************************************************\ - -Function: smt2_convt::set_to - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::set_to(const exprt &expr, bool value) { if(expr.id()==ID_and && value) @@ -4605,18 +4039,6 @@ void smt2_convt::set_to(const exprt &expr, bool value) return; } -/*******************************************************************\ - -Function: smt2_convt::find_symbols - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::find_symbols(const exprt &expr) { // recursive call on type @@ -4810,18 +4232,6 @@ void smt2_convt::find_symbols(const exprt &expr) } } -/*******************************************************************\ - -Function: smt2_convt::use_array_theory - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool smt2_convt::use_array_theory(const exprt &expr) { const typet &type=ns.follow(expr.type()); @@ -4844,18 +4254,6 @@ bool smt2_convt::use_array_theory(const exprt &expr) } } -/*******************************************************************\ - -Function: smt2_convt::convert_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::convert_type(const typet &type) { if(type.id()==ID_array) @@ -5007,36 +4405,12 @@ void smt2_convt::convert_type(const typet &type) } } -/*******************************************************************\ - -Function: smt2_convt::find_symbols - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::find_symbols(const typet &type) { std::set recstack; find_symbols_rec(type, recstack); } -/*******************************************************************\ - -Function: smt2_convt::find_symbols_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::find_symbols_rec( const typet &type, std::set &recstack) @@ -5233,18 +4607,6 @@ void smt2_convt::find_symbols_rec( } } -/*******************************************************************\ - -Function: smt2_convt::letify - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt smt2_convt::letify(exprt &expr) { seen_expressionst map; @@ -5255,18 +4617,6 @@ exprt smt2_convt::letify(exprt &expr) return letify_rec(expr, let_order, map, 0); } -/*******************************************************************\ - -Function: smt2_convt::letify_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt smt2_convt::letify_rec( exprt &expr, std::vector &let_order, @@ -5291,18 +4641,6 @@ exprt smt2_convt::letify_rec( return let; } -/*******************************************************************\ - -Function: smt2_convt::collect_bindings - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_convt::collect_bindings( exprt &expr, seen_expressionst &map, @@ -5334,18 +4672,6 @@ void smt2_convt::collect_bindings( let_order.push_back(expr); } -/*******************************************************************\ - -Function: smt2_convt::substitute_let - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt smt2_convt::substitute_let( exprt &expr, const seen_expressionst &map) diff --git a/src/solvers/smt2/smt2_conv.h b/src/solvers/smt2/smt2_conv.h index bfd03b506e9..c857cd8efaf 100644 --- a/src/solvers/smt2/smt2_conv.h +++ b/src/solvers/smt2/smt2_conv.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_SMT2_SMT2_CONV_H #define CPROVER_SOLVERS_SMT2_SMT2_CONV_H diff --git a/src/solvers/smt2/smt2_dec.cpp b/src/solvers/smt2/smt2_dec.cpp index 9a9c5d1fc62..1c3ea406e10 100644 --- a/src/solvers/smt2/smt2_dec.cpp +++ b/src/solvers/smt2/smt2_dec.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #if defined(__linux__) || \ @@ -26,18 +27,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "smt2_dec.h" #include "smt2irep.h" -/*******************************************************************\ - -Function: smt2_dect::decision_procedure_text - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string smt2_dect::decision_procedure_text() const { return "SMT2 "+logic+ @@ -54,18 +43,6 @@ std::string smt2_dect::decision_procedure_text() const "(unknown)"); } -/*******************************************************************\ - -Function: smt2_temp_filet::smt2_temp_filet - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - smt2_temp_filet::smt2_temp_filet() { temp_out_filename=get_temporary_file("smt2_dec_out_", ""); @@ -75,18 +52,6 @@ smt2_temp_filet::smt2_temp_filet() std::ios_base::out | std::ios_base::trunc); } -/*******************************************************************\ - -Function: smt2_temp_filet::~smt2_temp_filet - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - smt2_temp_filet::~smt2_temp_filet() { temp_out.close(); @@ -98,18 +63,6 @@ smt2_temp_filet::~smt2_temp_filet() unlink(temp_result_filename.c_str()); } -/*******************************************************************\ - -Function: smt2_dect::dec_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - decision_proceduret::resultt smt2_dect::dec_solve() { // we write the problem into a file @@ -216,18 +169,6 @@ decision_proceduret::resultt smt2_dect::dec_solve() return read_result(in); } -/*******************************************************************\ - -Function: smt2_dect::read_result - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - decision_proceduret::resultt smt2_dect::read_result(std::istream &in) { std::string line; diff --git a/src/solvers/smt2/smt2_dec.h b/src/solvers/smt2/smt2_dec.h index 30bf18f8796..b0806b4580a 100644 --- a/src/solvers/smt2/smt2_dec.h +++ b/src/solvers/smt2/smt2_dec.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_SMT2_SMT2_DEC_H #define CPROVER_SOLVERS_SMT2_SMT2_DEC_H diff --git a/src/solvers/smt2/smt2_parser.cpp b/src/solvers/smt2/smt2_parser.cpp index 96439833c11..cd271a37d5a 100644 --- a/src/solvers/smt2/smt2_parser.cpp +++ b/src/solvers/smt2/smt2_parser.cpp @@ -6,23 +6,12 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include "smt2_parser.h" -/*******************************************************************\ - -Function: smt2_parsert::is_simple_symbol_character - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool smt2_parsert::is_simple_symbol_character(char ch) { // any non-empty sequence of letters, digits and the characters @@ -36,18 +25,6 @@ bool smt2_parsert::is_simple_symbol_character(char ch) ch=='?' || ch=='/'; } -/*******************************************************************\ - -Function: smt2_parsert::get_simple_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_parsert::get_simple_symbol() { // any non-empty sequence of letters, digits and the characters @@ -73,18 +50,6 @@ void smt2_parsert::get_simple_symbol() // eof -- this is ok here } -/*******************************************************************\ - -Function: smt2_parsert::get_decimal_numeral - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_parsert::get_decimal_numeral() { // we accept any sequence of digits and dots @@ -108,18 +73,6 @@ void smt2_parsert::get_decimal_numeral() // eof -- this is ok here } -/*******************************************************************\ - -Function: smt2_parsert::get_bin_numeral - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_parsert::get_bin_numeral() { // we accept any sequence of '0' or '1' @@ -145,18 +98,6 @@ void smt2_parsert::get_bin_numeral() // eof -- this is ok here } -/*******************************************************************\ - -Function: smt2_parsert::get_hex_numeral - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_parsert::get_hex_numeral() { // we accept any sequence of '0'-'9', 'a'-'f', 'A'-'F' @@ -182,18 +123,6 @@ void smt2_parsert::get_hex_numeral() // eof -- this is ok here } -/*******************************************************************\ - -Function: smt2_parsert::get_quoted_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_parsert::get_quoted_symbol() { // any sequence of printable ASCII characters (including space, @@ -214,18 +143,6 @@ void smt2_parsert::get_quoted_symbol() // Hmpf. Eof before end of quoted string. This is an error. } -/*******************************************************************\ - -Function: smt2_parsert::get_string_literal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_parsert::get_string_literal() { buffer.clear(); @@ -257,18 +174,6 @@ void smt2_parsert::get_string_literal() error("EOF within string literal"); } -/*******************************************************************\ - -Function: smt2_parsert::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_parsert::operator()() { char ch; diff --git a/src/solvers/smt2/smt2_parser.h b/src/solvers/smt2/smt2_parser.h index c01069b3cfd..46633eaa174 100644 --- a/src/solvers/smt2/smt2_parser.h +++ b/src/solvers/smt2/smt2_parser.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_SMT2_SMT2_PARSER_H #define CPROVER_SOLVERS_SMT2_SMT2_PARSER_H diff --git a/src/solvers/smt2/smt2_prop.cpp b/src/solvers/smt2/smt2_prop.cpp index d1f7f8bd21f..9dac1b64e65 100644 --- a/src/solvers/smt2/smt2_prop.cpp +++ b/src/solvers/smt2/smt2_prop.cpp @@ -6,23 +6,12 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "smt2_prop.h" -/*******************************************************************\ - -Function: smt2_propt::smt2_propt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - smt2_propt::smt2_propt( const std::string &benchmark, const std::string &source, @@ -47,34 +36,10 @@ smt2_propt::smt2_propt( _no_variables=0; } -/*******************************************************************\ - -Function: smt2_propt::~smt2_propt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - smt2_propt::~smt2_propt() { } -/*******************************************************************\ - -Function: smt2_propt::finalize - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_propt::finalize() { out << "\n"; @@ -95,18 +60,6 @@ void smt2_propt::finalize() out << "; end of SMT2 file" << "\n"; } -/*******************************************************************\ - -Function: smt2_propt::land - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt smt2_propt::land(const bvt &bv) { out << "\n"; @@ -124,18 +77,6 @@ literalt smt2_propt::land(const bvt &bv) return l; } -/*******************************************************************\ - -Function: smt2_propt::lor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt smt2_propt::lor(const bvt &bv) { out << "\n"; @@ -153,18 +94,6 @@ literalt smt2_propt::lor(const bvt &bv) return l; } -/*******************************************************************\ - -Function: smt2_propt::lxor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt smt2_propt::lxor(const bvt &bv) { if(bv.empty()) @@ -187,18 +116,6 @@ literalt smt2_propt::lxor(const bvt &bv) return l; } -/*******************************************************************\ - -Function: smt2_propt::land - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt smt2_propt::land(literalt a, literalt b) { if(a==const_literal(true)) @@ -225,18 +142,6 @@ literalt smt2_propt::land(literalt a, literalt b) return l; } -/*******************************************************************\ - -Function: smt2_propt::lor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt smt2_propt::lor(literalt a, literalt b) { if(a==const_literal(false)) @@ -263,18 +168,6 @@ literalt smt2_propt::lor(literalt a, literalt b) return l; } -/*******************************************************************\ - -Function: smt2_propt::lxor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt smt2_propt::lxor(literalt a, literalt b) { if(a==const_literal(false)) @@ -299,86 +192,26 @@ literalt smt2_propt::lxor(literalt a, literalt b) return l; } -/*******************************************************************\ - -Function: smt2_propt::lnand - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt smt2_propt::lnand(literalt a, literalt b) { return !land(a, b); } -/*******************************************************************\ - -Function: smt2_propt::lnor - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt smt2_propt::lnor(literalt a, literalt b) { return !lor(a, b); } -/*******************************************************************\ - -Function: smt2_propt::lequal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt smt2_propt::lequal(literalt a, literalt b) { return !lxor(a, b); } -/*******************************************************************\ - -Function: smt2_propt::limplies - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt smt2_propt::limplies(literalt a, literalt b) { return lor(!a, b); } -/*******************************************************************\ - -Function: smt2_propt::lselect - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt smt2_propt::lselect(literalt a, literalt b, literalt c) { if(a==const_literal(true)) @@ -409,18 +242,6 @@ literalt smt2_propt::lselect(literalt a, literalt b, literalt c) return l; } -/*******************************************************************\ - -Function: smt2_propt::new_variable - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt smt2_propt::new_variable() { literalt l; @@ -432,18 +253,6 @@ literalt smt2_propt::new_variable() return l; } -/*******************************************************************\ - -Function: smt2_propt::define_new_variable - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - literalt smt2_propt::define_new_variable() { literalt l; @@ -457,18 +266,6 @@ literalt smt2_propt::define_new_variable() return l; } -/*******************************************************************\ - -Function: smt2_propt::lcnf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_propt::lcnf(const bvt &bv) { out << "\n"; @@ -492,18 +289,6 @@ void smt2_propt::lcnf(const bvt &bv) out << ")" << "\n"; } -/*******************************************************************\ - -Function: smt2_propt::smt2_literal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string smt2_propt::smt2_literal(literalt l) { if(l==const_literal(false)) @@ -521,18 +306,6 @@ std::string smt2_propt::smt2_literal(literalt l) return v; } -/*******************************************************************\ - -Function: smt2_propt::l_get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - tvt smt2_propt::l_get(literalt literal) const { if(literal.is_true()) @@ -547,18 +320,6 @@ tvt smt2_propt::l_get(literalt literal) const return literal.sign()?!r:r; } -/*******************************************************************\ - -Function: smt2_propt::set_assignment - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void smt2_propt::set_assignment(literalt literal, bool value) { if(literal.is_true() || literal.is_false()) @@ -569,18 +330,6 @@ void smt2_propt::set_assignment(literalt literal, bool value) assignment[v]=tvt(value); } -/*******************************************************************\ - -Function: smt2_propt::prop_solve - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - propt::resultt smt2_propt::prop_solve() { return P_ERROR; diff --git a/src/solvers/smt2/smt2_prop.h b/src/solvers/smt2/smt2_prop.h index e417adbafbe..e2d1074f1a7 100644 --- a/src/solvers/smt2/smt2_prop.h +++ b/src/solvers/smt2/smt2_prop.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_SMT2_SMT2_PROP_H #define CPROVER_SOLVERS_SMT2_SMT2_PROP_H diff --git a/src/solvers/smt2/smt2irep.cpp b/src/solvers/smt2/smt2irep.cpp index 97029db66c4..4154ea291e2 100644 --- a/src/solvers/smt2/smt2irep.cpp +++ b/src/solvers/smt2/smt2irep.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include diff --git a/src/solvers/smt2/smt2irep.h b/src/solvers/smt2/smt2irep.h index 52791c69783..94d1ecb6b94 100644 --- a/src/solvers/smt2/smt2irep.h +++ b/src/solvers/smt2/smt2irep.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_SOLVERS_SMT2_SMT2IREP_H #define CPROVER_SOLVERS_SMT2_SMT2IREP_H diff --git a/src/symex/path_search.cpp b/src/symex/path_search.cpp index 8d8e684c2cb..d90ffcbd49e 100644 --- a/src/symex/path_search.cpp +++ b/src/symex/path_search.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Path-based Symbolic Execution + #include #include @@ -17,18 +20,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "path_search.h" -/*******************************************************************\ - -Function: path_searcht::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - path_searcht::resultt path_searcht::operator()( const goto_functionst &goto_functions) { @@ -159,18 +150,6 @@ path_searcht::resultt path_searcht::operator()( return number_of_failed_properties==0?resultt::SAFE:resultt::UNSAFE; } -/*******************************************************************\ - -Function: path_searcht::report_statistics - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void path_searcht::report_statistics() { std::size_t number_of_visited_locations=0; @@ -208,18 +187,6 @@ void path_searcht::report_statistics() << sat_time << "s SAT" << messaget::eom; } -/*******************************************************************\ - -Function: path_searcht::pick_state - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void path_searcht::pick_state() { switch(search_heuristic) @@ -240,18 +207,6 @@ void path_searcht::pick_state() } } -/*******************************************************************\ - -Function: path_searcht::do_show_vcc - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void path_searcht::do_show_vcc(statet &state) { // keep statistics @@ -304,18 +259,7 @@ void path_searcht::do_show_vcc(statet &state) out << eom; } -/*******************************************************************\ - -Function: path_searcht::drop_state - - Inputs: - - Outputs: - - Purpose: decide whether to drop a state - -\*******************************************************************/ - +/// decide whether to drop a state bool path_searcht::drop_state(const statet &state) { goto_programt::const_targett pc=state.get_instruction(); @@ -367,18 +311,6 @@ bool path_searcht::drop_state(const statet &state) return false; } -/*******************************************************************\ - -Function: path_searcht::check_assertion - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void path_searcht::check_assertion(statet &state) { // keep statistics @@ -426,18 +358,6 @@ void path_searcht::check_assertion(statet &state) sat_time+=current_time()-sat_start_time; } -/*******************************************************************\ - -Function: path_searcht::is_feasible - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool path_searcht::is_feasible(statet &state) { status() << "Feasibility check" << eom; @@ -458,18 +378,6 @@ bool path_searcht::is_feasible(statet &state) return result; } -/*******************************************************************\ - -Function: path_searcht::initialize_property_map - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void path_searcht::initialize_property_map( const goto_functionst &goto_functions) { diff --git a/src/symex/path_search.h b/src/symex/path_search.h index 49fc621b84e..ca570819cc8 100644 --- a/src/symex/path_search.h +++ b/src/symex/path_search.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Path-based Symbolic Execution + #ifndef CPROVER_SYMEX_PATH_SEARCH_H #define CPROVER_SYMEX_PATH_SEARCH_H diff --git a/src/symex/symex_cover.cpp b/src/symex/symex_cover.cpp index cb0b81254c4..50c6a549885 100644 --- a/src/symex/symex_cover.cpp +++ b/src/symex/symex_cover.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symex Test Suite Generation + #include #include @@ -16,18 +19,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "symex_parse_options.h" -/*******************************************************************\ - -Function: symex_parse_optionst::get_test - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string symex_parse_optionst::get_test(const goto_tracet &goto_trace) { bool first=true; @@ -52,18 +43,6 @@ std::string symex_parse_optionst::get_test(const goto_tracet &goto_trace) return test; } -/*******************************************************************\ - -Function: symex_parse_optionst::report_cover - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_parse_optionst::report_cover( const path_searcht::property_mapt &property_map) { diff --git a/src/symex/symex_main.cpp b/src/symex/symex_main.cpp index 9407efd6c28..2407aad561c 100644 --- a/src/symex/symex_main.cpp +++ b/src/symex/symex_main.cpp @@ -6,22 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symex Main Module + #include #include "symex_parse_options.h" -/*******************************************************************\ - -Function: main - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - #ifdef _MSC_VER int wmain(int argc, const wchar_t **argv_wide) { diff --git a/src/symex/symex_parse_options.cpp b/src/symex/symex_parse_options.cpp index c7b284383c7..72f5b559a5f 100644 --- a/src/symex/symex_parse_options.cpp +++ b/src/symex/symex_parse_options.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symex Command Line Options Processing + #include #include #include @@ -51,18 +54,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "path_search.h" #include "symex_parse_options.h" -/*******************************************************************\ - -Function: symex_parse_optionst::symex_parse_optionst - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - symex_parse_optionst::symex_parse_optionst(int argc, const char **argv): parse_options_baset(SYMEX_OPTIONS, argc, argv), language_uit(cmdline, ui_message_handler), @@ -70,18 +61,6 @@ symex_parse_optionst::symex_parse_optionst(int argc, const char **argv): { } -/*******************************************************************\ - -Function: symex_parse_optionst::eval_verbosity - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_parse_optionst::eval_verbosity() { // this is our default verbosity @@ -99,18 +78,6 @@ void symex_parse_optionst::eval_verbosity() ui_message_handler.set_verbosity(v); } -/*******************************************************************\ - -Function: symex_parse_optionst::get_command_line_options - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_parse_optionst::get_command_line_options(optionst &options) { if(config.set(cmdline)) @@ -145,23 +112,12 @@ void symex_parse_optionst::get_command_line_options(optionst &options) options.set_option("error-label", cmdline.get_values("error-label")); } -/*******************************************************************\ - -Function: symex_parse_optionst::doit - - Inputs: - - Outputs: - - Purpose: invoke main modules - -\*******************************************************************/ - +/// invoke main modules int symex_parse_optionst::doit() { if(cmdline.isset("version")) { - std::cout << CBMC_VERSION << std::endl; + std::cout << CBMC_VERSION << '\n'; return 0; } @@ -296,18 +252,6 @@ int symex_parse_optionst::doit() #endif } -/*******************************************************************\ - -Function: symex_parse_optionst::set_properties - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool symex_parse_optionst::set_properties() { try @@ -337,18 +281,6 @@ bool symex_parse_optionst::set_properties() return false; } -/*******************************************************************\ - -Function: symex_parse_optionst::process_goto_program - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool symex_parse_optionst::process_goto_program(const optionst &options) { try @@ -463,18 +395,6 @@ bool symex_parse_optionst::process_goto_program(const optionst &options) return false; } -/*******************************************************************\ - -Function: symex_parse_optionst::report_properties - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_parse_optionst::report_properties( const path_searcht::property_mapt &property_map) { @@ -542,18 +462,6 @@ void symex_parse_optionst::report_properties( } } -/*******************************************************************\ - -Function: symex_parse_optionst::report_success - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_parse_optionst::report_success() { result() << "VERIFICATION SUCCESSFUL" << eom; @@ -568,7 +476,7 @@ void symex_parse_optionst::report_success() xmlt xml("cprover-status"); xml.data="SUCCESS"; std::cout << xml; - std::cout << std::endl; + std::cout << '\n'; } break; @@ -577,18 +485,6 @@ void symex_parse_optionst::report_success() } } -/*******************************************************************\ - -Function: symex_parse_optionst::show_counterexample - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_parse_optionst::show_counterexample( const goto_tracet &error_trace) { @@ -614,18 +510,6 @@ void symex_parse_optionst::show_counterexample( } } -/*******************************************************************\ - -Function: symex_parse_optionst::report_failure - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symex_parse_optionst::report_failure() { result() << "VERIFICATION FAILED" << eom; @@ -640,7 +524,7 @@ void symex_parse_optionst::report_failure() xmlt xml("cprover-status"); xml.data="FAILURE"; std::cout << xml; - std::cout << std::endl; + std::cout << '\n'; } break; @@ -649,18 +533,7 @@ void symex_parse_optionst::report_failure() } } -/*******************************************************************\ - -Function: symex_parse_optionst::help - - Inputs: - - Outputs: - - Purpose: display command line help - -\*******************************************************************/ - +/// display command line help void symex_parse_optionst::help() { std::cout << diff --git a/src/symex/symex_parse_options.h b/src/symex/symex_parse_options.h index 4a149e2147f..b4fc6fe2e1c 100644 --- a/src/symex/symex_parse_options.h +++ b/src/symex/symex_parse_options.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Command Line Parsing + #ifndef CPROVER_SYMEX_SYMEX_PARSE_OPTIONS_H #define CPROVER_SYMEX_SYMEX_PARSE_OPTIONS_H diff --git a/src/util/Makefile b/src/util/Makefile index c35e7887f93..6a94cabdb88 100644 --- a/src/util/Makefile +++ b/src/util/Makefile @@ -3,6 +3,7 @@ SRC = arith_tools.cpp \ base_type.cpp \ bv_arithmetic.cpp \ byte_operators.cpp \ + c_types.cpp \ cmdline.cpp \ config.cpp \ cout_message.cpp \ @@ -24,6 +25,7 @@ SRC = arith_tools.cpp \ guard.cpp \ identifier.cpp \ ieee_float.cpp \ + invariant.cpp \ irep.cpp \ irep_hash.cpp \ irep_hash_container.cpp \ diff --git a/src/util/arith_tools.cpp b/src/util/arith_tools.cpp index 37e96ec8ef8..cd657753604 100644 --- a/src/util/arith_tools.cpp +++ b/src/util/arith_tools.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "fixedbv.h" @@ -15,18 +16,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "arith_tools.h" -/*******************************************************************\ - -Function: to_integer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool to_integer(const exprt &expr, mp_integer &int_value) { if(!expr.is_constant()) @@ -34,18 +23,6 @@ bool to_integer(const exprt &expr, mp_integer &int_value) return to_integer(to_constant_expr(expr), int_value); } -/*******************************************************************\ - -Function: to_integer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool to_integer(const constant_exprt &expr, mp_integer &int_value) { const irep_idt &value=expr.get_value(); @@ -113,18 +90,9 @@ bool to_integer(const constant_exprt &expr, mp_integer &int_value) return true; } -/*******************************************************************\ - -Function: to_unsigned_integer - - Inputs: a constant expression and a reference to an unsigned int - - Outputs: an error flag - - Purpose: convert a positive integer expression to an unsigned int - -\*******************************************************************/ - +/// convert a positive integer expression to an unsigned int +/// \par parameters: a constant expression and a reference to an unsigned int +/// \return an error flag bool to_unsigned_integer(const constant_exprt &expr, unsigned &uint_value) { mp_integer i; @@ -139,18 +107,6 @@ bool to_unsigned_integer(const constant_exprt &expr, unsigned &uint_value) } } -/*******************************************************************\ - -Function: from_integer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - constant_exprt from_integer( const mp_integer &int_value, const typet &type) @@ -251,18 +207,7 @@ constant_exprt from_integer( } } -/*******************************************************************\ - -Function: address_bits - - Inputs: - - Outputs: - - Purpose: ceil(log2(size)) - -\*******************************************************************/ - +/// ceil(log2(size)) mp_integer address_bits(const mp_integer &size) { mp_integer result, x=2; @@ -272,18 +217,9 @@ mp_integer address_bits(const mp_integer &size) return result; } -/*******************************************************************\ - -Function: power - - Inputs: Two mp_integers, base and exponent - - Outputs: One mp_integer with the value base^{exponent} - - Purpose: A multi-precision implementation of the power operator. - -\*******************************************************************/ - +/// A multi-precision implementation of the power operator. +/// \par parameters: Two mp_integers, base and exponent +/// \return One mp_integer with the value base^{exponent} mp_integer power(const mp_integer &base, const mp_integer &exponent) { @@ -335,36 +271,12 @@ mp_integer power(const mp_integer &base, return result; } -/*******************************************************************\ - -Function: mp_min - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void mp_min(mp_integer &a, const mp_integer &b) { if(ba) diff --git a/src/util/arith_tools.h b/src/util/arith_tools.h index 54f83a2d923..e9691db7322 100644 --- a/src/util/arith_tools.h +++ b/src/util/arith_tools.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_ARITH_TOOLS_H #define CPROVER_UTIL_ARITH_TOOLS_H diff --git a/src/util/array_name.cpp b/src/util/array_name.cpp index d29d60f77fc..cd0c22dac61 100644 --- a/src/util/array_name.cpp +++ b/src/util/array_name.cpp @@ -6,24 +6,15 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Misc Utilities + #include "array_name.h" #include "expr.h" #include "namespace.h" #include "symbol.h" #include "ssa_expr.h" -/*******************************************************************\ - -Function: goto_checkt::array_name - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string array_name( const namespacet &ns, const exprt &expr) diff --git a/src/util/array_name.h b/src/util/array_name.h index 8c797668a65..e3aee4e57a3 100644 --- a/src/util/array_name.h +++ b/src/util/array_name.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Misc Utilities + #ifndef CPROVER_UTIL_ARRAY_NAME_H #define CPROVER_UTIL_ARRAY_NAME_H diff --git a/src/util/base_type.cpp b/src/util/base_type.cpp index 340d13116a0..148f7b42157 100644 --- a/src/util/base_type.cpp +++ b/src/util/base_type.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Base Type Computation + #include #include @@ -14,18 +17,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "namespace.h" #include "symbol.h" -/*******************************************************************\ - -Function: base_type_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void base_type_rec( typet &type, const namespacet &ns, std::set &symb) { @@ -84,36 +75,12 @@ void base_type_rec( } } -/*******************************************************************\ - -Function: base_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void base_type(typet &type, const namespacet &ns) { std::set symb; base_type_rec(type, ns, symb); } -/*******************************************************************\ - -Function: base_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void base_type(exprt &expr, const namespacet &ns) { base_type(expr.type(), ns); @@ -122,18 +89,6 @@ void base_type(exprt &expr, const namespacet &ns) base_type(*it, ns); } -/*******************************************************************\ - -Function: base_type_eqt::base_type_eq_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool base_type_eqt::base_type_eq_rec( const typet &type1, const typet &type2) @@ -142,8 +97,8 @@ bool base_type_eqt::base_type_eq_rec( return true; #if 0 - std::cout << "T1: " << type1.pretty() << std::endl; - std::cout << "T2: " << type2.pretty() << std::endl; + std::cout << "T1: " << type1.pretty() << '\n'; + std::cout << "T2: " << type2.pretty() << '\n'; #endif // loop avoidance @@ -282,18 +237,6 @@ bool base_type_eqt::base_type_eq_rec( return tmp1==tmp2; } -/*******************************************************************\ - -Function: base_type_eqt::base_type_eq_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool base_type_eqt::base_type_eq_rec( const exprt &expr1, const exprt &expr2) @@ -323,18 +266,6 @@ bool base_type_eqt::base_type_eq_rec( return true; } -/*******************************************************************\ - -Function: base_type_eq - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool base_type_eq( const typet &type1, const typet &type2, @@ -344,18 +275,6 @@ bool base_type_eq( return base_type_eq.base_type_eq(type1, type2); } -/*******************************************************************\ - -Function: base_type_eq - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool base_type_eq( const exprt &expr1, const exprt &expr2, diff --git a/src/util/base_type.h b/src/util/base_type.h index 41e2fe6df4f..833fd855cca 100644 --- a/src/util/base_type.h +++ b/src/util/base_type.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Base Type Computation + #ifndef CPROVER_UTIL_BASE_TYPE_H #define CPROVER_UTIL_BASE_TYPE_H @@ -26,14 +29,6 @@ bool base_type_eq( const exprt &expr2, const namespacet &ns); -/*******************************************************************\ - - Class: base_type_eqt - - Purpose: - -\*******************************************************************/ - class base_type_eqt { public: diff --git a/src/util/bv_arithmetic.cpp b/src/util/bv_arithmetic.cpp index 4e077ad0a1e..0507523930c 100644 --- a/src/util/bv_arithmetic.cpp +++ b/src/util/bv_arithmetic.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -15,18 +16,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "std_expr.h" #include "bv_arithmetic.h" -/*******************************************************************\ - -Function: bv_spect::to_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet bv_spect::to_type() const { if(is_signed) @@ -34,54 +23,18 @@ typet bv_spect::to_type() const return unsignedbv_typet(width); } -/*******************************************************************\ - -Function: bv_spect::max_value - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - mp_integer bv_spect::max_value() const { return is_signed?power(2, width-1)-1: power(2, width)-1; } -/*******************************************************************\ - -Function: bv_spect::min_value - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - mp_integer bv_spect::min_value() const { return is_signed?-power(2, width-1): 0; } -/*******************************************************************\ - -Function: bv_spect::from_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bv_spect::from_type(const typet &type) { if(type.id()==ID_unsignedbv) @@ -94,35 +47,11 @@ void bv_spect::from_type(const typet &type) width=unsafe_string2unsigned(type.get_string(ID_width)); } -/*******************************************************************\ - -Function: bv_arithmetict::print - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bv_arithmetict::print(std::ostream &out) const { out << to_ansi_c_string(); } -/*******************************************************************\ - -Function: bv_arithmetict::format - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string bv_arithmetict::format(const format_spect &format_spec) const { std::string result; @@ -132,36 +61,12 @@ std::string bv_arithmetict::format(const format_spect &format_spec) const return result; } -/*******************************************************************\ - -Function: bv_arithmetict::from_integer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bv_arithmetict::from_integer(const mp_integer &i) { value=i; adjust(); } -/*******************************************************************\ - -Function: bv_arithmetict::adjust - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bv_arithmetict::adjust() { mp_integer p=power(2, spec.width); @@ -171,18 +76,6 @@ void bv_arithmetict::adjust() value-=p; } -/*******************************************************************\ - -Function: bv_arithmetict::pack - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - mp_integer bv_arithmetict::pack() const { if(value>=0) @@ -190,18 +83,6 @@ mp_integer bv_arithmetict::pack() const return value+power(2, spec.width); } -/*******************************************************************\ - -Function: bv_arithmetict::to_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt bv_arithmetict::to_expr() const { constant_exprt result(spec.to_type()); @@ -209,18 +90,6 @@ exprt bv_arithmetict::to_expr() const return result; } -/*******************************************************************\ - -Function: operator /= - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bv_arithmetict &bv_arithmetict::operator/=(const bv_arithmetict &other) { assert(other.spec==spec); @@ -233,18 +102,6 @@ bv_arithmetict &bv_arithmetict::operator/=(const bv_arithmetict &other) return *this; } -/*******************************************************************\ - -Function: operator *= - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bv_arithmetict &bv_arithmetict::operator*=(const bv_arithmetict &other) { assert(other.spec==spec); @@ -255,18 +112,6 @@ bv_arithmetict &bv_arithmetict::operator*=(const bv_arithmetict &other) return *this; } -/*******************************************************************\ - -Function: operator += - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bv_arithmetict &bv_arithmetict::operator+=(const bv_arithmetict &other) { assert(other.spec==spec); @@ -277,18 +122,6 @@ bv_arithmetict &bv_arithmetict::operator+=(const bv_arithmetict &other) return *this; } -/*******************************************************************\ - -Function: operator -= - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bv_arithmetict &bv_arithmetict::operator -= (const bv_arithmetict &other) { assert(other.spec==spec); @@ -299,18 +132,6 @@ bv_arithmetict &bv_arithmetict::operator -= (const bv_arithmetict &other) return *this; } -/*******************************************************************\ - -Function: operator %= - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bv_arithmetict &bv_arithmetict::operator%=(const bv_arithmetict &other) { assert(other.spec==spec); @@ -321,155 +142,47 @@ bv_arithmetict &bv_arithmetict::operator%=(const bv_arithmetict &other) return *this; } -/*******************************************************************\ - -Function: operator < - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool bv_arithmetict::operator<(const bv_arithmetict &other) { return value - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool bv_arithmetict::operator>(const bv_arithmetict &other) { return value>other.value; } -/*******************************************************************\ - -Function: bv_arithmetict::operator>= - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool bv_arithmetict::operator>=(const bv_arithmetict &other) { return value>=other.value; } -/*******************************************************************\ - -Function: bv_arithmetict::operator== - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool bv_arithmetict::operator==(const bv_arithmetict &other) { return value==other.value; } -/*******************************************************************\ - -Function: bv_arithmetict::operator== - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool bv_arithmetict::operator==(int i) { return value==i; } -/*******************************************************************\ - -Function: bv_arithmetict::operator!= - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool bv_arithmetict::operator!=(const bv_arithmetict &other) { return value!=other.value; } -/*******************************************************************\ - -Function: bv_arithmetict::change_spec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bv_arithmetict::change_spec(const bv_spect &dest_spec) { spec=dest_spec; adjust(); } -/*******************************************************************\ - -Function: bv_arithmetict::from_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void bv_arithmetict::from_expr(const exprt &expr) { assert(expr.is_constant()); diff --git a/src/util/bv_arithmetic.h b/src/util/bv_arithmetic.h index a5d91485490..3774344d18f 100644 --- a/src/util/bv_arithmetic.h +++ b/src/util/bv_arithmetic.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_BV_ARITHMETIC_H #define CPROVER_UTIL_BV_ARITHMETIC_H diff --git a/src/util/byte_operators.cpp b/src/util/byte_operators.cpp index 46e7d3f218e..f1d58c52892 100644 --- a/src/util/byte_operators.cpp +++ b/src/util/byte_operators.cpp @@ -6,23 +6,12 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "byte_operators.h" #include "config.h" -/*******************************************************************\ - -Function: byte_extract_id - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - irep_idt byte_extract_id() { switch(config.ansi_c.endianness) @@ -38,18 +27,6 @@ irep_idt byte_extract_id() } } -/*******************************************************************\ - -Function: byte_update_id - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - irep_idt byte_update_id() { switch(config.ansi_c.endianness) diff --git a/src/util/byte_operators.h b/src/util/byte_operators.h index 9b0745833cc..6833a509346 100644 --- a/src/util/byte_operators.h +++ b/src/util/byte_operators.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_BYTE_OPERATORS_H #define CPROVER_UTIL_BYTE_OPERATORS_H diff --git a/src/util/c_types.cpp b/src/util/c_types.cpp new file mode 100644 index 00000000000..cc2880cb577 --- /dev/null +++ b/src/util/c_types.cpp @@ -0,0 +1,371 @@ +/*******************************************************************\ + +Module: + +Author: Daniel Kroening, kroening@kroening.com + +\*******************************************************************/ + + +#include "std_types.h" +#include "config.h" + +#include "c_types.h" + +bitvector_typet index_type() +{ + // same as signed size type + return signed_size_type(); +} + +/// return type of enum constants +bitvector_typet enum_constant_type() +{ + // usually same as 'int', + // but might be unsigned, or shorter than 'int' + return signed_int_type(); +} + +signedbv_typet signed_int_type() +{ + signedbv_typet result(config.ansi_c.int_width); + result.set(ID_C_c_type, ID_signed_int); + return result; +} + +signedbv_typet signed_short_int_type() +{ + signedbv_typet result(config.ansi_c.short_int_width); + result.set(ID_C_c_type, ID_signed_short_int); + return result; +} + +unsignedbv_typet unsigned_int_type() +{ + unsignedbv_typet result(config.ansi_c.int_width); + result.set(ID_C_c_type, ID_unsigned_int); + return result; +} + +unsignedbv_typet unsigned_short_int_type() +{ + unsignedbv_typet result(config.ansi_c.short_int_width); + result.set(ID_C_c_type, ID_unsigned_short_int); + return result; +} + +unsignedbv_typet size_type() +{ + // The size type varies. This is unsigned int on some systems, + // and unsigned long int on others, + // and unsigned long long on say Windows 64. + + if(config.ansi_c.pointer_width==config.ansi_c.int_width) + return unsigned_int_type(); + else if(config.ansi_c.pointer_width==config.ansi_c.long_int_width) + return unsigned_long_int_type(); + else if(config.ansi_c.pointer_width==config.ansi_c.long_long_int_width) + return unsigned_long_long_int_type(); + else + assert(false); // aaah! +} + +signedbv_typet signed_size_type() +{ + // we presume this is the same as pointer difference + return pointer_diff_type(); +} + +signedbv_typet signed_long_int_type() +{ + signedbv_typet result(config.ansi_c.long_int_width); + result.set(ID_C_c_type, ID_signed_long_int); + return result; +} + +signedbv_typet signed_long_long_int_type() +{ + signedbv_typet result(config.ansi_c.long_long_int_width); + result.set(ID_C_c_type, ID_signed_long_long_int); + return result; +} + +unsignedbv_typet unsigned_long_int_type() +{ + unsignedbv_typet result(config.ansi_c.long_int_width); + result.set(ID_C_c_type, ID_unsigned_long_int); + return result; +} + +unsignedbv_typet unsigned_long_long_int_type() +{ + unsignedbv_typet result(config.ansi_c.long_long_int_width); + result.set(ID_C_c_type, ID_unsigned_long_long_int); + return result; +} + +typet c_bool_type() +{ + typet result=c_bool_typet(config.ansi_c.bool_width); + return result; +} + +bitvector_typet char_type() +{ + // this can be signed or unsigned, depending on the architecture + + // There are 3 char types, i.e., this one is + // different from either signed char or unsigned char! + + if(config.ansi_c.char_is_unsigned) + { + unsignedbv_typet result(config.ansi_c.char_width); + result.set(ID_C_c_type, ID_char); + return result; + } + else + { + signedbv_typet result(config.ansi_c.char_width); + result.set(ID_C_c_type, ID_char); + return result; + } +} + +unsignedbv_typet unsigned_char_type() +{ + unsignedbv_typet result(config.ansi_c.char_width); + result.set(ID_C_c_type, ID_unsigned_char); + return result; +} + +signedbv_typet signed_char_type() +{ + signedbv_typet result(config.ansi_c.char_width); + result.set(ID_C_c_type, ID_signed_char); + return result; +} + +bitvector_typet wchar_t_type() +{ + if(config.ansi_c.wchar_t_is_unsigned) + { + unsignedbv_typet result(config.ansi_c.wchar_t_width); + result.set(ID_C_c_type, ID_wchar_t); + return result; + } + else + { + signedbv_typet result(config.ansi_c.wchar_t_width); + result.set(ID_C_c_type, ID_wchar_t); + return result; + } +} + +unsignedbv_typet char16_t_type() +{ + // Types char16_t and char32_t denote distinct types with the same size, + // signedness, and alignment as uint_least16_t and uint_least32_t, + // respectively, in , called the underlying types. + unsignedbv_typet result(16); + result.set(ID_C_c_type, ID_char16_t); + return result; +} + +unsignedbv_typet char32_t_type() +{ + // Types char16_t and char32_t denote distinct types with the same size, + // signedness, and alignment as uint_least16_t and uint_least32_t, + // respectively, in , called the underlying types. + unsignedbv_typet result(32); + result.set(ID_C_c_type, ID_char32_t); + return result; +} + +bitvector_typet float_type() +{ + if(config.ansi_c.use_fixed_for_float) + { + fixedbv_typet result; + result.set_width(config.ansi_c.single_width); + result.set_integer_bits(config.ansi_c.single_width/2); + result.set(ID_C_c_type, ID_float); + return result; + } + else + { + floatbv_typet result= + ieee_float_spect::single_precision().to_type(); + result.set(ID_C_c_type, ID_float); + return result; + } +} + +bitvector_typet double_type() +{ + if(config.ansi_c.use_fixed_for_float) + { + fixedbv_typet result; + result.set_width(config.ansi_c.double_width); + result.set_integer_bits(config.ansi_c.double_width/2); + result.set(ID_C_c_type, ID_double); + return result; + } + else + { + floatbv_typet result= + ieee_float_spect::double_precision().to_type(); + result.set(ID_C_c_type, ID_double); + return result; + } +} + +bitvector_typet long_double_type() +{ + if(config.ansi_c.use_fixed_for_float) + { + fixedbv_typet result; + result.set_width(config.ansi_c.long_double_width); + result.set_integer_bits(config.ansi_c.long_double_width/2); + result.set(ID_C_c_type, ID_long_double); + return result; + } + else + { + floatbv_typet result; + if(config.ansi_c.long_double_width==128) + result=ieee_float_spect::quadruple_precision().to_type(); + else if(config.ansi_c.long_double_width==64) + result=ieee_float_spect::double_precision().to_type(); + else if(config.ansi_c.long_double_width==80) + { + // x86 extended precision has 80 bits in total, and + // deviating from IEEE, does not use a hidden bit. + // We use the closest we have got, but the below isn't accurate. + result=ieee_float_spect(63, 15).to_type(); + } + else if(config.ansi_c.long_double_width==96) + { + result=ieee_float_spect(80, 15).to_type(); + // not quite right. The extra bits beyond 80 are usually padded. + } + else + assert(false); + + result.set(ID_C_c_type, ID_long_double); + + return result; + } +} + +bitvector_typet gcc_float128_type() +{ + // not same as long double! + + if(config.ansi_c.use_fixed_for_float) + { + fixedbv_typet result; + result.set_width(128); + result.set_integer_bits(128/2); + result.set(ID_C_c_type, ID_gcc_float128); + return result; + } + else + { + floatbv_typet result= + ieee_float_spect::quadruple_precision().to_type(); + result.set(ID_C_c_type, ID_gcc_float128); + return result; + } +} + +signedbv_typet pointer_diff_type() +{ + // The pointer-diff type varies. This is signed int on some systems, + // and signed long int on others, and signed long long on say Windows. + + if(config.ansi_c.pointer_width==config.ansi_c.int_width) + return signed_int_type(); + else if(config.ansi_c.pointer_width==config.ansi_c.long_int_width) + return signed_long_int_type(); + else if(config.ansi_c.pointer_width==config.ansi_c.long_long_int_width) + return signed_long_long_int_type(); + else + assert(false); // aaah! +} + +pointer_typet pointer_type(const typet &subtype) +{ + return pointer_typet(subtype); +} + +reference_typet reference_type(const typet &subtype) +{ + return reference_typet(subtype); +} + +typet void_type() +{ + return empty_typet(); +} + +unsignedbv_typet gcc_unsigned_int128_type() +{ + unsignedbv_typet result(128); + result.set(ID_C_c_type, ID_unsigned_int128); + return result; +} + +signedbv_typet gcc_signed_int128_type() +{ + signedbv_typet result(128); + result.set(ID_C_c_type, ID_signed_int128); + return result; +} + +std::string c_type_as_string(const irep_idt &c_type) +{ + if(c_type==ID_signed_int) + return "signed int"; + else if(c_type==ID_signed_short_int) + return "signed short int"; + else if(c_type==ID_unsigned_int) + return "unsigned int"; + else if(c_type==ID_unsigned_short_int) + return "unsigned short int"; + else if(c_type==ID_signed_long_int) + return "signed long int"; + else if(c_type==ID_signed_long_long_int) + return "signed long long int"; + else if(c_type==ID_unsigned_long_int) + return "unsigned long int"; + else if(c_type==ID_unsigned_long_long_int) + return "unsigned long long int"; + else if(c_type==ID_bool) + return "_Bool"; + else if(c_type==ID_char) + return "char"; + else if(c_type==ID_unsigned_char) + return "unsigned char"; + else if(c_type==ID_signed_char) + return "signed char"; + else if(c_type==ID_wchar_t) + return "wchar_t"; + else if(c_type==ID_char16_t) + return "char16_t"; + else if(c_type==ID_char32_t) + return "char32_t"; + else if(c_type==ID_float) + return "float"; + else if(c_type==ID_double) + return "double"; + else if(c_type==ID_long_double) + return "long double"; + else if(c_type==ID_gcc_float128) + return "__float128"; + else if(c_type==ID_unsigned_int128) + return "unsigned __int128"; + else if(c_type==ID_signed_int128) + return "signed __int128"; + else + return ""; +} diff --git a/src/util/c_types.h b/src/util/c_types.h new file mode 100644 index 00000000000..39e76a6c7b3 --- /dev/null +++ b/src/util/c_types.h @@ -0,0 +1,51 @@ +/*******************************************************************\ + +Module: + +Author: Daniel Kroening, kroening@kroening.com + +\*******************************************************************/ + + +#ifndef CPROVER_UTIL_C_TYPES_H +#define CPROVER_UTIL_C_TYPES_H + +#include "std_types.h" + +bitvector_typet index_type(); +bitvector_typet enum_constant_type(); +signedbv_typet signed_int_type(); +unsignedbv_typet unsigned_int_type(); +signedbv_typet signed_long_int_type(); +signedbv_typet signed_short_int_type(); +unsignedbv_typet unsigned_short_int_type(); +signedbv_typet signed_long_long_int_type(); +unsignedbv_typet unsigned_long_int_type(); +unsignedbv_typet unsigned_long_long_int_type(); +typet c_bool_type(); +bitvector_typet char_type(); +unsignedbv_typet unsigned_char_type(); +signedbv_typet signed_char_type(); +bitvector_typet wchar_t_type(); +unsignedbv_typet char16_t_type(); +unsignedbv_typet char32_t_type(); +bitvector_typet float_type(); +bitvector_typet double_type(); +bitvector_typet long_double_type(); +bitvector_typet gcc_float128_type(); +unsignedbv_typet gcc_unsigned_int128_type(); +signedbv_typet gcc_signed_int128_type(); +unsignedbv_typet size_type(); +signedbv_typet signed_size_type(); +signedbv_typet pointer_diff_type(); +pointer_typet pointer_type(const typet &); +typet void_type(); + +// This is for Java and C++ +reference_typet reference_type(const typet &); + +// Turns an ID_C_c_type into a string, e.g., +// ID_signed_int gets "signed int". +std::string c_type_as_string(const irep_idt &); + +#endif // CPROVER_UTIL_C_TYPES_H diff --git a/src/util/cmdline.cpp b/src/util/cmdline.cpp index 56d6a7a1a6c..10ca6ac97c8 100644 --- a/src/util/cmdline.cpp +++ b/src/util/cmdline.cpp @@ -6,75 +6,28 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include #include "cmdline.h" -/*******************************************************************\ - -Function: cmdlinet::cmdlinet - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - cmdlinet::cmdlinet() { } -/*******************************************************************\ - -Function: cmdlinet::~cmdlinet - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - cmdlinet::~cmdlinet() { clear(); } -/*******************************************************************\ - -Function: cmdlinet::clear - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cmdlinet::clear() { options.clear(); args.clear(); } -/*******************************************************************\ - -Function: cmdlinet::isset - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool cmdlinet::isset(char option) const { int i=getoptnr(option); @@ -83,18 +36,6 @@ bool cmdlinet::isset(char option) const return options[i].isset; } -/*******************************************************************\ - -Function: cmdlinet::isset - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool cmdlinet::isset(const char *option) const { int i=getoptnr(option); @@ -103,18 +44,6 @@ bool cmdlinet::isset(const char *option) const return options[i].isset; } -/*******************************************************************\ - -Function: cmdlinet::get_value - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string cmdlinet::get_value(char option) const { int i=getoptnr(option); @@ -125,18 +54,6 @@ std::string cmdlinet::get_value(char option) const return options[i].values.front(); } -/*******************************************************************\ - -Function: cmdlinet::set - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cmdlinet::set(const std::string &option) { int i=getoptnr(option); @@ -145,18 +62,6 @@ void cmdlinet::set(const std::string &option) options[i].isset=true; } -/*******************************************************************\ - -Function: cmdlinet::set - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void cmdlinet::set(const std::string &option, const std::string &value) { int i=getoptnr(option); @@ -166,18 +71,6 @@ void cmdlinet::set(const std::string &option, const std::string &value) options[i].values.push_back(value); } -/*******************************************************************\ - -Function: cmdlinet::get_values - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const std::list &cmdlinet::get_values(char option) const { int i=getoptnr(option); @@ -185,18 +78,6 @@ const std::list &cmdlinet::get_values(char option) const return options[i].values; } -/*******************************************************************\ - -Function: cmdlinet::get_value - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string cmdlinet::get_value(const char *option) const { int i=getoptnr(option); @@ -207,18 +88,6 @@ std::string cmdlinet::get_value(const char *option) const return options[i].values.front(); } -/*******************************************************************\ - -Function: cmdlinet::get_values - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const std::list &cmdlinet::get_values( const std::string &option) const { @@ -227,18 +96,6 @@ const std::list &cmdlinet::get_values( return options[i].values; } -/*******************************************************************\ - -Function: cmdlinet::getoptnr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - int cmdlinet::getoptnr(char option) const { for(unsigned i=0; i #include "namespace.h" @@ -19,52 +20,16 @@ Author: Daniel Kroening, kroening@kroening.com configt config; -/*******************************************************************\ - -Function: configt::ansi_ct::set_16 - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void configt::ansi_ct::set_16() { set_LP32(); } -/*******************************************************************\ - -Function: configt::ansi_ct::set_32 - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void configt::ansi_ct::set_32() { set_ILP32(); } -/*******************************************************************\ - -Function: configt::ansi_ct::set_64 - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void configt::ansi_ct::set_64() { #ifdef _WIN32 @@ -74,18 +39,7 @@ void configt::ansi_ct::set_64() #endif } -/*******************************************************************\ - -Function: configt::ansi_ct::set_LP64 - - Inputs: - - Outputs: - - Purpose: int=32, long=64, pointer=64 - -\*******************************************************************/ - +/// int=32, long=64, pointer=64 void configt::ansi_ct::set_LP64() { bool_width=1*8; @@ -105,18 +59,7 @@ void configt::ansi_ct::set_LP64() memory_operand_size=int_width/8; } -/*******************************************************************\ - -Function: configt::ansi_ct::set_ILP64 - - Inputs: - - Outputs: - - Purpose: int=64, long=64, pointer=64 - -\*******************************************************************/ - +/// int=64, long=64, pointer=64 // TODO: find the alignment restrictions (per type) of the different // architectures (currently: sizeof=alignedof) // TODO: implement the __attribute__((__aligned__(val))) @@ -140,18 +83,7 @@ void configt::ansi_ct::set_ILP64() memory_operand_size=int_width/8; } -/*******************************************************************\ - -Function: configt::ansi_ct::set_LLP64 - - Inputs: - - Outputs: - - Purpose: int=32, long=32, pointer=64 - -\*******************************************************************/ - +/// int=32, long=32, pointer=64 void configt::ansi_ct::set_LLP64() { bool_width=1*8; @@ -171,18 +103,7 @@ void configt::ansi_ct::set_LLP64() memory_operand_size=int_width/8; } -/*******************************************************************\ - -Function: configt::ansi_ct::set_ILP32 - - Inputs: - - Outputs: - - Purpose: int=32, long=32, pointer=32 - -\*******************************************************************/ - +/// int=32, long=32, pointer=32 void configt::ansi_ct::set_ILP32() { bool_width=1*8; @@ -202,18 +123,7 @@ void configt::ansi_ct::set_ILP32() memory_operand_size=int_width/8; } -/*******************************************************************\ - -Function: configt::ansi_ct::set_LP32 - - Inputs: - - Outputs: - - Purpose: int=16, long=32, pointer=32 - -\*******************************************************************/ - +/// int=16, long=32, pointer=32 void configt::ansi_ct::set_LP32() { bool_width=1*8; @@ -233,18 +143,6 @@ void configt::ansi_ct::set_LP32() memory_operand_size=int_width/8; } -/*******************************************************************\ - -Function: configt::ansi_ct::set_arch_spec_i386 - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void configt::ansi_ct::set_arch_spec_i386() { set_ILP32(); @@ -277,18 +175,6 @@ void configt::ansi_ct::set_arch_spec_i386() } } -/*******************************************************************\ - -Function: configt::ansi_ct::set_arch_spec_x86_64 - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void configt::ansi_ct::set_arch_spec_x86_64() { set_LP64(); @@ -326,18 +212,6 @@ void configt::ansi_ct::set_arch_spec_x86_64() } } -/*******************************************************************\ - -Function: configt::ansi_ct::set_arch_spec_power - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void configt::ansi_ct::set_arch_spec_power(const irep_idt &subarch) { if(subarch=="powerpc") @@ -399,18 +273,6 @@ void configt::ansi_ct::set_arch_spec_power(const irep_idt &subarch) } } -/*******************************************************************\ - -Function: configt::ansi_ct::set_arch_spec_arm - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void configt::ansi_ct::set_arch_spec_arm(const irep_idt &subarch) { if(subarch=="arm64") @@ -454,18 +316,6 @@ void configt::ansi_ct::set_arch_spec_arm(const irep_idt &subarch) } } -/*******************************************************************\ - -Function: configt::ansi_ct::set_arch_spec_alpha - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void configt::ansi_ct::set_arch_spec_alpha() { set_LP64(); @@ -495,18 +345,6 @@ void configt::ansi_ct::set_arch_spec_alpha() } } -/*******************************************************************\ - -Function: configt::ansi_ct::set_arch_spec_mips - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void configt::ansi_ct::set_arch_spec_mips(const irep_idt &subarch) { if(subarch=="mipsel" || @@ -557,18 +395,6 @@ void configt::ansi_ct::set_arch_spec_mips(const irep_idt &subarch) } } -/*******************************************************************\ - -Function: configt::ansi_ct::set_arch_spec_s390 - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void configt::ansi_ct::set_arch_spec_s390() { set_ILP32(); @@ -598,18 +424,6 @@ void configt::ansi_ct::set_arch_spec_s390() } } -/*******************************************************************\ - -Function: configt::ansi_ct::set_arch_spec_s390x - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void configt::ansi_ct::set_arch_spec_s390x() { set_LP64(); @@ -638,18 +452,6 @@ void configt::ansi_ct::set_arch_spec_s390x() } } -/*******************************************************************\ - -Function: configt::ansi_ct::set_arch_spec_sparc - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void configt::ansi_ct::set_arch_spec_sparc(const irep_idt &subarch) { if(subarch=="sparc64") @@ -690,18 +492,6 @@ void configt::ansi_ct::set_arch_spec_sparc(const irep_idt &subarch) } } -/*******************************************************************\ - -Function: configt::ansi_ct::set_arch_spec_ia64 - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void configt::ansi_ct::set_arch_spec_ia64() { set_LP64(); @@ -733,18 +523,6 @@ void configt::ansi_ct::set_arch_spec_ia64() } } -/*******************************************************************\ - -Function: configt::ansi_ct::set_arch_spec_x32 - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void configt::ansi_ct::set_arch_spec_x32() { // This is a variant of x86_64 that has @@ -780,18 +558,8 @@ void configt::ansi_ct::set_arch_spec_x32() } } -/*******************************************************************\ - -Function: configt::ansi_ct::set_arch_spec_v850 - - Inputs: None - - Outputs: None - - Purpose: Sets up the widths of variables for the Renesas V850 - -\*******************************************************************/ - +/// Sets up the widths of variables for the Renesas V850 +/// \return None void configt::ansi_ct::set_arch_spec_v850() { // The Renesas V850 is a 32-bit microprocessor used in @@ -815,18 +583,6 @@ void configt::ansi_ct::set_arch_spec_v850() // No preprocessor definitions due to lack of information } -/*******************************************************************\ - -Function: configt::ansi_ct::set_arch_spec_hppa - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void configt::ansi_ct::set_arch_spec_hppa() { set_ILP32(); @@ -856,18 +612,6 @@ void configt::ansi_ct::set_arch_spec_hppa() } } -/*******************************************************************\ - -Function: configt::ansi_ct::set_arch_spec_sh4 - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void configt::ansi_ct::set_arch_spec_sh4() { set_ILP32(); @@ -898,18 +642,6 @@ void configt::ansi_ct::set_arch_spec_sh4() } } -/*******************************************************************\ - -Function: configt::ansi_ct::default_c_standard - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - configt::ansi_ct::c_standardt configt::ansi_ct::default_c_standard() { #if defined(__APPLE__) @@ -923,35 +655,11 @@ configt::ansi_ct::c_standardt configt::ansi_ct::default_c_standard() #endif } -/*******************************************************************\ - -Function: configt::ansi_ct::default_cpp_standard - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - configt::cppt::cpp_standardt configt::cppt::default_cpp_standard() { return cpp_standardt::CPP98; } -/*******************************************************************\ - -Function: configt::set_arch - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void configt::set_arch(const irep_idt &arch) { ansi_c.arch=arch; @@ -1016,18 +724,6 @@ void configt::set_arch(const irep_idt &arch) } } -/*******************************************************************\ - -Function: configt::set - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool configt::set(const cmdlinet &cmdline) { // defaults -- we match the architecture we have ourselves @@ -1314,18 +1010,6 @@ bool configt::set(const cmdlinet &cmdline) return false; } -/*******************************************************************\ - -Function: configt::ansi_ct::os_to_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string configt::ansi_ct::os_to_string(ost os) { switch(os) @@ -1337,18 +1021,6 @@ std::string configt::ansi_ct::os_to_string(ost os) } } -/*******************************************************************\ - -Function: configt::ansi_ct::string_to_os - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - configt::ansi_ct::ost configt::ansi_ct::string_to_os(const std::string &os) { if(os=="linux") @@ -1361,18 +1033,6 @@ configt::ansi_ct::ost configt::ansi_ct::string_to_os(const std::string &os) return ost::NO_OS; } -/*******************************************************************\ - -Function: string_from_ns - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static irep_idt string_from_ns( const namespacet &ns, const std::string &what) @@ -1399,18 +1059,6 @@ static irep_idt string_from_ns( return tmp.op0().op0().get(ID_value); } -/*******************************************************************\ - -Function: unsigned_from_ns - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static unsigned unsigned_from_ns( const namespacet &ns, const std::string &what) @@ -1437,18 +1085,6 @@ static unsigned unsigned_from_ns( return integer2unsigned(int_value); } -/*******************************************************************\ - -Function: configt::set_from_symbol_table - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void configt::set_from_symbol_table( const symbol_tablet &symbol_table) { @@ -1506,18 +1142,6 @@ void configt::set_from_symbol_table( // lib, string_abstraction not stored in namespace } -/*******************************************************************\ - -Function: configt::ansi_ct::this_architecture - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - irep_idt configt::this_architecture() { irep_idt this_arch; @@ -1599,18 +1223,6 @@ irep_idt configt::this_architecture() return this_arch; } -/*******************************************************************\ - -Function: configt::set_classpath - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void configt::set_classpath(const std::string &cp) { std::string current; @@ -1640,18 +1252,6 @@ void configt::set_classpath(const std::string &cp) java.classpath.push_back(current); } -/*******************************************************************\ - -Function: configt::ansi_ct::this_operating_system - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - irep_idt configt::this_operating_system() { irep_idt this_os; diff --git a/src/util/config.h b/src/util/config.h index f8c2f1f96dd..6fb4a5a2376 100644 --- a/src/util/config.h +++ b/src/util/config.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_CONFIG_H #define CPROVER_UTIL_CONFIG_H diff --git a/src/util/cout_message.cpp b/src/util/cout_message.cpp index 393ec62432f..357453bd20e 100644 --- a/src/util/cout_message.cpp +++ b/src/util/cout_message.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #ifdef _WIN32 @@ -18,68 +19,22 @@ Author: Daniel Kroening, kroening@kroening.com #include "unicode.h" #include "cout_message.h" -/*******************************************************************\ - -Function: cout_message_handlert::print - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -void cout_message_handlert::print( - unsigned level, - const std::string &message) +cout_message_handlert::cout_message_handlert(): + stream_message_handlert(std::cout) { - if(verbosity>=level) - { - std::cout << message << '\n'; - - // We flush for level 6 or below. - if(level<=6) - std::cout << std::flush; - } } -/*******************************************************************\ - -Function: cerr_message_handlert::print - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -void cerr_message_handlert::print( - unsigned level, - const std::string &message) +cerr_message_handlert::cerr_message_handlert(): + stream_message_handlert(std::cerr) { - if(verbosity>=level) - std::cerr << message << '\n' << std::flush; } -/*******************************************************************\ - -Function: consolte_message_handlert::print - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void console_message_handlert::print( unsigned level, const std::string &message) { + message_handlert::print(level, message); + if(verbosity=4) { std::cout << message << '\n'; - - if(level<=6) - std::cout << std::flush; } else - std::cerr << message << '\n' << std::flush; + std::cerr << message << '\n'; } #else - // We flush after messages of level 6 or lower. - // We don't for messages of level 7 or higher to improve performance, - // in particular when writing to NFS. // Messages level 3 or lower go to cerr, messages level 4 or // above go to cout. if(level>=4) { std::cout << message << '\n'; + } + else + std::cerr << message << '\n'; + #endif +} +void console_message_handlert::flush(unsigned level) +{ + // We flush after messages of level 6 or lower. + // We don't for messages of level 7 or higher to improve performance, + // in particular when writing to NFS. + if(level>=4) + { if(level<=6) std::cout << std::flush; } else - std::cerr << message << '\n' << std::flush; - #endif + std::cerr << std::flush; } -/*******************************************************************\ - -Function: gcc_message_handlert::print - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void gcc_message_handlert::print( unsigned level, const std::string &message, @@ -183,9 +131,9 @@ void gcc_message_handlert::print( else dest+=id2string(column)+": "; - if(level==message_clientt::M_ERROR) + if(level==messaget::M_ERROR) dest+="error: "; - else if(level==message_clientt::M_WARNING) + else if(level==messaget::M_WARNING) dest+="warning: "; } @@ -194,22 +142,12 @@ void gcc_message_handlert::print( print(level, dest); } -/*******************************************************************\ - -Function: gcc_message_handlert::print - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void gcc_message_handlert::print( unsigned level, const std::string &message) { + message_handlert::print(level, message); + // gcc appears to send everything to cerr if(verbosity>=level) std::cerr << message << '\n' << std::flush; diff --git a/src/util/cout_message.h b/src/util/cout_message.h index ab78148c6d6..39d4bddd349 100644 --- a/src/util/cout_message.h +++ b/src/util/cout_message.h @@ -6,39 +6,38 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_COUT_MESSAGE_H #define CPROVER_UTIL_COUT_MESSAGE_H -#include "message.h" +#include "ui_message.h" -class cout_message_handlert:public message_handlert +class cout_message_handlert:public stream_message_handlert { public: - // all messages go to cout - virtual void print( - unsigned level, - const std::string &message) override; + // all messages go to stdout + cout_message_handlert(); }; -class cerr_message_handlert:public message_handlert +class cerr_message_handlert:public stream_message_handlert { public: - // all messages go to cerr - virtual void print( - unsigned level, - const std::string &message) override; + // all messages go to stderr + cerr_message_handlert(); }; -class console_message_handlert:public message_handlert +class console_message_handlert:public ui_message_handlert { public: // level 4 and upwards go to cout, level 1-3 to cerr virtual void print( unsigned level, const std::string &message) override; + + virtual void flush(unsigned level) override; }; -class gcc_message_handlert:public message_handlert +class gcc_message_handlert:public ui_message_handlert { public: // aims to imitate the messages gcc prints diff --git a/src/util/cprover_prefix.h b/src/util/cprover_prefix.h index 01fc391bf02..5d6fe6b84e0 100644 --- a/src/util/cprover_prefix.h +++ b/src/util/cprover_prefix.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_CPROVER_PREFIX_H #define CPROVER_UTIL_CPROVER_PREFIX_H diff --git a/src/util/decision_procedure.cpp b/src/util/decision_procedure.cpp index 6800b0148d6..bfee87da74e 100644 --- a/src/util/decision_procedure.cpp +++ b/src/util/decision_procedure.cpp @@ -6,22 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Decision Procedure Interface + #include #include "decision_procedure.h" -/*******************************************************************\ - -Function: decision_proceduret::in_core - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool decision_proceduret::in_core(const exprt &expr) { assert(false); diff --git a/src/util/decision_procedure.h b/src/util/decision_procedure.h index a3c1cf05710..65caffab17e 100644 --- a/src/util/decision_procedure.h +++ b/src/util/decision_procedure.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Decision Procedure Interface + #ifndef CPROVER_UTIL_DECISION_PROCEDURE_H #define CPROVER_UTIL_DECISION_PROCEDURE_H diff --git a/src/util/dstring.cpp b/src/util/dstring.cpp index 4fa9769be23..18602127ea1 100644 --- a/src/util/dstring.cpp +++ b/src/util/dstring.cpp @@ -6,4 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Container for C-Strings + #include "dstring.h" diff --git a/src/util/dstring.h b/src/util/dstring.h index bda6dece8e6..ae25a395071 100644 --- a/src/util/dstring.h +++ b/src/util/dstring.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Container for C-Strings + #ifndef CPROVER_UTIL_DSTRING_H #define CPROVER_UTIL_DSTRING_H diff --git a/src/util/endianness_map.cpp b/src/util/endianness_map.cpp index d030df0c75e..6b636ca658f 100644 --- a/src/util/endianness_map.cpp +++ b/src/util/endianness_map.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -15,18 +16,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "endianness_map.h" #include "namespace.h" -/*******************************************************************\ - -Function: endianness_mapt::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void endianness_mapt::output(std::ostream &out) const { for(std::vector::const_iterator it=map.begin(); @@ -39,18 +28,6 @@ void endianness_mapt::output(std::ostream &out) const } } -/*******************************************************************\ - -Function: endianness_mapt::build - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void endianness_mapt::build(const typet &src, bool little_endian) { if(little_endian) @@ -59,18 +36,6 @@ void endianness_mapt::build(const typet &src, bool little_endian) build_big_endian(src); } -/*******************************************************************\ - -Function: endianness_mapt::build_little_endian - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void endianness_mapt::build_little_endian(const typet &src) { mp_integer s=pointer_offset_bits(src, ns); // error is -1 @@ -84,18 +49,6 @@ void endianness_mapt::build_little_endian(const typet &src) map.push_back(i); } -/*******************************************************************\ - -Function: endianness_mapt::build_big_endian - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void endianness_mapt::build_big_endian(const typet &src) { if(src.id()==ID_symbol) diff --git a/src/util/endianness_map.h b/src/util/endianness_map.h index 03fb0a9e6b1..835f7e52938 100644 --- a/src/util/endianness_map.h +++ b/src/util/endianness_map.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_ENDIANNESS_MAP_H #define CPROVER_UTIL_ENDIANNESS_MAP_H diff --git a/src/util/error.h b/src/util/error.h index 8025dd10e7d..183ebec0872 100644 --- a/src/util/error.h +++ b/src/util/error.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_ERROR_H #define CPROVER_UTIL_ERROR_H diff --git a/src/util/expanding_vector.h b/src/util/expanding_vector.h index bb67ba73441..f8b0421db72 100644 --- a/src/util/expanding_vector.h +++ b/src/util/expanding_vector.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_EXPANDING_VECTOR_H #define CPROVER_UTIL_EXPANDING_VECTOR_H diff --git a/src/util/expr.cpp b/src/util/expr.cpp index 3b480e4bfe2..cc022538949 100644 --- a/src/util/expr.cpp +++ b/src/util/expr.cpp @@ -6,7 +6,8 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include +/// \file +/// Expression Representation #include @@ -14,24 +15,13 @@ Author: Daniel Kroening, kroening@kroening.com #include "mp_arith.h" #include "fixedbv.h" #include "ieee_float.h" +#include "invariant.h" #include "expr.h" #include "rational.h" #include "rational_tools.h" #include "arith_tools.h" #include "std_expr.h" -/*******************************************************************\ - -Function: exprt::move_to_operands - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void exprt::move_to_operands(exprt &expr) { operandst &op=operands(); @@ -39,18 +29,6 @@ void exprt::move_to_operands(exprt &expr) op.back().swap(expr); } -/*******************************************************************\ - -Function: exprt::move_to_operands - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void exprt::move_to_operands(exprt &e1, exprt &e2) { operandst &op=operands(); @@ -63,18 +41,6 @@ void exprt::move_to_operands(exprt &e1, exprt &e2) op.back().swap(e2); } -/*******************************************************************\ - -Function: exprt::move_to_operands - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void exprt::move_to_operands(exprt &e1, exprt &e2, exprt &e3) { operandst &op=operands(); @@ -89,35 +55,11 @@ void exprt::move_to_operands(exprt &e1, exprt &e2, exprt &e3) op.back().swap(e3); } -/*******************************************************************\ - -Function: exprt::copy_to_operands - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void exprt::copy_to_operands(const exprt &expr) { operands().push_back(expr); } -/*******************************************************************\ - -Function: exprt::copy_to_operands - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void exprt::copy_to_operands(const exprt &e1, const exprt &e2) { operandst &op=operands(); @@ -128,18 +70,6 @@ void exprt::copy_to_operands(const exprt &e1, const exprt &e2) op.push_back(e2); } -/*******************************************************************\ - -Function: exprt::copy_to_operands - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void exprt::copy_to_operands( const exprt &e1, const exprt &e2, @@ -154,18 +84,6 @@ void exprt::copy_to_operands( op.push_back(e3); } -/*******************************************************************\ - -Function: exprt::make_typecast - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void exprt::make_typecast(const typet &_type) { exprt new_expr(ID_typecast); @@ -176,18 +94,6 @@ void exprt::make_typecast(const typet &_type) swap(new_expr); } -/*******************************************************************\ - -Function: exprt::make_not - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void exprt::make_not() { if(is_true()) @@ -216,35 +122,11 @@ void exprt::make_not() swap(new_expr); } -/*******************************************************************\ - -Function: exprt::is_constant - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool exprt::is_constant() const { return id()==ID_constant; } -/*******************************************************************\ - -Function: exprt::is_true - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool exprt::is_true() const { return is_constant() && @@ -252,18 +134,6 @@ bool exprt::is_true() const get(ID_value)!=ID_false; } -/*******************************************************************\ - -Function: exprt::is_false - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool exprt::is_false() const { return is_constant() && @@ -271,72 +141,24 @@ bool exprt::is_false() const get(ID_value)==ID_false; } -/*******************************************************************\ - -Function: exprt::make_bool - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void exprt::make_bool(bool value) { *this=exprt(ID_constant, typet(ID_bool)); set(ID_value, value?ID_true:ID_false); } -/*******************************************************************\ - -Function: exprt::make_true - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void exprt::make_true() { *this=exprt(ID_constant, typet(ID_bool)); set(ID_value, ID_true); } -/*******************************************************************\ - -Function: exprt::make_false - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void exprt::make_false() { *this=exprt(ID_constant, typet(ID_bool)); set(ID_value, ID_false); } -/*******************************************************************\ - -Function: exprt::negate - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void exprt::negate() { const irep_idt &type_id=type().id(); @@ -380,7 +202,7 @@ void exprt::negate() else { make_nil(); - assert(false); + UNREACHABLE; } } else @@ -388,7 +210,8 @@ void exprt::negate() if(id()==ID_unary_minus) { exprt tmp; - assert(operands().size()==1); + DATA_INVARIANT(operands().size()==1, + "Unary minus must have one operand"); tmp.swap(op0()); swap(tmp); } @@ -402,35 +225,11 @@ void exprt::negate() } } -/*******************************************************************\ - -Function: exprt::is_boolean - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool exprt::is_boolean() const { return type().id()==ID_bool; } -/*******************************************************************\ - -Function: exprt::is_zero - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool exprt::is_zero() const { if(is_constant()) @@ -446,7 +245,7 @@ bool exprt::is_zero() const { rationalt rat_value; if(to_rational(*this, rat_value)) - assert(false); + CHECK_RETURN(false); return rat_value.is_zero(); } else if(type_id==ID_unsignedbv || @@ -475,18 +274,6 @@ bool exprt::is_zero() const return false; } -/*******************************************************************\ - -Function: exprt::is_one - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool exprt::is_one() const { if(is_constant()) @@ -504,7 +291,7 @@ bool exprt::is_one() const { rationalt rat_value; if(to_rational(*this, rat_value)) - assert(false); + CHECK_RETURN(false); return rat_value.is_one(); } else if(type_id==ID_unsignedbv || type_id==ID_signedbv) @@ -528,18 +315,6 @@ bool exprt::is_one() const return false; } -/*******************************************************************\ - -Function: exprt::sum - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool exprt::sum(const exprt &expr) { if(!is_constant() || !expr.is_constant()) @@ -593,18 +368,6 @@ bool exprt::sum(const exprt &expr) return true; } -/*******************************************************************\ - -Function: exprt::mul - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool exprt::mul(const exprt &expr) { if(!is_constant() || !expr.is_constant()) @@ -658,18 +421,6 @@ bool exprt::mul(const exprt &expr) return true; } -/*******************************************************************\ - -Function: exprt::subtract - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool exprt::subtract(const exprt &expr) { if(!is_constant() || !expr.is_constant()) @@ -709,18 +460,6 @@ bool exprt::subtract(const exprt &expr) return true; } -/*******************************************************************\ - -Function: exprt::find_source_location - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const source_locationt &exprt::find_source_location() const { const source_locationt &l=source_location(); @@ -738,18 +477,6 @@ const source_locationt &exprt::find_source_location() const return static_cast(get_nil_irep()); } -/*******************************************************************\ - -Function: exprt::visit - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void exprt::visit(expr_visitort &visitor) { std::stack stack; @@ -768,18 +495,6 @@ void exprt::visit(expr_visitort &visitor) } } -/*******************************************************************\ - -Function: exprt::visit - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void exprt::visit(const_expr_visitort &visitor) const { std::stack stack; diff --git a/src/util/expr.h b/src/util/expr.h index 47a85b50f1c..2d58dca1cf2 100644 --- a/src/util/expr.h +++ b/src/util/expr.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_EXPR_H #define CPROVER_UTIL_EXPR_H diff --git a/src/util/expr_util.cpp b/src/util/expr_util.cpp index d5a28e4f5fa..7370b165eab 100644 --- a/src/util/expr_util.cpp +++ b/src/util/expr_util.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include "expr_util.h" #include "expr.h" #include "fixedbv.h" @@ -15,18 +16,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "namespace.h" #include "arith_tools.h" -/*******************************************************************\ - -Function: make_next_state - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void make_next_state(exprt &expr) { Forall_operands(it, expr) @@ -36,18 +25,6 @@ void make_next_state(exprt &expr) expr.id(ID_next_symbol); } -/*******************************************************************\ - -Function: make_binary - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt make_binary(const exprt &expr) { const exprt::operandst &operands=expr.operands(); @@ -59,14 +36,14 @@ exprt make_binary(const exprt &expr) const typet &type=expr.type(); exprt previous=operands.front(); - assert(previous.type()==type); + PRECONDITION(previous.type()==type); for(exprt::operandst::const_iterator it=++operands.begin(); it!=operands.end(); ++it) { - assert(it->type()==type); + PRECONDITION(it->type()==type); exprt tmp=expr; tmp.operands().clear(); @@ -79,22 +56,10 @@ exprt make_binary(const exprt &expr) return previous; } -/*******************************************************************\ - -Function: make_with_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - with_exprt make_with_expr(const update_exprt &src) { const exprt::operandst &designator=src.designator(); - assert(!designator.empty()); + PRECONDITION(!designator.empty()); with_exprt result; exprt *dest=&result; @@ -113,7 +78,7 @@ with_exprt make_with_expr(const update_exprt &src) // to_member_designator(*it).get_component_name(); } else - assert(false); + UNREACHABLE; *dest=tmp; dest=&to_with_expr(*dest).new_value(); @@ -122,18 +87,6 @@ with_exprt make_with_expr(const update_exprt &src) return result; } -/*******************************************************************\ - -Function: is_not_zero - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt is_not_zero( const exprt &src, const namespacet &ns) @@ -155,7 +108,7 @@ exprt is_not_zero( src_type.id()==ID_floatbv?ID_ieee_float_notequal:ID_notequal; exprt zero=from_integer(0, src_type); - assert(zero.is_not_nil()); + CHECK_RETURN(zero.is_not_nil()); binary_exprt comparison(src, id, zero, bool_typet()); comparison.add_source_location()=src.source_location(); @@ -163,18 +116,6 @@ exprt is_not_zero( return comparison; } -/*******************************************************************\ - -Function: boolean_negate - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt boolean_negate(const exprt &src) { if(src.id()==ID_not && src.operands().size()==1) @@ -187,18 +128,6 @@ exprt boolean_negate(const exprt &src) return not_exprt(src); } -/*******************************************************************\ - -Function: has_subexpr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool has_subexpr(const exprt &src, const irep_idt &id) { if(src.id()==id) @@ -211,22 +140,10 @@ bool has_subexpr(const exprt &src, const irep_idt &id) return false; } -/*******************************************************************\ - -Function: lift_if - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - if_exprt lift_if(const exprt &src, std::size_t operand_number) { - assert(operand_number #if defined(__linux__) || \ @@ -37,18 +40,7 @@ Date: January 2012 #include "file_util.h" -/*******************************************************************\ - -Function: get_current_working_directory - - Inputs: none - - Outputs: current working directory - - Purpose: - -\*******************************************************************/ - +/// \return current working directory std::string get_current_working_directory() { unsigned bsize=50; @@ -71,18 +63,7 @@ std::string get_current_working_directory() return working_directory; } -/*******************************************************************\ - -Function: delete_directory - - Inputs: path - - Outputs: - - Purpose: deletes all files in 'path' and then the directory itself - -\*******************************************************************/ - +/// deletes all files in 'path' and then the directory itself #ifdef _WIN32 void delete_directory_utf16(const std::wstring &path) @@ -142,19 +123,8 @@ void delete_directory(const std::string &path) #endif } -/*******************************************************************\ - -Function: concat_dir_file - - Inputs: directory name and file name - - Outputs: concatenation of directory and file, if the file path is - relative - - Purpose: - -\*******************************************************************/ - +/// \par parameters: directory name and file name +/// \return concatenation of directory and file, if the file path is relative std::string concat_dir_file( const std::string &directory, const std::string &file_name) diff --git a/src/util/file_util.h b/src/util/file_util.h index f1bd21b37e2..54ed17e16c3 100644 --- a/src/util/file_util.h +++ b/src/util/file_util.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_FILE_UTIL_H #define CPROVER_UTIL_FILE_UTIL_H diff --git a/src/util/find_macros.cpp b/src/util/find_macros.cpp index 8e2e249ada6..f6b2b748adb 100644 --- a/src/util/find_macros.cpp +++ b/src/util/find_macros.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "find_macros.h" @@ -13,18 +14,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "namespace.h" #include "symbol.h" -/*******************************************************************\ - -Function: find_macros - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void find_macros( const exprt &src, const namespacet &ns, diff --git a/src/util/find_macros.h b/src/util/find_macros.h index 17b8282502c..23142dd478d 100644 --- a/src/util/find_macros.h +++ b/src/util/find_macros.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_FIND_MACROS_H #define CPROVER_UTIL_FIND_MACROS_H diff --git a/src/util/find_symbols.cpp b/src/util/find_symbols.cpp index b62ea77b368..32e10d33627 100644 --- a/src/util/find_symbols.cpp +++ b/src/util/find_symbols.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include "std_types.h" #include "std_expr.h" @@ -13,18 +14,6 @@ Author: Daniel Kroening, kroening@kroening.com enum class kindt { F_TYPE, F_TYPE_NON_PTR, F_EXPR, F_BOTH }; -/*******************************************************************\ - -Function: find_symbols - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void find_symbols( const exprt &src, find_symbols_sett &dest) @@ -32,18 +21,6 @@ void find_symbols( find_symbols(src, dest, true, true); } -/*******************************************************************\ - -Function: find_symbols - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void find_symbols( const exprt &src, find_symbols_sett &dest, @@ -60,18 +37,6 @@ void find_symbols( } } -/*******************************************************************\ - -Function: has_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool has_symbol( const exprt &src, const find_symbols_sett &symbols, @@ -91,18 +56,6 @@ bool has_symbol( return false; } -/*******************************************************************\ - -Function: has_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool has_symbol( const exprt &src, const find_symbols_sett &symbols) @@ -110,18 +63,6 @@ bool has_symbol( return has_symbol(src, symbols, true, true); } -/*******************************************************************\ - -Function: find_symbols - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void find_symbols( const exprt &src, std::set &dest) @@ -135,18 +76,6 @@ void find_symbols( } } -/*******************************************************************\ - -Function: find_symbols - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void find_symbols( const exprt &src, std::set &dest) @@ -160,18 +89,6 @@ void find_symbols( } } -/*******************************************************************\ - -Function: find_symbols - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void find_symbols(kindt kind, const typet &src, find_symbols_sett &dest); void find_symbols(kindt kind, const exprt &src, find_symbols_sett &dest) @@ -197,18 +114,6 @@ void find_symbols(kindt kind, const exprt &src, find_symbols_sett &dest) find_symbols(kind, static_cast(va_arg_type), dest); } -/*******************************************************************\ - -Function: find_symbols - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void find_symbols(kindt kind, const typet &src, find_symbols_sett &dest) { if(kind!=kindt::F_TYPE_NON_PTR || @@ -248,7 +153,7 @@ void find_symbols(kindt kind, const typet &src, find_symbols_sett &dest) find_symbols(kind, *it, dest); // irep_idt identifier=it->get_identifier(); - // if(identifier!=irep_idt() && (kind==F_TYPE || kind==F_BOTH)) + // if(!identifier.empty() && (kind==F_TYPE || kind==F_BOTH)) // dest.insert(identifier); } } @@ -273,52 +178,16 @@ void find_symbols(kindt kind, const typet &src, find_symbols_sett &dest) } } -/*******************************************************************\ - -Function: find_type_symbols - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void find_type_symbols(const exprt &src, find_symbols_sett &dest) { find_symbols(kindt::F_TYPE, src, dest); } -/*******************************************************************\ - -Function: find_type_symbols - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void find_type_symbols(const typet &src, find_symbols_sett &dest) { find_symbols(kindt::F_TYPE, src, dest); } -/*******************************************************************\ - -Function: find_non_pointer_type_symbols - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void find_non_pointer_type_symbols( const exprt &src, find_symbols_sett &dest) @@ -326,18 +195,6 @@ void find_non_pointer_type_symbols( find_symbols(kindt::F_TYPE_NON_PTR, src, dest); } -/*******************************************************************\ - -Function: find_non_pointer_type_symbols - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void find_non_pointer_type_symbols( const typet &src, find_symbols_sett &dest) @@ -345,35 +202,11 @@ void find_non_pointer_type_symbols( find_symbols(kindt::F_TYPE_NON_PTR, src, dest); } -/*******************************************************************\ - -Function: find_type_and_expr_symbols - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void find_type_and_expr_symbols(const exprt &src, find_symbols_sett &dest) { find_symbols(kindt::F_BOTH, src, dest); } -/*******************************************************************\ - -Function: find_type_and_expr_symbols - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void find_type_and_expr_symbols(const typet &src, find_symbols_sett &dest) { find_symbols(kindt::F_BOTH, src, dest); diff --git a/src/util/find_symbols.h b/src/util/find_symbols.h index 4ca899e4b40..e86957b7093 100644 --- a/src/util/find_symbols.h +++ b/src/util/find_symbols.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_FIND_SYMBOLS_H #define CPROVER_UTIL_FIND_SYMBOLS_H diff --git a/src/util/fixedbv.cpp b/src/util/fixedbv.cpp index d1703d85ca9..3f62619e741 100644 --- a/src/util/fixedbv.cpp +++ b/src/util/fixedbv.cpp @@ -6,111 +6,40 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include "std_types.h" #include "std_expr.h" #include "fixedbv.h" #include "arith_tools.h" -/*******************************************************************\ - -Function: fixedbv_spect::fixedbv_spect - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - fixedbv_spect::fixedbv_spect(const fixedbv_typet &type) { integer_bits=type.get_integer_bits(); width=type.get_width(); } -/*******************************************************************\ - -Function: fixedbvt::fixedbvt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - fixedbvt::fixedbvt(const constant_exprt &expr) { from_expr(expr); } -/*******************************************************************\ - -Function: fixedbvt::from_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void fixedbvt::from_expr(const constant_exprt &expr) { spec=fixedbv_spect(to_fixedbv_type(expr.type())); v=binary2integer(id2string(expr.get_value()), true); } -/*******************************************************************\ - -Function: fixedbvt::from_integer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void fixedbvt::from_integer(const mp_integer &i) { v=i*power(2, spec.get_fraction_bits()); } -/*******************************************************************\ - -Function: fixedbvt::to_integer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - mp_integer fixedbvt::to_integer() const { // this rounds to zero, i.e., we just divide return v/power(2, spec.get_fraction_bits()); } -/*******************************************************************\ - -Function: fixedbvt::to_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - constant_exprt fixedbvt::to_expr() const { fixedbv_typet type; @@ -122,18 +51,6 @@ constant_exprt fixedbvt::to_expr() const return expr; } -/*******************************************************************\ - -Function: fixedbvt::round - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void fixedbvt::round(const fixedbv_spect &dest_spec) { std::size_t old_fraction_bits=spec.width-spec.integer_bits; @@ -167,35 +84,11 @@ void fixedbvt::round(const fixedbv_spect &dest_spec) spec=dest_spec; } -/*******************************************************************\ - -Function: fixedbvt::negate - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void fixedbvt::negate() { v=-v; } -/*******************************************************************\ - -Function: fixedbvt::operator* - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - fixedbvt &fixedbvt::operator*=(const fixedbvt &o) { v*=o.v; @@ -210,18 +103,6 @@ fixedbvt &fixedbvt::operator*=(const fixedbvt &o) return *this; } -/*******************************************************************\ - -Function: fixedbvt::operator/= - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - fixedbvt &fixedbvt::operator/=(const fixedbvt &o) { v*=power(2, o.spec.get_fraction_bits()); @@ -230,35 +111,11 @@ fixedbvt &fixedbvt::operator/=(const fixedbvt &o) return *this; } -/*******************************************************************\ - -Function: fixedbvt::operator== - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool fixedbvt::operator==(int i) const { return v==power(2, spec.get_fraction_bits())*i; } -/*******************************************************************\ - -Function: fixedbvt::format - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string fixedbvt::format( const format_spect &format_spec) const { diff --git a/src/util/fixedbv.h b/src/util/fixedbv.h index 8354e0bef7c..bf37be62b7f 100644 --- a/src/util/fixedbv.h +++ b/src/util/fixedbv.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_FIXEDBV_H #define CPROVER_UTIL_FIXEDBV_H diff --git a/src/util/format_constant.cpp b/src/util/format_constant.cpp index a63b1d01555..f5419f4dcd0 100644 --- a/src/util/format_constant.cpp +++ b/src/util/format_constant.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include "format_constant.h" #include "arith_tools.h" #include "fixedbv.h" @@ -13,18 +14,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "expr.h" #include "std_expr.h" -/*******************************************************************\ - -Function: format_constantt::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string format_constantt::operator()(const exprt &expr) { if(expr.is_constant()) diff --git a/src/util/format_constant.h b/src/util/format_constant.h index 08702096596..a17765b1a44 100644 --- a/src/util/format_constant.h +++ b/src/util/format_constant.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_FORMAT_CONSTANT_H #define CPROVER_UTIL_FORMAT_CONSTANT_H diff --git a/src/util/format_number_range.cpp b/src/util/format_number_range.cpp index cca3bbf154c..c3cc9d24b9c 100644 --- a/src/util/format_number_range.cpp +++ b/src/util/format_number_range.cpp @@ -6,24 +6,18 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Format vector of numbers into a compressed range + #include #include #include #include "format_number_range.h" -/*******************************************************************\ - -Function: format_number_range::operator() - - Inputs: vector of numbers - - Outputs: string of compressed number range representation - - Purpose: create shorter representation for output - -\*******************************************************************/ - +/// create shorter representation for output +/// \par parameters: vector of numbers +/// \return string of compressed number range representation std::string format_number_ranget::operator()(std::vector &numbers) { std::string number_range; diff --git a/src/util/format_number_range.h b/src/util/format_number_range.h index 7ff016e9c4d..493b82abc99 100644 --- a/src/util/format_number_range.h +++ b/src/util/format_number_range.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Format vector of numbers into a compressed range + #ifndef CPROVER_UTIL_FORMAT_NUMBER_RANGE_H #define CPROVER_UTIL_FORMAT_NUMBER_RANGE_H diff --git a/src/util/format_spec.h b/src/util/format_spec.h index 796452a932d..828ccdcb0ce 100644 --- a/src/util/format_spec.h +++ b/src/util/format_spec.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_FORMAT_SPEC_H #define CPROVER_UTIL_FORMAT_SPEC_H diff --git a/src/util/fresh_symbol.cpp b/src/util/fresh_symbol.cpp index fbe6f09b871..7fb9d7f286a 100644 --- a/src/util/fresh_symbol.cpp +++ b/src/util/fresh_symbol.cpp @@ -6,27 +6,19 @@ Author: Chris Smowton, chris.smowton@diffblue.com \*******************************************************************/ -#include "fresh_symbol.h" - -/*******************************************************************\ - -Function: get_fresh_aux_symbol - - Inputs: `type`: type of new symbol - `name_prefix`, `basename_prefix`: - new symbol will be named name_prefix::basename_prefix$num - unless name_prefix is empty, in which case the :: prefix - is omitted. - `source_location`: new symbol source loc - `symbol_mode`: new symbol mode - `symbol_table`: table to add the new symbol to +/// \file +/// Fresh auxiliary symbol creation - Outputs: - - Purpose: Installs a fresh-named symbol with the requested name pattern - -\*******************************************************************/ +#include "fresh_symbol.h" +/// Installs a fresh-named symbol with the requested name pattern +/// \par parameters: `type`: type of new symbol +/// `name_prefix`, `basename_prefix`: new symbol will be named +/// name_prefix::basename_prefix$num unless name_prefix is empty, in which +/// case the :: prefix is omitted. +/// `source_location`: new symbol source loc +/// `symbol_mode`: new symbol mode +/// `symbol_table`: table to add the new symbol to symbolt &get_fresh_aux_symbol( const typet &type, const std::string &name_prefix, diff --git a/src/util/fresh_symbol.h b/src/util/fresh_symbol.h index c3b2749cbe3..a176a16a551 100644 --- a/src/util/fresh_symbol.h +++ b/src/util/fresh_symbol.h @@ -6,6 +6,9 @@ Author: Chris Smowton, chris.smowton@diffblue.com \*******************************************************************/ +/// \file +/// Fresh auxiliary symbol creation + #ifndef CPROVER_UTIL_FRESH_SYMBOL_H #define CPROVER_UTIL_FRESH_SYMBOL_H diff --git a/src/util/get_base_name.cpp b/src/util/get_base_name.cpp index 3f7bb186937..79d72618a61 100644 --- a/src/util/get_base_name.cpp +++ b/src/util/get_base_name.cpp @@ -8,20 +8,12 @@ Author: CM Wintersteiger \*******************************************************************/ -#include "get_base_name.h" - -/*******************************************************************\ - -Function: get_base_name - - Inputs: a string - Outputs: a new string - - Purpose: cleans a filename from path and extension - -\*******************************************************************/ +#include "get_base_name.h" +/// cleans a filename from path and extension +/// \par parameters: a string +/// \return a new string std::string get_base_name(const std::string &in, bool strip_suffix) { size_t r=std::string::npos; diff --git a/src/util/get_base_name.h b/src/util/get_base_name.h index 648b4689dc8..d1edfc09765 100644 --- a/src/util/get_base_name.h +++ b/src/util/get_base_name.h @@ -8,6 +8,7 @@ Author: CM Wintersteiger \*******************************************************************/ + #ifndef CPROVER_UTIL_GET_BASE_NAME_H #define CPROVER_UTIL_GET_BASE_NAME_H diff --git a/src/util/get_module.cpp b/src/util/get_module.cpp index e4afd21400f..655c64c6653 100644 --- a/src/util/get_module.cpp +++ b/src/util/get_module.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Find module symbol using name + #include #include @@ -23,18 +26,6 @@ typedef std::list symbolptr_listt; for(symbolptr_listt::iterator it=(list).begin(); \ it!=(list).end(); ++it) -/*******************************************************************\ - -Function: get_module_by_name - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const symbolt &get_module_by_name( const symbol_tablet &symbol_table, const std::string &module, @@ -80,18 +71,6 @@ const symbolt &get_module_by_name( return *symbolptr_list.front(); } -/*******************************************************************\ - -Function: get_module - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const symbolt &get_module( const symbol_tablet &symbol_table, const std::string &module, diff --git a/src/util/get_module.h b/src/util/get_module.h index 1f1063c073c..73eda37dfbb 100644 --- a/src/util/get_module.h +++ b/src/util/get_module.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Find module symbol using name + #ifndef CPROVER_UTIL_GET_MODULE_H #define CPROVER_UTIL_GET_MODULE_H diff --git a/src/util/graph.cpp b/src/util/graph.cpp index 07fabf150da..2d80781f41a 100644 --- a/src/util/graph.cpp +++ b/src/util/graph.cpp @@ -6,4 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// A Template Class for Graphs + #include "graph.h" diff --git a/src/util/graph.h b/src/util/graph.h index 42988914362..4a49719f7a2 100644 --- a/src/util/graph.h +++ b/src/util/graph.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// A Template Class for Graphs + #ifndef CPROVER_UTIL_GRAPH_H #define CPROVER_UTIL_GRAPH_H @@ -255,18 +258,6 @@ class grapht bool non_trivial) const; }; -/*******************************************************************\ - -Function: grapht::add_undirected_edge - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void grapht::add_undirected_edge(node_indext a, node_indext b) { @@ -280,18 +271,6 @@ void grapht::add_undirected_edge(node_indext a, node_indext b) nb.add_in(a); } -/*******************************************************************\ - -Function: grapht::remove_undirected_edge - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void grapht::remove_undirected_edge(node_indext a, node_indext b) { @@ -303,18 +282,6 @@ void grapht::remove_undirected_edge(node_indext a, node_indext b) nb.in.erase(a); } -/*******************************************************************\ - -Function: grapht::remove_in_edges - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void grapht::remove_in_edges(node_indext n) { @@ -330,18 +297,6 @@ void grapht::remove_in_edges(node_indext n) node.in.clear(); } -/*******************************************************************\ - -Function: grapht::remove_out_edges - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void grapht::remove_out_edges(node_indext n) { @@ -357,18 +312,6 @@ void grapht::remove_out_edges(node_indext n) node.out.clear(); } -/*******************************************************************\ - -Function: grapht::shortest_path - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void grapht::shortest_path( node_indext src, @@ -460,18 +403,6 @@ void grapht::shortest_path( } } -/*******************************************************************\ - -Function: grapht::visit_reachable - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void grapht::visit_reachable(node_indext src) { @@ -497,18 +428,6 @@ void grapht::visit_reachable(node_indext src) } } -/*******************************************************************\ - -Function: grapht::connected_subgraphs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template std::size_t grapht::connected_subgraphs( std::vector &subgraph_nr) @@ -554,18 +473,6 @@ std::size_t grapht::connected_subgraphs( return nr; } -/*******************************************************************\ - -Function: grapht::tarjan - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void grapht::tarjan(tarjant &t, node_indext v) { @@ -610,18 +517,6 @@ void grapht::tarjan(tarjant &t, node_indext v) } } -/*******************************************************************\ - -Function: grapht::SCCs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template std::size_t grapht::SCCs(std::vector &subgraph_nr) { @@ -634,18 +529,6 @@ std::size_t grapht::SCCs(std::vector &subgraph_nr) return t.scc_count; } -/*******************************************************************\ - -Function: grapht::make_chordal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void grapht::make_chordal() { @@ -682,18 +565,6 @@ void grapht::make_chordal() } } -/*******************************************************************\ - -Function: grapht::output_dot - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void grapht::output_dot(std::ostream &out) const { @@ -701,18 +572,6 @@ void grapht::output_dot(std::ostream &out) const output_dot_node(out, n); } -/*******************************************************************\ - -Function: grapht::output_dot_node - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template void grapht::output_dot_node(std::ostream &out, node_indext n) const { diff --git a/src/util/guard.cpp b/src/util/guard.cpp index da9cc130723..6bad260f84f 100644 --- a/src/util/guard.cpp +++ b/src/util/guard.cpp @@ -6,24 +6,15 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Symbolic Execution + #include #include "std_expr.h" #include "simplify_utils.h" #include "guard.h" -/*******************************************************************\ - -Function: guardt::as_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void guardt::guard_expr(exprt &dest) const { if(is_true()) @@ -48,18 +39,6 @@ void guardt::guard_expr(exprt &dest) const } #if 0 -/*******************************************************************\ - -Function: guardt::as_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt guardt::as_expr(guard_listt::const_iterator it) const { if(it==guard_list.end()) @@ -81,18 +60,6 @@ exprt guardt::as_expr(guard_listt::const_iterator it) const } #endif -/*******************************************************************\ - -Function: guardt::add - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void guardt::add(const exprt &expr) { assert(expr.type().id()==ID_bool); @@ -122,18 +89,6 @@ void guardt::add(const exprt &expr) op.push_back(expr); } -/*******************************************************************\ - -Function: operator -= - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - guardt &operator -= (guardt &g1, const guardt &g2) { if(g1.id()!=ID_and || g2.id()!=ID_and) @@ -163,18 +118,6 @@ guardt &operator -= (guardt &g1, const guardt &g2) return g1; } -/*******************************************************************\ - -Function: operator |= - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - guardt &operator |= (guardt &g1, const guardt &g2) { if(g2.is_false() || g1.is_true()) @@ -260,37 +203,13 @@ guardt &operator |= (guardt &g1, const guardt &g2) } #if 0 -/*******************************************************************\ - -Function: operator << - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::ostream &operator << (std::ostream &out, const guardt &g) { forall_expr_list(it, g.guard_list) - out << "*** " << it->pretty() << std::endl; + out << "*** " << it->pretty() << '\n'; return out; } -/*******************************************************************\ - -Function: guardt::is_false - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - #define forall_guard(it, guard_list) \ for(guardt::guard_listt::const_iterator it=(guard_list).begin(); \ it!=(guard_list).end(); ++it) @@ -304,18 +223,6 @@ bool guardt::is_false() const return false; } -/*******************************************************************\ - -Function: guardt::make_false - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void guardt::make_false() { guard_list.clear(); diff --git a/src/util/guard.h b/src/util/guard.h index 215ac58ba02..a923680e2ad 100644 --- a/src/util/guard.h +++ b/src/util/guard.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Guard Data Structure + #ifndef CPROVER_UTIL_GUARD_H #define CPROVER_UTIL_GUARD_H diff --git a/src/util/identifier.cpp b/src/util/identifier.cpp index 96074d9c43e..289eb4ecb22 100644 --- a/src/util/identifier.cpp +++ b/src/util/identifier.cpp @@ -6,22 +6,11 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "identifier.h" -/*******************************************************************\ - -Function: identifiert::as_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string identifiert::as_string() const { std::string result; @@ -37,18 +26,6 @@ std::string identifiert::as_string() const return result; } -/*******************************************************************\ - -Function: identifiert::parse - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void identifiert::parse(const std::string &s) { std::string component; diff --git a/src/util/identifier.h b/src/util/identifier.h index 5bcd8e9b6eb..c9148eb5c10 100644 --- a/src/util/identifier.h +++ b/src/util/identifier.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_IDENTIFIER_H #define CPROVER_UTIL_IDENTIFIER_H diff --git a/src/util/ieee_float.cpp b/src/util/ieee_float.cpp index 73290f70654..448719b8465 100644 --- a/src/util/ieee_float.cpp +++ b/src/util/ieee_float.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + // is yet to come #include @@ -19,35 +20,11 @@ Author: Daniel Kroening, kroening@kroening.com #include "std_expr.h" #include "ieee_float.h" -/*******************************************************************\ - -Function: ieee_float_spect::bias - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - mp_integer ieee_float_spect::bias() const { return power(2, e-1)-1; } -/*******************************************************************\ - -Function: ieee_float_spect::to_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - floatbv_typet ieee_float_spect::to_type() const { floatbv_typet result; @@ -58,52 +35,16 @@ floatbv_typet ieee_float_spect::to_type() const return result; } -/*******************************************************************\ - -Function: ieee_float_spect::max_exponent - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - mp_integer ieee_float_spect::max_exponent() const { return power(2, e)-1; } -/*******************************************************************\ - -Function: ieee_float_spect::max_fraction - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - mp_integer ieee_float_spect::max_fraction() const { return power(2, f)-1; } -/*******************************************************************\ - -Function: ieee_float_spect::from_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ieee_float_spect::from_type(const floatbv_typet &type) { std::size_t width=type.get_width(); @@ -116,35 +57,11 @@ void ieee_float_spect::from_type(const floatbv_typet &type) e=e-1; // no hidden bit } -/*******************************************************************\ - -Function: ieee_floatt::print - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ieee_floatt::print(std::ostream &out) const { out << to_ansi_c_string(); } -/*******************************************************************\ - -Function: ieee_floatt::format - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string ieee_floatt::format(const format_spect &format_spec) const { std::string result; @@ -205,18 +122,6 @@ std::string ieee_floatt::format(const format_spect &format_spec) const return result; } -/*******************************************************************\ - -Function: ieee_floatt::base10_digits - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - mp_integer ieee_floatt::base10_digits(const mp_integer &src) { mp_integer tmp=src; @@ -226,18 +131,6 @@ mp_integer ieee_floatt::base10_digits(const mp_integer &src) return result; } -/*******************************************************************\ - -Function: ieee_floatt::to_string_decimal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string ieee_floatt::to_string_decimal(std::size_t precision) const { std::string result; @@ -329,20 +222,8 @@ std::string ieee_floatt::to_string_decimal(std::size_t precision) const return result; } -/*******************************************************************\ - -Function: ieee_floatt::to_string_scientific - - Inputs: - - Outputs: - - Purpose: format as [-]d.ddde+-d - Note that printf always produces at least two digits - for the exponent. - -\*******************************************************************/ - +/// format as [-]d.ddde+-d Note that printf always produces at least two digits +/// for the exponent. std::string ieee_floatt::to_string_scientific(std::size_t precision) const { std::string result; @@ -430,18 +311,6 @@ std::string ieee_floatt::to_string_scientific(std::size_t precision) const return result; } -/*******************************************************************\ - -Function: ieee_floatt::unpack - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ieee_floatt::unpack(const mp_integer &i) { assert(spec.f!=0); @@ -492,35 +361,11 @@ void ieee_floatt::unpack(const mp_integer &i) } } -/*******************************************************************\ - -Function: ieee_floatt::is_normal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool ieee_floatt::is_normal() const { return fraction>=power(2, spec.f); } -/*******************************************************************\ - -Function: ieee_floatt::pack - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - mp_integer ieee_floatt::pack() const { mp_integer result=0; @@ -559,18 +404,6 @@ mp_integer ieee_floatt::pack() const return result; } -/*******************************************************************\ - -Function: ieee_floatt::extract_base2 - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ieee_floatt::extract_base2( mp_integer &_fraction, mp_integer &_exponent) const @@ -595,18 +428,6 @@ void ieee_floatt::extract_base2( } } -/*******************************************************************\ - -Function: ieee_floatt::extract_base10 - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ieee_floatt::extract_base10( mp_integer &_fraction, mp_integer &_exponent) const @@ -643,18 +464,6 @@ void ieee_floatt::extract_base10( } } -/*******************************************************************\ - -Function: ieee_floatt::build - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ieee_floatt::build( const mp_integer &_fraction, const mp_integer &_exponent) @@ -668,18 +477,7 @@ void ieee_floatt::build( align(); } -/*******************************************************************\ - -Function: ieee_floatt::from_base10 - - Inputs: - - Outputs: - - Purpose: compute f * (10^e) - -\*******************************************************************/ - +/// compute f * (10^e) void ieee_floatt::from_base10( const mp_integer &_fraction, const mp_integer &_exponent) @@ -709,18 +507,6 @@ void ieee_floatt::from_base10( align(); } -/*******************************************************************\ - -Function: ieee_floatt::from_integer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ieee_floatt::from_integer(const mp_integer &i) { NaN_flag=infinity_flag=sign_flag=false; @@ -729,18 +515,6 @@ void ieee_floatt::from_integer(const mp_integer &i) align(); } -/*******************************************************************\ - -Function: ieee_floatt::align - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ieee_floatt::align() { // NaN? @@ -861,18 +635,6 @@ void ieee_floatt::align() exponent=0; } -/*******************************************************************\ - -Function: ieee_floatt::divide_and_round - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ieee_floatt::divide_and_round( mp_integer &fraction, const mp_integer &factor) @@ -923,18 +685,6 @@ void ieee_floatt::divide_and_round( } } -/*******************************************************************\ - -Function: ieee_floatt::to_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - constant_exprt ieee_floatt::to_expr() const { constant_exprt result(spec.to_type()); @@ -942,18 +692,6 @@ constant_exprt ieee_floatt::to_expr() const return result; } -/*******************************************************************\ - -Function: operator /= - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - ieee_floatt &ieee_floatt::operator/=(const ieee_floatt &other) { assert(other.spec.f==spec.f); @@ -1028,18 +766,6 @@ ieee_floatt &ieee_floatt::operator/=(const ieee_floatt &other) return *this; } -/*******************************************************************\ - -Function: operator *= - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - ieee_floatt &ieee_floatt::operator*=(const ieee_floatt &other) { assert(other.spec.f==spec.f); @@ -1076,18 +802,6 @@ ieee_floatt &ieee_floatt::operator*=(const ieee_floatt &other) return *this; } -/*******************************************************************\ - -Function: operator += - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - ieee_floatt &ieee_floatt::operator+=(const ieee_floatt &other) { ieee_floatt _other=other; @@ -1177,18 +891,6 @@ ieee_floatt &ieee_floatt::operator+=(const ieee_floatt &other) return *this; } -/*******************************************************************\ - -Function: operator -= - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - ieee_floatt &ieee_floatt::operator-=(const ieee_floatt &other) { ieee_floatt _other=other; @@ -1196,18 +898,6 @@ ieee_floatt &ieee_floatt::operator-=(const ieee_floatt &other) return (*this)+=_other; } -/*******************************************************************\ - -Function: ieee_floatt::operator< - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool ieee_floatt::operator<(const ieee_floatt &other) const { if(NaN_flag || other.NaN_flag) @@ -1254,18 +944,6 @@ bool ieee_floatt::operator<(const ieee_floatt &other) const return fraction - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool ieee_floatt::operator>(const ieee_floatt &other) const { return other<*this; } -/*******************************************************************\ - -Function: ieee_floatt::operator>= - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool ieee_floatt::operator>=(const ieee_floatt &other) const { return other<=*this; } -/*******************************************************************\ - -Function: ieee_floatt::operator== - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool ieee_floatt::operator==(const ieee_floatt &other) const { // packed equality! @@ -1357,18 +999,6 @@ bool ieee_floatt::operator==(const ieee_floatt &other) const sign_flag==other.sign_flag; } -/*******************************************************************\ - -Function: ieee_floatt::ieee_equal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool ieee_floatt::ieee_equal(const ieee_floatt &other) const { if(NaN_flag || other.NaN_flag) @@ -1379,18 +1009,6 @@ bool ieee_floatt::ieee_equal(const ieee_floatt &other) const return *this==other; } -/*******************************************************************\ - -Function: ieee_floatt::operator== - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool ieee_floatt::operator==(int i) const { ieee_floatt other(spec); @@ -1398,35 +1016,11 @@ bool ieee_floatt::operator==(int i) const return *this==other; } -/*******************************************************************\ - -Function: ieee_floatt::operator!= - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool ieee_floatt::operator!=(const ieee_floatt &other) const { return !(*this==other); } -/*******************************************************************\ - -Function: ieee_floatt::ieee_not_equal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool ieee_floatt::ieee_not_equal(const ieee_floatt &other) const { if(NaN_flag || other.NaN_flag) @@ -1437,18 +1031,6 @@ bool ieee_floatt::ieee_not_equal(const ieee_floatt &other) const return *this!=other; } -/*******************************************************************\ - -Function: ieee_floatt::change_spec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ieee_floatt::change_spec(const ieee_float_spect &dest_spec) { mp_integer _exponent=exponent-spec.f; @@ -1468,36 +1050,12 @@ void ieee_floatt::change_spec(const ieee_float_spect &dest_spec) build(_fraction, _exponent); } -/*******************************************************************\ - -Function: ieee_floatt::from_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ieee_floatt::from_expr(const constant_exprt &expr) { spec=ieee_float_spect(to_floatbv_type(expr.type())); unpack(binary2integer(id2string(expr.get_value()), false)); } -/*******************************************************************\ - -Function: ieee_floatt::to_integer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - mp_integer ieee_floatt::to_integer() const { if(NaN_flag || infinity_flag || is_zero()) @@ -1519,18 +1077,6 @@ mp_integer ieee_floatt::to_integer() const return result; } -/*******************************************************************\ - -Function: ieee_floatt::from_double - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ieee_floatt::from_double(const double d) { spec.f=52; @@ -1551,18 +1097,6 @@ void ieee_floatt::from_double(const double d) unpack(u.i); } -/*******************************************************************\ - -Function: ieee_floatt::from_float - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ieee_floatt::from_float(const float f) { spec.f=23; @@ -1582,18 +1116,6 @@ void ieee_floatt::from_float(const float f) unpack(u.i); } -/*******************************************************************\ - -Function: ieee_floatt::make_NaN - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ieee_floatt::make_NaN() { NaN_flag=true; @@ -1603,18 +1125,6 @@ void ieee_floatt::make_NaN() infinity_flag=false; } -/*******************************************************************\ - -Function: ieee_floatt::make_fltmax - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ieee_floatt::make_fltmax() { mp_integer bit_pattern= @@ -1622,35 +1132,11 @@ void ieee_floatt::make_fltmax() unpack(bit_pattern); } -/*******************************************************************\ - -Function: ieee_floatt::make_fltmin - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ieee_floatt::make_fltmin() { unpack(power(2, spec.f)); } -/*******************************************************************\ - -Function: ieee_floatt::make_plus_infinity - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ieee_floatt::make_plus_infinity() { NaN_flag=false; @@ -1660,71 +1146,24 @@ void ieee_floatt::make_plus_infinity() infinity_flag=true; } -/*******************************************************************\ - -Function: ieee_floatt::make_minus_infinity - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ieee_floatt::make_minus_infinity() { make_plus_infinity(); sign_flag=true; } -/*******************************************************************\ - -Function: ieee_floatt::is_double - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool ieee_floatt::is_double() const { return spec.f==52 && spec.e==11; } -/*******************************************************************\ - -Function: ieee_floatt::is_float - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool ieee_floatt::is_float() const { return spec.f==23 && spec.e==8; } -/*******************************************************************\ - -Function: ieee_floatt::to_double - - Inputs: - - Outputs: - - Purpose: Note that calling from_double -> to_double can return different bit - patterns for NaN. - -\*******************************************************************/ - +/// Note that calling from_double -> to_double can return different bit patterns +/// for NaN. double ieee_floatt::to_double() const { union { double f; uint64_t i; } a; @@ -1752,19 +1191,8 @@ double ieee_floatt::to_double() const return a.f; } -/*******************************************************************\ - -Function: ieee_floatt::to_float - - Inputs: - - Outputs: - - Purpose: Note that calling from_float -> to_float can return different bit - patterns for NaN. - -\*******************************************************************/ - +/// Note that calling from_float -> to_float can return different bit patterns +/// for NaN. float ieee_floatt::to_float() const { if(sizeof(unsigned)!=sizeof(float)) @@ -1797,20 +1225,8 @@ float ieee_floatt::to_float() const return a.f; } -/*******************************************************************\ - -Function: ieee_floatt::next_representable - - Inputs: - - Outputs: - - Purpose: Sets *this to the next representable number closer to - plus infinity (greater = true) or minus infinity - (greater = false). - -\*******************************************************************/ - +/// Sets *this to the next representable number closer to plus infinity (greater +/// = true) or minus infinity (greater = false). void ieee_floatt::next_representable(bool greater) { if(is_NaN()) diff --git a/src/util/ieee_float.h b/src/util/ieee_float.h index 227427c8b5f..fbad6d092d5 100644 --- a/src/util/ieee_float.h +++ b/src/util/ieee_float.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_IEEE_FLOAT_H #define CPROVER_UTIL_IEEE_FLOAT_H diff --git a/src/util/infix.h b/src/util/infix.h index 2fcc1338d5d..0ff47c646c1 100644 --- a/src/util/infix.h +++ b/src/util/infix.h @@ -6,6 +6,9 @@ Author: Chris Smowton, chris.smowton@diffblue.com \*******************************************************************/ +/// \file +/// String infix shorthand + #ifndef CPROVER_UTIL_INFIX_H #define CPROVER_UTIL_INFIX_H diff --git a/src/util/invariant.cpp b/src/util/invariant.cpp new file mode 100644 index 00000000000..b0047cccf40 --- /dev/null +++ b/src/util/invariant.cpp @@ -0,0 +1,139 @@ +/*******************************************************************\ + +Module: + +Author: Martin Brain, martin.brain@diffblue.com + +\*******************************************************************/ + + +#include "invariant.h" + +#include +#include + +#ifdef CPROVER_INVARIANT_PRINT_STACK_TRACE +#include +#include +#endif + +// Backtraces compiler and C library specific +// So we should include something explicitly from the C library +// to check if the C library is glibc. +#include +#ifdef __GLIBC__ + +// GCC needs LINKFLAGS="-rdynamic" to give function names in the backtrace +#include +#include + + +/// Attempts to demangle the function name assuming the glibc +/// format of stack entry: +/// +/// path '(' mangled_name '+' offset ') [' address ']\0' +/// +/// \param out: The output stream +/// \param stack_entry: Description of the stack_entry +/// +/// \return True <=> the entry has been successfully demangled and printed. +static bool output_demangled_name( + std::ostream &out, + const char * const stack_entry) +{ + bool return_value=false; + + std::string working(stack_entry); + + std::string::size_type start=working.rfind('('); // Path may contain '(' ! + std::string::size_type end=working.find('+', start); + + if(start!=std::string::npos && + end!=std::string::npos && + start+1<=end-1) + { + std::string::size_type length=end-(start+1); + std::string mangled(working.substr(start+1, length)); + + int demangle_success=1; + char *demangled= + abi::__cxa_demangle(mangled.c_str(), NULL, 0, &demangle_success); + + if(demangle_success==0) + { + out << working.substr(0, start+1) + << demangled + << working.substr(end); + return_value=true; + } + + free(demangled); + } + + return return_value; +} +#endif + + +/// Checks that the given invariant condition holds and prints a back trace +/// and / or throws an exception depending on build configuration. +/// Does not return if condition is false. +/// Returns with no output or state change if true. +/// +/// \param file : C string giving the name of the file. +/// \param function : C string giving the name of the function. +/// \param line : The line number of the invariant +/// \param condition : The result of evaluating the invariant condition. +/// \param reason : C string giving the reason why the invariant should be true. +void check_invariant( + const char * const file, + const char * const function, + const int line, + const bool condition, + const char * const reason) +{ + if(condition) + return; + +#ifdef CPROVER_INVARIANT_PRINT_STACK_TRACE + std::ostream & out(std::cerr); +#else + std::ostringstream out; +#endif + + // Flush regularly so that errors during output will result in + // partial error logs rather than nothing + out << "Invariant check failed\n" << std::flush; + out << "File " << file + << " function " << function + << " line " << line + << '\n' << std::flush; + +#ifdef __GLIBC__ + out << "Backtrace\n" << std::flush; + + void * stack[50] = {}; + + std::size_t entries=backtrace(stack, sizeof(stack) / sizeof(void *)); + char **description=backtrace_symbols(stack, entries); + + for(std::size_t i=0; i + +/* +** Invariants document conditions that the programmer believes to +** be always true as a consequence of the system architecture and / or +** preceeding code. In principle it should be possible to (machine +** checked) verify them. The condition should be side-effect free and +** evaluate to a boolean. +** +** As well as the condition they have a text argument that should be +** used to say why they are true. The reason should be a string literals. +** Longer diagnostics should be output to error(). For example: +** +** INVARIANT(x > 0, "x negative and zero case handled by other branches"); +** +** To help classify different kinds of invariants, various short-hand +** macros are provided. +** +** Invariants are used to document and check design / implementation +** knowledge. They should *not* be used: +** - to validate user input or options +** (throw an exception or handle more gracefully) +** - to log information (use debug(), progress(), etc.) +** - as TODO notes (acceptable in private repositories but fix before PR) +** - to handle cases that are unlikely, tedious or expensive (ditto) +** - to modify the state of the system (i.e. no side effects) +** +** Invariants provide the following guarantee: +** IF the condition is false +** THEN an invariant_failed exception will be thrown +** OR there will be undefined behaviour +** +** Consequentally, programmers may assume that the condition of an +** invariant is true after it has been executed. Applications are +** encouraged to (at least) catch exceptions at the top level and +** output them. +** +** Various different approaches to checking (or not) the invariants +** and handling their failure are supported and can be configured with +** CPROVER_INVARIANT_* macros. +*/ + +class invariant_failedt: public std::logic_error +{ +public: + explicit invariant_failedt(const std::string& what) : logic_error(what) {} + explicit invariant_failedt(const char* what) : logic_error(what) {} +}; + + +#if defined(CPROVER_INVARIANT_CPROVER_ASSERT) +// Used to allow CPROVER to check itself +#define INVARIANT(CONDITION, REASON) \ + __CPROVER_assert((CONDITION), "Invariant : " REASON) + + +#elif defined(CPROVER_INVARIANT_DO_NOT_CHECK) +// For performance builds, invariants can be ignored +// This is *not* recommended as it can result in unpredictable behaviour +// including silently reporting incorrect results. +// This is also useful for checking side-effect freedom. +#define INVARIANT(CONDITION, REASON) do {} while(0) + + +#elif defined(CPROVER_INVARIANT_ASSERT) +// Not recommended but provided for backwards compatability +#include +// NOLINTNEXTLINE(*) +#define INVARIANT(CONDITION, REASON) assert((CONDITION) && (REASON)) + + +#else +// CPROVER_INVARIANT_PRINT_STACK_TRACE affects the implementation of +// this function but not it's generation from the macro + +void check_invariant( + const char * const file, + const char * const function, + const int line, + const bool condition, + const char * const reason); + +#ifdef _MSC_VER +#define INVARIANT(CONDITION, REASON) \ + check_invariant(__FILE__, __FUNCTION__, __LINE__, (CONDITION), (REASON)) +#else +#define INVARIANT(CONDITION, REASON) \ + check_invariant(__FILE__, __func__, __LINE__, (CONDITION), (REASON)) +#endif + + +#endif + + + +// Short hand macros + +// The condition should only contain (unmodified) arguments to the method. +// "The design of the system means that the arguments to this method +// will always meet this condition". +#define PRECONDITION(CONDITION) INVARIANT(CONDITION, "Precondition") + +// The condition should only contain variables that will be returned / +// output without further modification. +// "The implementation of this method means that the condition will hold". +#define POSTCONDITION(CONDITION) INVARIANT(CONDITION, "Postcondition") + +// The condition should only contain (unmodified) values that were +// changed by a previous method call. +// "The contract of the previous method call means the following +// condition holds". +#define CHECK_RETURN(CONDITION) INVARIANT(CONDITION, "Check return value") + +// This should be used to mark dead code +#define UNREACHABLE INVARIANT(false, "Unreachable") + +// This condition should be used to document that assumptions that are +// made on goto_functions, goto_programs, exprts, etc. being well formed. +// "The data structure is corrupt or malformed" +#define DATA_INVARIANT(CONDITION, REASON) INVARIANT(CONDITION, REASON) + + +// Legacy annotations + +// The following should not be used in new code and are only intended +// to migrate documentation and "error handling" in older code +#define TODO INVARIANT(0, "Todo") +#define UNIMPLEMENTED INVARIANT(0, "Unimplemented") +#define UNHANDLED_CASE INVARIANT(0, "Unhandled case") + +#endif // CPROVER_UTIL_INVARIANT_H diff --git a/src/util/irep.cpp b/src/util/irep.cpp index 886f8ce9d7b..6efa7ccf826 100644 --- a/src/util/irep.cpp +++ b/src/util/irep.cpp @@ -6,9 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include +/// \file +/// Internal Representation + #include +#include "invariant.h" + #include "string2int.h" #include "irep.h" #include "string_hash.h" @@ -28,18 +32,6 @@ irept nil_rep_storage; irept::dt irept::empty_d; #endif -/*******************************************************************\ - -Function: named_subt_lower_bound - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - #ifdef SUB_IS_LIST static inline bool named_subt_order( const std::pair &a, @@ -61,18 +53,6 @@ static inline irept::named_subt::iterator named_subt_lower_bound( } #endif -/*******************************************************************\ - -Function: get_nil_irep - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const irept &get_nil_irep() { if(nil_rep_storage.id().empty()) // initialized? @@ -80,23 +60,11 @@ const irept &get_nil_irep() return nil_rep_storage; } -/*******************************************************************\ - -Function: irept::detach - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - #ifdef SHARING void irept::detach() { #ifdef IREP_DEBUG - std::cout << "DETACH1: " << data << std::endl; + std::cout << "DETACH1: " << data << '\n'; #endif if(data==&empty_d) @@ -104,7 +72,7 @@ void irept::detach() data=new dt; #ifdef IREP_DEBUG - std::cout << "ALLOCATED " << data << std::endl; + std::cout << "ALLOCATED " << data << '\n'; #endif } else if(data->ref_count>1) @@ -113,33 +81,21 @@ void irept::detach() data=new dt(*old_data); #ifdef IREP_DEBUG - std::cout << "ALLOCATED " << data << std::endl; + std::cout << "ALLOCATED " << data << '\n'; #endif data->ref_count=1; remove_ref(old_data); } - assert(data->ref_count==1); + POSTCONDITION(data->ref_count==1); #ifdef IREP_DEBUG - std::cout << "DETACH2: " << data << std::endl; + std::cout << "DETACH2: " << data << '\n'; #endif } #endif -/*******************************************************************\ - -Function: irept::remove_ref - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - #ifdef SHARING void irept::remove_ref(dt *old_data) { @@ -150,19 +106,19 @@ void irept::remove_ref(dt *old_data) nonrecursive_destructor(old_data); #else - assert(old_data->ref_count!=0); + PRECONDITION(old_data->ref_count!=0); #ifdef IREP_DEBUG - std::cout << "R: " << old_data << " " << old_data->ref_count << std::endl; + std::cout << "R: " << old_data << " " << old_data->ref_count << '\n'; #endif old_data->ref_count--; if(old_data->ref_count==0) { #ifdef IREP_DEBUG - std::cout << "D: " << pretty() << std::endl; + std::cout << "D: " << pretty() << '\n'; std::cout << "DELETING " << old_data->data - << " " << old_data << std::endl; + << " " << old_data << '\n'; old_data->clear(); std::cout << "DEALLOCATING " << old_data << "\n"; #endif @@ -178,19 +134,8 @@ void irept::remove_ref(dt *old_data) } #endif -/*******************************************************************\ - -Function: irept::nonrecursive_destructor - - Inputs: - - Outputs: - - Purpose: Does the same as remove_ref, but - using an explicit stack instead of recursion. - -\*******************************************************************/ - +/// Does the same as remove_ref, but using an explicit stack instead of +/// recursion. #ifdef SHARING void irept::nonrecursive_destructor(dt *old_data) { @@ -203,7 +148,7 @@ void irept::nonrecursive_destructor(dt *old_data) if(d==&empty_d) continue; - assert(d->ref_count!=0); + INVARIANT(d->ref_count!=0, "All contents of the stack must be in use"); d->ref_count--; if(d->ref_count==0) @@ -247,18 +192,6 @@ void irept::nonrecursive_destructor(dt *old_data) } #endif -/*******************************************************************\ - -Function: irept::move_to_named_sub - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void irept::move_to_named_sub(const irep_namet &name, irept &irep) { #ifdef SHARING @@ -268,18 +201,6 @@ void irept::move_to_named_sub(const irep_namet &name, irept &irep) irep.clear(); } -/*******************************************************************\ - -Function: irept::move_to_sub - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void irept::move_to_sub(irept &irep) { #ifdef SHARING @@ -289,18 +210,6 @@ void irept::move_to_sub(irept &irep) get_sub().back().swap(irep); } -/*******************************************************************\ - -Function: irept::get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const irep_idt &irept::get(const irep_namet &name) const { const named_subt &s= @@ -328,120 +237,36 @@ const irep_idt &irept::get(const irep_namet &name) const return it->second.id(); } -/*******************************************************************\ - -Function: irept::get_bool - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool irept::get_bool(const irep_namet &name) const { return get(name)==ID_1; } -/*******************************************************************\ - -Function: irept::get_int - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - int irept::get_int(const irep_namet &name) const { return unsafe_string2int(get_string(name)); } -/*******************************************************************\ - -Function: irept::get_unsigned_int - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - unsigned int irept::get_unsigned_int(const irep_namet &name) const { return unsafe_string2unsigned(get_string(name)); } -/*******************************************************************\ - -Function: irept::get_size_t - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::size_t irept::get_size_t(const irep_namet &name) const { return unsafe_string2size_t(get_string(name)); } -/*******************************************************************\ - -Function: irept::get_long_long - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - long long irept::get_long_long(const irep_namet &name) const { return unsafe_string2signedlonglong(get_string(name)); } -/*******************************************************************\ - -Function: irept::set - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void irept::set(const irep_namet &name, const long long value) { add(name).id(std::to_string(value)); } -/*******************************************************************\ - -Function: irept::remove - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void irept::remove(const irep_namet &name) { named_subt &s= @@ -457,18 +282,6 @@ void irept::remove(const irep_namet &name) #endif } -/*******************************************************************\ - -Function: irept::find - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const irept &irept::find(const irep_namet &name) const { const named_subt &s= @@ -490,18 +303,6 @@ const irept &irept::find(const irep_namet &name) const return it->second; } -/*******************************************************************\ - -Function: irept::add - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - irept &irept::add(const irep_namet &name) { named_subt &s= @@ -520,18 +321,6 @@ irept &irept::add(const irep_namet &name) #endif } -/*******************************************************************\ - -Function: irept::add - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - irept &irept::add(const irep_namet &name, const irept &irep) { named_subt &s= @@ -558,18 +347,6 @@ irept &irept::add(const irep_namet &name, const irept &irep) #endif } -/*******************************************************************\ - -Function: irept::operator== - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - #ifdef IREP_HASH_STATS unsigned long long irep_cmp_cnt=0; unsigned long long irep_cmp_ne_cnt=0; @@ -600,18 +377,6 @@ bool irept::operator==(const irept &other) const return true; } -/*******************************************************************\ - -Function: irept::full_eq - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool irept::full_eq(const irept &other) const { #ifdef SHARING @@ -661,18 +426,7 @@ bool irept::full_eq(const irept &other) const return true; } -/*******************************************************************\ - -Function: irept::ordering - - Inputs: - - Outputs: - - Purpose: defines ordering on the internal represenation - -\*******************************************************************/ - +/// defines ordering on the internal represenation bool irept::ordering(const irept &other) const { return compare(other)<0; @@ -703,7 +457,8 @@ bool irept::ordering(const irept &other) const return false; } - assert(it1==X.sub.end() && it2==Y.sub.end()); + INVARIANT(it1==X.sub.end() && it2==Y.sub.end(), + "Unequal lengths will return before this"); } if(X.named_sub.size()0 && indent>max_indent) diff --git a/src/util/irep.h b/src/util/irep.h index 938462868b6..f0f42abda20 100644 --- a/src/util/irep.h +++ b/src/util/irep.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_IREP_H #define CPROVER_UTIL_IREP_H @@ -102,7 +103,10 @@ class irept bool is_nil() const { return id()==ID_nil; } bool is_not_nil() const { return id()!=ID_nil; } - explicit irept(const irep_idt &_id):data(&empty_d) + explicit irept(const irep_idt &_id) +#ifdef SHARING + :data(&empty_d) +#endif { id(_id); } @@ -121,7 +125,7 @@ class irept assert(data->ref_count!=0); data->ref_count++; #ifdef IREP_DEBUG - std::cout << "COPY " << data << " " << data->ref_count << std::endl; + std::cout << "COPY " << data << " " << data->ref_count << '\n'; #endif } } diff --git a/src/util/irep_hash.cpp b/src/util/irep_hash.cpp index 96a00a27595..a68776d00cd 100644 --- a/src/util/irep_hash.cpp +++ b/src/util/irep_hash.cpp @@ -6,4 +6,7 @@ Author: Michael Tautschnig, mt@eecs.qmul.ac.uk \*******************************************************************/ +/// \file +/// irep hash functions + #include "irep_hash.h" diff --git a/src/util/irep_hash.h b/src/util/irep_hash.h index b0d24221ff3..ce4ef52da76 100644 --- a/src/util/irep_hash.h +++ b/src/util/irep_hash.h @@ -6,6 +6,9 @@ Author: Michael Tautschnig, mt@eecs.qmul.ac.uk \*******************************************************************/ +/// \file +/// irep hash functions + #ifndef CPROVER_UTIL_IREP_HASH_H #define CPROVER_UTIL_IREP_HASH_H @@ -74,18 +77,6 @@ std::size_t basic_hash_combine( std::size_t h1, std::size_t h2); -/*******************************************************************\ - -Function: basic_hash_combine - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template<> inline std::size_t basic_hash_combine<32>( std::size_t h1, @@ -94,18 +85,6 @@ inline std::size_t basic_hash_combine<32>( return ROTL32(h1, 7)^h2; } -/*******************************************************************\ - -Function: basic_hash_combine - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template<> inline std::size_t basic_hash_combine<64>( std::size_t h1, @@ -127,18 +106,6 @@ inline std::size_t basic_hash_combine<64>( #endif } -/*******************************************************************\ - -Function: basic_hash_finalize - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - inline std::size_t basic_hash_finalize( std::size_t h1, std::size_t len) @@ -175,18 +142,6 @@ std::size_t murmurhash2a_hash_finalize( std::size_t h1, std::size_t len); -/*******************************************************************\ - -Function: murmurhash2a_hash_combine - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static FORCE_INLINE uint32_t mmix32(uint32_t h1, uint32_t h2) { const int r=24; @@ -209,18 +164,7 @@ inline std::size_t murmurhash2a_hash_combine<32>( return mmix32(h1, h2); } -/*******************************************************************\ - -Function: murmurhash2a_hash_finalize - - Inputs: - - Outputs: - - Purpose: force all bits of a hash block to avalanche - -\*******************************************************************/ - +/// force all bits of a hash block to avalanche template<> inline std::size_t murmurhash2a_hash_finalize<32>( std::size_t h1, @@ -237,18 +181,6 @@ inline std::size_t murmurhash2a_hash_finalize<32>( return h1; } -/*******************************************************************\ - -Function: murmurhash2a_hash_combine - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static FORCE_INLINE uint64_t mmix64(uint64_t h1, uint64_t h2) { const int r=47; @@ -273,18 +205,7 @@ inline std::size_t murmurhash2a_hash_combine<64>( return mmix64(h1, h2); } -/*******************************************************************\ - -Function: murmurhash2a_hash_finalize - - Inputs: - - Outputs: - - Purpose: force all bits of a hash block to avalanche - -\*******************************************************************/ - +/// force all bits of a hash block to avalanche template<> inline std::size_t murmurhash2a_hash_finalize<64>( std::size_t h1, @@ -328,18 +249,6 @@ std::size_t murmurhash3_hash_finalize( std::size_t h1, std::size_t len); -/*******************************************************************\ - -Function: murmurhash3_hash_combine - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template<> inline std::size_t murmurhash3_hash_combine<32>( std::size_t h1, @@ -359,18 +268,7 @@ inline std::size_t murmurhash3_hash_combine<32>( return h1; } -/*******************************************************************\ - -Function: murmurhash3_hash_finalize - - Inputs: - - Outputs: - - Purpose: force all bits of a hash block to avalanche - -\*******************************************************************/ - +/// force all bits of a hash block to avalanche static FORCE_INLINE uint32_t fmix32(uint32_t h) { h^=h>>16; @@ -392,18 +290,6 @@ inline std::size_t murmurhash3_hash_finalize<32>( return fmix32(h1); } -/*******************************************************************\ - -Function: murmurhash3_hash_combine - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template<> inline std::size_t murmurhash3_hash_combine<64>( std::size_t h1, @@ -429,18 +315,7 @@ inline std::size_t murmurhash3_hash_combine<64>( return h1; } -/*******************************************************************\ - -Function: murmurhash3_hash_finalize - - Inputs: - - Outputs: - - Purpose: force all bits of a hash block to avalanche - -\*******************************************************************/ - +/// force all bits of a hash block to avalanche static FORCE_INLINE uint64_t fmix64(uint64_t h) { // a brief experiment with supposedly better constants from diff --git a/src/util/irep_hash_container.cpp b/src/util/irep_hash_container.cpp index 5d17b3d3f9f..82f6b812484 100644 --- a/src/util/irep_hash_container.cpp +++ b/src/util/irep_hash_container.cpp @@ -6,22 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Hashing IREPs + #include "irep_hash_container.h" #include "irep.h" #include "irep_hash.h" -/*******************************************************************\ - -Function: irep_hash_container_baset::number - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - size_t irep_hash_container_baset::number(const irept &irep) { // the ptr-hash provides a speedup of up to 3x @@ -40,18 +31,6 @@ size_t irep_hash_container_baset::number(const irept &irep) return id; } -/*******************************************************************\ - -Function: irep_hash_container_baset::vector_hasht::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - size_t irep_hash_container_baset::vector_hasht::operator()( const packedt &p) const { @@ -61,18 +40,6 @@ size_t irep_hash_container_baset::vector_hasht::operator()( return result; } -/*******************************************************************\ - -Function: irep_hash_container_baset::pack - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void irep_hash_container_baset::pack( const irept &irep, packedt &packed) diff --git a/src/util/irep_hash_container.h b/src/util/irep_hash_container.h index 6edaaf0c21c..382130659e0 100644 --- a/src/util/irep_hash_container.h +++ b/src/util/irep_hash_container.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// IREP Hash Container + #ifndef CPROVER_UTIL_IREP_HASH_CONTAINER_H #define CPROVER_UTIL_IREP_HASH_CONTAINER_H diff --git a/src/util/irep_ids.cpp b/src/util/irep_ids.cpp index bb67b275f0a..15ff849a058 100644 --- a/src/util/irep_ids.cpp +++ b/src/util/irep_ids.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Internal Representation + #include #include "irep_ids.h" @@ -39,18 +42,6 @@ const char *irep_ids_table[]= #include "irep_ids.def" // NOLINT(build/include) -/*******************************************************************\ - -Function: initialize_string_container - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void initialize_string_container() { // this is called by the constructor of string_containert diff --git a/src/util/irep_ids.def b/src/util/irep_ids.def index 9f18ca1b3a5..38b8783ee8e 100644 --- a/src/util/irep_ids.def +++ b/src/util/irep_ids.def @@ -745,6 +745,7 @@ 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(length_upper_bound) IREP_ID_ONE(string_constraint) IREP_ID_ONE(string_not_contains_constraint) IREP_ID_ONE(cprover_char_literal_func) @@ -812,6 +813,7 @@ IREP_ID_ONE(cprover_string_value_of_func) IREP_ID_ONE(skip_initialize) IREP_ID_ONE(basic_block_covered_lines) IREP_ID_ONE(is_nondet_nullable) +IREP_ID_ONE(array_replace) #undef IREP_ID_ONE #undef IREP_ID_TWO diff --git a/src/util/irep_ids.h b/src/util/irep_ids.h index c456840ef5f..2202c95c62b 100644 --- a/src/util/irep_ids.h +++ b/src/util/irep_ids.h @@ -6,6 +6,9 @@ Author: Reuben Thomas, reuben.thomas@me.com \*******************************************************************/ +/// \file +/// util + #ifndef CPROVER_UTIL_IREP_IDS_H #define CPROVER_UTIL_IREP_IDS_H diff --git a/src/util/irep_serialization.cpp b/src/util/irep_serialization.cpp index 3d5734bbb43..ac148c1e81e 100644 --- a/src/util/irep_serialization.cpp +++ b/src/util/irep_serialization.cpp @@ -8,24 +8,15 @@ Date: May 2007 \*******************************************************************/ +/// \file +/// binary irep conversions with hashing + #include #include #include "irep_serialization.h" #include "string_hash.h" -/*******************************************************************\ - -Function: irep_serializationt::write_irep - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void irep_serializationt::write_irep( std::ostream &out, const irept &irep) @@ -55,18 +46,6 @@ void irep_serializationt::write_irep( out.put(0); // terminator } -/*******************************************************************\ - -Function: irep_serializationt::reference_convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void irep_serializationt::reference_convert( std::istream &in, irept &irep) @@ -85,18 +64,6 @@ void irep_serializationt::reference_convert( } } -/*******************************************************************\ - -Function: irep_serializationt::read_irep - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void irep_serializationt::read_irep( std::istream &in, irept &irep) @@ -127,23 +94,11 @@ void irep_serializationt::read_irep( if(in.get()!=0) { - std::cerr << "irep not terminated" << std::endl; + std::cerr << "irep not terminated\n"; throw 0; } } -/*******************************************************************\ - -Function: irep_serializationt::reference_convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void irep_serializationt::reference_convert( const irept &irep, std::ostream &out) @@ -166,18 +121,9 @@ void irep_serializationt::reference_convert( } } -/*******************************************************************\ - -Function: irep_serializationt::insert_on_write - - Inputs: a size_t and an irep - - Outputs: true on success, false otherwise - - Purpose: inserts an irep into the hashtable - -\*******************************************************************/ - +/// inserts an irep into the hashtable +/// \par parameters: a size_t and an irep +/// \return true on success, false otherwise std::size_t irep_serializationt::insert_on_write(std::size_t h) { std::pair res= @@ -190,19 +136,10 @@ std::size_t irep_serializationt::insert_on_write(std::size_t h) return res.first->second; } -/*******************************************************************\ - -Function: irep_serializationt::insert_on_read - - Inputs: a size_t and an irep - - Outputs: true on success, false otherwise - - Purpose: inserts an irep into the hashtable, but only the id-hashtable - (only to be used upon reading ireps from a file) - -\*******************************************************************/ - +/// inserts an irep into the hashtable, but only the id-hashtable (only to be +/// used upon reading ireps from a file) +/// \par parameters: a size_t and an irep +/// \return true on success, false otherwise std::size_t irep_serializationt::insert_on_read( std::size_t id, const irept &i) @@ -222,19 +159,9 @@ std::size_t irep_serializationt::insert_on_read( return id; } -/*******************************************************************\ - -Function: write_gb_word - - Inputs: an output stream and a number - - Outputs: nothing - - Purpose: outputs 4 characters for a long, - most-significand byte first - -\*******************************************************************/ - +/// outputs 4 characters for a long, most-significand byte first +/// \par parameters: an output stream and a number +/// \return nothing void write_gb_word(std::ostream &out, std::size_t u) { // we write 7 bits each time, until we have zero @@ -254,18 +181,9 @@ void write_gb_word(std::ostream &out, std::size_t u) } } -/*******************************************************************\ - -Function: irep_serializationt::read_gb_word - - Inputs: a stream - - Outputs: a long - - Purpose: reads 4 characters and builds a long int from them - -\*******************************************************************/ - +/// reads 4 characters and builds a long int from them +/// \par parameters: a stream +/// \return a long std::size_t irep_serializationt::read_gb_word(std::istream &in) { std::size_t res=0; @@ -284,18 +202,9 @@ std::size_t irep_serializationt::read_gb_word(std::istream &in) return res; } -/*******************************************************************\ - -Function: write_gb_string - - Inputs: an output stream and a string - - Outputs: nothing - - Purpose: outputs the string and then a zero byte. - -\*******************************************************************/ - +/// outputs the string and then a zero byte. +/// \par parameters: an output stream and a string +/// \return nothing void write_gb_string(std::ostream &out, const std::string &s) { for(std::string::const_iterator it=s.begin(); @@ -310,18 +219,9 @@ void write_gb_string(std::ostream &out, const std::string &s) out.put(0); } -/*******************************************************************\ - -Function: irep_serializationt::read_gb_string - - Inputs: a stream - - Outputs: a string - - Purpose: reads a string from the stream - -\*******************************************************************/ - +/// reads a string from the stream +/// \par parameters: a stream +/// \return a string irep_idt irep_serializationt::read_gb_string(std::istream &in) { char c; @@ -343,18 +243,9 @@ irep_idt irep_serializationt::read_gb_string(std::istream &in) return irep_idt(std::string(read_buffer.data(), length)); } -/*******************************************************************\ - -Function: irep_serializationt::write_string_ref - - Inputs: an output stream and a string - - Outputs: nothing - - Purpose: outputs the string reference - -\*******************************************************************/ - +/// outputs the string reference +/// \par parameters: an output stream and a string +/// \return nothing void irep_serializationt::write_string_ref( std::ostream &out, const irep_idt &s) @@ -373,18 +264,9 @@ void irep_serializationt::write_string_ref( } } -/*******************************************************************\ - -Function: irep_serializationt::read_string_ref - - Inputs: a stream - - Outputs: a string - - Purpose: reads a string reference from the stream - -\*******************************************************************/ - +/// reads a string reference from the stream +/// \par parameters: a stream +/// \return a string irep_idt irep_serializationt::read_string_ref(std::istream &in) { std::size_t id = read_gb_word(in); diff --git a/src/util/irep_serialization.h b/src/util/irep_serialization.h index 715e042300d..6162826475a 100644 --- a/src/util/irep_serialization.h +++ b/src/util/irep_serialization.h @@ -8,6 +8,9 @@ Date: May 2007 \*******************************************************************/ +/// \file +/// binary irep conversions with hashing + #ifndef CPROVER_UTIL_IREP_SERIALIZATION_H #define CPROVER_UTIL_IREP_SERIALIZATION_H diff --git a/src/util/json.cpp b/src/util/json.cpp index 39769a8c5c2..dcfa9858601 100644 --- a/src/util/json.cpp +++ b/src/util/json.cpp @@ -6,24 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "json.h" const jsont jsont::null_json_object(jsont::kindt::J_NULL); -/*******************************************************************\ - -Function: jsont::escape_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsont::escape_string(const std::string &src, std::ostream &out) { for(const auto &ch : src) @@ -62,18 +51,6 @@ void jsont::escape_string(const std::string &src, std::ostream &out) } } -/*******************************************************************\ - -Function: jsont::output_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsont::output_rec(std::ostream &out, unsigned indent) const { switch(kind) @@ -157,18 +134,6 @@ void jsont::output_rec(std::ostream &out, unsigned indent) const } } -/*******************************************************************\ - -Function: jsont::swap - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void jsont::swap(jsont &other) { std::swap(other.kind, kind); diff --git a/src/util/json.h b/src/util/json.h index f6fe381ff11..5095a3044df 100644 --- a/src/util/json.h +++ b/src/util/json.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_JSON_H #define CPROVER_UTIL_JSON_H diff --git a/src/util/json_expr.cpp b/src/util/json_expr.cpp index d8e44bb58f8..a9135f9f5ce 100644 --- a/src/util/json_expr.cpp +++ b/src/util/json_expr.cpp @@ -6,6 +6,9 @@ Author: Peter Schrammel \*******************************************************************/ +/// \file +/// Expressions in JSON + #include #include "namespace.h" @@ -22,18 +25,6 @@ Author: Peter Schrammel #include "json_expr.h" -/*******************************************************************\ - -Function: simplify_json_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static exprt simplify_json_expr( const exprt &src, const namespacet &ns) @@ -77,18 +68,6 @@ static exprt simplify_json_expr( return src; } -/*******************************************************************\ - -Function: json - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - json_objectt json(const source_locationt &location) { json_objectt result; @@ -112,24 +91,13 @@ json_objectt json(const source_locationt &location) return result; } -/*******************************************************************\ - -Function: json - - Inputs: - type - a type - ns - a namespace - mode - language in which the code was written; - for now ID_C and ID_java are supported - - Outputs: a json object - - Purpose: - Output a CBMC type in json. - The `mode` argument is used to correctly report types. - -\*******************************************************************/ - +/// Output a CBMC type in json. +/// The `mode` argument is used to correctly report types. +/// \param type: a type +/// \param ns: a namespace +/// \param mode: language in which the code was written; for now ID_C and +/// ID_java are supported +/// \return a json object json_objectt json( const typet &type, const namespacet &ns, @@ -232,24 +200,13 @@ json_objectt json( return result; } -/*******************************************************************\ - -Function: json - - Inputs: - expr - an expression - ns - a namespace - mode - language in which the code was written; - for now ID_C and ID_java are supported - - Outputs: a json object - - Purpose: - Output a CBMC expression in json. - The mode is used to correctly report types. - -\*******************************************************************/ - +/// Output a CBMC expression in json. +/// The mode is used to correctly report types. +/// \param expr: an expression +/// \param ns: a namespace +/// \param mode: language in which the code was written; for now ID_C and +/// ID_java are supported +/// \return a json object json_objectt json( const exprt &expr, const namespacet &ns, diff --git a/src/util/json_expr.h b/src/util/json_expr.h index 61f6977a1ff..6b9a124680b 100644 --- a/src/util/json_expr.h +++ b/src/util/json_expr.h @@ -6,6 +6,9 @@ Author: Peter Schrammel \*******************************************************************/ +/// \file +/// Expressions in JSON + #ifndef CPROVER_UTIL_JSON_EXPR_H #define CPROVER_UTIL_JSON_EXPR_H diff --git a/src/util/json_irep.cpp b/src/util/json_irep.cpp index 2740228d1db..7f8c0b58b16 100644 --- a/src/util/json_irep.cpp +++ b/src/util/json_irep.cpp @@ -6,46 +6,27 @@ Author: Thomas Kiley, thomas.kiley@diffblue.com \*******************************************************************/ +/// \file +/// Util + #include "irep.h" #include "json.h" #include "json_irep.h" #include -/*******************************************************************\ - -Function: json_irept::json_irept - - Inputs: - include_comments - when writing JSON, should the comments - sub tree be included. - - Outputs: - - Purpose: To convert to JSON from an irep structure by recurssively - generating JSON for the different sub trees. - -\*******************************************************************/ - +/// To convert to JSON from an irep structure by recurssively generating JSON +/// for the different sub trees. +/// \param include_comments: when writing JSON, should the comments +/// sub tree be included. json_irept::json_irept(bool include_comments): include_comments(include_comments) {} -/*******************************************************************\ - -Function: json_irept::convert_from_irep - - Inputs: - irep - The irep structure to turn into json - json - The json object to be filled up. - - Outputs: - - Purpose: To convert to JSON from an irep structure by recurssively - generating JSON for the different sub trees. - -\*******************************************************************/ - +/// To convert to JSON from an irep structure by recurssively generating JSON +/// for the different sub trees. +/// \param irep: The irep structure to turn into json +/// \param json: The json object to be filled up. void json_irept::convert_from_irep(const irept &irep, jsont &json) const { json_objectt &irep_object=json.make_object(); @@ -60,24 +41,12 @@ void json_irept::convert_from_irep(const irept &irep, jsont &json) const } } -/*******************************************************************\ - -Function: json_irept::convert_sub_tree - - Inputs: - sub_tree_id - the name to give the subtree in the parent object - sub_trees - the list of subtrees to parse - parent - the parent JSON object who should be added to - - Outputs: - - Purpose: To convert to JSON from a list of ireps that are in an - unlabelled subtree. The parent JSON object will get a key - called sub_tree_id and the value shall be an array of JSON - objects generated from each of the sub trees - -\*******************************************************************/ - +/// To convert to JSON from a list of ireps that are in an unlabelled subtree. +/// The parent JSON object will get a key called sub_tree_id and the value shall +/// be an array of JSON objects generated from each of the sub trees +/// \param sub_tree_id: the name to give the subtree in the parent object +/// \param sub_trees: the list of subtrees to parse +/// \param parent: the parent JSON object who should be added to void json_irept::convert_sub_tree( const std::string &sub_tree_id, const irept::subt &sub_trees, @@ -96,25 +65,13 @@ void json_irept::convert_sub_tree( } } -/*******************************************************************\ - -Function: json_irept::convert_named_sub_tree - - Inputs: - sub_tree_id - the name to give the subtree in the parent object - sub_trees - the map of subtrees to parse - parent - the parent JSON object who should be added to - - Outputs: - - Purpose: To convert to JSON from a map of ireps that are in a - named subtree. The parent JSON object will get a key - called sub_tree_id and the value shall be a JSON object - whose keys shall be the name of the sub tree and the value - will be the object generated from the sub tree. - -\*******************************************************************/ - +/// To convert to JSON from a map of ireps that are in a named subtree. The +/// parent JSON object will get a key called sub_tree_id and the value shall be +/// a JSON object whose keys shall be the name of the sub tree and the value +/// will be the object generated from the sub tree. +/// \param sub_tree_id: the name to give the subtree in the parent object +/// \param sub_trees: the map of subtrees to parse +/// \param parent: the parent JSON object who should be added to void json_irept::convert_named_sub_tree( const std::string &sub_tree_id, const irept::named_subt &sub_trees, @@ -133,18 +90,9 @@ void json_irept::convert_named_sub_tree( } } -/*******************************************************************\ - -Function: json_irept::convert_from_json - - Inputs: input - json object to convert - - Outputs: result - irep equivalent of input - - Purpose: Deserialize a JSON irep representation. - -\*******************************************************************/ - +/// Deserialize a JSON irep representation. +/// \param input: json object to convert +/// \return result - irep equivalent of input void json_irept::convert_from_json(const jsont &in, irept &out) const { std::vector have_keys; diff --git a/src/util/json_irep.h b/src/util/json_irep.h index 20a364d31e9..83c8a6902d8 100644 --- a/src/util/json_irep.h +++ b/src/util/json_irep.h @@ -6,6 +6,9 @@ Author: Thomas Kiley, thomas.kiley@diffblue.com \*******************************************************************/ +/// \file +/// Util + #ifndef CPROVER_UTIL_JSON_IREP_H #define CPROVER_UTIL_JSON_IREP_H diff --git a/src/util/language.cpp b/src/util/language.cpp index ddb41979040..35758547b8f 100644 --- a/src/util/language.cpp +++ b/src/util/language.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Abstract interface to support a programming language + #include "language.h" #include "expr.h" #include @@ -14,70 +17,22 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -/*******************************************************************\ - -Function: languaget::final - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool languaget::final(symbol_tablet &symbol_table) { return false; } -/*******************************************************************\ - -Function: languaget::interfaces - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool languaget::interfaces(symbol_tablet &symbol_table) { return false; } -/*******************************************************************\ - -Function: languaget::dependencies - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void languaget::dependencies( const std::string &module, std::set &modules) { } -/*******************************************************************\ - -Function: languaget::from_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool languaget::from_expr( const exprt &expr, std::string &code, @@ -87,18 +42,6 @@ bool languaget::from_expr( return false; } -/*******************************************************************\ - -Function: languaget::from_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool languaget::from_type( const typet &type, std::string &code, @@ -108,18 +51,6 @@ bool languaget::from_type( return false; } -/*******************************************************************\ - -Function: languaget::type_to_name - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool languaget::type_to_name( const typet &type, std::string &name, @@ -131,41 +62,19 @@ bool languaget::type_to_name( return false; } -/*******************************************************************\ - -Function: languaget::set_should_generate_opaque_method_stubs - - Inputs: - should_generate_stubs - Should stub generation be enabled - - Outputs: - - Purpose: Turn on or off stub generation. - -\*******************************************************************/ +/// Turn on or off stub generation. +/// \param should_generate_stubs: Should stub generation be enabled void languaget::set_should_generate_opaque_method_stubs( bool should_generate_stubs) { generate_opaque_stubs=should_generate_stubs; } -/*******************************************************************\ - -Function: languaget::generate_opaque_method_stubs - - Inputs: - symbol_table - the symbol table for the program - - Outputs: - - Purpose: When there are opaque methods (e.g. ones where we don't - have a body), we create a stub function in the goto - program and mark it as opaque so the interpreter fills in - appropriate values for it. This will only happen if - generate_opaque_stubs is enabled. - -\*******************************************************************/ - +/// When there are opaque methods (e.g. ones where we don't have a body), we +/// create a stub function in the goto program and mark it as opaque so the +/// interpreter fills in appropriate values for it. This will only happen if +/// generate_opaque_stubs is enabled. +/// \param symbol_table: the symbol table for the program void languaget::generate_opaque_method_stubs(symbol_tablet &symbol_table) { if(generate_opaque_stubs) @@ -193,24 +102,13 @@ void languaget::generate_opaque_method_stubs(symbol_tablet &symbol_table) } } -/*******************************************************************\ - -Function: languaget::generate_opaque_stub_body - - Inputs: - symbol - the function symbol which is opaque - symbol_table - the symbol table - - Outputs: The identifier of the return variable. ID_nil if the function - doesn't return anything. - - Purpose: To generate the stub function for the opaque function in - question. The identifier is used in the flag to the interpreter - that the function is opaque. This function should be implemented - in the languages. - -\*******************************************************************/ - +/// To generate the stub function for the opaque function in question. The +/// identifier is used in the flag to the interpreter that the function is +/// opaque. This function should be implemented in the languages. +/// \param symbol: the function symbol which is opaque +/// \param symbol_table: the symbol table +/// \return The identifier of the return variable. ID_nil if the function +/// doesn't return anything. irep_idt languaget::generate_opaque_stub_body( symbolt &symbol, symbol_tablet &symbol_table) @@ -218,24 +116,14 @@ irep_idt languaget::generate_opaque_stub_body( return ID_nil; } -/*******************************************************************\ - -Function: languaget::build_stub_parameter_symbol - - Inputs: - function_symbol - the symbol of an opaque function - parameter_index - the index of the parameter within the - the parameter list - parameter_type - the type of the parameter - - Outputs: A named symbol to be added to the symbol table representing - one of the parameters in this opaque function. - - Purpose: To build the parameter symbol and choose its name. This should - be implemented in each language. - -\*******************************************************************/ - +/// To build the parameter symbol and choose its name. This should be +/// implemented in each language. +/// \param function_symbol: the symbol of an opaque function +/// \param parameter_index: the index of the parameter within the the parameter +/// list +/// \param parameter_type: the type of the parameter +/// \return A named symbol to be added to the symbol table representing one of +/// the parameters in this opaque function. parameter_symbolt languaget::build_stub_parameter_symbol( const symbolt &function_symbol, size_t parameter_index, @@ -248,21 +136,11 @@ parameter_symbolt languaget::build_stub_parameter_symbol( return parameter_symbolt(); } -/*******************************************************************\ - -Function: languaget::get_stub_return_symbol_name - - Inputs: - function_id - the function that has a return value - - Outputs: the identifier to use for the symbol that will store the - return value of this function. - - Purpose: To get the name of the symbol to be used for the return value - of the function. Generates a name like to_return_function_name - -\*******************************************************************/ - +/// To get the name of the symbol to be used for the return value of the +/// function. Generates a name like to_return_function_name +/// \param function_id: the function that has a return value +/// \return the identifier to use for the symbol that will store the return +/// value of this function. irep_idt languaget::get_stub_return_symbol_name(const irep_idt &function_id) { std::ostringstream return_symbol_name_builder; @@ -271,22 +149,11 @@ irep_idt languaget::get_stub_return_symbol_name(const irep_idt &function_id) } -/*******************************************************************\ - -Function: languaget::is_symbol_opaque_function - - Inputs: - symbol - the symbol to be checked - - Outputs: True if the symbol is an opaque (e.g. non-bodied) function - - Purpose: To identify if a given symbol is an opaque function and - hence needs to be stubbed. We explicitly exclude CPROVER - functions, if they have no body it is because we haven't - generated it yet. - -\*******************************************************************/ - +/// To identify if a given symbol is an opaque function and hence needs to be +/// stubbed. We explicitly exclude CPROVER functions, if they have no body it is +/// because we haven't generated it yet. +/// \param symbol: the symbol to be checked +/// \return True if the symbol is an opaque (e.g. non-bodied) function bool languaget::is_symbol_opaque_function(const symbolt &symbol) { std::set headers; @@ -301,23 +168,10 @@ bool languaget::is_symbol_opaque_function(const symbolt &symbol) !is_internal; } -/*******************************************************************\ - -Function: languaget::generate_opaque_parameter_symbols - - Inputs: - function_symbol - the symbol of an opaque function - symbol_table - the symbol table to add the new parameter - symbols into - - Outputs: - - Purpose: To create stub parameter symbols for each parameter the - function has and assign their IDs into the parameters - identifier. - -\*******************************************************************/ - +/// To create stub parameter symbols for each parameter the function has and +/// assign their IDs into the parameters identifier. +/// \param function_symbol: the symbol of an opaque function +/// \param symbol_table: the symbol table to add the new parameter symbols into void languaget::generate_opaque_parameter_symbols( symbolt &function_symbol, symbol_tablet &symbol_table) diff --git a/src/util/language.h b/src/util/language.h index 73ead1cd8e4..fac0e13aed7 100644 --- a/src/util/language.h +++ b/src/util/language.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Abstract interface to support a programming language + #ifndef CPROVER_UTIL_LANGUAGE_H #define CPROVER_UTIL_LANGUAGE_H diff --git a/src/util/language_file.cpp b/src/util/language_file.cpp index b0fbb47c2f9..891e70565b0 100644 --- a/src/util/language_file.cpp +++ b/src/util/language_file.cpp @@ -6,23 +6,12 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "language.h" #include "language_file.h" -/*******************************************************************\ - -Function: language_filet::language_filet - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - language_filet::language_filet(const language_filet &rhs): modules(rhs.modules), language(rhs.language==NULL?NULL:rhs.language->new_language()), @@ -30,36 +19,12 @@ language_filet::language_filet(const language_filet &rhs): { } -/*******************************************************************\ - -Function: language_filet::~language_filet - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - language_filet::~language_filet() { if(language!=NULL) delete language; } -/*******************************************************************\ - -Function: language_filet::get_modules - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void language_filet::get_modules() { language->modules_provided(modules); @@ -72,18 +37,6 @@ void language_filet::convert_lazy_method( language->convert_lazy_method(id, symbol_table); } -/*******************************************************************\ - -Function: language_filest::show_parse - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void language_filest::show_parse(std::ostream &out) { for(file_mapt::iterator it=file_map.begin(); @@ -91,19 +44,8 @@ void language_filest::show_parse(std::ostream &out) it->second.language->show_parse(out); } -/*******************************************************************\ - -Function: language_filest::set_should_generate_opqaue_method_stubs - - Inputs: - should_generate_stubs - Should stub generation be enabled - - Outputs: - - Purpose: Turn on or off stub generation for all the languages - -\*******************************************************************/ - +/// Turn on or off stub generation for all the languages +/// \param should_generate_stubs: Should stub generation be enabled void language_filest::set_should_generate_opaque_method_stubs( bool stubs_enabled) { @@ -114,17 +56,6 @@ void language_filest::set_should_generate_opaque_method_stubs( } } -/*******************************************************************\ -Function: language_filest::parse - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool language_filest::parse() { for(file_mapt::iterator it=file_map.begin(); @@ -158,18 +89,6 @@ bool language_filest::parse() return false; } -/*******************************************************************\ - -Function: language_filest::typecheck - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool language_filest::typecheck(symbol_tablet &symbol_table) { // typecheck interfaces @@ -244,18 +163,6 @@ bool language_filest::typecheck(symbol_tablet &symbol_table) return false; } -/*******************************************************************\ - -Function: language_filest::final - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool language_filest::final( symbol_tablet &symbol_table) { @@ -272,18 +179,6 @@ bool language_filest::final( return false; } -/*******************************************************************\ - -Function: language_filest::interfaces - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool language_filest::interfaces( symbol_tablet &symbol_table) { @@ -297,18 +192,6 @@ bool language_filest::interfaces( return false; } -/*******************************************************************\ - -Function: language_filest::typecheck_module - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool language_filest::typecheck_module( symbol_tablet &symbol_table, const std::string &module) @@ -326,18 +209,6 @@ bool language_filest::typecheck_module( return typecheck_module(symbol_table, it->second); } -/*******************************************************************\ - -Function: language_filest::typecheck_module - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool language_filest::typecheck_module( symbol_tablet &symbol_table, language_modulet &module) diff --git a/src/util/language_file.h b/src/util/language_file.h index f023047b32a..6c4b8a07d06 100644 --- a/src/util/language_file.h +++ b/src/util/language_file.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_LANGUAGE_FILE_H #define CPROVER_UTIL_LANGUAGE_FILE_H diff --git a/src/util/lispexpr.cpp b/src/util/lispexpr.cpp index 7b19fe5db37..156d718f5bc 100644 --- a/src/util/lispexpr.cpp +++ b/src/util/lispexpr.cpp @@ -6,22 +6,11 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "lispexpr.h" -/*******************************************************************\ - -Function: lispexprt::expr2string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string lispexprt::expr2string() const { std::string result; @@ -61,36 +50,12 @@ std::string lispexprt::expr2string() const return result; } -/*******************************************************************\ - -Function: lispexprt::parse - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool lispexprt::parse(const std::string &s) { std::string::size_type ptr=0; return parse(s, ptr); } -/*******************************************************************\ - -Function: lispexprt::parse - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool lispexprt::parse( const std::string &s, std::string::size_type &ptr) @@ -183,18 +148,6 @@ bool lispexprt::parse( return false; } -/*******************************************************************\ - -Function: escape - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string escape(const std::string &s) { std::string result; @@ -210,18 +163,6 @@ std::string escape(const std::string &s) return result; } -/*******************************************************************\ - -Function: test_lispexpr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - int test_lispexpr() { std::string line; diff --git a/src/util/lispexpr.h b/src/util/lispexpr.h index 0eae32ef779..09c1ff50f42 100644 --- a/src/util/lispexpr.h +++ b/src/util/lispexpr.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + // THIS HEADER IS DEPRECATED AND WILL GO AWAY #ifndef CPROVER_UTIL_LISPEXPR_H diff --git a/src/util/lispirep.cpp b/src/util/lispirep.cpp index 75e926e8107..e31af4595cd 100644 --- a/src/util/lispirep.cpp +++ b/src/util/lispirep.cpp @@ -6,22 +6,11 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include "lispirep.h" #include "irep.h" #include "lispexpr.h" -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void lisp2irep(const lispexprt &src, irept &dest) { dest.make_nil(); diff --git a/src/util/lispirep.h b/src/util/lispirep.h index 8faba937e49..914ba099ad2 100644 --- a/src/util/lispirep.h +++ b/src/util/lispirep.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_LISPIREP_H #define CPROVER_UTIL_LISPIREP_H diff --git a/src/util/memory_info.cpp b/src/util/memory_info.cpp index af4f2ef1d52..59cc9874795 100644 --- a/src/util/memory_info.cpp +++ b/src/util/memory_info.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifdef __APPLE__ #include #include @@ -25,18 +26,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "memory_info.h" -/*******************************************************************\ - -Function: memory_info - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void memory_info(std::ostream &out) { #if defined(__linux__) && defined(__GLIBC__) diff --git a/src/util/memory_info.h b/src/util/memory_info.h index 7c35825742a..7364e0e2bd6 100644 --- a/src/util/memory_info.h +++ b/src/util/memory_info.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_MEMORY_INFO_H #define CPROVER_UTIL_MEMORY_INFO_H diff --git a/src/util/merge_irep.cpp b/src/util/merge_irep.cpp index 6b8d4a6924a..fafc834eab0 100644 --- a/src/util/merge_irep.cpp +++ b/src/util/merge_irep.cpp @@ -6,21 +6,10 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include "irep_hash.h" #include "merge_irep.h" -/*******************************************************************\ - -Function: to_be_merged_irept::hash - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::size_t to_be_merged_irept::hash() const { std::size_t result=hash_string(id()); @@ -44,18 +33,6 @@ std::size_t to_be_merged_irept::hash() const return result; } -/*******************************************************************\ - -Function: to_be_merged_irept::operator== - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool to_be_merged_irept::operator == (const to_be_merged_irept &other) const { if(id()!=other.id()) @@ -95,18 +72,6 @@ bool to_be_merged_irept::operator == (const to_be_merged_irept &other) const return true; } -/*******************************************************************\ - -Function: merged_irepst::merged - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const merged_irept &merged_irepst::merged(const irept &irep) { // first see if it's already a merged_irep @@ -149,18 +114,6 @@ const merged_irept &merged_irepst::merged(const irept &irep) static_cast(*result.first)); } -/*******************************************************************\ - -Function: merge_irept::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void merge_irept::operator()(irept &irep) { // only useful if there is sharing @@ -169,18 +122,6 @@ void merge_irept::operator()(irept &irep) #endif } -/*******************************************************************\ - -Function: merge_irept::merged - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const irept &merge_irept::merged(const irept &irep) { irep_storet::const_iterator entry=irep_store.find(irep); @@ -221,18 +162,6 @@ const irept &merge_irept::merged(const irept &irep) return *irep_store.insert(new_irep).first; } -/*******************************************************************\ - -Function: merge_full_irept::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void merge_full_irept::operator()(irept &irep) { // only useful if there is sharing @@ -241,18 +170,6 @@ void merge_full_irept::operator()(irept &irep) #endif } -/*******************************************************************\ - -Function: merge_full_irept::merged - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const irept &merge_full_irept::merged(const irept &irep) { irep_storet::const_iterator entry=irep_store.find(irep); diff --git a/src/util/merge_irep.h b/src/util/merge_irep.h index c656cfccca0..9b7d34b580d 100644 --- a/src/util/merge_irep.h +++ b/src/util/merge_irep.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_MERGE_IREP_H #define CPROVER_UTIL_MERGE_IREP_H @@ -20,16 +21,19 @@ class merged_irept:public irept { // We assume that both are in the same container, // which isn't checked. - return data==other.data; + return &read()==&other.read(); } bool operator<(const merged_irept &other) const { // again, assumes that both are in the same container - return ((std::size_t)data)<((std::size_t)other.data); + return &read()<&other.read(); } - std::size_t hash() const { return (std::size_t)data; } + std::size_t hash() const + { + return reinterpret_cast(&read()); + } // copy constructor: will only copy from other merged_irepts merged_irept(const merged_irept &_src):irept(_src) diff --git a/src/util/message.cpp b/src/util/message.cpp index 21a67433609..ad0448adf28 100644 --- a/src/util/message.cpp +++ b/src/util/message.cpp @@ -6,19 +6,8 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "message.h" - -/*******************************************************************\ - -Function: message_handlert::print - - Inputs: - - Outputs: - - Purpose: -\*******************************************************************/ +#include "message.h" void message_handlert::print( unsigned level, @@ -65,77 +54,15 @@ void message_handlert::print( print(level, dest); } -/*******************************************************************\ - -Function: messaget::print - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -void messaget::print(unsigned level, const std::string &message) -{ - if(message_handler!=NULL) - message_handler->print(level, message); -} - -/*******************************************************************\ - -Function: messaget::print - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -void messaget::print( +void message_handlert::print( unsigned level, - const std::string &message, - int sequence_number, - const source_locationt &location) + const std::string &message) { - if(message_handler!=NULL) - message_handler->print(level, message, sequence_number, - location); + if(level>=message_count.size()) + message_count.resize(level+1, 0); + ++message_count[level]; } -/*******************************************************************\ - -Function: message_clientt::~message_clientt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -message_clientt::~message_clientt() -{ -} - -/*******************************************************************\ - -Function: message_clientt::set_message_handler - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - -void message_clientt::set_message_handler( - message_handlert &_message_handler) +messaget::~messaget() { - message_handler=&_message_handler; } diff --git a/src/util/message.h b/src/util/message.h index b92fb8f3dfd..1d4b3d54e40 100644 --- a/src/util/message.h +++ b/src/util/message.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_MESSAGE_H #define CPROVER_UTIL_MESSAGE_H @@ -18,7 +19,7 @@ Author: Daniel Kroening, kroening@kroening.com class message_handlert { public: - message_handlert():verbosity(10) + message_handlert():verbosity(10), message_count(10, 0) { } @@ -30,6 +31,11 @@ class message_handlert int sequence_number, const source_locationt &location); + virtual void flush(unsigned level) + { + // no-op by default + } + virtual ~message_handlert() { } @@ -37,8 +43,17 @@ class message_handlert void set_verbosity(unsigned _verbosity) { verbosity=_verbosity; } unsigned get_verbosity() const { return verbosity; } + unsigned get_message_count(unsigned level) const + { + if(level>=message_count.size()) + return 0; + + return message_count[level]; + } + protected: unsigned verbosity; + std::vector message_count; }; class null_message_handlert:public message_handlert @@ -46,6 +61,7 @@ class null_message_handlert:public message_handlert public: virtual void print(unsigned level, const std::string &message) { + message_handlert::print(level, message); } virtual void print( @@ -54,6 +70,7 @@ class null_message_handlert:public message_handlert int sequence_number, const source_locationt &location) { + print(level, message); } }; @@ -65,13 +82,23 @@ class stream_message_handlert:public message_handlert } virtual void print(unsigned level, const std::string &message) - { out << message << '\n'; } + { + message_handlert::print(level, message); + + if(verbosity>=level) + out << message << '\n'; + } + + virtual void flush(unsigned level) + { + out << std::flush; + } protected: std::ostream &out; }; -class message_clientt +class messaget { public: // Standard message levels: @@ -91,17 +118,9 @@ class message_clientt M_STATISTICS=8, M_PROGRESS=9, M_DEBUG=10 }; - virtual ~message_clientt(); - - virtual void set_message_handler(message_handlert &_message_handler); - - message_clientt():message_handler(NULL) - { - } - - explicit message_clientt(message_handlert &_message_handler): - message_handler(&_message_handler) + virtual void set_message_handler(message_handlert &_message_handler) { + message_handler=&_message_handler; } message_handlert &get_message_handler() @@ -109,62 +128,27 @@ class message_clientt return *message_handler; } -protected: - message_handlert *message_handler; -}; - -class messaget:public message_clientt -{ -public: // constructors, destructor messaget(): + message_handler(NULL), mstream(M_DEBUG, *this) { } messaget(const messaget &other): - message_clientt(other), - mstream(M_DEBUG, *this) + message_handler(other.message_handler), + mstream(other.mstream) { } explicit messaget(message_handlert &_message_handler): - message_clientt(_message_handler), + message_handler(&_message_handler), mstream(M_DEBUG, *this) { } - virtual ~messaget() { } - - // old interface, will go away - void status( - const std::string &message, - const std::string &file) - { - source_locationt location; - location.set_file(file); - print(6, message, -1, location); - } - - void error( - const std::string &message, - const std::string &file) - { - source_locationt location; - location.set_file(file); - print(1, message, -1, location); - } - - virtual void print(unsigned level, const std::string &message); - - virtual void print( - unsigned level, - const std::string &message, - int sequence_number, // -1: no sequence information - const source_locationt &location); - - // New interface + virtual ~messaget(); class mstreamt:public std::ostringstream { @@ -177,6 +161,13 @@ class messaget:public message_clientt { } + mstreamt(const mstreamt &other): + message_level(other.message_level), + message(other.message), + source_location(other.source_location) + { + } + unsigned message_level; messaget &message; source_locationt source_location; @@ -197,9 +188,17 @@ class messaget:public message_clientt // Feeding 'eom' into the stream triggers // the printing of the message - static inline mstreamt &eom(mstreamt &m) + static mstreamt &eom(mstreamt &m) { - m.message.print(m.message_level, m.str(), -1, m.source_location); + if(m.message.message_handler) + { + m.message.message_handler->print( + m.message_level, + m.str(), + -1, + m.source_location); + m.message.message_handler->flush(m.message_level); + } m.clear(); // clears error bits m.str(std::string()); // clears the string m.source_location.clear(); @@ -207,61 +206,55 @@ class messaget:public message_clientt } // in lieu of std::endl - static inline mstreamt &endl(mstreamt &m) + static mstreamt &endl(mstreamt &m) { static_cast(m) << std::endl; return m; } - mstreamt &error() + mstreamt &get_mstream(unsigned message_level) { - mstream.message_level=M_ERROR; + mstream.message_level=message_level; return mstream; } + mstreamt &error() + { + return get_mstream(M_ERROR); + } + mstreamt &warning() { - mstream.message_level=M_WARNING; - return mstream; + return get_mstream(M_WARNING); } mstreamt &result() { - mstream.message_level=M_RESULT; - return mstream; + return get_mstream(M_RESULT); } mstreamt &status() { - mstream.message_level=M_STATUS; - return mstream; + return get_mstream(M_STATUS); } mstreamt &statistics() { - mstream.message_level=M_STATISTICS; - return mstream; + return get_mstream(M_STATISTICS); } mstreamt &progress() { - mstream.message_level=M_PROGRESS; - return mstream; + return get_mstream(M_PROGRESS); } mstreamt &debug() { - mstream.message_level=M_DEBUG; - return mstream; - } - - mstreamt &get_mstream(unsigned message_level) - { - mstream.message_level=message_level; - return mstream; + return get_mstream(M_DEBUG); } protected: + message_handlert *message_handler; mstreamt mstream; }; diff --git a/src/util/mp_arith.cpp b/src/util/mp_arith.cpp index 6a9082b6823..6afa8451057 100644 --- a/src/util/mp_arith.cpp +++ b/src/util/mp_arith.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include @@ -21,18 +22,6 @@ Author: Daniel Kroening, kroening@kroening.com typedef BigInt::ullong_t ullong_t; // NOLINT(readability/identifiers) typedef BigInt::llong_t llong_t; // NOLINT(readability/identifiers) -/*******************************************************************\ - -Function: >> - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - mp_integer operator>>(const mp_integer &a, const mp_integer &b) { mp_integer power=::power(2, b); @@ -51,54 +40,20 @@ mp_integer operator>>(const mp_integer &a, const mp_integer &b) } } -/*******************************************************************\ - -Function: << - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - mp_integer operator<<(const mp_integer &a, const mp_integer &b) { return a*power(2, b); } -/*******************************************************************\ - -Function: << - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::ostream &operator<<(std::ostream &out, const mp_integer &n) { out << integer2string(n); return out; } -/*******************************************************************\ - -Function: string2integer - - Inputs: string of '0'-'9' etc. most significant digit first - base of number representation - - Outputs: mp_integer - - Purpose: - -\*******************************************************************/ - +/// \par parameters: string of '0'-'9' etc. most significant digit first +/// base of number representation +/// \return mp_integer const mp_integer string2integer(const std::string &n, unsigned base) { for(unsigned i=0; i=0); @@ -305,18 +204,6 @@ std::size_t integer2size_t(const mp_integer &n) return (std::size_t)ull; } -/*******************************************************************\ - -Function: integer2unsigned - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - unsigned integer2unsigned(const mp_integer &n) { assert(n>=0); @@ -325,105 +212,45 @@ unsigned integer2unsigned(const mp_integer &n) return (unsigned)ull; } -/*******************************************************************\ - -Function: bitwise_or - - Inputs: - - Outputs: - - Purpose: bitwise or - bitwise operations only make sense on native objects, hence the - largest object size should be the largest available c++ integer - size (currently long long) - -\*******************************************************************/ - +/// bitwise or bitwise operations only make sense on native objects, hence the +/// largest object size should be the largest available c++ integer size +/// (currently long long) mp_integer bitwise_or(const mp_integer &a, const mp_integer &b) { ullong_t result=a.to_ulong()|b.to_ulong(); return result; } -/*******************************************************************\ - -Function: bitwise_and - - Inputs: - - Outputs: - - Purpose: bitwise and - bitwise operations only make sense on native objects, hence the - largest object size should be the largest available c++ integer - size (currently long long) - -\*******************************************************************/ - +/// bitwise and bitwise operations only make sense on native objects, hence the +/// largest object size should be the largest available c++ integer size +/// (currently long long) mp_integer bitwise_and(const mp_integer &a, const mp_integer &b) { ullong_t result=a.to_ulong()&b.to_ulong(); return result; } -/*******************************************************************\ - -Function: bitwise_xor - - Inputs: - - Outputs: - - Purpose: bitwise xor - bitwise operations only make sense on native objects, hence the - largest object size should be the largest available c++ integer - size (currently long long) - -\*******************************************************************/ - +/// bitwise xor bitwise operations only make sense on native objects, hence the +/// largest object size should be the largest available c++ integer size +/// (currently long long) mp_integer bitwise_xor(const mp_integer &a, const mp_integer &b) { ullong_t result=a.to_ulong()^b.to_ulong(); return result; } -/*******************************************************************\ - -Function: bitwise_neg - - Inputs: - - Outputs: - - Purpose: bitwise negation - bitwise operations only make sense on native objects, hence the - largest object size should be the largest available c++ integer - size (currently long long) - -\*******************************************************************/ - +/// bitwise negation bitwise operations only make sense on native objects, hence +/// the largest object size should be the largest available c++ integer size +/// (currently long long) mp_integer bitwise_neg(const mp_integer &a) { ullong_t result=~a.to_ulong(); return result; } -/*******************************************************************\ - -Function: arith_left_shift - - Inputs: - - Outputs: - - Purpose: arithmetic left shift - bitwise operations only make sense on native objects, hence the - largest object size should be the largest available c++ integer - size (currently long long) - -\*******************************************************************/ - +/// arithmetic left shift bitwise operations only make sense on native objects, +/// hence the largest object size should be the largest available c++ integer +/// size (currently long long) mp_integer arith_left_shift( const mp_integer &a, const mp_integer &b, @@ -441,21 +268,9 @@ mp_integer arith_left_shift( return result&mask; } -/*******************************************************************\ - -Function: arith_right_shift - - Inputs: - - Outputs: - - Purpose: arithmetic right shift (loads sign on MSB) - bitwise operations only make sense on native objects, hence the - largest object size should be the largest available c++ integer - size (currently long long) - -\*******************************************************************/ - +/// arithmetic right shift (loads sign on MSB) bitwise operations only make +/// sense on native objects, hence the largest object size should be the largest +/// available c++ integer size (currently long long) mp_integer arith_right_shift( const mp_integer &a, const mp_integer &b, @@ -472,21 +287,9 @@ mp_integer arith_right_shift( return result; } -/*******************************************************************\ - -Function: logic_left_shift - - Inputs: - - Outputs: - - Purpose: logic left shift - bitwise operations only make sense on native objects, hence the - largest object size should be the largest available c++ integer - size (currently long long) - -\*******************************************************************/ - +/// logic left shift bitwise operations only make sense on native objects, hence +/// the largest object size should be the largest available c++ integer size +/// (currently long long) mp_integer logic_left_shift( const mp_integer &a, const mp_integer &b, @@ -509,21 +312,9 @@ mp_integer logic_left_shift( return result; } -/*******************************************************************\ - -Function: logic_right_shift - - Inputs: - - Outputs: - - Purpose: logic right shift (loads 0 on MSB) - bitwise operations only make sense on native objects, hence the - largest object size should be the largest available c++ integer - size (currently long long) - -\*******************************************************************/ - +/// logic right shift (loads 0 on MSB) bitwise operations only make sense on +/// native objects, hence the largest object size should be the largest +/// available c++ integer size (currently long long) mp_integer logic_right_shift( const mp_integer &a, const mp_integer &b, @@ -537,21 +328,9 @@ mp_integer logic_right_shift( return result; } -/*******************************************************************\ - -Function: rotate_right - - Inputs: - - Outputs: - - Purpose: rotates right (MSB=LSB) - bitwise operations only make sense on native objects, hence the - largest object size should be the largest available c++ integer - size (currently long long) - -\*******************************************************************/ - +/// rotates right (MSB=LSB) bitwise operations only make sense on native +/// objects, hence the largest object size should be the largest available c++ +/// integer size (currently long long) mp_integer rotate_right( const mp_integer &a, const mp_integer &b, @@ -568,21 +347,9 @@ mp_integer rotate_right( return result; } -/*******************************************************************\ - -Function: rotate_left - - Inputs: - - Outputs: - - Purpose: rotate left (LSB=MSB) - bitwise operations only make sense on native objects, hence the - largest object size should be the largest available c++ integer - size (currently long long) - -\*******************************************************************/ - +/// rotate left (LSB=MSB) bitwise operations only make sense on native objects, +/// hence the largest object size should be the largest available c++ integer +/// size (currently long long) mp_integer rotate_left( const mp_integer &a, const mp_integer &b, diff --git a/src/util/mp_arith.h b/src/util/mp_arith.h index 046b1bff788..7cc4dd7dfad 100644 --- a/src/util/mp_arith.h +++ b/src/util/mp_arith.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_MP_ARITH_H #define CPROVER_UTIL_MP_ARITH_H diff --git a/src/util/namespace.cpp b/src/util/namespace.cpp index 1abf0fb1c59..4aeff9046e1 100644 --- a/src/util/namespace.cpp +++ b/src/util/namespace.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Namespace + #include #include @@ -16,18 +19,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "std_types.h" #include "namespace.h" -/*******************************************************************\ - -Function: get_max - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - unsigned get_max( const std::string &prefix, const symbol_tablet::symbolst &symbols) @@ -44,34 +35,10 @@ unsigned get_max( return max_nr; } -/*******************************************************************\ - -Function: namespace_baset::~namespace_baset - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - namespace_baset::~namespace_baset() { } -/*******************************************************************\ - -Function: namespace_baset::follow_symbol - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void namespace_baset::follow_symbol(irept &irep) const { while(irep.id()==ID_symbol) @@ -95,18 +62,6 @@ void namespace_baset::follow_symbol(irept &irep) const } } -/*******************************************************************\ - -Function: namespace_baset::follow - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const typet &namespace_baset::follow(const typet &src) const { if(src.id()!=ID_symbol) @@ -124,18 +79,6 @@ const typet &namespace_baset::follow(const typet &src) const } } -/*******************************************************************\ - -Function: namespace_baset::follow_tag - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const typet &namespace_baset::follow_tag(const union_tag_typet &src) const { const symbolt &symbol=lookup(src.get_identifier()); @@ -144,18 +87,6 @@ const typet &namespace_baset::follow_tag(const union_tag_typet &src) const return symbol.type; } -/*******************************************************************\ - -Function: namespace_baset::follow_tag - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const typet &namespace_baset::follow_tag(const struct_tag_typet &src) const { const symbolt &symbol=lookup(src.get_identifier()); @@ -164,18 +95,6 @@ const typet &namespace_baset::follow_tag(const struct_tag_typet &src) const return symbol.type; } -/*******************************************************************\ - -Function: namespace_baset::follow_tag - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const typet &namespace_baset::follow_tag(const c_enum_tag_typet &src) const { const symbolt &symbol=lookup(src.get_identifier()); @@ -184,18 +103,6 @@ const typet &namespace_baset::follow_tag(const c_enum_tag_typet &src) const return symbol.type; } -/*******************************************************************\ - -Function: namespace_baset::follow_macros - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void namespace_baset::follow_macros(exprt &expr) const { if(expr.id()==ID_symbol) @@ -215,18 +122,6 @@ void namespace_baset::follow_macros(exprt &expr) const follow_macros(*it); } -/*******************************************************************\ - -Function: namespace_baset::get_max - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - unsigned namespacet::get_max(const std::string &prefix) const { unsigned m=0; @@ -240,18 +135,6 @@ unsigned namespacet::get_max(const std::string &prefix) const return m; } -/*******************************************************************\ - -Function: namespacet::lookup - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool namespacet::lookup( const irep_idt &name, const symbolt *&symbol) const @@ -283,18 +166,6 @@ bool namespacet::lookup( return true; } -/*******************************************************************\ - -Function: multi_namespacet::get_max - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - unsigned multi_namespacet::get_max(const std::string &prefix) const { unsigned m=0; @@ -308,18 +179,6 @@ unsigned multi_namespacet::get_max(const std::string &prefix) const return m; } -/*******************************************************************\ - -Function: multi_namespacet::lookup - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool multi_namespacet::lookup( const irep_idt &name, const symbolt *&symbol) const diff --git a/src/util/namespace.h b/src/util/namespace.h index 6f81ed8a55d..ea6b33cfdbd 100644 --- a/src/util/namespace.h +++ b/src/util/namespace.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_NAMESPACE_H #define CPROVER_UTIL_NAMESPACE_H diff --git a/src/util/nondet_bool.h b/src/util/nondet_bool.h index 6aee700b889..af628d3456e 100644 --- a/src/util/nondet_bool.h +++ b/src/util/nondet_bool.h @@ -6,24 +6,17 @@ Author: Chris Smowton, chris@smowton.net \*******************************************************************/ +/// \file +/// Nondeterministic boolean helper + #ifndef CPROVER_UTIL_NONDET_BOOL_H #define CPROVER_UTIL_NONDET_BOOL_H #include #include -/*******************************************************************\ - -Function: get_nondet_bool - - Inputs: Desired type (C_bool or plain bool) - - Outputs: nondet expr of that type - - Purpose: - -\*******************************************************************/ - +/// \par parameters: Desired type (C_bool or plain bool) +/// \return nondet expr of that type inline exprt get_nondet_bool(const typet &type) { // We force this to 0 and 1 and won't consider diff --git a/src/util/nondet_ifthenelse.cpp b/src/util/nondet_ifthenelse.cpp index ae2f9040977..d02f1ecd114 100644 --- a/src/util/nondet_ifthenelse.cpp +++ b/src/util/nondet_ifthenelse.cpp @@ -6,6 +6,9 @@ Author: Chris Smowton, chris@smowton.net \*******************************************************************/ +/// \file +/// Nondeterministic if-then-else + #include "nondet_ifthenelse.h" #include @@ -39,31 +42,14 @@ static symbolt &new_tmp_symbol( return *symbol_ptr; } -/*******************************************************************\ - -Function: nondet_ifthenelset::begin_if - - Inputs: - - Outputs: - - Purpose: Emits instructions and defines labels for the beginning of - a nondeterministic if-else diamond. Code is emitted to the - `result_code` member of this object's associated - `java_object_factoryt` instance `state`. - The caller should use the following pattern (where *this - is an instance of java_object_factoryt): - ``` - nondet_ifthenelset diamond(*this, "name"); - diamond.begin_if(); - result_code.copy_to_operands(Some if-branch code) - diamond.begin_else(); - result_code.copy_to_operands(Some else-branch code) - diamond.finish(); - ``` - -\*******************************************************************/ - +/// Emits instructions and defines labels for the beginning of a +/// nondeterministic if-else diamond. Code is emitted to the `result_code` +/// member of this object's associated `java_object_factoryt` instance `state`. +/// The caller should use the following pattern (where *this is an instance of +/// java_object_factoryt): ``` nondet_ifthenelset diamond(*this, "name"); +/// diamond.begin_if(); result_code.copy_to_operands(Some if-branch code) +/// diamond.begin_else(); result_code.copy_to_operands(Some else-branch code) +/// diamond.finish(); ``` void nondet_ifthenelset::begin_if() { static size_t nondet_ifthenelse_count=0; @@ -96,38 +82,15 @@ void nondet_ifthenelset::begin_if() result_code.move_to_operands(test); } -/*******************************************************************\ - -Function: nondet_ifthenelset::begin_else - - Inputs: - - Outputs: - - Purpose: Terminates the if-block and begins the else-block of a - nondet if-then-else diamond. See ::begin_if for detail. - -\*******************************************************************/ - +/// Terminates the if-block and begins the else-block of a nondet if-then-else +/// diamond. See ::begin_if for detail. void nondet_ifthenelset::begin_else() { result_code.copy_to_operands(code_gotot(join_label.get_label())); result_code.copy_to_operands(else_label); } -/*******************************************************************\ - -Function: nondet_ifthenelset::finish - - Inputs: - - Outputs: - - Purpose: Concludes a nondet if-then-else diamond. - See ::begin_if for detail. - -\*******************************************************************/ - +/// Concludes a nondet if-then-else diamond. See ::begin_if for detail. void nondet_ifthenelset::finish() { result_code.move_to_operands(join_label); diff --git a/src/util/nondet_ifthenelse.h b/src/util/nondet_ifthenelse.h index c6ee25afcab..664a6bdf1b2 100644 --- a/src/util/nondet_ifthenelse.h +++ b/src/util/nondet_ifthenelse.h @@ -6,6 +6,9 @@ Author: Chris Smowton, chris@smowton.net \*******************************************************************/ +/// \file +/// Nondeterministic if-then-else + #ifndef CPROVER_UTIL_NONDET_IFTHENELSE_H #define CPROVER_UTIL_NONDET_IFTHENELSE_H diff --git a/src/util/numbering.h b/src/util/numbering.h index aab703b9121..359f3c48ed2 100644 --- a/src/util/numbering.h +++ b/src/util/numbering.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_NUMBERING_H #define CPROVER_UTIL_NUMBERING_H diff --git a/src/util/options.cpp b/src/util/options.cpp index e1cb8a369db..85b59d64fad 100644 --- a/src/util/options.cpp +++ b/src/util/options.cpp @@ -6,21 +6,12 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Options + #include "string2int.h" #include "options.h" -/*******************************************************************\ - -Function: optionst::set_option - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void optionst::set_option(const std::string &option, const std::string &value) { @@ -29,126 +20,42 @@ void optionst::set_option(const std::string &option, value_list.push_back(value); } -/*******************************************************************\ - -Function: optionst::set_option - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void optionst::set_option(const std::string &option, const bool value) { set_option(option, std::string(value?"1":"0")); } -/*******************************************************************\ - -Function: optionst::set_option - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void optionst::set_option(const std::string &option, const signed int value) { set_option(option, std::to_string(value)); } -/*******************************************************************\ - -Function: optionst::set_option - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void optionst::set_option(const std::string &option, const unsigned int value) { set_option(option, std::to_string(value)); } -/*******************************************************************\ - -Function: optionst::get_bool_option - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool optionst::get_bool_option(const std::string &option) const { const std::string value=get_option(option); return value.empty()?false:(std::stoi(value)!=0); } -/*******************************************************************\ - -Function: optionst::get_signed_int_option - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - signed int optionst::get_signed_int_option(const std::string &option) const { const std::string value=get_option(option); return value.empty()?0:std::stoi(value); } -/*******************************************************************\ - -Function: optionst::get_unsigned_int_option - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - unsigned int optionst::get_unsigned_int_option(const std::string &option) const { const std::string value=get_option(option); return value.empty()?0:safe_string2unsigned(value); } -/*******************************************************************\ - -Function: optionst::get_option - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const std::string optionst::get_option(const std::string &option) const { option_mapt::const_iterator it= @@ -162,18 +69,6 @@ const std::string optionst::get_option(const std::string &option) const return it->second.front(); } -/*******************************************************************\ - -Function: optionst::get_list_option - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const optionst::value_listt &optionst::get_list_option( const std::string &option) const { diff --git a/src/util/options.h b/src/util/options.h index 118c365c992..1a558a37331 100644 --- a/src/util/options.h +++ b/src/util/options.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Options + #ifndef CPROVER_UTIL_OPTIONS_H #define CPROVER_UTIL_OPTIONS_H diff --git a/src/util/parse_options.cpp b/src/util/parse_options.cpp index f674d9717e6..2e4d91e75e9 100644 --- a/src/util/parse_options.cpp +++ b/src/util/parse_options.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #if defined (_WIN32) @@ -19,18 +20,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "parse_options.h" #include "signal_catcher.h" -/*******************************************************************\ - -Function: parse_options_baset::parse_options_baset - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - parse_options_baset::parse_options_baset( const std::string &_optstring, int argc, const char **argv) { @@ -38,52 +27,16 @@ parse_options_baset::parse_options_baset( parse_result=cmdline.parse(argc, argv, optstring.c_str()); } -/*******************************************************************\ - -Function: parse_options_baset::help - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void parse_options_baset::help() { } -/*******************************************************************\ - -Function: parse_options_baset::usage_error - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void parse_options_baset::usage_error() { std::cerr << "Usage error!\n\n"; help(); } -/*******************************************************************\ - -Function: parse_options_baset::main - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - int parse_options_baset::main() { if(parse_result) diff --git a/src/util/parse_options.h b/src/util/parse_options.h index 52a201158a1..73f436cf331 100644 --- a/src/util/parse_options.h +++ b/src/util/parse_options.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_PARSE_OPTIONS_H #define CPROVER_UTIL_PARSE_OPTIONS_H diff --git a/src/util/parser.cpp b/src/util/parser.cpp index 539ed1f0e63..98f1508e07e 100644 --- a/src/util/parser.cpp +++ b/src/util/parser.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include "parser.h" #ifdef _WIN32 @@ -15,18 +16,6 @@ int isatty(int f) } #endif -/*******************************************************************\ - -Function: _newstack - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt &_newstack(parsert &parser, unsigned &x) { x=(unsigned)parser.stack.size(); @@ -38,18 +27,6 @@ exprt &_newstack(parsert &parser, unsigned &x) return parser.stack.back(); } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void parsert::parse_error( const std::string &message, const std::string &before) @@ -63,6 +40,7 @@ void parsert::parse_error( tmp_source_location.set_column(column-before.size()); print(1, tmp, -1, tmp_source_location); #else - print(1, tmp, -1, source_location); + error().source_location=source_location; + error() << tmp << eom; #endif } diff --git a/src/util/parser.h b/src/util/parser.h index f8792a75c66..b450de7f614 100644 --- a/src/util/parser.h +++ b/src/util/parser.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Parser utilities + #ifndef CPROVER_UTIL_PARSER_H #define CPROVER_UTIL_PARSER_H diff --git a/src/util/pipe_stream.cpp b/src/util/pipe_stream.cpp index 104dd3a2075..9a9c6297018 100644 --- a/src/util/pipe_stream.cpp +++ b/src/util/pipe_stream.cpp @@ -6,6 +6,9 @@ Module: A stdin/stdout pipe as STL stream \*******************************************************************/ +/// \file +/// A stdin/stdout pipe as STL stream + #include #include #include @@ -26,18 +29,7 @@ Module: A stdin/stdout pipe as STL stream #define READ_BUFFER_SIZE 1024 -/*******************************************************************\ - -Function: pipe_streamt::pipe_streamt - - Inputs: - - Outputs: - - Purpose: Constructor for external process - -\*******************************************************************/ - +/// Constructor for external process pipe_streamt::pipe_streamt( const std::string &_executable, const std::list &_args): @@ -50,19 +42,9 @@ pipe_streamt::pipe_streamt( #endif } -/*******************************************************************\ - -Function: pipe_streamt::run - - Inputs: - - Outputs: Returns -1 if an error occurs. - - Purpose: Starts an external process. A new process is forked and - run returns immediately. - -\*******************************************************************/ - +/// Starts an external process. A new process is forked and run returns +/// immediately. +/// \return Returns -1 if an error occurs. #ifdef _WIN32 int pipe_streamt::run() @@ -204,18 +186,7 @@ int pipe_streamt::run() #endif -/*******************************************************************\ - -Function: pipe_streamt::wait - - Inputs: - - Outputs: - - Purpose: Wait for the process to terminate - -\*******************************************************************/ - +/// Wait for the process to terminate int pipe_streamt::wait() { #ifdef _WIN32 @@ -242,18 +213,7 @@ int pipe_streamt::wait() #endif } -/*******************************************************************\ - -Function: filedescriptor_streambuft::filedescriptor_streambuft - - Inputs: - - Outputs: - - Purpose: Constructor - -\*******************************************************************/ - +/// Constructor filedescriptor_streambuft::filedescriptor_streambuft(): #ifdef _WIN32 proc_in(INVALID_HANDLE_VALUE), @@ -267,18 +227,7 @@ filedescriptor_streambuft::filedescriptor_streambuft(): setg(in_buffer, in_buffer, in_buffer); } -/*******************************************************************\ - -Function: filedescriptor_streambuft::~filedescriptor_streambuft - - Inputs: - - Outputs: - - Purpose: Destructor - -\*******************************************************************/ - +/// Destructor filedescriptor_streambuft::~filedescriptor_streambuft() { #ifdef _WIN32 @@ -302,18 +251,7 @@ filedescriptor_streambuft::~filedescriptor_streambuft() delete in_buffer; } -/*******************************************************************\ - -Function: filedescriptor_streambuft::overflow - - Inputs: - - Outputs: - - Purpose: write one character to the piped process - -\*******************************************************************/ - +/// write one character to the piped process std::streambuf::int_type filedescriptor_streambuft::overflow( std::streambuf::int_type character) { @@ -334,18 +272,7 @@ std::streambuf::int_type filedescriptor_streambuft::overflow( return character; } -/*******************************************************************\ - -Function: filedescriptor_streambuft::xsputn - - Inputs: - - Outputs: - - Purpose: write a number of character to the piped process - -\*******************************************************************/ - +/// write a number of character to the piped process std::streamsize filedescriptor_streambuft::xsputn( const char* str, std::streamsize count) { @@ -358,18 +285,7 @@ std::streamsize filedescriptor_streambuft::xsputn( #endif } -/*******************************************************************\ - -Function: filedescriptor_streambuft::underflow - - Inputs: - - Outputs: - - Purpose: read a character from the piped process - -\*******************************************************************/ - +/// read a character from the piped process std::streambuf::int_type filedescriptor_streambuft::underflow() { if(gptr()==0) @@ -396,18 +312,7 @@ std::streambuf::int_type filedescriptor_streambuft::underflow() return traits_type::to_int_type(*gptr()); } -/*******************************************************************\ - -Function: filedescriptor_streambuft::xsgetn - - Inputs: - - Outputs: - - Purpose: read a number of characters from the piped process - -\*******************************************************************/ - +/// read a number of characters from the piped process std::streamsize filedescriptor_streambuft::xsgetn( char *target, std::streamsize count) { @@ -430,18 +335,7 @@ std::streamsize filedescriptor_streambuft::xsgetn( return (available + xsgetn(target+available, count-available)); } -/*******************************************************************\ - -Function: filedescriptor_streambuft::showmanyc - - Inputs: - - Outputs: - - Purpose: determine number of available characters in stream - -\*******************************************************************/ - +/// determine number of available characters in stream std::streamsize filedescriptor_streambuft::showmanyc() { if(gptr()==0) @@ -453,12 +347,6 @@ std::streamsize filedescriptor_streambuft::showmanyc() return 0; } -/*******************************************************************\ - - Brief demonstration of the pipe_streamt class - -\*******************************************************************/ - #ifdef UNIT #include @@ -472,13 +360,13 @@ int main(int argc, char** argv) if(process.run() < 0) return -1; - process << "xxx\n" << std::endl; + process << "xxx\n\n"; char token; for(int i=0; i<3; ++i) { process >> token; - std::cout << "Answer: " << token << std::endl; + std::cout << "Answer: " << token << '\n'; } return process.wait(); diff --git a/src/util/pipe_stream.h b/src/util/pipe_stream.h index b2b5bcea533..e03169ffd1a 100644 --- a/src/util/pipe_stream.h +++ b/src/util/pipe_stream.h @@ -6,6 +6,9 @@ Module: A stdin/stdout pipe as STL stream \*******************************************************************/ +/// \file +/// A stdin/stdout pipe as STL stream + #ifndef CPROVER_UTIL_PIPE_STREAM_H #define CPROVER_UTIL_PIPE_STREAM_H diff --git a/src/util/pointer_offset_size.cpp b/src/util/pointer_offset_size.cpp index 43e7dd0d5a9..28915b5af04 100644 --- a/src/util/pointer_offset_size.cpp +++ b/src/util/pointer_offset_size.cpp @@ -6,8 +6,12 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Pointer Logic + #include +#include "c_types.h" #include "expr.h" #include "arith_tools.h" #include "std_types.h" @@ -56,18 +60,6 @@ member_offset_iterator &member_offset_iterator::operator++() return *this; } -/*******************************************************************\ - -Function: member_offset - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - mp_integer member_offset( const struct_typet &type, const irep_idt &member, @@ -88,18 +80,6 @@ mp_integer member_offset( return offsets->second; } -/*******************************************************************\ - -Function: pointer_offset_size - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - mp_integer pointer_offset_size( const typet &type, const namespacet &ns) @@ -110,18 +90,6 @@ mp_integer pointer_offset_size( return bits/8+(((bits%8)==0)?0:1); } -/*******************************************************************\ - -Function: pointer_offset_bits - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - mp_integer pointer_offset_bits( const typet &type, const namespacet &ns) @@ -129,6 +97,8 @@ mp_integer pointer_offset_bits( if(type.id()==ID_array) { mp_integer sub=pointer_offset_bits(type.subtype(), ns); + if(sub<0) + return -1; // get size const exprt &size=to_array_type(type).size(); @@ -144,6 +114,8 @@ mp_integer pointer_offset_bits( else if(type.id()==ID_vector) { mp_integer sub=pointer_offset_bits(type.subtype(), ns); + if(sub<0) + return -1; // get size const exprt &size=to_vector_type(type).size(); @@ -159,6 +131,9 @@ mp_integer pointer_offset_bits( else if(type.id()==ID_complex) { mp_integer sub=pointer_offset_bits(type.subtype(), ns); + if(sub<0) + return -1; + return sub*2; } else if(type.id()==ID_struct) @@ -200,6 +175,8 @@ mp_integer pointer_offset_bits( { const typet &subtype=it->type(); mp_integer sub_size=pointer_offset_bits(subtype, ns); + if(sub_size==-1) + return -1; if(sub_size>result) result=sub_size; } @@ -251,18 +228,6 @@ mp_integer pointer_offset_bits( return mp_integer(-1); } -/*******************************************************************\ - -Function: member_offset_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt member_offset_expr( const member_exprt &member_expr, const namespacet &ns) @@ -273,23 +238,11 @@ exprt member_offset_expr( return member_offset_expr( to_struct_type(type), member_expr.get_component_name(), ns); else if(type.id()==ID_union) - return from_integer(0, signedbv_typet(config.ansi_c.pointer_width)); + return from_integer(0, size_type()); else return nil_exprt(); } -/*******************************************************************\ - -Function: member_offset_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt member_offset_expr( const struct_typet &type, const irep_idt &member, @@ -297,7 +250,7 @@ exprt member_offset_expr( { const struct_typet::componentst &components=type.components(); - exprt result=from_integer(0, signedbv_typet(config.ansi_c.pointer_width)); + exprt result=from_integer(0, size_type()); std::size_t bit_field_bits=0; for(struct_typet::componentst::const_iterator @@ -331,18 +284,6 @@ exprt member_offset_expr( return result; } -/*******************************************************************\ - -Function: size_of_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt size_of_expr( const typet &type, const namespacet &ns) @@ -407,7 +348,7 @@ exprt size_of_expr( const struct_typet::componentst &components= struct_type.components(); - exprt result=from_integer(0, signedbv_typet(config.ansi_c.pointer_width)); + exprt result=from_integer(0, size_type()); std::size_t bit_field_bits=0; for(struct_typet::componentst::const_iterator @@ -466,11 +407,16 @@ exprt size_of_expr( else sub_size=pointer_offset_size(subtype, ns); + if(sub_size==-1) + { + result=-1; + break; + } if(sub_size>result) result=sub_size; } - return from_integer(result, signedbv_typet(config.ansi_c.pointer_width)); + return from_integer(result, size_type()); } else if(type.id()==ID_signedbv || type.id()==ID_unsignedbv || @@ -483,7 +429,7 @@ exprt size_of_expr( std::size_t bytes=width/8; if(bytes*8!=width) bytes++; - return from_integer(bytes, signedbv_typet(config.ansi_c.pointer_width)); + return from_integer(bytes, size_type()); } else if(type.id()==ID_c_enum) { @@ -491,7 +437,7 @@ exprt size_of_expr( std::size_t bytes=width/8; if(bytes*8!=width) bytes++; - return from_integer(bytes, signedbv_typet(config.ansi_c.pointer_width)); + return from_integer(bytes, size_type()); } else if(type.id()==ID_c_enum_tag) { @@ -499,7 +445,7 @@ exprt size_of_expr( } else if(type.id()==ID_bool) { - return from_integer(1, signedbv_typet(config.ansi_c.pointer_width)); + return from_integer(1, size_type()); } else if(type.id()==ID_pointer) { @@ -507,7 +453,7 @@ exprt size_of_expr( std::size_t bytes=width/8; if(bytes*8!=width) bytes++; - return from_integer(bytes, signedbv_typet(config.ansi_c.pointer_width)); + return from_integer(bytes, size_type()); } else if(type.id()==ID_symbol) { @@ -515,29 +461,16 @@ exprt size_of_expr( } else if(type.id()==ID_code) { - return from_integer(0, signedbv_typet(config.ansi_c.pointer_width)); + return from_integer(0, size_type()); } else if(type.id()==ID_string) { - return from_integer( - 32/8, signedbv_typet(config.ansi_c.pointer_width)); + return from_integer(32/8, size_type()); } else return nil_exprt(); } -/*******************************************************************\ - -Function: compute_pointer_offset - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - mp_integer compute_pointer_offset( const exprt &expr, const namespacet &ns) @@ -566,7 +499,7 @@ mp_integer compute_pointer_offset( mp_integer i; - if(sub_size!=0 && !to_integer(expr.op1(), i)) + if(sub_size>0 && !to_integer(expr.op1(), i)) return o+i*sub_size; } @@ -597,18 +530,6 @@ mp_integer compute_pointer_offset( return -1; // don't know } -/*******************************************************************\ - -Function: build_sizeof_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt build_sizeof_expr( const constant_exprt &expr, const namespacet &ns) @@ -628,7 +549,7 @@ exprt build_sizeof_expr( return nil_exprt(); assert(address_bits(val+1)<=config.ansi_c.pointer_width); - const unsignedbv_typet t(config.ansi_c.pointer_width); + const typet t(size_type()); mp_integer remainder=0; if(type_size!=0) diff --git a/src/util/pointer_offset_size.h b/src/util/pointer_offset_size.h index e6f7ae15314..aeb62e03d74 100644 --- a/src/util/pointer_offset_size.h +++ b/src/util/pointer_offset_size.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Pointer Logic + #ifndef CPROVER_UTIL_POINTER_OFFSET_SIZE_H #define CPROVER_UTIL_POINTER_OFFSET_SIZE_H diff --git a/src/util/pointer_predicates.cpp b/src/util/pointer_predicates.cpp index 53427d056e2..9d2791a9231 100644 --- a/src/util/pointer_predicates.cpp +++ b/src/util/pointer_predicates.cpp @@ -6,6 +6,10 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Various predicates over pointers in programs + +#include "c_types.h" #include "cprover_prefix.h" #include "namespace.h" #include "std_expr.h" @@ -17,90 +21,26 @@ Author: Daniel Kroening, kroening@kroening.com #include "pointer_predicates.h" -/*******************************************************************\ - -Function: pointer_object - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt pointer_object(const exprt &p) { - return unary_exprt( - ID_pointer_object, p, - unsignedbv_typet(config.ansi_c.pointer_width)); + return unary_exprt(ID_pointer_object, p, size_type()); } -/*******************************************************************\ - -Function: same_object - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt same_object(const exprt &p1, const exprt &p2) { return equal_exprt(pointer_object(p1), pointer_object(p2)); } -/*******************************************************************\ - -Function: object_size - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt object_size(const exprt &pointer) { - typet type=signedbv_typet(config.ansi_c.pointer_width); - return unary_exprt(ID_object_size, pointer, type); + return unary_exprt(ID_object_size, pointer, size_type()); } -/*******************************************************************\ - -Function: pointer_offset - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt pointer_offset(const exprt &pointer) { - typet type=signedbv_typet(config.ansi_c.pointer_width); - return unary_exprt(ID_pointer_offset, pointer, type); + return unary_exprt(ID_pointer_offset, pointer, signed_size_type()); } -/*******************************************************************\ - -Function: malloc_object - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt malloc_object(const exprt &pointer, const namespacet &ns) { // we check __CPROVER_malloc_object! @@ -109,18 +49,6 @@ exprt malloc_object(const exprt &pointer, const namespacet &ns) return same_object(pointer, malloc_object_symbol.symbol_expr()); } -/*******************************************************************\ - -Function: deallocated - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt deallocated(const exprt &pointer, const namespacet &ns) { // we check __CPROVER_deallocated! @@ -129,18 +57,6 @@ exprt deallocated(const exprt &pointer, const namespacet &ns) return same_object(pointer, deallocated_symbol.symbol_expr()); } -/*******************************************************************\ - -Function: dead_object - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt dead_object(const exprt &pointer, const namespacet &ns) { // we check __CPROVER_dead_object! @@ -149,52 +65,16 @@ exprt dead_object(const exprt &pointer, const namespacet &ns) return same_object(pointer, deallocated_symbol.symbol_expr()); } -/*******************************************************************\ - -Function: dynamic_size - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt dynamic_size(const namespacet &ns) { return ns.lookup(CPROVER_PREFIX "malloc_size").symbol_expr(); } -/*******************************************************************\ - -Function: pointer_object_has_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt pointer_object_has_type(const exprt &pointer, const typet &type) { return false_exprt(); } -/*******************************************************************\ - -Function: dynamic_object - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt dynamic_object(const exprt &pointer) { exprt dynamic_expr(ID_dynamic_object, bool_typet()); @@ -202,35 +82,11 @@ exprt dynamic_object(const exprt &pointer) return dynamic_expr; } -/*******************************************************************\ - -Function: good_pointer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt good_pointer(const exprt &pointer) { return unary_exprt(ID_good_pointer, pointer, bool_typet()); } -/*******************************************************************\ - -Function: good_pointer_def - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt good_pointer_def( const exprt &pointer, const namespacet &ns) @@ -287,36 +143,12 @@ exprt good_pointer_def( good_other); } -/*******************************************************************\ - -Function: null_object - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt null_object(const exprt &pointer) { null_pointer_exprt null_pointer(to_pointer_type(pointer.type())); return same_object(null_pointer, pointer); } -/*******************************************************************\ - -Function: integer_address - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt integer_address(const exprt &pointer) { null_pointer_exprt null_pointer(to_pointer_type(pointer.type())); @@ -324,53 +156,17 @@ exprt integer_address(const exprt &pointer) notequal_exprt(null_pointer, pointer)); } -/*******************************************************************\ - -Function: null_pointer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt null_pointer(const exprt &pointer) { null_pointer_exprt null_pointer(to_pointer_type(pointer.type())); return same_object(pointer, null_pointer); } -/*******************************************************************\ - -Function: invalid_pointer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt invalid_pointer(const exprt &pointer) { return unary_exprt(ID_invalid_pointer, pointer, bool_typet()); } -/*******************************************************************\ - -Function: dynamic_object_lower_bound - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt dynamic_object_lower_bound( const exprt &pointer, const namespacet &ns, @@ -379,18 +175,6 @@ exprt dynamic_object_lower_bound( return object_lower_bound(pointer, ns, offset); } -/*******************************************************************\ - -Function: dynamic_object_upper_bound - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt dynamic_object_upper_bound( const exprt &pointer, const typet &dereference_type, @@ -411,6 +195,10 @@ exprt dynamic_object_upper_bound( if(access_size.is_not_nil()) { op=ID_gt; + + if(ns.follow(object_offset.type())!= + ns.follow(access_size.type())) + object_offset.make_typecast(access_size.type()); sum=plus_exprt(object_offset, access_size); } @@ -421,18 +209,6 @@ exprt dynamic_object_upper_bound( return binary_relation_exprt(sum, op, malloc_size); } -/*******************************************************************\ - -Function: object_upper_bound - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt object_upper_bound( const exprt &pointer, const typet &dereference_type, @@ -453,6 +229,10 @@ exprt object_upper_bound( if(access_size.is_not_nil()) { op=ID_gt; + + if(ns.follow(object_offset.type())!= + ns.follow(access_size.type())) + object_offset.make_typecast(access_size.type()); sum=plus_exprt(object_offset, access_size); } @@ -464,18 +244,6 @@ exprt object_upper_bound( return binary_relation_exprt(sum, op, object_size_expr); } -/*******************************************************************\ - -Function: object_lower_bound - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt object_lower_bound( const exprt &pointer, const namespacet &ns, diff --git a/src/util/pointer_predicates.h b/src/util/pointer_predicates.h index 9f3ee3980fd..201d094f50a 100644 --- a/src/util/pointer_predicates.h +++ b/src/util/pointer_predicates.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Various predicates over pointers in programs + #ifndef CPROVER_UTIL_POINTER_PREDICATES_H #define CPROVER_UTIL_POINTER_PREDICATES_H diff --git a/src/util/prefix.h b/src/util/prefix.h index 1efd86bae7a..7edb43a80a0 100644 --- a/src/util/prefix.h +++ b/src/util/prefix.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_PREFIX_H #define CPROVER_UTIL_PREFIX_H diff --git a/src/util/preprocessor.h b/src/util/preprocessor.h index 248a85d0402..64919612319 100644 --- a/src/util/preprocessor.h +++ b/src/util/preprocessor.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Preprocessing Base Class + #ifndef CPROVER_UTIL_PREPROCESSOR_H #define CPROVER_UTIL_PREPROCESSOR_H diff --git a/src/util/rational.cpp b/src/util/rational.cpp index 45dfdec86db..f43b5915a28 100644 --- a/src/util/rational.cpp +++ b/src/util/rational.cpp @@ -6,23 +6,14 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Rational Numbers + #include #include #include "rational.h" -/*******************************************************************\ - -Function: rationalt::operator+= - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - rationalt &rationalt::operator+=(const rationalt &n) { rationalt tmp(n); @@ -32,18 +23,6 @@ rationalt &rationalt::operator+=(const rationalt &n) return *this; } -/*******************************************************************\ - -Function: rationalt::operator-= - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - rationalt &rationalt::operator-=(const rationalt &n) { rationalt tmp(n); @@ -53,36 +32,12 @@ rationalt &rationalt::operator-=(const rationalt &n) return *this; } -/*******************************************************************\ - -Function: rationalt::operator-= - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - rationalt &rationalt::operator-() { numerator.negate(); return *this; } -/*******************************************************************\ - -Function: rationalt::operator*= - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - rationalt &rationalt::operator*=(const rationalt &n) { numerator*=n.numerator; @@ -91,18 +46,6 @@ rationalt &rationalt::operator*=(const rationalt &n) return *this; } -/*******************************************************************\ - -Function: rationalt::operator/= - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - rationalt &rationalt::operator/=(const rationalt &n) { assert(!n.numerator.is_zero()); @@ -112,18 +55,6 @@ rationalt &rationalt::operator/=(const rationalt &n) return *this; } -/*******************************************************************\ - -Function: rationalt::normalize - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rationalt::normalize() { // first do sign @@ -144,18 +75,6 @@ void rationalt::normalize() } } -/*******************************************************************\ - -Function: rationalt::same_denominator - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rationalt::same_denominator(rationalt &n) { if(denominator==n.denominator) @@ -169,36 +88,12 @@ void rationalt::same_denominator(rationalt &n) n.denominator=t; } -/*******************************************************************\ - -Function: rationalt::invert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rationalt::invert() { assert(numerator!=0); std::swap(numerator, denominator); } -/*******************************************************************\ - -Function: inverse - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - rationalt inverse(const rationalt &n) { rationalt tmp(n); @@ -206,18 +101,6 @@ rationalt inverse(const rationalt &n) return tmp; } -/*******************************************************************\ - -Function: operator<< - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::ostream &operator<<(std::ostream &out, const rationalt &a) { std::string d=integer2string(a.get_numerator()); diff --git a/src/util/rational.h b/src/util/rational.h index 6551b35a033..809f237c95a 100644 --- a/src/util/rational.h +++ b/src/util/rational.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_RATIONAL_H #define CPROVER_UTIL_RATIONAL_H diff --git a/src/util/rational_tools.cpp b/src/util/rational_tools.cpp index 3e57beefc91..140241a9179 100644 --- a/src/util/rational_tools.cpp +++ b/src/util/rational_tools.cpp @@ -6,23 +6,14 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Rational Numbers + #include "rational.h" #include "std_types.h" #include "rational_tools.h" -/*******************************************************************\ - -Function: power10 - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static mp_integer power10(size_t i) { mp_integer result=1; @@ -33,18 +24,6 @@ static mp_integer power10(size_t i) return result; } -/*******************************************************************\ - -Function: to_rational - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool to_rational(const exprt &expr, rationalt &rational_value) { if(expr.id()!=ID_constant) @@ -99,18 +78,6 @@ bool to_rational(const exprt &expr, rationalt &rational_value) return false; } -/*******************************************************************\ - -Function: from_rational - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - constant_exprt from_rational(const rationalt &a) { std::string d=integer2string(a.get_numerator()); diff --git a/src/util/rational_tools.h b/src/util/rational_tools.h index 34dcf8d4932..fe4ed4d4321 100644 --- a/src/util/rational_tools.h +++ b/src/util/rational_tools.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_RATIONAL_TOOLS_H #define CPROVER_UTIL_RATIONAL_TOOLS_H diff --git a/src/util/ref_expr_set.cpp b/src/util/ref_expr_set.cpp index 7e54107fd52..2b9fc3b213d 100644 --- a/src/util/ref_expr_set.cpp +++ b/src/util/ref_expr_set.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Value Set + #include "ref_expr_set.h" const ref_expr_set_dt ref_expr_set_dt::blank; diff --git a/src/util/ref_expr_set.h b/src/util/ref_expr_set.h index d7846d092d1..349619c233f 100644 --- a/src/util/ref_expr_set.h +++ b/src/util/ref_expr_set.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Value Set + #ifndef CPROVER_UTIL_REF_EXPR_SET_H #define CPROVER_UTIL_REF_EXPR_SET_H diff --git a/src/util/reference_counting.h b/src/util/reference_counting.h index e6746f3c3a6..ffdc8eed754 100644 --- a/src/util/reference_counting.h +++ b/src/util/reference_counting.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Reference Counting + #ifndef CPROVER_UTIL_REFERENCE_COUNTING_H #define CPROVER_UTIL_REFERENCE_COUNTING_H @@ -33,7 +36,7 @@ class reference_counting assert(d->ref_count!=0); d->ref_count++; #ifdef REFERENCE_COUNTING_DEBUG - std::cout << "COPY " << d << " " << d->ref_count << std::endl; + std::cout << "COPY " << d << " " << d->ref_count << '\n'; #endif } } @@ -121,14 +124,14 @@ void reference_counting::remove_ref(dt *old_d) assert(old_d->ref_count!=0); #ifdef REFERENCE_COUNTING_DEBUG - std::cout << "R: " << old_d << " " << old_d->ref_count << std::endl; + std::cout << "R: " << old_d << " " << old_d->ref_count << '\n'; #endif old_d->ref_count--; if(old_d->ref_count==0) { #ifdef REFERENCE_COUNTING_DEBUG - std::cout << "DELETING " << old_d << std::endl; + std::cout << "DELETING " << old_d << '\n'; old_d->clear(); std::cout << "DEALLOCATING " << old_d << "\n"; #endif @@ -145,7 +148,7 @@ template void reference_counting::detatch() { #ifdef REFERENCE_COUNTING_DEBUG - std::cout << "DETATCH1: " << d << std::endl; + std::cout << "DETATCH1: " << d << '\n'; #endif if(d==NULL) @@ -153,7 +156,7 @@ void reference_counting::detatch() d=new dt; #ifdef REFERENCE_COUNTING_DEBUG - std::cout << "ALLOCATED " << d << std::endl; + std::cout << "ALLOCATED " << d << '\n'; #endif } else if(d->ref_count>1) @@ -162,7 +165,7 @@ void reference_counting::detatch() d=new dt(*old_d); #ifdef REFERENCE_COUNTING_DEBUG - std::cout << "ALLOCATED " << d << std::endl; + std::cout << "ALLOCATED " << d << '\n'; #endif d->ref_count=1; @@ -172,7 +175,7 @@ void reference_counting::detatch() assert(d->ref_count==1); #ifdef REFERENCE_COUNTING_DEBUG - std::cout << "DETATCH2: " << d << std::endl; + std::cout << "DETATCH2: " << d << '\n' #endif } diff --git a/src/util/refined_string_type.cpp b/src/util/refined_string_type.cpp index 0625149cf83..29f73f88da6 100644 --- a/src/util/refined_string_type.cpp +++ b/src/util/refined_string_type.cpp @@ -10,18 +10,16 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com \*******************************************************************/ +/// \file +/// Type for string expressions used by the string solver. These string +/// expressions contain a field `length`, of type `index_type`, a field +/// `content` of type `content_type`. This module also defines functions to +/// recognise the C and java string types. + #include #include "refined_string_type.h" -/*******************************************************************\ - -Constructor: refined_string_typet::refined_string_typet - - Inputs: type of characters - -\*******************************************************************/ - refined_string_typet::refined_string_typet( const typet &index_type, const typet &char_type) { @@ -32,16 +30,8 @@ refined_string_typet::refined_string_typet( set_tag(CPROVER_PREFIX"refined_string_type"); } -/*******************************************************************\ - -Function: refined_string_typet::is_refined_string_type - - Inputs: a type - - Outputs: Boolean telling whether the input is a refined string type - -\*******************************************************************/ - +/// \par parameters: a type +/// \return Boolean telling whether the input is a refined string type bool refined_string_typet::is_refined_string_type(const typet &type) { return diff --git a/src/util/refined_string_type.h b/src/util/refined_string_type.h index a0cb7500e7f..efa8a0987ec 100644 --- a/src/util/refined_string_type.h +++ b/src/util/refined_string_type.h @@ -10,6 +10,12 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com \*******************************************************************/ +/// \file +/// Type for string expressions used by the string solver. These string +/// expressions contain a field `length`, of type `index_type`, a field +/// `content` of type `content_type`. This module also defines functions to +/// recognise the C and java string types. + #ifndef CPROVER_UTIL_REFINED_STRING_TYPE_H #define CPROVER_UTIL_REFINED_STRING_TYPE_H diff --git a/src/util/rename.cpp b/src/util/rename.cpp index b121edb6acb..da127c4f3f4 100644 --- a/src/util/rename.cpp +++ b/src/util/rename.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "rename.h" @@ -13,35 +14,17 @@ Author: Daniel Kroening, kroening@kroening.com #include "expr.h" #include "namespace.h" -/*******************************************************************\ - -Function: get_new_name - - Inputs: symbol to be renamed, namespace - - Outputs: new symbol - - Purpose: automated variable renaming - -\*******************************************************************/ - +/// automated variable renaming +/// \par parameters: symbol to be renamed, namespace +/// \return new symbol void get_new_name(symbolt &symbol, const namespacet &ns) { get_new_name(symbol.name, ns); } -/*******************************************************************\ - -Function: get_new_name - - Inputs: symbol to be renamed, namespace - - Outputs: new symbol - - Purpose: automated variable renaming - -\*******************************************************************/ - +/// automated variable renaming +/// \par parameters: symbol to be renamed, namespace +/// \return new symbol void get_new_name(irep_idt &new_name, const namespacet &ns) { const symbolt *symbol; @@ -53,19 +36,9 @@ void get_new_name(irep_idt &new_name, const namespacet &ns) new_name=prefix+std::to_string(ns.get_max(prefix)+1); } -/*******************************************************************\ - -Function: rename - - Inputs: expression, old name, new name - - Outputs: modifies the expression - returns false iff something was renamed - - Purpose: automated variable renaming - -\*******************************************************************/ - +/// automated variable renaming +/// \par parameters: expression, old name, new name +/// \return modifies the expression returns false iff something was renamed bool rename(exprt &expr, const irep_idt &old_name, const irep_idt &new_name) { diff --git a/src/util/rename.h b/src/util/rename.h index 16be66f9599..691f877d3a1 100644 --- a/src/util/rename.h +++ b/src/util/rename.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_RENAME_H #define CPROVER_UTIL_RENAME_H diff --git a/src/util/rename_symbol.cpp b/src/util/rename_symbol.cpp index c6930a01d87..727f83b0ed3 100644 --- a/src/util/rename_symbol.cpp +++ b/src/util/rename_symbol.cpp @@ -6,54 +6,19 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include "std_types.h" #include "std_expr.h" #include "rename_symbol.h" -/*******************************************************************\ - -Function: rename_symbolt::rename_symbolt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - rename_symbolt::rename_symbolt() { } -/*******************************************************************\ - -Function: rename_symbolt::~rename_symbolt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - rename_symbolt::~rename_symbolt() { } -/*******************************************************************\ - -Function: rename_symbolt::insert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void rename_symbolt::insert( const symbol_exprt &old_expr, const symbol_exprt &new_expr) @@ -61,18 +26,6 @@ void rename_symbolt::insert( insert_expr(old_expr.get_identifier(), new_expr.get_identifier()); } -/*******************************************************************\ - -Function: rename_symbolt::rename - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool rename_symbolt::rename(exprt &dest) const { bool result=true; @@ -119,18 +72,6 @@ bool rename_symbolt::rename(exprt &dest) const return result; } -/*******************************************************************\ - -Function: rename_symbolt::have_to_rename - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool rename_symbolt::have_to_rename(const exprt &dest) const { if(expr_map.empty() && type_map.empty()) @@ -165,18 +106,6 @@ bool rename_symbolt::have_to_rename(const exprt &dest) const return false; } -/*******************************************************************\ - -Function: rename_symbolt::rename - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool rename_symbolt::rename(typet &dest) const { if(!have_to_rename(dest)) @@ -263,18 +192,6 @@ bool rename_symbolt::rename(typet &dest) const return result; } -/*******************************************************************\ - -Function: rename_symbolt::have_to_rename - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool rename_symbolt::have_to_rename(const typet &dest) const { if(expr_map.empty() && type_map.empty()) diff --git a/src/util/rename_symbol.h b/src/util/rename_symbol.h index e103ff37ecd..88e08991b6d 100644 --- a/src/util/rename_symbol.h +++ b/src/util/rename_symbol.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_RENAME_SYMBOL_H #define CPROVER_UTIL_RENAME_SYMBOL_H diff --git a/src/util/replace_expr.cpp b/src/util/replace_expr.cpp index fc419aa59fa..9655359796a 100644 --- a/src/util/replace_expr.cpp +++ b/src/util/replace_expr.cpp @@ -6,19 +6,8 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "replace_expr.h" - -/*******************************************************************\ - -Function: replace_expr - - Inputs: - Outputs: - - Purpose: - -\*******************************************************************/ +#include "replace_expr.h" bool replace_expr(const exprt &what, const exprt &by, exprt &dest) { @@ -36,18 +25,6 @@ bool replace_expr(const exprt &what, const exprt &by, exprt &dest) return result; } -/*******************************************************************\ - -Function: replace_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool replace_expr(const replace_mapt &what, exprt &dest) { { diff --git a/src/util/replace_expr.h b/src/util/replace_expr.h index 74b2a64374c..058909076dc 100644 --- a/src/util/replace_expr.h +++ b/src/util/replace_expr.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_REPLACE_EXPR_H #define CPROVER_UTIL_REPLACE_EXPR_H diff --git a/src/util/replace_symbol.cpp b/src/util/replace_symbol.cpp index 4dce48d8b93..51d4a140493 100644 --- a/src/util/replace_symbol.cpp +++ b/src/util/replace_symbol.cpp @@ -6,54 +6,19 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include "std_types.h" #include "std_expr.h" #include "replace_symbol.h" -/*******************************************************************\ - -Function: replace_symbolt::replace_symbolt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - replace_symbolt::replace_symbolt() { } -/*******************************************************************\ - -Function: replace_symbolt::~replace_symbolt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - replace_symbolt::~replace_symbolt() { } -/*******************************************************************\ - -Function: replace_symbolt::insert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void replace_symbolt::insert( const symbol_exprt &old_expr, const exprt &new_expr) @@ -62,18 +27,6 @@ void replace_symbolt::insert( old_expr.get_identifier(), new_expr)); } -/*******************************************************************\ - -Function: replace_symbolt::replace - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool replace_symbolt::replace(exprt &dest) const { bool result=true; @@ -120,18 +73,6 @@ bool replace_symbolt::replace(exprt &dest) const return result; } -/*******************************************************************\ - -Function: replace_symbolt::have_to_replace - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool replace_symbolt::have_to_replace(const exprt &dest) const { // first look at type @@ -163,18 +104,6 @@ bool replace_symbolt::have_to_replace(const exprt &dest) const return false; } -/*******************************************************************\ - -Function: replace_symbolt::replace - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool replace_symbolt::replace(typet &dest) const { if(!have_to_replace(dest)) @@ -236,18 +165,6 @@ bool replace_symbolt::replace(typet &dest) const return result; } -/*******************************************************************\ - -Function: replace_symbolt::have_to_replace - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool replace_symbolt::have_to_replace(const typet &dest) const { if(dest.has_subtype()) diff --git a/src/util/replace_symbol.h b/src/util/replace_symbol.h index f26c8eb067a..ebc1102e921 100644 --- a/src/util/replace_symbol.h +++ b/src/util/replace_symbol.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_REPLACE_SYMBOL_H #define CPROVER_UTIL_REPLACE_SYMBOL_H @@ -56,6 +57,11 @@ class replace_symbolt type_map.clear(); } + bool empty() const + { + return expr_map.empty() && type_map.empty(); + } + replace_symbolt(); virtual ~replace_symbolt(); diff --git a/src/util/run.cpp b/src/util/run.cpp index 8a8a1c68659..d29082ea0b0 100644 --- a/src/util/run.cpp +++ b/src/util/run.cpp @@ -8,6 +8,7 @@ Date: August 2012 \*******************************************************************/ + #include #ifdef _WIN32 @@ -33,18 +34,6 @@ Date: August 2012 #include "run.h" -/*******************************************************************\ - -Function: run_shell - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - int run_shell(const std::string &command) { std::string shell="/bin/sh"; @@ -54,18 +43,6 @@ int run_shell(const std::string &command) return run(shell, argv, "", ""); } -/*******************************************************************\ - -Function: run - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - int run( const std::string &what, const std::vector &argv, diff --git a/src/util/run.h b/src/util/run.h index 015a63ae7c1..83f971d5d1a 100644 --- a/src/util/run.h +++ b/src/util/run.h @@ -8,6 +8,7 @@ Date: August 2012 \*******************************************************************/ + #ifndef CPROVER_UTIL_RUN_H #define CPROVER_UTIL_RUN_H diff --git a/src/util/safe_pointer.h b/src/util/safe_pointer.h index 47e52ac13fe..152eb3242d9 100644 --- a/src/util/safe_pointer.h +++ b/src/util/safe_pointer.h @@ -6,6 +6,9 @@ Author: Chris Smowton, chris@smowton.net \*******************************************************************/ +/// \file +/// Simple checked pointers + #ifndef CPROVER_UTIL_SAFE_POINTER_H #define CPROVER_UTIL_SAFE_POINTER_H diff --git a/src/util/sharing_map.h b/src/util/sharing_map.h index 23f08d0bb06..8cbfcce4002 100644 --- a/src/util/sharing_map.h +++ b/src/util/sharing_map.h @@ -6,6 +6,9 @@ Author: Daniel Poetzl \*******************************************************************/ +/// \file +/// Sharing map + #ifndef CPROVER_UTIL_SHARING_MAP_H #define CPROVER_UTIL_SHARING_MAP_H @@ -211,18 +214,6 @@ class sharing_mapt void gather_all(const node_type &n, delta_viewt &delta_view) const; }; -/*******************************************************************\ - -Function: get_view - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - SHARING_MAPT(void)::get_view(viewt &view) const { assert(view.empty()); @@ -259,18 +250,6 @@ SHARING_MAPT(void)::get_view(viewt &view) const while(!stack.empty()); } -/*******************************************************************\ - -Function: gather_all - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - SHARING_MAPT(void)::gather_all(const node_type &n, delta_viewt &delta_view) const { @@ -307,18 +286,6 @@ SHARING_MAPT(void)::gather_all(const node_type &n, delta_viewt &delta_view) while(!stack.empty()); } -/*******************************************************************\ - -Function: get_delta_view - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - SHARING_MAPT(void)::get_delta_view( const self_type &other, delta_viewt &delta_view, @@ -425,18 +392,6 @@ SHARING_MAPT(void)::get_delta_view( while(!stack.empty()); } -/*******************************************************************\ - -Function: get_container_node - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - SHARING_MAPT2(, node_type *)::get_container_node(const key_type &k) { size_t key=hash()(k); @@ -453,18 +408,6 @@ SHARING_MAPT2(, node_type *)::get_container_node(const key_type &k) return p; } -/*******************************************************************\ - -Function: get_container_node - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - SHARING_MAPT2(const, node_type *)::get_container_node(const key_type &k) const { size_t key=hash()(k); @@ -485,18 +428,6 @@ SHARING_MAPT2(const, node_type *)::get_container_node(const key_type &k) const return p; } -/*******************************************************************\ - -Function: get_leaf_node - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - SHARING_MAPT2(const, node_type *)::get_leaf_node(const key_type &k) const { const node_type *p=get_container_node(k); @@ -508,18 +439,6 @@ SHARING_MAPT2(const, node_type *)::get_leaf_node(const key_type &k) const return p; } -/*******************************************************************\ - -Function: erase - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - SHARING_MAPT2(, size_type)::erase( const key_type &k, const tvt &key_exists) @@ -572,18 +491,6 @@ SHARING_MAPT2(, size_type)::erase( return 1; } -/*******************************************************************\ - -Function: erase_all - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - SHARING_MAPT2(, size_type)::erase_all( const keyst &ks, const tvt &key_exists) @@ -598,18 +505,6 @@ SHARING_MAPT2(, size_type)::erase_all( return cnt; } -/*******************************************************************\ - -Function: insert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - SHARING_MAPT2(, const_find_type)::insert( const key_type &k, const mapped_type &m, @@ -633,18 +528,6 @@ SHARING_MAPT2(, const_find_type)::insert( return const_find_type(as_const(p)->get_value(), true); } -/*******************************************************************\ - -Function: insert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - SHARING_MAPT2(, const_find_type)::insert( const value_type &p, const tvt &key_exists) @@ -652,18 +535,6 @@ SHARING_MAPT2(, const_find_type)::insert( return insert(p.first, p.second, key_exists); } -/*******************************************************************\ - -Function: place - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - SHARING_MAPT2(, find_type)::place( const key_type &k, const mapped_type &m) @@ -682,36 +553,12 @@ SHARING_MAPT2(, find_type)::place( return find_type(p->get_value(), true); } -/*******************************************************************\ - -Function: place - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - SHARING_MAPT2(, find_type)::place( const value_type &p) { return place(p.first, p.second); } -/*******************************************************************\ - -Function: find - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - SHARING_MAPT2(, find_type)::find( const key_type &k, const tvt &key_exists) @@ -731,18 +578,6 @@ SHARING_MAPT2(, find_type)::find( } -/*******************************************************************\ - -Function: find - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - SHARING_MAPT2(, const_find_type)::find(const key_type &k) const { const node_type *p=get_leaf_node(k); @@ -753,18 +588,6 @@ SHARING_MAPT2(, const_find_type)::find(const key_type &k) const return const_find_type(p->get_value(), true); } -/*******************************************************************\ - -Function: at - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - SHARING_MAPT2(, mapped_type &)::at( const key_type &k, const tvt &key_exists) @@ -777,18 +600,6 @@ SHARING_MAPT2(, mapped_type &)::at( return r.first; } -/*******************************************************************\ - -Function: at - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - SHARING_MAPT2(const, mapped_type &)::at(const key_type &k) const { const_find_type r=find(k); @@ -798,18 +609,6 @@ SHARING_MAPT2(const, mapped_type &)::at(const key_type &k) const return r.first; } -/*******************************************************************\ - -Function: operator[] - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - SHARING_MAPT2(, mapped_type &)::operator[](const key_type &k) { return place(k, mapped_type()).first; diff --git a/src/util/sharing_node.h b/src/util/sharing_node.h index 1e3d29a413e..9f8cc0a4416 100644 --- a/src/util/sharing_node.h +++ b/src/util/sharing_node.h @@ -6,6 +6,9 @@ Author: Daniel Poetzl \*******************************************************************/ +/// \file +/// Sharing node + #ifndef CPROVER_UTIL_SHARING_NODE_H #define CPROVER_UTIL_SHARING_NODE_H diff --git a/src/util/signal_catcher.cpp b/src/util/signal_catcher.cpp index b0178340543..9c67c23f301 100644 --- a/src/util/signal_catcher.cpp +++ b/src/util/signal_catcher.cpp @@ -8,6 +8,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #if defined(_WIN32) #include #else @@ -28,18 +29,6 @@ Author: Daniel Kroening, kroening@kroening.com std::vector pids_of_children; #endif -/*******************************************************************\ - -Function: install_signal_catcher - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void install_signal_catcher() { #if defined(_WIN32) @@ -57,18 +46,6 @@ void install_signal_catcher() #endif } -/*******************************************************************\ - -Function: remove_signal_catcher - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void remove_signal_catcher() { #if defined(_WIN32) @@ -85,18 +62,6 @@ void remove_signal_catcher() #endif } -/*******************************************************************\ - -Function: signal_catcher - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void signal_catcher(int sig) { #if defined(_WIN32) diff --git a/src/util/signal_catcher.h b/src/util/signal_catcher.h index 3896252ad20..399e6bb960e 100644 --- a/src/util/signal_catcher.h +++ b/src/util/signal_catcher.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_SIGNAL_CATCHER_H #define CPROVER_UTIL_SIGNAL_CATCHER_H diff --git a/src/util/simplify_expr.cpp b/src/util/simplify_expr.cpp index 837138258d0..23d814b75a9 100644 --- a/src/util/simplify_expr.cpp +++ b/src/util/simplify_expr.cpp @@ -6,9 +6,11 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include +#include "c_types.h" #include "rational.h" #include "simplify_expr_class.h" #include "simplify_expr.h" @@ -63,18 +65,6 @@ struct simplify_expr_cachet simplify_expr_cachet simplify_expr_cache; #endif -/*******************************************************************\ - -Function: simplify_exprt::simplify_abs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_abs(exprt &expr) { if(expr.operands().size()!=1) @@ -115,18 +105,6 @@ bool simplify_exprt::simplify_abs(exprt &expr) return true; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_sign - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_sign(exprt &expr) { if(expr.operands().size()!=1) @@ -157,18 +135,6 @@ bool simplify_exprt::simplify_sign(exprt &expr) return true; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_popcount - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_popcount(exprt &expr) { if(expr.operands().size()!=1) @@ -200,18 +166,6 @@ bool simplify_exprt::simplify_popcount(exprt &expr) return true; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_typecast - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_typecast(exprt &expr) { if(expr.operands().size()!=1) @@ -334,7 +288,7 @@ bool simplify_exprt::simplify_typecast(exprt &expr) expr.op0().operands().size()==1 && op_type.id()==ID_pointer) { - expr.op0().type()=unsignedbv_typet(config.ansi_c.pointer_width); + expr.op0().type()=size_type(); simplify_typecast(expr.op0()); // rec. call simplify_typecast(expr); // rec. call return false; @@ -351,17 +305,15 @@ bool simplify_exprt::simplify_typecast(exprt &expr) expr.op0().op0().op0().is_zero() && op_type.id()==ID_pointer) { - unsignedbv_typet size_type(config.ansi_c.pointer_width); - mp_integer sub_size=pointer_offset_size(op_type.subtype(), ns); if(sub_size!=-1) { // void* if(sub_size==0 || sub_size==1) - expr.op0()=typecast_exprt(expr.op0().op1(), size_type); + expr.op0()=typecast_exprt(expr.op0().op1(), size_type()); else - expr.op0()=mult_exprt(from_integer(sub_size, size_type), - typecast_exprt(expr.op0().op1(), size_type)); + expr.op0()=mult_exprt(from_integer(sub_size, size_type()), + typecast_exprt(expr.op0().op1(), size_type())); simplify_rec(expr.op0()); simplify_typecast(expr); // rec. call @@ -428,7 +380,7 @@ bool simplify_exprt::simplify_typecast(exprt &expr) if(step>0) { - const unsignedbv_typet size_t_type(config.ansi_c.pointer_width); + const typet size_t_type(size_type()); expr.op0().type()=size_t_type; for(auto &op : expr.op0().operands()) @@ -759,18 +711,6 @@ bool simplify_exprt::simplify_typecast(exprt &expr) return true; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_dereference - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_dereference(exprt &expr) { const exprt &pointer=to_dereference_expr(expr).pointer(); @@ -829,18 +769,6 @@ bool simplify_exprt::simplify_dereference(exprt &expr) return true; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_if_implies - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_if_implies( exprt &expr, const exprt &cond, @@ -932,18 +860,6 @@ bool simplify_exprt::simplify_if_implies( return true; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_if_recursive - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_if_recursive( exprt &expr, const exprt &cond, @@ -976,18 +892,6 @@ bool simplify_exprt::simplify_if_recursive( return result; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_if_conj - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_if_conj( exprt &expr, const exprt &cond) @@ -1009,18 +913,6 @@ bool simplify_exprt::simplify_if_conj( return result; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_if_disj - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_if_disj( exprt &expr, const exprt &cond) @@ -1042,18 +934,6 @@ bool simplify_exprt::simplify_if_disj( return result; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_if_branch - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_if_branch( exprt &trueexpr, exprt &falseexpr, @@ -1086,18 +966,6 @@ bool simplify_exprt::simplify_if_branch( return tresult && fresult; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_if_cond - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_if_cond(exprt &expr) { bool result=true; @@ -1134,18 +1002,6 @@ bool simplify_exprt::simplify_if_cond(exprt &expr) return result; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_if_preorder - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_if_preorder(if_exprt &expr) { exprt &cond=expr.cond(); @@ -1231,18 +1087,6 @@ bool simplify_exprt::simplify_if_preorder(if_exprt &expr) return result; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_if - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_if(if_exprt &expr) { exprt &cond=expr.cond(); @@ -1351,18 +1195,6 @@ bool simplify_exprt::simplify_if(if_exprt &expr) return result; } -/*******************************************************************\ - -Function: simplify_exprt::get_values - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::get_values( const exprt &expr, value_listt &value_list) @@ -1389,18 +1221,6 @@ bool simplify_exprt::get_values( return true; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_lambda - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_lambda(exprt &expr) { bool result=true; @@ -1408,18 +1228,6 @@ bool simplify_exprt::simplify_lambda(exprt &expr) return result; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_with - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_with(exprt &expr) { bool result=true; @@ -1493,18 +1301,6 @@ bool simplify_exprt::simplify_with(exprt &expr) return result; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_update - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_update(exprt &expr) { if(expr.operands().size()!=3) @@ -1562,18 +1358,6 @@ bool simplify_exprt::simplify_update(exprt &expr) return false; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_object - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_object(exprt &expr) { if(expr.id()==ID_plus) @@ -1665,18 +1449,6 @@ bool simplify_exprt::simplify_object(exprt &expr) return true; } -/*******************************************************************\ - -Function: simplify_exprt::bits2expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt simplify_exprt::bits2expr( const std::string &bits, const typet &_type, @@ -1791,18 +1563,6 @@ exprt simplify_exprt::bits2expr( return nil_exprt(); } -/*******************************************************************\ - -Function: simplify_exprt::expr2bits - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string simplify_exprt::expr2bits( const exprt &expr, bool little_endian) @@ -1863,18 +1623,6 @@ std::string simplify_exprt::expr2bits( return ""; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_byte_extract - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_byte_extract(byte_extract_exprt &expr) { // lift up any ID_if on the object @@ -2046,7 +1794,9 @@ bool simplify_exprt::simplify_byte_extract(byte_extract_exprt &expr) assert(el_size%8==0); mp_integer el_bytes=el_size/8; - if(base_type_eq(expr.type(), op_type_ptr->subtype(), ns)) + if(base_type_eq(expr.type(), op_type_ptr->subtype(), ns) || + (expr.type().id()==ID_pointer && + op_type_ptr->subtype().id()==ID_pointer)) { if(offset%el_bytes==0) { @@ -2057,6 +1807,9 @@ bool simplify_exprt::simplify_byte_extract(byte_extract_exprt &expr) result, from_integer(offset, expr.offset().type())); + if(!base_type_eq(expr.type(), op_type_ptr->subtype(), ns)) + result.make_typecast(expr.type()); + expr.swap(result); simplify_rec(expr); return false; @@ -2125,18 +1878,6 @@ bool simplify_exprt::simplify_byte_extract(byte_extract_exprt &expr) return true; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_byte_update - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_byte_update(byte_update_exprt &expr) { // byte_update(byte_update(root, offset, value), offset, value2) => @@ -2409,18 +2150,6 @@ bool simplify_exprt::simplify_byte_update(byte_update_exprt &expr) return true; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_node_preorder - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_node_preorder(exprt &expr) { bool result=true; @@ -2446,18 +2175,6 @@ bool simplify_exprt::simplify_node_preorder(exprt &expr) return result; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_node - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_node(exprt &expr) { if(!expr.has_operands()) @@ -2591,19 +2308,7 @@ bool simplify_exprt::simplify_node(exprt &expr) return result; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_rec - - Inputs: - - Outputs: returns true if expression unchanged; - returns false if changed - - Purpose: - -\*******************************************************************/ - +/// \return returns true if expression unchanged; returns false if changed bool simplify_exprt::simplify_rec(exprt &expr) { // look up in cache @@ -2617,7 +2322,7 @@ bool simplify_exprt::simplify_rec(exprt &expr) { const exprt &new_expr=cache_result.first->second; - if(new_expr.id()==irep_idt()) + if(new_expr.id().empty()) return true; // no change expr=new_expr; @@ -2663,18 +2368,6 @@ bool simplify_exprt::simplify_rec(exprt &expr) return result; } -/*******************************************************************\ - -Function: simplify_exprt::simplify - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify(exprt &expr) { #ifdef DEBUG_ON_DEMAND @@ -2689,35 +2382,11 @@ bool simplify_exprt::simplify(exprt &expr) return res; } -/*******************************************************************\ - -Function: simplify - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify(exprt &expr, const namespacet &ns) { return simplify_exprt(ns).simplify(expr); } -/*******************************************************************\ - -Function: simplify_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt simplify_expr(const exprt &src, const namespacet &ns) { exprt tmp=src; diff --git a/src/util/simplify_expr.h b/src/util/simplify_expr.h index f327f26ca52..1ef1533eb30 100644 --- a/src/util/simplify_expr.h +++ b/src/util/simplify_expr.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_SIMPLIFY_EXPR_H #define CPROVER_UTIL_SIMPLIFY_EXPR_H diff --git a/src/util/simplify_expr_array.cpp b/src/util/simplify_expr_array.cpp index f00c039a6ef..c12d810939b 100644 --- a/src/util/simplify_expr_array.cpp +++ b/src/util/simplify_expr_array.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "simplify_expr_class.h" @@ -16,18 +17,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "arith_tools.h" #include "pointer_offset_size.h" -/*******************************************************************\ - -Function: simplify_exprt::simplify_index - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_index(exprt &expr) { bool result=true; diff --git a/src/util/simplify_expr_boolean.cpp b/src/util/simplify_expr_boolean.cpp index b747047cf98..f50c9b61b19 100644 --- a/src/util/simplify_expr_boolean.cpp +++ b/src/util/simplify_expr_boolean.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -14,18 +15,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "namespace.h" #include "std_expr.h" -/*******************************************************************\ - -Function: simplify_exprt::simplify_boolean - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_boolean(exprt &expr) { if(!expr.has_operands()) @@ -199,18 +188,6 @@ bool simplify_exprt::simplify_boolean(exprt &expr) return true; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_not - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_not(exprt &expr) { if(expr.operands().size()!=1) diff --git a/src/util/simplify_expr_class.h b/src/util/simplify_expr_class.h index eec5fab9fb4..3aa34492cb5 100644 --- a/src/util/simplify_expr_class.h +++ b/src/util/simplify_expr_class.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_SIMPLIFY_EXPR_CLASS_H #define CPROVER_UTIL_SIMPLIFY_EXPR_CLASS_H diff --git a/src/util/simplify_expr_floatbv.cpp b/src/util/simplify_expr_floatbv.cpp index 7115e23024a..f8da4276bbe 100644 --- a/src/util/simplify_expr_floatbv.cpp +++ b/src/util/simplify_expr_floatbv.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "simplify_expr_class.h" @@ -15,18 +16,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "std_expr.h" #include "arith_tools.h" -/*******************************************************************\ - -Function: simplify_exprt::simplify_isinf - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_isinf(exprt &expr) { if(expr.operands().size()!=1) @@ -45,18 +34,6 @@ bool simplify_exprt::simplify_isinf(exprt &expr) return true; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_isnan - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_isnan(exprt &expr) { if(expr.operands().size()!=1) @@ -72,18 +49,6 @@ bool simplify_exprt::simplify_isnan(exprt &expr) return true; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_isnormal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_isnormal(exprt &expr) { if(expr.operands().size()!=1) @@ -99,18 +64,6 @@ bool simplify_exprt::simplify_isnormal(exprt &expr) return true; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_abs - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - #if 0 bool simplify_exprt::simplify_abs(exprt &expr) { @@ -153,18 +106,6 @@ bool simplify_exprt::simplify_abs(exprt &expr) } #endif -/*******************************************************************\ - -Function: simplify_exprt::simplify_sign - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - #if 0 bool simplify_exprt::simplify_sign(exprt &expr) { @@ -197,18 +138,6 @@ bool simplify_exprt::simplify_sign(exprt &expr) } #endif -/*******************************************************************\ - -Function: simplify_exprt::simplify_floatbv_typecast - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_floatbv_typecast(exprt &expr) { // These casts usually reduce precision, and thus, usually round. @@ -338,18 +267,6 @@ bool simplify_exprt::simplify_floatbv_typecast(exprt &expr) return true; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_floatbv_op - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_floatbv_op(exprt &expr) { const typet &type=ns.follow(expr.type()); @@ -413,18 +330,6 @@ bool simplify_exprt::simplify_floatbv_op(exprt &expr) return true; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_ieee_float_relation - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_ieee_float_relation(exprt &expr) { assert(expr.id()==ID_ieee_float_equal || diff --git a/src/util/simplify_expr_int.cpp b/src/util/simplify_expr_int.cpp index c9c8a7f12a0..b41de055d69 100644 --- a/src/util/simplify_expr_int.cpp +++ b/src/util/simplify_expr_int.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "base_type.h" @@ -22,18 +23,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "rational_tools.h" #include "ieee_float.h" -/*******************************************************************\ - -Function: simplify_exprt::simplify_bswap - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_bswap(exprt &expr) { if(expr.type().id()==ID_unsignedbv && @@ -66,18 +55,6 @@ bool simplify_exprt::simplify_bswap(exprt &expr) return true; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_mult - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_mult(exprt &expr) { // check to see if it is a number type @@ -183,18 +160,6 @@ bool simplify_exprt::simplify_mult(exprt &expr) return result; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_div - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_div(exprt &expr) { if(!is_number(expr.type())) @@ -315,18 +280,6 @@ bool simplify_exprt::simplify_div(exprt &expr) return true; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_mod - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_mod(exprt &expr) { if(!is_number(expr.type())) @@ -376,18 +329,6 @@ bool simplify_exprt::simplify_mod(exprt &expr) return true; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_plus - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_plus(exprt &expr) { if(!is_number(expr.type()) && @@ -545,18 +486,6 @@ bool simplify_exprt::simplify_plus(exprt &expr) return result; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_minus - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_minus(exprt &expr) { if(!is_number(expr.type()) && @@ -616,18 +545,6 @@ bool simplify_exprt::simplify_minus(exprt &expr) return true; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_bitwise - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_bitwise(exprt &expr) { if(!is_bitvector_type(expr.type())) @@ -798,18 +715,6 @@ bool simplify_exprt::simplify_bitwise(exprt &expr) return result; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_extractbit - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_extractbit(exprt &expr) { const typet &op0_type=expr.op0().type(); @@ -844,18 +749,6 @@ bool simplify_exprt::simplify_extractbit(exprt &expr) return false; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_concatenation - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_concatenation(exprt &expr) { bool result=true; @@ -943,18 +836,6 @@ bool simplify_exprt::simplify_concatenation(exprt &expr) return result; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_shifts - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_shifts(exprt &expr) { if(!is_number(expr.type())) @@ -1067,18 +948,6 @@ bool simplify_exprt::simplify_shifts(exprt &expr) return true; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_power - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_power(exprt &expr) { if(!is_number(expr.type())) @@ -1101,18 +970,7 @@ bool simplify_exprt::simplify_power(exprt &expr) return false; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_extractbits - - Inputs: - - Outputs: - - Purpose: Simplifies extracting of bits from a constant. - -\*******************************************************************/ - +/// Simplifies extracting of bits from a constant. bool simplify_exprt::simplify_extractbits(exprt &expr) { assert(expr.operands().size()==3); @@ -1161,18 +1019,6 @@ bool simplify_exprt::simplify_extractbits(exprt &expr) return true; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_unary_plus - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_unary_plus(exprt &expr) { if(expr.operands().size()!=1) @@ -1183,18 +1029,6 @@ bool simplify_exprt::simplify_unary_plus(exprt &expr) return false; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_unary_minus - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_unary_minus(exprt &expr) { if(expr.operands().size()!=1) @@ -1272,18 +1106,6 @@ bool simplify_exprt::simplify_unary_minus(exprt &expr) return true; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_bitnot - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_bitnot(exprt &expr) { if(!expr.has_operands()) @@ -1320,18 +1142,7 @@ bool simplify_exprt::simplify_bitnot(exprt &expr) return true; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_inequality - - Inputs: - - Outputs: - - Purpose: simplifies inequalities !=, <=, <, >=, >, and also == - -\*******************************************************************/ - +/// simplifies inequalities !=, <=, <, >=, >, and also == bool simplify_exprt::simplify_inequality(exprt &expr) { exprt::operandst &operands=expr.operands(); @@ -1548,18 +1359,6 @@ bool simplify_exprt::simplify_inequality(exprt &expr) return false; } -/*******************************************************************\ - -Function: simplify_exprt::eliminate_common_addends - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::eliminate_common_addends( exprt &op0, exprt &op1) @@ -1608,18 +1407,6 @@ bool simplify_exprt::eliminate_common_addends( return true; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_inequality_not_constant - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_inequality_not_constant(exprt &expr) { exprt::operandst &operands=expr.operands(); @@ -1746,18 +1533,7 @@ bool simplify_exprt::simplify_inequality_not_constant(exprt &expr) return true; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_inequality_constant - - Inputs: an inequality with a constant on the RHS - - Outputs: - - Purpose: - -\*******************************************************************/ - +/// \par parameters: an inequality with a constant on the RHS bool simplify_exprt::simplify_inequality_constant(exprt &expr) { // the constant is always on the RHS diff --git a/src/util/simplify_expr_pointer.cpp b/src/util/simplify_expr_pointer.cpp index 9bc2496f5ff..d4b9736c431 100644 --- a/src/util/simplify_expr_pointer.cpp +++ b/src/util/simplify_expr_pointer.cpp @@ -6,8 +6,10 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include +#include "c_types.h" #include "simplify_expr_class.h" #include "expr.h" #include "namespace.h" @@ -20,18 +22,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "prefix.h" #include "pointer_predicates.h" -/*******************************************************************\ - -Function: is_dereference_integer_object - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static bool is_dereference_integer_object( const exprt &expr, mp_integer &address) @@ -61,18 +51,6 @@ static bool is_dereference_integer_object( return false; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_address_of_arg - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_address_of_arg(exprt &expr) { if(expr.id()==ID_index) @@ -100,11 +78,10 @@ bool simplify_exprt::simplify_address_of_arg(exprt &expr) if(!to_integer(expr.op1(), index) && step_size!=-1) { - unsignedbv_typet int_type(config.ansi_c.pointer_width); pointer_typet pointer_type; pointer_type.subtype()=expr.type(); typecast_exprt typecast_expr( - from_integer(step_size*index+address, int_type), pointer_type); + from_integer(step_size*index+address, index_type()), pointer_type); exprt new_expr=dereference_exprt(typecast_expr, expr.type()); expr=new_expr; result=true; @@ -137,11 +114,10 @@ bool simplify_exprt::simplify_address_of_arg(exprt &expr) mp_integer offset=member_offset(struct_type, member, ns); if(offset!=-1) { - unsignedbv_typet int_type(config.ansi_c.pointer_width); pointer_typet pointer_type; pointer_type.subtype()=expr.type(); typecast_exprt typecast_expr( - from_integer(address+offset, int_type), pointer_type); + from_integer(address+offset, index_type()), pointer_type); exprt new_expr=dereference_exprt(typecast_expr, expr.type()); expr=new_expr; result=true; @@ -192,18 +168,6 @@ bool simplify_exprt::simplify_address_of_arg(exprt &expr) return true; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_address_of - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_address_of(exprt &expr) { if(expr.operands().size()!=1) @@ -246,18 +210,6 @@ bool simplify_exprt::simplify_address_of(exprt &expr) return result; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_pointer_offset - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_pointer_offset(exprt &expr) { if(expr.operands().size()!=1) @@ -384,18 +336,19 @@ bool simplify_exprt::simplify_pointer_offset(exprt &expr) if(ptr_expr.size()!=1 || int_expr.empty()) return true; - typet pointer_type=ptr_expr.front().type(); + typet pointer_sub_type=ptr_expr.front().type().subtype(); + if(pointer_sub_type.id()==ID_empty) + pointer_sub_type=char_type(); mp_integer element_size= - pointer_offset_size(pointer_type.subtype(), ns); + pointer_offset_size(pointer_sub_type, ns); - if(element_size==0) + if(element_size<0) return true; // this might change the type of the pointer! - exprt pointer_offset(ID_pointer_offset, expr.type()); - pointer_offset.copy_to_operands(ptr_expr.front()); - simplify_node(pointer_offset); + exprt pointer_offset_expr=pointer_offset(ptr_expr.front()); + simplify_node(pointer_offset_expr); exprt sum; @@ -416,7 +369,7 @@ bool simplify_exprt::simplify_pointer_offset(exprt &expr) simplify_node(product); - expr=binary_exprt(pointer_offset, ID_plus, product, expr.type()); + expr=binary_exprt(pointer_offset_expr, ID_plus, product, expr.type()); simplify_node(expr); @@ -435,18 +388,6 @@ bool simplify_exprt::simplify_pointer_offset(exprt &expr) return true; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_inequality_address_of - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_inequality_address_of(exprt &expr) { assert(expr.type().id()==ID_bool); @@ -488,18 +429,6 @@ bool simplify_exprt::simplify_inequality_address_of(exprt &expr) return true; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_inequality_pointer_object - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_inequality_pointer_object(exprt &expr) { assert(expr.type().id()==ID_bool); @@ -532,18 +461,6 @@ bool simplify_exprt::simplify_inequality_pointer_object(exprt &expr) return false; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_pointer_object - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_pointer_object(exprt &expr) { if(expr.operands().size()!=1) @@ -572,18 +489,6 @@ bool simplify_exprt::simplify_pointer_object(exprt &expr) return result; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_dynamic_object - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_dynamic_object(exprt &expr) { if(expr.operands().size()!=1) @@ -640,18 +545,6 @@ bool simplify_exprt::simplify_dynamic_object(exprt &expr) return result; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_invalid_pointer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_invalid_pointer(exprt &expr) { if(expr.operands().size()!=1) @@ -681,18 +574,6 @@ bool simplify_exprt::simplify_invalid_pointer(exprt &expr) return result; } -/*******************************************************************\ - -Function: simplify_exprt::objects_equal - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - tvt simplify_exprt::objects_equal(const exprt &a, const exprt &b) { if(a==b) @@ -717,18 +598,6 @@ tvt simplify_exprt::objects_equal(const exprt &a, const exprt &b) return tvt::unknown(); } -/*******************************************************************\ - -Function: simplify_exprt::objects_equal_address_of - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - tvt simplify_exprt::objects_equal_address_of(const exprt &a, const exprt &b) { if(a==b) @@ -753,18 +622,6 @@ tvt simplify_exprt::objects_equal_address_of(const exprt &a, const exprt &b) return tvt::unknown(); } -/*******************************************************************\ - -Function: simplify_exprt::simplify_object_size - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_object_size(exprt &expr) { if(expr.operands().size()!=1) @@ -811,18 +668,6 @@ bool simplify_exprt::simplify_object_size(exprt &expr) return result; } -/*******************************************************************\ - -Function: simplify_exprt::simplify_good_pointer - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_good_pointer(exprt &expr) { if(expr.operands().size()!=1) diff --git a/src/util/simplify_expr_struct.cpp b/src/util/simplify_expr_struct.cpp index a59c355e72c..148b45fc677 100644 --- a/src/util/simplify_expr_struct.cpp +++ b/src/util/simplify_expr_struct.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "simplify_expr_class.h" @@ -15,18 +16,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "pointer_offset_size.h" #include "arith_tools.h" -/*******************************************************************\ - -Function: simplify_exprt::simplify_member - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool simplify_exprt::simplify_member(exprt &expr) { if(expr.operands().size()!=1) diff --git a/src/util/simplify_utils.cpp b/src/util/simplify_utils.cpp index ff5abf78930..482d6ba4fee 100644 --- a/src/util/simplify_utils.cpp +++ b/src/util/simplify_utils.cpp @@ -6,24 +6,14 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "simplify_utils.h" -/*******************************************************************\ - -Function: simplify_exprt::sort_operands - - Inputs: operand list - - Outputs: modifies operand list - returns true iff nothing was changed - - Purpose: sort operands of an expression according to ordering - defined by operator< - -\*******************************************************************/ - +/// sort operands of an expression according to ordering defined by operator< +/// \par parameters: operand list +/// \return modifies operand list returns true iff nothing was changed bool sort_operands(exprt::operandst &operands) { bool do_sort=false; @@ -48,19 +38,7 @@ bool sort_operands(exprt::operandst &operands) return false; } -/*******************************************************************\ - -Function: sort_and_join - - Inputs: - - Outputs: - - Purpose: produce canonical ordering for associative and commutative - binary operators - -\*******************************************************************/ - +/// produce canonical ordering for associative and commutative binary operators // The entries // { ID_plus, ID_floatbv }, // { ID_mult, ID_floatbv }, @@ -121,7 +99,7 @@ static bool sort_and_join( const struct saj_tablet &saj_entry, const irep_idt &type_id) { - for(unsigned i=0; saj_entry.type_ids[i]!=irep_idt(); i++) + for(unsigned i=0; !saj_entry.type_ids[i].empty(); i++) if(type_id==saj_entry.type_ids[i]) return true; @@ -134,7 +112,7 @@ static const struct saj_tablet &sort_and_join( { unsigned i=0; - for( ; saj_table[i].id!=irep_idt(); i++) + for( ; !saj_table[i].id.empty(); i++) if(id==saj_table[i].id && sort_and_join(saj_table[i], type_id)) return saj_table[i]; @@ -142,18 +120,6 @@ static const struct saj_tablet &sort_and_join( return saj_table[i]; } -/*******************************************************************\ - -Function: sort_and_join - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool sort_and_join(exprt &expr) { bool result=true; @@ -163,7 +129,7 @@ bool sort_and_join(exprt &expr) const struct saj_tablet &saj_entry= sort_and_join(expr.id(), expr.type().id()); - if(saj_entry.id==irep_idt()) + if(saj_entry.id.empty()) return true; // check operand types diff --git a/src/util/simplify_utils.h b/src/util/simplify_utils.h index 7860912a58f..33e294f4e96 100644 --- a/src/util/simplify_utils.h +++ b/src/util/simplify_utils.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_SIMPLIFY_UTILS_H #define CPROVER_UTIL_SIMPLIFY_UTILS_H diff --git a/src/util/source_location.cpp b/src/util/source_location.cpp index 7583b40b496..6ec49d530f3 100644 --- a/src/util/source_location.cpp +++ b/src/util/source_location.cpp @@ -6,23 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "source_location.h" #include "file_util.h" -/*******************************************************************\ - -Function: source_locationt::as_string - - Inputs: print_cwd, print the absolute path to the file - - Outputs: - - Purpose: - -\*******************************************************************/ - +/// \par parameters: print_cwd, print the absolute path to the file std::string source_locationt::as_string(bool print_cwd) const { std::string dest; @@ -72,18 +62,6 @@ std::string source_locationt::as_string(bool print_cwd) const return dest; } -/*******************************************************************\ - -Function: operator<< - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::ostream &operator << ( std::ostream &out, const source_locationt &source_location) diff --git a/src/util/source_location.h b/src/util/source_location.h index a9dc8bbec0f..95bef820ae9 100644 --- a/src/util/source_location.h +++ b/src/util/source_location.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_SOURCE_LOCATION_H #define CPROVER_UTIL_SOURCE_LOCATION_H diff --git a/src/util/sparse_vector.h b/src/util/sparse_vector.h index 193e9a68a01..226564d636e 100644 --- a/src/util/sparse_vector.h +++ b/src/util/sparse_vector.h @@ -6,6 +6,9 @@ Author: Romain Brenguier \*******************************************************************/ +/// \file +/// Sparse Vectors + #ifndef CPROVER_UTIL_SPARSE_VECTOR_H #define CPROVER_UTIL_SPARSE_VECTOR_H diff --git a/src/util/ssa_expr.cpp b/src/util/ssa_expr.cpp index affd2907eb5..e9b7258b276 100644 --- a/src/util/ssa_expr.cpp +++ b/src/util/ssa_expr.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -13,18 +14,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "ssa_expr.h" -/*******************************************************************\ - -Function: build_identifier_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static void build_ssa_identifier_rec( const exprt &expr, const irep_idt &l0, @@ -91,18 +80,6 @@ bool ssa_exprt::can_build_identifier(const exprt &expr) return false; } -/*******************************************************************\ - -Function: ssa_exprt::build_identifier - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::pair ssa_exprt::build_identifier( const exprt &expr, const irep_idt &l0, diff --git a/src/util/ssa_expr.h b/src/util/ssa_expr.h index 578d854d687..63e6dfaf7d7 100644 --- a/src/util/ssa_expr.h +++ b/src/util/ssa_expr.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_SSA_EXPR_H #define CPROVER_UTIL_SSA_EXPR_H diff --git a/src/util/std_code.cpp b/src/util/std_code.cpp index d7a4f2aa0fd..021f244ac40 100644 --- a/src/util/std_code.cpp +++ b/src/util/std_code.cpp @@ -6,55 +6,20 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include "std_code.h" #include "std_expr.h" -/*******************************************************************\ - -Function: code_declt::get_identifier - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const irep_idt &code_declt::get_identifier() const { return to_symbol_expr(symbol()).get_identifier(); } -/*******************************************************************\ - -Function: code_deadt::get_identifier - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const irep_idt &code_deadt::get_identifier() const { return to_symbol_expr(symbol()).get_identifier(); } -/*******************************************************************\ - -Function: codet::make_block - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - code_blockt &codet::make_block() { if(get_statement()==ID_block) @@ -70,18 +35,6 @@ code_blockt &codet::make_block() return static_cast(*this); } -/*******************************************************************\ - -Function: codet::first_statement - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - codet &codet::first_statement() { const irep_idt &statement=get_statement(); @@ -97,18 +50,6 @@ codet &codet::first_statement() return *this; } -/*******************************************************************\ - -Function: first_statement - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const codet &codet::first_statement() const { const irep_idt &statement=get_statement(); @@ -124,18 +65,6 @@ const codet &codet::first_statement() const return *this; } -/*******************************************************************\ - -Function: codet::last_statement - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - codet &codet::last_statement() { const irep_idt &statement=get_statement(); @@ -151,18 +80,6 @@ codet &codet::last_statement() return *this; } -/*******************************************************************\ - -Function: codet::last_statement - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const codet &codet::last_statement() const { const irep_idt &statement=get_statement(); @@ -178,20 +95,8 @@ const codet &codet::last_statement() const return *this; } -/*******************************************************************\ - -Function: code_blockt::append - - Inputs: - extra_block - The input code_blockt - - Outputs: - - Purpose: Add all the codets from extra_block to the current - code_blockt - -\*******************************************************************/ - +/// Add all the codets from extra_block to the current code_blockt +/// \param extra_block: The input code_blockt void code_blockt::append(const code_blockt &extra_block) { operands().reserve(operands().size()+extra_block.operands().size()); diff --git a/src/util/std_code.h b/src/util/std_code.h index a48e722be82..1591348ed32 100644 --- a/src/util/std_code.h +++ b/src/util/std_code.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_STD_CODE_H #define CPROVER_UTIL_STD_CODE_H diff --git a/src/util/std_expr.cpp b/src/util/std_expr.cpp index 4cb9eeff9cc..14b4072cd23 100644 --- a/src/util/std_expr.cpp +++ b/src/util/std_expr.cpp @@ -6,10 +6,12 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "arith_tools.h" #include "byte_operators.h" +#include "c_types.h" #include "config.h" #include "namespace.h" #include "pointer_offset_size.h" @@ -17,36 +19,12 @@ Author: Daniel Kroening, kroening@kroening.com #include "std_types.h" #include "std_expr.h" -/*******************************************************************\ - -Function: constant_exprt::value_is_zero_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool constant_exprt::value_is_zero_string() const { const std::string val=id2string(get_value()); return val.find_first_not_of('0')==std::string::npos; } -/*******************************************************************\ - -Function: disjunction - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt disjunction(const exprt::operandst &op) { if(op.empty()) @@ -71,18 +49,6 @@ unsigned int dynamic_object_exprt::get_instance() const return std::stoul(id2string(to_constant_expr(op0()).get_value())); } -/*******************************************************************\ - -Function: conjunction - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - exprt conjunction(const exprt::operandst &op) { if(op.empty()) @@ -97,25 +63,12 @@ exprt conjunction(const exprt::operandst &op) } } -/*******************************************************************\ - -Function: build_object_descriptor_rec - - Inputs: - - Outputs: - - Purpose: Build an object_descriptor_exprt from a given expr - -\*******************************************************************/ - +/// Build an object_descriptor_exprt from a given expr static void build_object_descriptor_rec( const namespacet &ns, const exprt &expr, object_descriptor_exprt &dest) { - const signedbv_typet index_type(config.ansi_c.pointer_width); - if(expr.id()==ID_index) { const index_exprt &index=to_index_expr(expr); @@ -127,8 +80,8 @@ static void build_object_descriptor_rec( dest.offset()= plus_exprt(dest.offset(), - mult_exprt(typecast_exprt(index.index(), index_type), - typecast_exprt(sub_size, index_type))); + mult_exprt(typecast_exprt(index.index(), index_type()), + typecast_exprt(sub_size, index_type()))); } else if(expr.id()==ID_member) { @@ -142,7 +95,7 @@ static void build_object_descriptor_rec( dest.offset()= plus_exprt(dest.offset(), - typecast_exprt(offset, index_type)); + typecast_exprt(offset, index_type())); } else if(expr.id()==ID_byte_extract_little_endian || expr.id()==ID_byte_extract_big_endian) @@ -156,7 +109,7 @@ static void build_object_descriptor_rec( dest.offset()= plus_exprt(dest.offset(), typecast_exprt(to_byte_extract_expr(expr).offset(), - index_type)); + index_type())); } else if(expr.id()==ID_typecast) { @@ -168,18 +121,7 @@ static void build_object_descriptor_rec( } } -/*******************************************************************\ - -Function: object_descriptor_exprt::build - - Inputs: - - Outputs: - - Purpose: Build an object_descriptor_exprt from a given expr - -\*******************************************************************/ - +/// Build an object_descriptor_exprt from a given expr void object_descriptor_exprt::build( const exprt &expr, const namespacet &ns) @@ -188,42 +130,18 @@ void object_descriptor_exprt::build( object()=expr; if(offset().id()==ID_unknown) - offset()=from_integer(0, signedbv_typet(config.ansi_c.pointer_width)); + offset()=from_integer(0, index_type()); build_object_descriptor_rec(ns, expr, *this); assert(root_object().type().id()!=ID_empty); } -/*******************************************************************\ - -Function: constant_exprt::integer_constant - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - constant_exprt constant_exprt::integer_constant(unsigned v) { return constant_exprt(std::to_string(v), integer_typet()); } -/*******************************************************************\ - -Function: shift_exprt::shift_exprt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - shift_exprt::shift_exprt( const exprt &_src, const irep_idt &_id, @@ -232,18 +150,6 @@ shift_exprt::shift_exprt( { } -/*******************************************************************\ - -Function: extractbit_exprt::extractbit_exprt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - extractbit_exprt::extractbit_exprt( const exprt &_src, const std::size_t _index): @@ -252,18 +158,6 @@ extractbit_exprt::extractbit_exprt( { } -/*******************************************************************\ - -Function: extractbit_exprt::extractbits_exprt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - extractbits_exprt::extractbits_exprt( const exprt &_src, const std::size_t _upper, diff --git a/src/util/std_expr.h b/src/util/std_expr.h index e40868c40b5..69a03bdfa9c 100644 --- a/src/util/std_expr.h +++ b/src/util/std_expr.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_STD_EXPR_H #define CPROVER_UTIL_STD_EXPR_H @@ -16,8 +17,7 @@ Author: Daniel Kroening, kroening@kroening.com * \date Sun Jul 31 21:54:44 BST 2011 */ -#include - +#include "invariant.h" #include "std_types.h" /*! \defgroup gr_std_expr Conversion to specific expressions @@ -58,7 +58,10 @@ class transt:public exprt */ inline const transt &to_trans_expr(const exprt &expr) { - assert(expr.id()==ID_trans && expr.operands().size()==3); + PRECONDITION(expr.id()==ID_trans); + DATA_INVARIANT( + expr.operands().size()==3, + "Transition systems must have three operands"); return static_cast(expr); } @@ -67,7 +70,10 @@ inline const transt &to_trans_expr(const exprt &expr) */ inline transt &to_trans_expr(exprt &expr) { - assert(expr.id()==ID_trans && expr.operands().size()==3); + PRECONDITION(expr.id()==ID_trans); + DATA_INVARIANT( + expr.operands().size()==3, + "Transition systems must have three operands"); return static_cast(expr); } @@ -195,7 +201,8 @@ class decorated_symbol_exprt:public symbol_exprt */ inline const symbol_exprt &to_symbol_expr(const exprt &expr) { - assert(expr.id()==ID_symbol && !expr.has_operands()); + PRECONDITION(expr.id()==ID_symbol); + DATA_INVARIANT(!expr.has_operands(), "Symbols must not have operands"); return static_cast(expr); } @@ -204,7 +211,8 @@ inline const symbol_exprt &to_symbol_expr(const exprt &expr) */ inline symbol_exprt &to_symbol_expr(exprt &expr) { - assert(expr.id()==ID_symbol && !expr.has_operands()); + PRECONDITION(expr.id()==ID_symbol); + DATA_INVARIANT(!expr.has_operands(), "Symbols must not have operands"); return static_cast(expr); } @@ -270,7 +278,9 @@ class unary_exprt:public exprt */ inline const unary_exprt &to_unary_expr(const exprt &expr) { - assert(expr.operands().size()==1); + DATA_INVARIANT( + expr.operands().size()==1, + "Unary expressions must have one operand"); return static_cast(expr); } @@ -279,7 +289,9 @@ inline const unary_exprt &to_unary_expr(const exprt &expr) */ inline unary_exprt &to_unary_expr(exprt &expr) { - assert(expr.operands().size()==1); + DATA_INVARIANT( + expr.operands().size()==1, + "Unary expressions must have one operand"); return static_cast(expr); } @@ -310,7 +322,10 @@ class abs_exprt:public unary_exprt */ inline const abs_exprt &to_abs_expr(const exprt &expr) { - assert(expr.id()==ID_abs && expr.operands().size()==1); + PRECONDITION(expr.id()==ID_abs); + DATA_INVARIANT( + expr.operands().size()==1, + "Absolute value must have one operand"); return static_cast(expr); } @@ -319,7 +334,10 @@ inline const abs_exprt &to_abs_expr(const exprt &expr) */ inline abs_exprt &to_abs_expr(exprt &expr) { - assert(expr.id()==ID_abs && expr.operands().size()==1); + PRECONDITION(expr.id()==ID_abs); + DATA_INVARIANT( + expr.operands().size()==1, + "Absolute value must have one operand"); return static_cast(expr); } @@ -357,7 +375,10 @@ class unary_minus_exprt:public unary_exprt */ inline const unary_minus_exprt &to_unary_minus_expr(const exprt &expr) { - assert(expr.id()==ID_unary_minus && expr.operands().size()==1); + PRECONDITION(expr.id()==ID_unary_minus); + DATA_INVARIANT( + expr.operands().size()==1, + "Unary minus must have one operand"); return static_cast(expr); } @@ -366,7 +387,10 @@ inline const unary_minus_exprt &to_unary_minus_expr(const exprt &expr) */ inline unary_minus_exprt &to_unary_minus_expr(exprt &expr) { - assert(expr.id()==ID_unary_minus && expr.operands().size()==1); + PRECONDITION(expr.id()==ID_unary_minus); + DATA_INVARIANT( + expr.operands().size()==1, + "Unary minus must have one operand"); return static_cast(expr); } @@ -499,7 +523,9 @@ class binary_exprt:public exprt */ inline const binary_exprt &to_binary_expr(const exprt &expr) { - assert(expr.operands().size()==2); + DATA_INVARIANT( + expr.operands().size()==2, + "Binary expressions must have two operands"); return static_cast(expr); } @@ -508,7 +534,9 @@ inline const binary_exprt &to_binary_expr(const exprt &expr) */ inline binary_exprt &to_binary_expr(exprt &expr) { - assert(expr.operands().size()==2); + DATA_INVARIANT( + expr.operands().size()==2, + "Binary expressions must have two operands"); return static_cast(expr); } @@ -590,7 +618,9 @@ class binary_relation_exprt:public binary_predicate_exprt */ inline const binary_relation_exprt &to_binary_relation_expr(const exprt &expr) { - assert(expr.operands().size()==2); + DATA_INVARIANT( + expr.operands().size()==2, + "Binary relations must have two operands"); return static_cast(expr); } @@ -599,7 +629,9 @@ inline const binary_relation_exprt &to_binary_relation_expr(const exprt &expr) */ inline binary_relation_exprt &to_binary_relation_expr(exprt &expr) { - assert(expr.operands().size()==2); + DATA_INVARIANT( + expr.operands().size()==2, + "Binary relations must have two operands"); return static_cast(expr); } @@ -702,7 +734,10 @@ class plus_exprt:public multi_ary_exprt */ inline const plus_exprt &to_plus_expr(const exprt &expr) { - assert(expr.id()==ID_plus && expr.operands().size()>=2); + PRECONDITION(expr.id()==ID_plus); + DATA_INVARIANT( + expr.operands().size()>=2, + "Plus must have two or more operands"); return static_cast(expr); } @@ -711,7 +746,10 @@ inline const plus_exprt &to_plus_expr(const exprt &expr) */ inline plus_exprt &to_plus_expr(exprt &expr) { - assert(expr.id()==ID_plus && expr.operands().size()>=2); + PRECONDITION(expr.id()==ID_plus); + DATA_INVARIANT( + expr.operands().size()>=2, + "Plus must have two or more operands"); return static_cast(expr); } @@ -744,7 +782,10 @@ class minus_exprt:public binary_exprt */ inline const minus_exprt &to_minus_expr(const exprt &expr) { - assert(expr.id()==ID_minus && expr.operands().size()>=2); + PRECONDITION(expr.id()==ID_minus); + DATA_INVARIANT( + expr.operands().size()>=2, + "Minus must have two or more operands"); return static_cast(expr); } @@ -753,7 +794,10 @@ inline const minus_exprt &to_minus_expr(const exprt &expr) */ inline minus_exprt &to_minus_expr(exprt &expr) { - assert(expr.id()==ID_minus && expr.operands().size()>=2); + PRECONDITION(expr.id()==ID_minus); + DATA_INVARIANT( + expr.operands().size()>=2, + "Minus must have two or more operands"); return static_cast(expr); } @@ -786,7 +830,10 @@ class mult_exprt:public multi_ary_exprt */ inline const mult_exprt &to_mult_expr(const exprt &expr) { - assert(expr.id()==ID_mult && expr.operands().size()>=2); + PRECONDITION(expr.id()==ID_mult); + DATA_INVARIANT( + expr.operands().size()>=2, + "Multiply must have two or more operands"); return static_cast(expr); } @@ -795,7 +842,10 @@ inline const mult_exprt &to_mult_expr(const exprt &expr) */ inline mult_exprt &to_mult_expr(exprt &expr) { - assert(expr.id()==ID_mult && expr.operands().size()>=2); + PRECONDITION(expr.id()==ID_mult); + DATA_INVARIANT( + expr.operands().size()>=2, + "Multiply must have two or more operands"); return static_cast(expr); } @@ -828,7 +878,10 @@ class div_exprt:public binary_exprt */ inline const div_exprt &to_div_expr(const exprt &expr) { - assert(expr.id()==ID_div && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_div); + DATA_INVARIANT( + expr.operands().size()==2, + "Divide must have two operands"); return static_cast(expr); } @@ -837,7 +890,10 @@ inline const div_exprt &to_div_expr(const exprt &expr) */ inline div_exprt &to_div_expr(exprt &expr) { - assert(expr.id()==ID_div && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_div); + DATA_INVARIANT( + expr.operands().size()==2, + "Divide must have two operands"); return static_cast(expr); } @@ -870,7 +926,8 @@ class mod_exprt:public binary_exprt */ inline const mod_exprt &to_mod_expr(const exprt &expr) { - assert(expr.id()==ID_mod && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_mod); + DATA_INVARIANT(expr.operands().size()==2, "Modulo must have two operands"); return static_cast(expr); } @@ -879,7 +936,8 @@ inline const mod_exprt &to_mod_expr(const exprt &expr) */ inline mod_exprt &to_mod_expr(exprt &expr) { - assert(expr.id()==ID_mod && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_mod); + DATA_INVARIANT(expr.operands().size()==2, "Modulo must have two operands"); return static_cast(expr); } @@ -912,7 +970,8 @@ class rem_exprt:public binary_exprt */ inline const rem_exprt &to_rem_expr(const exprt &expr) { - assert(expr.id()==ID_rem && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_rem); + DATA_INVARIANT(expr.operands().size()==2, "Remainder must have two operands"); return static_cast(expr); } @@ -921,7 +980,8 @@ inline const rem_exprt &to_rem_expr(const exprt &expr) */ inline rem_exprt &to_rem_expr(exprt &expr) { - assert(expr.id()==ID_rem && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_rem); + DATA_INVARIANT(expr.operands().size()==2, "Remainder must have two operands"); return static_cast(expr); } @@ -954,7 +1014,8 @@ class power_exprt:public binary_exprt */ inline const power_exprt &to_power_expr(const exprt &expr) { - assert(expr.id()==ID_power && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_power); + DATA_INVARIANT(expr.operands().size()==2, "Power must have two operands"); return static_cast(expr); } @@ -963,7 +1024,8 @@ inline const power_exprt &to_power_expr(const exprt &expr) */ inline power_exprt &to_power_expr(exprt &expr) { - assert(expr.id()==ID_power && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_power); + DATA_INVARIANT(expr.operands().size()==2, "Power must have two operands"); return static_cast(expr); } @@ -996,7 +1058,10 @@ class factorial_power_exprt:public binary_exprt */ inline const factorial_power_exprt &to_factorial_power_expr(const exprt &expr) { - assert(expr.id()==ID_factorial_power && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_factorial_power); + DATA_INVARIANT( + expr.operands().size()==2, + "Factorial power must have two operands"); return static_cast(expr); } @@ -1005,7 +1070,10 @@ inline const factorial_power_exprt &to_factorial_power_expr(const exprt &expr) */ inline factorial_power_exprt &to_factorial_expr(exprt &expr) { - assert(expr.id()==ID_factorial_power && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_factorial_power); + DATA_INVARIANT( + expr.operands().size()==2, + "Factorial power must have two operands"); return static_cast(expr); } @@ -1036,7 +1104,8 @@ class equal_exprt:public binary_relation_exprt */ inline const equal_exprt &to_equal_expr(const exprt &expr) { - assert(expr.id()==ID_equal && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_equal); + DATA_INVARIANT(expr.operands().size()==2, "Equality must have two operands"); return static_cast(expr); } @@ -1045,7 +1114,8 @@ inline const equal_exprt &to_equal_expr(const exprt &expr) */ inline equal_exprt &to_equal_expr(exprt &expr) { - assert(expr.id()==ID_equal && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_equal); + DATA_INVARIANT(expr.operands().size()==2, "Equality must have two operands"); return static_cast(expr); } @@ -1076,7 +1146,10 @@ class notequal_exprt:public binary_relation_exprt */ inline const notequal_exprt &to_notequal_expr(const exprt &expr) { - assert(expr.id()==ID_notequal && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_notequal); + DATA_INVARIANT( + expr.operands().size()==2, + "Inequality must have two operands"); return static_cast(expr); } @@ -1085,7 +1158,10 @@ inline const notequal_exprt &to_notequal_expr(const exprt &expr) */ inline notequal_exprt &to_notequal_expr(exprt &expr) { - assert(expr.id()==ID_notequal && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_notequal); + DATA_INVARIANT( + expr.operands().size()==2, + "Inequality must have two operands"); return static_cast(expr); } @@ -1152,7 +1228,10 @@ class index_exprt:public exprt */ inline const index_exprt &to_index_expr(const exprt &expr) { - assert(expr.id()==ID_index && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_index); + DATA_INVARIANT( + expr.operands().size()==2, + "Array index must have two operands"); return static_cast(expr); } @@ -1161,7 +1240,10 @@ inline const index_exprt &to_index_expr(const exprt &expr) */ inline index_exprt &to_index_expr(exprt &expr) { - assert(expr.id()==ID_index && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_index); + DATA_INVARIANT( + expr.operands().size()==2, + "Array index must have two operands"); return static_cast(expr); } @@ -1203,7 +1285,10 @@ class array_of_exprt:public unary_exprt */ inline const array_of_exprt &to_array_of_expr(const exprt &expr) { - assert(expr.id()==ID_array_of && expr.operands().size()==1); + PRECONDITION(expr.id()==ID_array_of); + DATA_INVARIANT( + expr.operands().size()==1, + "'Array of' must have one operand"); return static_cast(expr); } @@ -1212,7 +1297,10 @@ inline const array_of_exprt &to_array_of_expr(const exprt &expr) */ inline array_of_exprt &to_array_of_expr(exprt &expr) { - assert(expr.id()==ID_array_of && expr.operands().size()==1); + PRECONDITION(expr.id()==ID_array_of); + DATA_INVARIANT( + expr.operands().size()==1, + "'Array of' must have one operand"); return static_cast(expr); } @@ -1243,7 +1331,7 @@ class array_exprt:public exprt */ inline const array_exprt &to_array_expr(const exprt &expr) { - assert(expr.id()==ID_array); + PRECONDITION(expr.id()==ID_array); return static_cast(expr); } @@ -1252,11 +1340,11 @@ inline const array_exprt &to_array_expr(const exprt &expr) */ inline array_exprt &to_array_expr(exprt &expr) { - assert(expr.id()==ID_array); + PRECONDITION(expr.id()==ID_array); return static_cast(expr); } -/*! \brief array constructor from list of elements +/*! \brief vector constructor from list of elements */ class vector_exprt:public exprt { @@ -1283,7 +1371,7 @@ class vector_exprt:public exprt */ inline const vector_exprt &to_vector_expr(const exprt &expr) { - assert(expr.id()==ID_vector); + PRECONDITION(expr.id()==ID_vector); return static_cast(expr); } @@ -1292,7 +1380,7 @@ inline const vector_exprt &to_vector_expr(const exprt &expr) */ inline vector_exprt &to_vector_expr(exprt &expr) { - assert(expr.id()==ID_vector); + PRECONDITION(expr.id()==ID_vector); return static_cast(expr); } @@ -1352,7 +1440,10 @@ class union_exprt:public unary_exprt */ inline const union_exprt &to_union_expr(const exprt &expr) { - assert(expr.id()==ID_union && expr.operands().size()==1); + PRECONDITION(expr.id()==ID_union); + DATA_INVARIANT( + expr.operands().size()==1, + "Union constructor must have one operand"); return static_cast(expr); } @@ -1361,7 +1452,10 @@ inline const union_exprt &to_union_expr(const exprt &expr) */ inline union_exprt &to_union_expr(exprt &expr) { - assert(expr.id()==ID_union && expr.operands().size()==1); + PRECONDITION(expr.id()==ID_union); + DATA_INVARIANT( + expr.operands().size()==1, + "Union constructor must have one operand"); return static_cast(expr); } @@ -1392,7 +1486,7 @@ class struct_exprt:public exprt */ inline const struct_exprt &to_struct_expr(const exprt &expr) { - assert(expr.id()==ID_struct); + PRECONDITION(expr.id()==ID_struct); return static_cast(expr); } @@ -1401,7 +1495,7 @@ inline const struct_exprt &to_struct_expr(const exprt &expr) */ inline struct_exprt &to_struct_expr(exprt &expr) { - assert(expr.id()==ID_struct); + PRECONDITION(expr.id()==ID_struct); return static_cast(expr); } @@ -1458,7 +1552,10 @@ class complex_exprt:public binary_exprt */ inline const complex_exprt &to_complex_expr(const exprt &expr) { - assert(expr.id()==ID_complex && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_complex); + DATA_INVARIANT( + expr.operands().size()==2, + "Complex constructor must have two operands"); return static_cast(expr); } @@ -1467,7 +1564,10 @@ inline const complex_exprt &to_complex_expr(const exprt &expr) */ inline complex_exprt &to_complex_expr(exprt &expr) { - assert(expr.id()==ID_complex && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_complex); + DATA_INVARIANT( + expr.operands().size()==2, + "Complex constructor must have two operands"); return static_cast(expr); } @@ -1534,7 +1634,10 @@ class object_descriptor_exprt:public exprt inline const object_descriptor_exprt &to_object_descriptor_expr( const exprt &expr) { - assert(expr.id()==ID_object_descriptor && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_object_descriptor); + DATA_INVARIANT( + expr.operands().size()==2, + "Object descriptor must have two operands"); return static_cast(expr); } @@ -1543,7 +1646,10 @@ inline const object_descriptor_exprt &to_object_descriptor_expr( */ inline object_descriptor_exprt &to_object_descriptor_expr(exprt &expr) { - assert(expr.id()==ID_object_descriptor && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_object_descriptor); + DATA_INVARIANT( + expr.operands().size()==2, + "Object descriptor must have two operands"); return static_cast(expr); } @@ -1595,7 +1701,10 @@ class dynamic_object_exprt:public exprt inline const dynamic_object_exprt &to_dynamic_object_expr( const exprt &expr) { - assert(expr.id()==ID_dynamic_object && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_dynamic_object); + DATA_INVARIANT( + expr.operands().size()==2, + "Dynamic object must have two operands"); return static_cast(expr); } @@ -1604,7 +1713,10 @@ inline const dynamic_object_exprt &to_dynamic_object_expr( */ inline dynamic_object_exprt &to_dynamic_object_expr(exprt &expr) { - assert(expr.id()==ID_dynamic_object && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_dynamic_object); + DATA_INVARIANT( + expr.operands().size()==2, + "Dynamic object must have two operands"); return static_cast(expr); } @@ -1647,7 +1759,10 @@ class typecast_exprt:public exprt */ inline const typecast_exprt &to_typecast_expr(const exprt &expr) { - assert(expr.id()==ID_typecast && expr.operands().size()==1); + PRECONDITION(expr.id()==ID_typecast); + DATA_INVARIANT( + expr.operands().size()==1, + "Typecast must have one operand"); return static_cast(expr); } @@ -1656,7 +1771,10 @@ inline const typecast_exprt &to_typecast_expr(const exprt &expr) */ inline typecast_exprt &to_typecast_expr(exprt &expr) { - assert(expr.id()==ID_typecast && expr.operands().size()==1); + PRECONDITION(expr.id()==ID_typecast); + DATA_INVARIANT( + expr.operands().size()==1, + "Typecast must have one operand"); return static_cast(expr); } @@ -1710,7 +1828,10 @@ class floatbv_typecast_exprt:public binary_exprt */ inline const floatbv_typecast_exprt &to_floatbv_typecast_expr(const exprt &expr) { - assert(expr.id()==ID_floatbv_typecast && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_floatbv_typecast); + DATA_INVARIANT( + expr.operands().size()==2, + "Float typecast must have two operands"); return static_cast(expr); } @@ -1719,7 +1840,10 @@ inline const floatbv_typecast_exprt &to_floatbv_typecast_expr(const exprt &expr) */ inline floatbv_typecast_exprt &to_floatbv_typecast_expr(exprt &expr) { - assert(expr.id()==ID_floatbv_typecast && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_floatbv_typecast); + DATA_INVARIANT( + expr.operands().size()==2, + "Float typecast must have two operands"); return static_cast(expr); } @@ -1778,7 +1902,10 @@ exprt conjunction(const exprt::operandst &); */ inline const and_exprt &to_and_expr(const exprt &expr) { - assert(expr.id()==ID_and); + PRECONDITION(expr.id()==ID_and); + // DATA_INVARIANT( + // expr.operands().size()>=2, + // "And must have two or more operands"); return static_cast(expr); } @@ -1787,7 +1914,10 @@ inline const and_exprt &to_and_expr(const exprt &expr) */ inline and_exprt &to_and_expr(exprt &expr) { - assert(expr.id()==ID_and); + PRECONDITION(expr.id()==ID_and); + // DATA_INVARIANT( + // expr.operands().size()>=2, + // "And must have two or more operands"); return static_cast(expr); } @@ -1818,7 +1948,8 @@ class implies_exprt:public binary_exprt */ inline const implies_exprt &to_implies_expr(const exprt &expr) { - assert(expr.id()==ID_implies && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_implies); + DATA_INVARIANT(expr.operands().size()==2, "Implies must have two operands"); return static_cast(expr); } @@ -1827,7 +1958,8 @@ inline const implies_exprt &to_implies_expr(const exprt &expr) */ inline implies_exprt &to_implies_expr(exprt &expr) { - assert(expr.id()==ID_implies && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_implies); + DATA_INVARIANT(expr.operands().size()==2, "Implies must have two operands"); return static_cast(expr); } @@ -1886,7 +2018,10 @@ exprt disjunction(const exprt::operandst &); */ inline const or_exprt &to_or_expr(const exprt &expr) { - assert(expr.id()==ID_or); + PRECONDITION(expr.id()==ID_or); + // DATA_INVARIANT( + // expr.operands().size()>=2, + // "Or must have two or more operands"); return static_cast(expr); } @@ -1895,7 +2030,10 @@ inline const or_exprt &to_or_expr(const exprt &expr) */ inline or_exprt &to_or_expr(exprt &expr) { - assert(expr.id()==ID_or); + PRECONDITION(expr.id()==ID_or); + // DATA_INVARIANT( + // expr.operands().size()>=2, + // "Or must have two or more operands"); return static_cast(expr); } @@ -1914,6 +2052,36 @@ class bitnot_exprt:public unary_exprt } }; +/*! \brief Cast a generic exprt to a \ref bitnot_exprt + * + * This is an unchecked conversion. \a expr must be known to be \ref + * bitnot_exprt. + * + * \param expr Source expression + * \return Object of type \ref bitnot_exprt + * + * \ingroup gr_std_expr +*/ +inline const bitnot_exprt &to_bitnot_expr(const exprt &expr) +{ + PRECONDITION(expr.id()==ID_bitnot); + // DATA_INVARIANT(expr.operands().size()==1, + // "Bit-wise not must have one operand"); + return static_cast(expr); +} + +/*! \copydoc to_bitnot_expr(const exprt &) + * \ingroup gr_std_expr +*/ +inline bitnot_exprt &to_bitnot_expr(exprt &expr) +{ + PRECONDITION(expr.id()==ID_bitnot); + // DATA_INVARIANT(expr.operands().size()==1, + // "Bit-wise not must have one operand"); + return static_cast(expr); +} + + /*! \brief Bit-wise OR */ class bitor_exprt:public multi_ary_exprt @@ -1942,7 +2110,10 @@ class bitor_exprt:public multi_ary_exprt */ inline const bitor_exprt &to_bitor_expr(const exprt &expr) { - assert(expr.id()==ID_bitor); + PRECONDITION(expr.id()==ID_bitor); + // DATA_INVARIANT( + // expr.operands().size()>=2, + // "Bit-wise or must have two or more operands"); return static_cast(expr); } @@ -1951,7 +2122,10 @@ inline const bitor_exprt &to_bitor_expr(const exprt &expr) */ inline bitor_exprt &to_bitor_expr(exprt &expr) { - assert(expr.id()==ID_bitor); + PRECONDITION(expr.id()==ID_bitor); + // DATA_INVARIANT( + // expr.operands().size()>=2, + // "Bit-wise or must have two or more operands"); return static_cast(expr); } @@ -1982,7 +2156,10 @@ class bitxor_exprt:public multi_ary_exprt */ inline const bitxor_exprt &to_bitxor_expr(const exprt &expr) { - assert(expr.id()==ID_bitxor); + PRECONDITION(expr.id()==ID_bitxor); + // DATA_INVARIANT( + // expr.operands().size()>=2, + // "Bit-wise xor must have two or more operands"); return static_cast(expr); } @@ -1991,7 +2168,10 @@ inline const bitxor_exprt &to_bitxor_expr(const exprt &expr) */ inline bitxor_exprt &to_bitxor_expr(exprt &expr) { - assert(expr.id()==ID_bitxor); + PRECONDITION(expr.id()==ID_bitxor); + // DATA_INVARIANT( + // expr.operands().size()>=2, + // "Bit-wise xor must have two or more operands"); return static_cast(expr); } @@ -2023,7 +2203,10 @@ class bitand_exprt:public multi_ary_exprt */ inline const bitand_exprt &to_bitand_expr(const exprt &expr) { - assert(expr.id()==ID_bitand); + PRECONDITION(expr.id()==ID_bitand); + // DATA_INVARIANT( + // expr.operands().size()>=2, + // "Bit-wise and must have two or more operands"); return static_cast(expr); } @@ -2032,7 +2215,10 @@ inline const bitand_exprt &to_bitand_expr(const exprt &expr) */ inline bitand_exprt &to_bitand_expr(exprt &expr) { - assert(expr.id()==ID_bitand); + PRECONDITION(expr.id()==ID_bitand); + // DATA_INVARIANT( + // expr.operands().size()>=2, + // "Bit-wise and must have two or more operands"); return static_cast(expr); } @@ -2093,7 +2279,9 @@ class shift_exprt:public binary_exprt */ inline const shift_exprt &to_shift_expr(const exprt &expr) { - assert(expr.operands().size()==2); + DATA_INVARIANT( + expr.operands().size()==2, + "Shifts must have two operands"); return static_cast(expr); } @@ -2102,7 +2290,9 @@ inline const shift_exprt &to_shift_expr(const exprt &expr) */ inline shift_exprt &to_shift_expr(exprt &expr) { - assert(expr.operands().size()==2); + DATA_INVARIANT( + expr.operands().size()==2, + "Shifts must have two operands"); return static_cast(expr); } @@ -2220,7 +2410,10 @@ class replication_exprt:public binary_exprt */ inline const replication_exprt &to_replication_expr(const exprt &expr) { - assert(expr.id()==ID_replication && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_replication); + DATA_INVARIANT( + expr.operands().size()==2, + "Bit-wise replication must have two operands"); return static_cast(expr); } @@ -2229,7 +2422,10 @@ inline const replication_exprt &to_replication_expr(const exprt &expr) */ inline replication_exprt &to_replication_expr(exprt &expr) { - assert(expr.id()==ID_replication && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_replication); + DATA_INVARIANT( + expr.operands().size()==2, + "Bit-wise replication must have two operands"); return static_cast(expr); } @@ -2285,7 +2481,10 @@ class extractbit_exprt:public binary_predicate_exprt */ inline const extractbit_exprt &to_extractbit_expr(const exprt &expr) { - assert(expr.id()==ID_extractbit && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_extractbit); + DATA_INVARIANT( + expr.operands().size()==2, + "Extract bit must have two operands"); return static_cast(expr); } @@ -2294,7 +2493,10 @@ inline const extractbit_exprt &to_extractbit_expr(const exprt &expr) */ inline extractbit_exprt &to_extractbit_expr(exprt &expr) { - assert(expr.id()==ID_extractbit && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_extractbit); + DATA_INVARIANT( + expr.operands().size()==2, + "Extract bit must have two operands"); return static_cast(expr); } @@ -2315,7 +2517,7 @@ class extractbits_exprt:public exprt const exprt &_lower, const typet &_type):exprt(ID_extractbits, _type) { - copy_to_operands(_src, _lower, _upper); + copy_to_operands(_src, _upper, _lower); } extractbits_exprt( @@ -2367,7 +2569,10 @@ class extractbits_exprt:public exprt */ inline const extractbits_exprt &to_extractbits_expr(const exprt &expr) { - assert(expr.id()==ID_extractbits && expr.operands().size()==3); + PRECONDITION(expr.id()==ID_extractbits); + DATA_INVARIANT( + expr.operands().size()==3, + "Extract bits must have three operands"); return static_cast(expr); } @@ -2376,7 +2581,10 @@ inline const extractbits_exprt &to_extractbits_expr(const exprt &expr) */ inline extractbits_exprt &to_extractbits_expr(exprt &expr) { - assert(expr.id()==ID_extractbits && expr.operands().size()==3); + PRECONDITION(expr.id()==ID_extractbits); + DATA_INVARIANT( + expr.operands().size()==3, + "Extract bits must have three operands"); return static_cast(expr); } @@ -2420,7 +2628,8 @@ class address_of_exprt:public exprt */ inline const address_of_exprt &to_address_of_expr(const exprt &expr) { - assert(expr.id()==ID_address_of && expr.operands().size()==1); + PRECONDITION(expr.id()==ID_address_of); + DATA_INVARIANT(expr.operands().size()==1, "Address of must have one operand"); return static_cast(expr); } @@ -2429,7 +2638,8 @@ inline const address_of_exprt &to_address_of_expr(const exprt &expr) */ inline address_of_exprt &to_address_of_expr(exprt &expr) { - assert(expr.id()==ID_address_of && expr.operands().size()==1); + PRECONDITION(expr.id()==ID_address_of); + DATA_INVARIANT(expr.operands().size()==1, "Address of must have one operand"); return static_cast(expr); } @@ -2471,7 +2681,8 @@ class not_exprt:public exprt */ inline const not_exprt &to_not_expr(const exprt &expr) { - assert(expr.id()==ID_not && expr.operands().size()==1); + PRECONDITION(expr.id()==ID_not); + DATA_INVARIANT(expr.operands().size()==1, "Not must have one operand"); return static_cast(expr); } @@ -2480,7 +2691,8 @@ inline const not_exprt &to_not_expr(const exprt &expr) */ inline not_exprt &to_not_expr(exprt &expr) { - assert(expr.id()==ID_not && expr.operands().size()==1); + PRECONDITION(expr.id()==ID_not); + DATA_INVARIANT(expr.operands().size()==1, "Not must have one operand"); return static_cast(expr); } @@ -2535,7 +2747,10 @@ class dereference_exprt:public exprt */ inline const dereference_exprt &to_dereference_expr(const exprt &expr) { - assert(expr.id()==ID_dereference && expr.operands().size()==1); + PRECONDITION(expr.id()==ID_dereference); + DATA_INVARIANT( + expr.operands().size()==1, + "Dereference must have one operand"); return static_cast(expr); } @@ -2544,7 +2759,10 @@ inline const dereference_exprt &to_dereference_expr(const exprt &expr) */ inline dereference_exprt &to_dereference_expr(exprt &expr) { - assert(expr.id()==ID_dereference && expr.operands().size()==1); + PRECONDITION(expr.id()==ID_dereference); + DATA_INVARIANT( + expr.operands().size()==1, + "Dereference must have one operand"); return static_cast(expr); } @@ -2617,7 +2835,10 @@ class if_exprt:public exprt */ inline const if_exprt &to_if_expr(const exprt &expr) { - assert(expr.id()==ID_if && expr.operands().size()==3); + PRECONDITION(expr.id()==ID_if); + DATA_INVARIANT( + expr.operands().size()==3, + "If-then-else must have three operands"); return static_cast(expr); } @@ -2626,7 +2847,10 @@ inline const if_exprt &to_if_expr(const exprt &expr) */ inline if_exprt &to_if_expr(exprt &expr) { - assert(expr.id()==ID_if && expr.operands().size()==3); + PRECONDITION(expr.id()==ID_if); + DATA_INVARIANT( + expr.operands().size()==3, + "If-then-else must have three operands"); return static_cast(expr); } @@ -2694,7 +2918,10 @@ class with_exprt:public exprt */ inline const with_exprt &to_with_expr(const exprt &expr) { - assert(expr.id()==ID_with && expr.operands().size()==3); + PRECONDITION(expr.id()==ID_with); + DATA_INVARIANT( + expr.operands().size()==3, + "Array/structure update must have three operands"); return static_cast(expr); } @@ -2703,7 +2930,10 @@ inline const with_exprt &to_with_expr(const exprt &expr) */ inline with_exprt &to_with_expr(exprt &expr) { - assert(expr.id()==ID_with && expr.operands().size()==3); + PRECONDITION(expr.id()==ID_with); + DATA_INVARIANT( + expr.operands().size()==3, + "Array/structure update must have three operands"); return static_cast(expr); } @@ -2739,7 +2969,10 @@ class index_designatort:public exprt */ inline const index_designatort &to_index_designator(const exprt &expr) { - assert(expr.id()==ID_index_designator && expr.operands().size()==1); + PRECONDITION(expr.id()==ID_index_designator); + DATA_INVARIANT( + expr.operands().size()==1, + "Index designator must have one operand"); return static_cast(expr); } @@ -2748,7 +2981,10 @@ inline const index_designatort &to_index_designator(const exprt &expr) */ inline index_designatort &to_index_designator(exprt &expr) { - assert(expr.id()==ID_index_designator && expr.operands().size()==1); + PRECONDITION(expr.id()==ID_index_designator); + DATA_INVARIANT( + expr.operands().size()==1, + "Index designator must have one operand"); return static_cast(expr); } @@ -2779,7 +3015,10 @@ class member_designatort:public exprt */ inline const member_designatort &to_member_designator(const exprt &expr) { - assert(expr.id()==ID_member_designator && expr.operands().size()==0); + PRECONDITION(expr.id()==ID_member_designator); + DATA_INVARIANT( + !expr.has_operands(), + "Member designator must not have operands"); return static_cast(expr); } @@ -2788,7 +3027,10 @@ inline const member_designatort &to_member_designator(const exprt &expr) */ inline member_designatort &to_member_designator(exprt &expr) { - assert(expr.id()==ID_member_designator && expr.operands().size()==0); + PRECONDITION(expr.id()==ID_member_designator); + DATA_INVARIANT( + !expr.has_operands(), + "Member designator must not have operands"); return static_cast(expr); } @@ -2865,7 +3107,10 @@ class update_exprt:public exprt */ inline const update_exprt &to_update_expr(const exprt &expr) { - assert(expr.id()==ID_update && expr.operands().size()==3); + PRECONDITION(expr.id()==ID_update); + DATA_INVARIANT( + expr.operands().size()==3, + "Array/structure update must have three operands"); return static_cast(expr); } @@ -2874,7 +3119,10 @@ inline const update_exprt &to_update_expr(const exprt &expr) */ inline update_exprt &to_update_expr(exprt &expr) { - assert(expr.id()==ID_update && expr.operands().size()==3); + PRECONDITION(expr.id()==ID_update); + DATA_INVARIANT( + expr.operands().size()==3, + "Array/structure update must have three operands"); return static_cast(expr); } @@ -2941,7 +3189,10 @@ class array_update_exprt:public exprt */ inline const array_update_exprt &to_array_update_expr(const exprt &expr) { - assert(expr.id()==ID_array_update && expr.operands().size()==3); + PRECONDITION(expr.id()==ID_array_update); + DATA_INVARIANT( + expr.operands().size()==3, + "Array update must have three operands"); return static_cast(expr); } @@ -2950,7 +3201,10 @@ inline const array_update_exprt &to_array_update_expr(const exprt &expr) */ inline array_update_exprt &to_array_update_expr(exprt &expr) { - assert(expr.id()==ID_array_update && expr.operands().size()==3); + PRECONDITION(expr.id()==ID_array_update); + DATA_INVARIANT( + expr.operands().size()==3, + "Array update must have three operands"); return static_cast(expr); } #endif @@ -3058,7 +3312,10 @@ class member_exprt:public exprt */ inline const member_exprt &to_member_expr(const exprt &expr) { - assert(expr.id()==ID_member && expr.operands().size()==1); + PRECONDITION(expr.id()==ID_member); + DATA_INVARIANT( + expr.operands().size()==1, + "Extract member must have one operand"); return static_cast(expr); } @@ -3067,7 +3324,10 @@ inline const member_exprt &to_member_expr(const exprt &expr) */ inline member_exprt &to_member_expr(exprt &expr) { - assert(expr.id()==ID_member && expr.operands().size()==1); + PRECONDITION(expr.id()==ID_member); + DATA_INVARIANT( + expr.operands().size()==1, + "Extract member must have one operand"); return static_cast(expr); } @@ -3098,7 +3358,8 @@ class isnan_exprt:public unary_predicate_exprt */ inline const isnan_exprt &to_isnan_expr(const exprt &expr) { - assert(expr.id()==ID_isnan && expr.operands().size()==1); + PRECONDITION(expr.id()==ID_isnan); + DATA_INVARIANT(expr.operands().size()==1, "Is NaN must have one operand"); return static_cast(expr); } @@ -3107,7 +3368,8 @@ inline const isnan_exprt &to_isnan_expr(const exprt &expr) */ inline isnan_exprt &to_isnan_expr(exprt &expr) { - assert(expr.id()==ID_isnan && expr.operands().size()==1); + PRECONDITION(expr.id()==ID_isnan); + DATA_INVARIANT(expr.operands().size()==1, "Is NaN must have one operand"); return static_cast(expr); } @@ -3138,7 +3400,10 @@ class isinf_exprt:public unary_predicate_exprt */ inline const isinf_exprt &to_isinf_expr(const exprt &expr) { - assert(expr.id()==ID_isinf && expr.operands().size()==1); + PRECONDITION(expr.id()==ID_isinf); + DATA_INVARIANT( + expr.operands().size()==1, + "Is infinite must have one operand"); return static_cast(expr); } @@ -3147,7 +3412,10 @@ inline const isinf_exprt &to_isinf_expr(const exprt &expr) */ inline isinf_exprt &to_isinf_expr(exprt &expr) { - assert(expr.id()==ID_isinf && expr.operands().size()==1); + PRECONDITION(expr.id()==ID_isinf); + DATA_INVARIANT( + expr.operands().size()==1, + "Is infinite must have one operand"); return static_cast(expr); } @@ -3178,7 +3446,8 @@ class isfinite_exprt:public unary_predicate_exprt */ inline const isfinite_exprt &to_isfinite_expr(const exprt &expr) { - assert(expr.id()==ID_isfinite && expr.operands().size()==1); + PRECONDITION(expr.id()==ID_isfinite); + DATA_INVARIANT(expr.operands().size()==1, "Is finite must have one operand"); return static_cast(expr); } @@ -3187,7 +3456,8 @@ inline const isfinite_exprt &to_isfinite_expr(const exprt &expr) */ inline isfinite_exprt &to_isfinite_expr(exprt &expr) { - assert(expr.id()==ID_isfinite && expr.operands().size()==1); + PRECONDITION(expr.id()==ID_isfinite); + DATA_INVARIANT(expr.operands().size()==1, "Is finite must have one operand"); return static_cast(expr); } @@ -3218,7 +3488,8 @@ class isnormal_exprt:public unary_predicate_exprt */ inline const isnormal_exprt &to_isnormal_expr(const exprt &expr) { - assert(expr.id()==ID_isnormal && expr.operands().size()==1); + PRECONDITION(expr.id()==ID_isnormal); + DATA_INVARIANT(expr.operands().size()==1, "Is normal must have one operand"); return static_cast(expr); } @@ -3227,7 +3498,8 @@ inline const isnormal_exprt &to_isnormal_expr(const exprt &expr) */ inline isnormal_exprt &to_isnormal_expr(exprt &expr) { - assert(expr.id()==ID_isnormal && expr.operands().size()==1); + PRECONDITION(expr.id()==ID_isnormal); + DATA_INVARIANT(expr.operands().size()==1, "Is normal must have one operand"); return static_cast(expr); } @@ -3258,7 +3530,10 @@ class ieee_float_equal_exprt:public binary_relation_exprt */ inline const ieee_float_equal_exprt &to_ieee_float_equal_expr(const exprt &expr) { - assert(expr.id()==ID_ieee_float_equal && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_ieee_float_equal); + DATA_INVARIANT( + expr.operands().size()==2, + "IEEE equality must have two operands"); return static_cast(expr); } @@ -3267,11 +3542,14 @@ inline const ieee_float_equal_exprt &to_ieee_float_equal_expr(const exprt &expr) */ inline ieee_float_equal_exprt &to_ieee_float_equal_expr(exprt &expr) { - assert(expr.id()==ID_ieee_float_equal && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_ieee_float_equal); + DATA_INVARIANT( + expr.operands().size()==2, + "IEEE equality must have two operands"); return static_cast(expr); } -/*! \brief IEEE-floating-point disequality +/*! \brief IEEE floating-point disequality */ class ieee_float_notequal_exprt:public binary_relation_exprt { @@ -3300,7 +3578,10 @@ class ieee_float_notequal_exprt:public binary_relation_exprt inline const ieee_float_notequal_exprt &to_ieee_float_notequal_expr( const exprt &expr) { - assert(expr.id()==ID_ieee_float_notequal && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_ieee_float_notequal); + DATA_INVARIANT( + expr.operands().size()==2, + "IEEE inequality must have two operands"); return static_cast(expr); } @@ -3309,11 +3590,14 @@ inline const ieee_float_notequal_exprt &to_ieee_float_notequal_expr( */ inline ieee_float_notequal_exprt &to_ieee_float_notequal_expr(exprt &expr) { - assert(expr.id()==ID_ieee_float_notequal && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_ieee_float_notequal); + DATA_INVARIANT( + expr.operands().size()==2, + "IEEE inequality must have two operands"); return static_cast(expr); } -/*! \brief IEEE-floating-point disequality +/*! \brief IEEE floating-point operations */ class ieee_float_op_exprt:public exprt { @@ -3376,7 +3660,9 @@ class ieee_float_op_exprt:public exprt */ inline const ieee_float_op_exprt &to_ieee_float_op_expr(const exprt &expr) { - assert(expr.operands().size()==3); + DATA_INVARIANT( + expr.operands().size()==3, + "IEEE float operations must have three arguments"); return static_cast(expr); } @@ -3385,7 +3671,9 @@ inline const ieee_float_op_exprt &to_ieee_float_op_expr(const exprt &expr) */ inline ieee_float_op_exprt &to_ieee_float_op_expr(exprt &expr) { - assert(expr.operands().size()==3); + DATA_INVARIANT( + expr.operands().size()==3, + "IEEE float operations must have three arguments"); return static_cast(expr); } @@ -3449,7 +3737,7 @@ class constant_exprt:public exprt */ inline const constant_exprt &to_constant_expr(const exprt &expr) { - assert(expr.id()==ID_constant); + PRECONDITION(expr.id()==ID_constant); return static_cast(expr); } @@ -3458,7 +3746,7 @@ inline const constant_exprt &to_constant_expr(const exprt &expr) */ inline constant_exprt &to_constant_expr(exprt &expr) { - assert(expr.id()==ID_constant); + PRECONDITION(expr.id()==ID_constant); return static_cast(expr); } @@ -3564,7 +3852,10 @@ class function_application_exprt:public exprt inline const function_application_exprt &to_function_application_expr( const exprt &expr) { - assert(expr.id()==ID_function_application && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_function_application); + DATA_INVARIANT( + expr.operands().size()==2, + "Function application must have two operands"); return static_cast(expr); } @@ -3573,7 +3864,10 @@ inline const function_application_exprt &to_function_application_expr( */ inline function_application_exprt &to_function_application_expr(exprt &expr) { - assert(expr.id()==ID_function_application && expr.operands().size()==2); + PRECONDITION(expr.id()==ID_function_application); + DATA_INVARIANT( + expr.operands().size()==2, + "Function application must have two operands"); return static_cast(expr); } @@ -3616,7 +3910,10 @@ class concatenation_exprt:public exprt */ inline const concatenation_exprt &to_concatenation_expr(const exprt &expr) { - assert(expr.id()==ID_concatenation); + PRECONDITION(expr.id()==ID_concatenation); + // DATA_INVARIANT( + // expr.operands().size()>=2, + // "Concatenation must have two or more operands"); return static_cast(expr); } @@ -3625,7 +3922,10 @@ inline const concatenation_exprt &to_concatenation_expr(const exprt &expr) */ inline concatenation_exprt &to_concatenation_expr(exprt &expr) { - assert(expr.id()==ID_concatenation); + PRECONDITION(expr.id()==ID_concatenation); + // DATA_INVARIANT( + // expr.operands().size()>=2, + // "Concatenation must have two or more operands"); return static_cast(expr); } @@ -3694,7 +3994,8 @@ class let_exprt:public exprt */ inline const let_exprt &to_let_expr(const exprt &expr) { - assert(expr.id()==ID_let && expr.operands().size()==3); + PRECONDITION(expr.id()==ID_let); + DATA_INVARIANT(expr.operands().size()==3, "Let must have three operands"); return static_cast(expr); } @@ -3703,7 +4004,8 @@ inline const let_exprt &to_let_expr(const exprt &expr) */ inline let_exprt &to_let_expr(exprt &expr) { - assert(expr.id()==ID_let && expr.operands().size()==3); + PRECONDITION(expr.id()==ID_let); + DATA_INVARIANT(expr.operands().size()==3, "Let must have three operands"); return static_cast(expr); } diff --git a/src/util/std_types.cpp b/src/util/std_types.cpp index e6244ab5c9b..b06af1ecf77 100644 --- a/src/util/std_types.cpp +++ b/src/util/std_types.cpp @@ -6,61 +6,26 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include "string2int.h" #include "arith_tools.h" #include "std_types.h" #include "std_expr.h" -/*******************************************************************\ - -Function: fixedbv_typet::get_integer_bits - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::size_t fixedbv_typet::get_integer_bits() const { const irep_idt integer_bits=get(ID_integer_bits); - assert(integer_bits!=irep_idt()); + assert(!integer_bits.empty()); return unsafe_string2unsigned(id2string(integer_bits)); } -/*******************************************************************\ - -Function: floatbv_typet::get_f - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::size_t floatbv_typet::get_f() const { const irep_idt &f=get(ID_f); - assert(f!=irep_idt()); + assert(!f.empty()); return unsafe_string2unsigned(id2string(f)); } -/*******************************************************************\ - -Function: struct_union_typet::component_number - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::size_t struct_union_typet::component_number( const irep_idt &component_name) const { @@ -83,18 +48,6 @@ std::size_t struct_union_typet::component_number( return 0; } -/*******************************************************************\ - -Function: struct_union_typet::get_component - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const struct_union_typet::componentt &struct_union_typet::get_component( const irep_idt &component_name) const { @@ -112,18 +65,6 @@ const struct_union_typet::componentt &struct_union_typet::get_component( return static_cast(get_nil_irep()); } -/*******************************************************************\ - -Function: struct_union_typet::component_type - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - typet struct_union_typet::component_type( const irep_idt &component_name) const { @@ -132,18 +73,6 @@ typet struct_union_typet::component_type( return c.type(); } -/*******************************************************************\ - -Function: struct_typet::is_prefix_of - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool struct_typet::is_prefix_of(const struct_typet &other) const { const componentst &ot_components=other.components(); @@ -173,275 +102,83 @@ bool struct_typet::is_prefix_of(const struct_typet &other) const return true; // ok, *this is a prefix of ot } -/*******************************************************************\ - -Function: is_reference - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool is_reference(const typet &type) { return type.id()==ID_pointer && type.get_bool(ID_C_reference); } -/*******************************************************************\ - -Function: is_rvalue_reference - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool is_rvalue_reference(const typet &type) { return type.id()==ID_pointer && type.get_bool(ID_C_rvalue_reference); } -/*******************************************************************\ - -Function: range_typet::set_from - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void range_typet::set_from(const mp_integer &from) { set(ID_from, integer2string(from)); } -/*******************************************************************\ - -Function: range_typet::set_to - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void range_typet::set_to(const mp_integer &to) { set(ID_to, integer2string(to)); } -/*******************************************************************\ - -Function: range_typet::get_from - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - mp_integer range_typet::get_from() const { return string2integer(get_string(ID_from)); } -/*******************************************************************\ - -Function: range_typet::get_to - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - mp_integer range_typet::get_to() const { return string2integer(get_string(ID_to)); } -/*******************************************************************\ - -Function: signedbv_typet::smallest - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - mp_integer signedbv_typet::smallest() const { return -power(2, get_width()-1); } -/*******************************************************************\ - -Function: signedbv_typet::largest - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - mp_integer signedbv_typet::largest() const { return power(2, get_width()-1)-1; } -/*******************************************************************\ - -Function: signedbv_typet::zero_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - constant_exprt signedbv_typet::zero_expr() const { return to_constant_expr(from_integer(0, *this)); } -/*******************************************************************\ - -Function: signedbv_typet::smallest_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - constant_exprt signedbv_typet::smallest_expr() const { return to_constant_expr(from_integer(smallest(), *this)); } -/*******************************************************************\ - -Function: signedbv_typet::largest_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - constant_exprt signedbv_typet::largest_expr() const { return to_constant_expr(from_integer(largest(), *this)); } -/*******************************************************************\ - -Function: unsignedbv_typet::smallest - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - mp_integer unsignedbv_typet::smallest() const { return 0; } -/*******************************************************************\ - -Function: unsignedbv_typet::largest - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - mp_integer unsignedbv_typet::largest() const { return power(2, get_width())-1; } -/*******************************************************************\ - -Function: unsignedbv_typet::zero_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - constant_exprt unsignedbv_typet::zero_expr() const { return to_constant_expr(from_integer(0, *this)); } -/*******************************************************************\ - -Function: unsignedbv_typet::smallest_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - constant_exprt unsignedbv_typet::smallest_expr() const { return to_constant_expr(from_integer(smallest(), *this)); } -/*******************************************************************\ - -Function: unsignedbv_typet::largest_expr - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - constant_exprt unsignedbv_typet::largest_expr() const { return to_constant_expr(from_integer(largest(), *this)); diff --git a/src/util/std_types.h b/src/util/std_types.h index 28d8b9fe69a..1f5b16ee1ea 100644 --- a/src/util/std_types.h +++ b/src/util/std_types.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_STD_TYPES_H #define CPROVER_UTIL_STD_TYPES_H @@ -1431,6 +1432,31 @@ class reference_typet:public pointer_typet } }; +/*! \brief Cast a generic typet to a \ref reference_typet + * + * This is an unchecked conversion. \a type must be known to be \ref + * reference_typet. + * + * \param type Source type + * \return Object of type \ref reference_typet + * + * \ingroup gr_std_types +*/ +inline const reference_typet &to_reference_type(const typet &type) +{ + assert(type.id()==ID_pointer && type.get_bool(ID_C_reference)); + return static_cast(type); +} + +/*! \copydoc to_reference_type(const typet &) + * \ingroup gr_std_types +*/ +inline reference_typet &to_reference_type(typet &type) +{ + assert(type.id()==ID_pointer && type.get_bool(ID_C_reference)); + return static_cast(type); +} + /*! \brief TO_BE_DOCUMENTED */ bool is_reference(const typet &type); diff --git a/src/util/string2int.cpp b/src/util/string2int.cpp index 224e5779858..4febe054b5a 100644 --- a/src/util/string2int.cpp +++ b/src/util/string2int.cpp @@ -6,6 +6,7 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk \*******************************************************************/ + #include #include #include @@ -13,18 +14,6 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk #include "string2int.h" -/*******************************************************************\ - -Function: str2number - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - template inline T str2number(const char *str, int base, bool safe) { @@ -60,103 +49,31 @@ inline T str2number(const char *str, int base, bool safe) return (T)val; } -/*******************************************************************\ - -Function: safe_string2unsigned - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - unsigned safe_string2unsigned(const std::string &str, int base) { return str2number(str.c_str(), base, true); } -/*******************************************************************\ - -Function: safe_string2size_t - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::size_t safe_string2size_t(const std::string &str, int base) { return str2number(str.c_str(), base, true); } -/*******************************************************************\ - -Function: unsafe_string2int - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - int unsafe_string2int(const std::string &str, int base) { return str2number(str.c_str(), base, false); } -/*******************************************************************\ - -Function: unsafe_string2unsigned - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - unsigned unsafe_string2unsigned(const std::string &str, int base) { return str2number(str.c_str(), base, false); } -/*******************************************************************\ - -Function: unsafe_string2size_t - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::size_t unsafe_string2size_t(const std::string &str, int base) { return str2number(str.c_str(), base, false); } -/*******************************************************************\ - -Function: unsafe_string2signedlonglong - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - signed long long int unsafe_string2signedlonglong( const std::string &str, int base) @@ -164,18 +81,6 @@ signed long long int unsafe_string2signedlonglong( return str2number(str.c_str(), base, false); } -/*******************************************************************\ - -Function: unsafe_string2unsignedlonglong - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - unsigned long long int unsafe_string2unsignedlonglong( const std::string &str, int base) diff --git a/src/util/string2int.h b/src/util/string2int.h index 9b39c0ed829..1b0007a644a 100644 --- a/src/util/string2int.h +++ b/src/util/string2int.h @@ -6,6 +6,7 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk \*******************************************************************/ + #ifndef CPROVER_UTIL_STRING2INT_H #define CPROVER_UTIL_STRING2INT_H diff --git a/src/util/string_container.cpp b/src/util/string_container.cpp index 1b1603631d0..189d721b8ed 100644 --- a/src/util/string_container.cpp +++ b/src/util/string_container.cpp @@ -6,40 +6,19 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Container for C-Strings + #include #include "string_container.h" string_containert string_container; -/*******************************************************************\ - -Function: string_ptrt::string_ptrt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - string_ptrt::string_ptrt(const char *_s):s(_s), len(strlen(_s)) { } -/*******************************************************************\ - -Function: string_ptrt::operator== - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool string_ptrt::operator==(const string_ptrt &other) const { if(len!=other.len) @@ -48,18 +27,6 @@ bool string_ptrt::operator==(const string_ptrt &other) const return len==0 || memcmp(s, other.s, len)==0; } -/*******************************************************************\ - -Function: string_containert::string_containert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void initialize_string_container(); string_containert::string_containert() @@ -71,34 +38,10 @@ string_containert::string_containert() initialize_string_container(); } -/*******************************************************************\ - -Function: string_containert::~string_containert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - string_containert::~string_containert() { } -/*******************************************************************\ - -Function: string_containert::get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - unsigned string_containert::get(const char *s) { string_ptrt string_ptr(s); @@ -122,18 +65,6 @@ unsigned string_containert::get(const char *s) return r; } -/*******************************************************************\ - -Function: string_containert::get - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - unsigned string_containert::get(const std::string &s) { string_ptrt string_ptr(s); diff --git a/src/util/string_container.h b/src/util/string_container.h index cbd8d0d320b..59a5daff0b8 100644 --- a/src/util/string_container.h +++ b/src/util/string_container.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Container for C-Strings + #ifndef CPROVER_UTIL_STRING_CONTAINER_H #define CPROVER_UTIL_STRING_CONTAINER_H diff --git a/src/util/string_expr.h b/src/util/string_expr.h index ff19a8c8259..cdb801988ae 100644 --- a/src/util/string_expr.h +++ b/src/util/string_expr.h @@ -6,6 +6,9 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com \*******************************************************************/ +/// \file +/// String expressions for the string solver + #ifndef CPROVER_UTIL_STRING_EXPR_H #define CPROVER_UTIL_STRING_EXPR_H diff --git a/src/util/string_hash.cpp b/src/util/string_hash.cpp index c59a0a61280..ee212232fa7 100644 --- a/src/util/string_hash.cpp +++ b/src/util/string_hash.cpp @@ -6,19 +6,10 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "string_hash.h" - -/*******************************************************************\ - -Function: hash_string - - Inputs: +/// \file +/// string hasing - Outputs: - - Purpose: - -\*******************************************************************/ +#include "string_hash.h" size_t hash_string(const std::string &s) { @@ -31,18 +22,6 @@ size_t hash_string(const std::string &s) return h; } -/*******************************************************************\ - -Function: hash_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - size_t hash_string(const char *s) { size_t h=0; diff --git a/src/util/string_hash.h b/src/util/string_hash.h index 41f45adeda0..021cb95b341 100644 --- a/src/util/string_hash.h +++ b/src/util/string_hash.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// string hashing + #ifndef CPROVER_UTIL_STRING_HASH_H #define CPROVER_UTIL_STRING_HASH_H diff --git a/src/util/string_utils.cpp b/src/util/string_utils.cpp index 9fb81dfa08c..1bf5af4f68a 100644 --- a/src/util/string_utils.cpp +++ b/src/util/string_utils.cpp @@ -6,24 +6,13 @@ Author: Daniel Poetzl \*******************************************************************/ + #include #include #include #include "string_utils.h" -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string strip_string(const std::string &s) { auto pred=[](char c){ return std::isspace(c); }; @@ -42,18 +31,6 @@ std::string strip_string(const std::string &s) return s.substr(i, (j-i+1)); } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void split_string( const std::string &s, char delim, @@ -104,18 +81,6 @@ void split_string( result.push_back(""); } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void split_string( const std::string &s, char delim, diff --git a/src/util/string_utils.h b/src/util/string_utils.h index 703fc359e82..5e4ef23a63a 100644 --- a/src/util/string_utils.h +++ b/src/util/string_utils.h @@ -6,6 +6,7 @@ Author: Daniel Poetzl \*******************************************************************/ + #ifndef CPROVER_UTIL_STRING_UTILS_H #define CPROVER_UTIL_STRING_UTILS_H diff --git a/src/util/substitute.cpp b/src/util/substitute.cpp index d83ad9361fe..fc0eb2bea16 100644 --- a/src/util/substitute.cpp +++ b/src/util/substitute.cpp @@ -6,22 +6,11 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "substitute.h" -/*******************************************************************\ - -Function: substitute - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void substitute( std::string &dest, const std::string &what, diff --git a/src/util/substitute.h b/src/util/substitute.h index c39774fa615..ed3ea5293a0 100644 --- a/src/util/substitute.h +++ b/src/util/substitute.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_SUBSTITUTE_H #define CPROVER_UTIL_SUBSTITUTE_H diff --git a/src/util/suffix.h b/src/util/suffix.h index 7ddc08fe5cf..1c2568e239b 100644 --- a/src/util/suffix.h +++ b/src/util/suffix.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_SUFFIX_H #define CPROVER_UTIL_SUFFIX_H diff --git a/src/util/symbol.cpp b/src/util/symbol.cpp index d2883832faf..1a7bc849949 100644 --- a/src/util/symbol.cpp +++ b/src/util/symbol.cpp @@ -6,24 +6,13 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "symbol.h" #include "source_location.h" #include "std_expr.h" -/*******************************************************************\ - -Function: symbolt::show - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symbolt::show(std::ostream &out) const { out << " " << name << '\n'; @@ -77,18 +66,6 @@ void symbolt::show(std::ostream &out) const out << '\n'; } -/*******************************************************************\ - -Function: operator<< - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::ostream &operator<<(std::ostream &out, const symbolt &symbol) { @@ -96,18 +73,6 @@ std::ostream &operator<<(std::ostream &out, return out; } -/*******************************************************************\ - -Function: symbolt::to_irep - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - irept symbolt::to_irep() const { irept dest; @@ -158,18 +123,6 @@ irept symbolt::to_irep() const return dest; } -/*******************************************************************\ - -Function: symbolt::from_irep - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symbolt::from_irep(const irept &src) { type=static_cast(src.find(ID_type)); @@ -200,18 +153,6 @@ void symbolt::from_irep(const irept &src) is_volatile=src.get_bool("is_volatile"); } -/*******************************************************************\ - -Function: symbolt::swap - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void symbolt::swap(symbolt &b) { #define SYM_SWAP1(x) x.swap(b.x) @@ -245,18 +186,8 @@ void symbolt::swap(symbolt &b) SYM_SWAP2(is_volatile); } -/*******************************************************************\ - -Function: symbolt::symbol_expr - - Inputs: symbol - - Outputs: symbol_exprt - - Purpose: produces a symbol_exprt for a symbol - -\*******************************************************************/ - +/// produces a symbol_exprt for a symbol +/// \return symbol_exprt symbol_exprt symbolt::symbol_expr() const { return symbol_exprt(name, type); diff --git a/src/util/symbol.h b/src/util/symbol.h index b8f52fc7099..5c9240c1dd7 100644 --- a/src/util/symbol.h +++ b/src/util/symbol.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_SYMBOL_H #define CPROVER_UTIL_SYMBOL_H diff --git a/src/util/symbol_table.cpp b/src/util/symbol_table.cpp index 37053b7737b..2dd167600cf 100644 --- a/src/util/symbol_table.cpp +++ b/src/util/symbol_table.cpp @@ -6,25 +6,16 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "symbol_table.h" -/*******************************************************************\ - -Function: symbol_tablet::add - - Inputs: - symbol - The symbol to be added to the symbol table - - Outputs: Returns a boolean indicating whether the process failed, - which should only happen if there is a symbol with the same - name already in the symbol table - - Purpose: Add a new symbol to the symbol table - -\*******************************************************************/ - +/// Add a new symbol to the symbol table +/// \param symbol: The symbol to be added to the symbol table +/// \return Returns a boolean indicating whether the process failed, which +/// should only happen if there is a symbol with the same name already in the +/// symbol table bool symbol_tablet::add(const symbolt &symbol) { if(!symbols.insert(std::pair(symbol.name, symbol)).second) @@ -38,35 +29,21 @@ bool symbol_tablet::add(const symbolt &symbol) return false; } -/*******************************************************************\ - -Function: symbol_tablet::move - - Inputs: - symbol - The symbol to be added to the symbol table - new_symbol - Pointer which the function will set to either point - to the symbol in the symbol table with the same name - or to the symbol that has been successfully moved - into the symbol table - - Outputs: Returns a boolean indicating whether the process failed, - which should only happen if there is a symbol with the - same name already in the symbol table. If the process - failed then symbol is unchanged and new_symbol points to - the symbol with the same name. If the process succeeded - symbol is set to be empty and new_symbol points to its new - location in the symbol table - - Purpose: Move a symbol into the symbol table. If there is already - a symbol with the same name then symbol is unchanged, - new_symbol points to the symbol with the same name and - true is returned. Otherwise, the symbol is moved into the - symbol table, symbol is set to be empty, new_symbol points - to its new location in the symbol table and false is - returned - -\*******************************************************************/ - +/// Move a symbol into the symbol table. If there is already a symbol with the +/// same name then symbol is unchanged, new_symbol points to the symbol with the +/// same name and true is returned. Otherwise, the symbol is moved into the +/// symbol table, symbol is set to be empty, new_symbol points to its new +/// location in the symbol table and false is returned +/// \param symbol: The symbol to be added to the symbol table +/// \param new_symbol: Pointer which the function will set to either point to +/// the symbol in the symbol table with the same name or to the symbol that +/// has been successfully moved into the symbol table +/// \return Returns a boolean indicating whether the process failed, which +/// should only happen if there is a symbol with the same name already in the +/// symbol table. If the process failed then symbol is unchanged and +/// new_symbol points to the symbol with the same name. If the process +/// succeeded symbol is set to be empty and new_symbol points to its new +/// location in the symbol table bool symbol_tablet::move(symbolt &symbol, symbolt *&new_symbol) { symbolt tmp; @@ -91,19 +68,9 @@ bool symbol_tablet::move(symbolt &symbol, symbolt *&new_symbol) return false; } -/*******************************************************************\ - -Function: symbol_tablet::remove - - Inputs: - name - The name of the symbol to remove - - Outputs: Returns a boolean indicating whether the process failed - - Purpose: Remove a symbol from the symbol table - -\*******************************************************************/ - +/// Remove a symbol from the symbol table +/// \param name: The name of the symbol to remove +/// \return Returns a boolean indicating whether the process failed bool symbol_tablet::remove(const irep_idt &name) { symbolst::iterator entry=symbols.find(name); @@ -138,19 +105,8 @@ bool symbol_tablet::remove(const irep_idt &name) return false; } -/*******************************************************************\ - -Function: symbol_tablet::show - - Inputs: - out - The ostream to direct output to - - Outputs: - - Purpose: Print the contents of the symbol table - -\*******************************************************************/ - +/// Print the contents of the symbol table +/// \param out: The ostream to direct output to void symbol_tablet::show(std::ostream &out) const { out << "\n" << "Symbols:" << "\n"; @@ -159,20 +115,10 @@ void symbol_tablet::show(std::ostream &out) const out << it->second; } -/*******************************************************************\ - -Function: symbol_tablet::lookup - - Inputs: - identifier - The name of the symbol to look for - - Outputs: The symbol in the symbol table with the correct name - - Purpose: Find a symbol in the symbol table. Throws a string if no - such symbol is found. - -\*******************************************************************/ - +/// Find a symbol in the symbol table. Throws a string if no such symbol is +/// found. +/// \param identifier: The name of the symbol to look for +/// \return The symbol in the symbol table with the correct name const symbolt &symbol_tablet::lookup(const irep_idt &identifier) const { symbolst::const_iterator it=symbols.find(identifier); @@ -183,20 +129,10 @@ const symbolt &symbol_tablet::lookup(const irep_idt &identifier) const return it->second; } -/*******************************************************************\ - -Function: symbol_tablet::lookup - - Inputs: - identifier - The name of the symbol to look for - - Outputs: The symbol in the symbol table with the correct name - - Purpose: Find a symbol in the symbol table. Throws a string if no - such symbol is found. - -\*******************************************************************/ - +/// Find a symbol in the symbol table. Throws a string if no such symbol is +/// found. +/// \param identifier: The name of the symbol to look for +/// \return The symbol in the symbol table with the correct name symbolt &symbol_tablet::lookup(const irep_idt &identifier) { symbolst::iterator it=symbols.find(identifier); @@ -207,20 +143,9 @@ symbolt &symbol_tablet::lookup(const irep_idt &identifier) return it->second; } -/*******************************************************************\ - -Function: operator << - - Inputs: - out - The ostream to direct output to - symbol_table - The symbol table to print out - - Outputs: - - Purpose: Print the contents of the symbol table - -\*******************************************************************/ - +/// Print the contents of the symbol table +/// \param out: The ostream to direct output to +/// \param symbol_table: The symbol table to print out std::ostream &operator << (std::ostream &out, const symbol_tablet &symbol_table) { symbol_table.show(out); diff --git a/src/util/symbol_table.h b/src/util/symbol_table.h index 08eb616c852..9a1b0b7f95c 100644 --- a/src/util/symbol_table.h +++ b/src/util/symbol_table.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_SYMBOL_TABLE_H #define CPROVER_UTIL_SYMBOL_TABLE_H diff --git a/src/util/tempdir.cpp b/src/util/tempdir.cpp index e160c664558..317112b0c00 100644 --- a/src/util/tempdir.cpp +++ b/src/util/tempdir.cpp @@ -6,6 +6,7 @@ Author: CM Wintersteiger \*******************************************************************/ + #ifdef _WIN32 #include #include @@ -28,18 +29,6 @@ Author: CM Wintersteiger #include "tempdir.h" #include "file_util.h" -/*******************************************************************\ - -Function: get_temporary_directory - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string get_temporary_directory(const std::string &name_template) { std::string result; @@ -86,86 +75,26 @@ std::string get_temporary_directory(const std::string &name_template) return result; } -/*******************************************************************\ - -Function: temp_dirt::temp_dirt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - temp_dirt::temp_dirt(const std::string &name_template) { path=get_temporary_directory(name_template); } -/*******************************************************************\ - -Function: temp_dirt::operator() - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string temp_dirt::operator()(const std::string &file) { return concat_dir_file(path, file); } -/*******************************************************************\ - -Function: temp_dirt::~temp_dirt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void temp_dirt::clear() { delete_directory(path); } -/*******************************************************************\ - -Function: temp_dirt::~temp_dirt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - temp_dirt::~temp_dirt() { clear(); } -/*******************************************************************\ - -Function: temp_working_dirt::temp_working_dirt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - temp_working_dirt::temp_working_dirt(const std::string &name_template): temp_dirt(name_template) { @@ -174,18 +103,6 @@ temp_working_dirt::temp_working_dirt(const std::string &name_template): assert(false); } -/*******************************************************************\ - -Function: temp_working_dirt::~temp_working_dirt - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - temp_working_dirt::~temp_working_dirt() { if(chdir(old_working_directory.c_str())!=0) diff --git a/src/util/tempdir.h b/src/util/tempdir.h index b8c467e7a76..a01e6352562 100644 --- a/src/util/tempdir.h +++ b/src/util/tempdir.h @@ -6,6 +6,7 @@ Author: CM Wintersteiger \*******************************************************************/ + #ifndef CPROVER_UTIL_TEMPDIR_H #define CPROVER_UTIL_TEMPDIR_H diff --git a/src/util/tempfile.cpp b/src/util/tempfile.cpp index 023043e232f..3e6fe0a31a0 100644 --- a/src/util/tempfile.cpp +++ b/src/util/tempfile.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening \*******************************************************************/ + #ifdef _WIN32 #include #include @@ -34,19 +35,8 @@ Author: Daniel Kroening #include "tempfile.h" -/*******************************************************************\ - -Function: my_mkstemps - - Inputs: - - Outputs: - - Purpose: Substitute for mkstemps (OpenBSD standard) for Windows, - where it is unavailable. - -\*******************************************************************/ - +/// Substitute for mkstemps (OpenBSD standard) for Windows, where it is +/// unavailable. #ifdef _WIN32 #define mkstemps my_mkstemps int my_mkstemps(char *template_str, int suffix_len) @@ -92,18 +82,6 @@ int my_mkstemps(char *template_str, int suffix_len) } #endif -/*******************************************************************\ - -Function: get_temporary_file - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string get_temporary_file( const std::string &prefix, const std::string &suffix) @@ -150,18 +128,6 @@ std::string get_temporary_file( return result; } -/*******************************************************************\ - -Function: temporary_filet::~temporary_filet - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - temporary_filet::~temporary_filet() { if(!name.empty()) diff --git a/src/util/tempfile.h b/src/util/tempfile.h index 0d11a1fbcfd..6445086c26e 100644 --- a/src/util/tempfile.h +++ b/src/util/tempfile.h @@ -6,6 +6,7 @@ Author: Daniel Kroening \*******************************************************************/ + #ifndef CPROVER_UTIL_TEMPFILE_H #define CPROVER_UTIL_TEMPFILE_H diff --git a/src/util/threeval.cpp b/src/util/threeval.cpp index ea073177df2..b959d5c9ac2 100644 --- a/src/util/threeval.cpp +++ b/src/util/threeval.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "threeval.h" diff --git a/src/util/threeval.h b/src/util/threeval.h index 59c0400f7da..6bf3f0ebecd 100644 --- a/src/util/threeval.h +++ b/src/util/threeval.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_THREEVAL_H #define CPROVER_UTIL_THREEVAL_H diff --git a/src/util/time_stopping.cpp b/src/util/time_stopping.cpp index 3dda40c9ee5..f41b3401fd6 100644 --- a/src/util/time_stopping.cpp +++ b/src/util/time_stopping.cpp @@ -8,6 +8,9 @@ Date: February 2004 \*******************************************************************/ +/// \file +/// Time Stopping + #include #if defined(_WIN32) && !defined(__MINGW32__) @@ -41,18 +44,6 @@ void gettimeofday(struct timeval* p, struct timezone *tz) } #endif -/*******************************************************************\ - -Function: current_time - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - absolute_timet current_time() { // NOLINTNEXTLINE(readability/identifiers) @@ -65,35 +56,11 @@ absolute_timet current_time() return absolute_timet(tv.tv_usec/1000+(unsigned long long)tv.tv_sec*1000); } -/*******************************************************************\ - -Function: operator << - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::ostream &operator << (std::ostream &out, const time_periodt &period) { return out << static_cast(period.get_t())/1000; } -/*******************************************************************\ - -Function: time_periodt::as_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string time_periodt::as_string() const { std::ostringstream out; diff --git a/src/util/time_stopping.h b/src/util/time_stopping.h index 9187ce2529c..d09a4a91077 100644 --- a/src/util/time_stopping.h +++ b/src/util/time_stopping.h @@ -8,6 +8,9 @@ Date: February 2004 \*******************************************************************/ +/// \file +/// Time Stopping + #ifndef CPROVER_UTIL_TIME_STOPPING_H #define CPROVER_UTIL_TIME_STOPPING_H diff --git a/src/util/timer.cpp b/src/util/timer.cpp index 655dcb21ffb..63b561174cc 100644 --- a/src/util/timer.cpp +++ b/src/util/timer.cpp @@ -8,39 +8,18 @@ Module: Time Stopping \*******************************************************************/ +/// \file +/// Time Stopping + #include #include #include "timer.h" -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - timert::~timert() { } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void timert::start() { assert(!started); @@ -50,18 +29,6 @@ void timert::start() nr_starts++; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void timert::stop() { assert(started); @@ -71,18 +38,6 @@ void timert::stop() _total_time += _latest_time; } -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void timert::clear() { _total_time.clear(); diff --git a/src/util/timer.h b/src/util/timer.h index dcdba700542..79d60082f65 100644 --- a/src/util/timer.h +++ b/src/util/timer.h @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Time Stopping + #ifndef CPROVER_UTIL_TIMER_H #define CPROVER_UTIL_TIMER_H diff --git a/src/util/type.cpp b/src/util/type.cpp index fa33c7ea58b..288666ac443 100644 --- a/src/util/type.cpp +++ b/src/util/type.cpp @@ -6,37 +6,14 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "type.h" - -/*******************************************************************\ - -Function: typet::copy_to_subtypes - - Inputs: - - Outputs: - - Purpose: -\*******************************************************************/ +#include "type.h" void typet::copy_to_subtypes(const typet &type) { subtypes().push_back(type); } -/*******************************************************************\ - -Function: typet::move_to_subtypes - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void typet::move_to_subtypes(typet &type) { subtypest &sub=subtypes(); @@ -44,18 +21,6 @@ void typet::move_to_subtypes(typet &type) sub.back().swap(type); } -/*******************************************************************\ - -Function: is_number - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool is_number(const typet &type) { const irep_idt &id=type.id(); diff --git a/src/util/type.h b/src/util/type.h index c9640959a2f..7e9b3a47e87 100644 --- a/src/util/type.h +++ b/src/util/type.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_TYPE_H #define CPROVER_UTIL_TYPE_H diff --git a/src/util/type_eq.cpp b/src/util/type_eq.cpp index 0a63181b04f..0166c347789 100644 --- a/src/util/type_eq.cpp +++ b/src/util/type_eq.cpp @@ -6,6 +6,9 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +/// \file +/// Type Checking + #include #include "type_eq.h" @@ -13,18 +16,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "symbol.h" #include "namespace.h" -/*******************************************************************\ - -Function: type_eq - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool type_eq(const typet &type1, const typet &type2, const namespacet &ns) { if(type1==type2) diff --git a/src/util/type_eq.h b/src/util/type_eq.h index f81cb9b19b4..d871536eca8 100644 --- a/src/util/type_eq.h +++ b/src/util/type_eq.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_TYPE_EQ_H #define CPROVER_UTIL_TYPE_EQ_H diff --git a/src/util/typecheck.cpp b/src/util/typecheck.cpp index 67b695e53fa..a09f54d8ff0 100644 --- a/src/util/typecheck.cpp +++ b/src/util/typecheck.cpp @@ -6,22 +6,16 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "typecheck.h" - -/*******************************************************************\ - -Function: - - Inputs: - - Outputs: - Purpose: - -\*******************************************************************/ +#include "typecheck.h" bool typecheckt::typecheck_main() { + assert(message_handler); + + const unsigned errors_before= + message_handler->get_message_count(messaget::M_ERROR); + try { typecheck(); @@ -29,7 +23,7 @@ bool typecheckt::typecheck_main() catch(int) { - error_found=true; + error(); } catch(const char *e) @@ -42,5 +36,5 @@ bool typecheckt::typecheck_main() error() << e << eom; } - return error_found; + return message_handler->get_message_count(messaget::M_ERROR)!=errors_before; } diff --git a/src/util/typecheck.h b/src/util/typecheck.h index ee80f6e42f0..a11b2738fb8 100644 --- a/src/util/typecheck.h +++ b/src/util/typecheck.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_TYPECHECK_H #define CPROVER_UTIL_TYPECHECK_H @@ -16,30 +17,27 @@ class typecheckt:public messaget { public: explicit typecheckt(message_handlert &_message_handler): - messaget(_message_handler), - error_found(false) + messaget(_message_handler) { } virtual ~typecheckt() { } - mstreamt &error() + // not pretty, but makes transition easier + void err_location(const source_locationt &loc) { - error_found=true; - return messaget::error(); + messaget::error().source_location=loc; } // not pretty, but makes transition easier void err_location(const exprt &src) { - error().source_location=src.find_source_location(); + err_location(src.find_source_location()); } - bool error_found; - - bool get_error_found() const + void err_location(const typet &src) { - return error_found; + err_location(src.source_location()); } protected: diff --git a/src/util/ui_message.cpp b/src/util/ui_message.cpp index 25f6eac92dc..e750c60e3bb 100644 --- a/src/util/ui_message.cpp +++ b/src/util/ui_message.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include @@ -16,18 +17,6 @@ Author: Daniel Kroening, kroening@kroening.com #include "ui_message.h" #include "cmdline.h" -/*******************************************************************\ - -Function: ui_message_handlert::ui_message_handlert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - ui_message_handlert::ui_message_handlert( uit __ui, const std::string &program):_ui(__ui) { @@ -60,18 +49,6 @@ ui_message_handlert::ui_message_handlert( } } -/*******************************************************************\ - -Function: ui_message_handlert::ui_message_handlert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - ui_message_handlert::ui_message_handlert( const class cmdlinet &cmdline, const std::string &program): @@ -83,18 +60,6 @@ ui_message_handlert::ui_message_handlert( { } -/*******************************************************************\ - -Function: ui_message_handlert::~ui_message_handlert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - ui_message_handlert::~ui_message_handlert() { switch(get_ui()) @@ -112,18 +77,6 @@ ui_message_handlert::~ui_message_handlert() } } -/*******************************************************************\ - -Function: ui_message_handlert::level_string - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const char *ui_message_handlert::level_string(unsigned level) { if(level==1) @@ -134,18 +87,6 @@ const char *ui_message_handlert::level_string(unsigned level) return "STATUS-MESSAGE"; } -/*******************************************************************\ - -Function: ui_message_handlert::print - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ui_message_handlert::print( unsigned level, const std::string &message) @@ -173,24 +114,14 @@ void ui_message_handlert::print( } } -/*******************************************************************\ - -Function: ui_message_handlert::print - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ui_message_handlert::print( unsigned level, const std::string &message, int sequence_number, const source_locationt &location) { + message_handlert::print(level, message); + if(verbosity>=level) { switch(get_ui()) @@ -220,18 +151,6 @@ void ui_message_handlert::print( } } -/*******************************************************************\ - -Function: ui_message_handlert::ui_msg - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ui_message_handlert::ui_msg( const std::string &type, const std::string &msg1, @@ -253,18 +172,6 @@ void ui_message_handlert::ui_msg( } } -/*******************************************************************\ - -Function: ui_message_handlert::xml_ui_msg - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ui_message_handlert::xml_ui_msg( const std::string &type, const std::string &msg1, @@ -282,21 +189,9 @@ void ui_message_handlert::xml_ui_msg( result.set_attribute("type", type); std::cout << result; - std::cout << std::endl; + std::cout << '\n'; } -/*******************************************************************\ - -Function: ui_message_handlert::json_ui_msg - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void ui_message_handlert::json_ui_msg( const std::string &type, const std::string &msg1, @@ -319,3 +214,23 @@ void ui_message_handlert::json_ui_msg( // a trailing comma. std::cout << ",\n" << result; } + +void ui_message_handlert::flush(unsigned level) +{ + switch(get_ui()) + { + case uit::PLAIN: + { + console_message_handlert console_message_handler; + console_message_handler.flush(level); + } + break; + + case uit::XML_UI: + case uit::JSON_UI: + { + std::cout << std::flush; + } + break; + } +} diff --git a/src/util/ui_message.h b/src/util/ui_message.h index 59cc5c21009..757108483f1 100644 --- a/src/util/ui_message.h +++ b/src/util/ui_message.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_UI_MESSAGE_H #define CPROVER_UTIL_UI_MESSAGE_H @@ -18,6 +19,10 @@ class ui_message_handlert:public message_handlert ui_message_handlert(uit, const std::string &program); ui_message_handlert(const class cmdlinet &, const std::string &program); + ui_message_handlert(): + _ui(uit::PLAIN) + { + } virtual ~ui_message_handlert(); @@ -31,6 +36,8 @@ class ui_message_handlert:public message_handlert _ui=__ui; } + virtual void flush(unsigned level); + protected: uit _ui; diff --git a/src/util/unicode.cpp b/src/util/unicode.cpp index 4c997f1a6c3..bf8ce51531d 100644 --- a/src/util/unicode.cpp +++ b/src/util/unicode.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include @@ -18,36 +19,14 @@ Author: Daniel Kroening, kroening@kroening.com #include #endif -/*******************************************************************\ - -Function: is_little_endian_arch - - Inputs: - - Outputs: True if the architecture is little_endian - - Purpose: Determine endianness of the architecture - -\*******************************************************************/ - +/// Determine endianness of the architecture +/// \return True if the architecture is little_endian bool is_little_endian_arch() { uint32_t i=1; return reinterpret_cast(i); } -/*******************************************************************\ - -Function: narrow - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - #define BUFSIZE 100 std::string narrow(const wchar_t *s) @@ -75,18 +54,6 @@ std::string narrow(const wchar_t *s) #endif } -/*******************************************************************\ - -Function: widen - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::wstring widen(const char *s) { #ifdef _WIN32 @@ -112,18 +79,6 @@ std::wstring widen(const char *s) #endif } -/*******************************************************************\ - -Function: narrow - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::string narrow(const std::wstring &s) { #ifdef _WIN32 @@ -141,18 +96,6 @@ std::string narrow(const std::wstring &s) #endif } -/*******************************************************************\ - -Function: widen - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - std::wstring widen(const std::string &s) { #ifdef _WIN32 @@ -170,18 +113,8 @@ std::wstring widen(const std::string &s) #endif } -/*******************************************************************\ - -Function: utf8_append_code - - Inputs: character to append, string to append to - - Outputs: - - Purpose: Appends a unicode character to a utf8-encoded string - -\*******************************************************************/ - +/// Appends a unicode character to a utf8-encoded string +/// \par parameters: character to append, string to append to static void utf8_append_code(unsigned int c, std::string &result) { if(c<=0x7f) @@ -206,19 +139,8 @@ static void utf8_append_code(unsigned int c, std::string &result) } } -/*******************************************************************\ - -Function: utf32_to_utf8 - - Inputs: utf32-encoded wide string - - Outputs: utf8-encoded string with the same unicode characters - as the input. - - Purpose: - -\*******************************************************************/ - +/// \param utf32:encoded wide string +/// \return utf8-encoded string with the same unicode characters as the input. std::string utf32_to_utf8(const std::basic_string &s) { std::string result; @@ -231,18 +153,6 @@ std::string utf32_to_utf8(const std::basic_string &s) return result; } -/*******************************************************************\ - -Function: narrow_argv - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - const char **narrow_argv(int argc, const wchar_t **argv_wide) { if(argv_wide==NULL) @@ -258,18 +168,9 @@ const char **narrow_argv(int argc, const wchar_t **argv_wide) return argv_narrow; } -/*******************************************************************\ - -Function: do_swap_bytes - - Inputs: A 16-bit integer - - Outputs: A 16-bit integer with bytes swapped - - Purpose: A helper function for dealing with different UTF16 endians - -\*******************************************************************/ - +/// A helper function for dealing with different UTF16 endians +/// \par parameters: A 16-bit integer +/// \return A 16-bit integer with bytes swapped uint16_t do_swap_bytes(uint16_t x) { uint16_t b1=x & 0xFF; @@ -307,19 +208,10 @@ void utf16_append_code(unsigned int code, bool swap_bytes, std::wstring &result) } -/*******************************************************************\ - -Function: utf8_to_utf16 - - Inputs: String in UTF-8 format, bool value indicating whether the - endianness should be different from the architecture one. - - Outputs: String in UTF-16 format. The encoding follows the - endianness of the architecture iff swap_bytes is true. - - Purpose: - -\*******************************************************************/ +/// \par parameters: String in UTF-8 format, bool value indicating whether the +/// endianness should be different from the architecture one. +/// \return String in UTF-16 format. The encoding follows the endianness of the +/// architecture iff swap_bytes is true. std::wstring utf8_to_utf16(const std::string& in, bool swap_bytes) { std::wstring result; @@ -379,55 +271,24 @@ std::wstring utf8_to_utf16(const std::string& in, bool swap_bytes) return result; } -/*******************************************************************\ - -Function: utf8_to_utf16_big_endian - - Inputs: String in UTF-8 format - - Outputs: String in UTF-16BE format - - Purpose: - -\*******************************************************************/ - +/// \par parameters: String in UTF-8 format +/// \return String in UTF-16BE format std::wstring utf8_to_utf16_big_endian(const std::string& in) { bool swap_bytes=is_little_endian_arch(); return utf8_to_utf16(in, swap_bytes); } -/*******************************************************************\ - -Function: utf8_to_utf16_little_endian - - Inputs: String in UTF-8 format - - Outputs: String in UTF-16LE format - - Purpose: - -\*******************************************************************/ - +/// \par parameters: String in UTF-8 format +/// \return String in UTF-16LE format std::wstring utf8_to_utf16_little_endian(const std::string& in) { bool swap_bytes=!is_little_endian_arch(); return utf8_to_utf16(in, swap_bytes); } -/*******************************************************************\ - -Function: utf16_little_endian_to_ascii - - Inputs: String in UTF-16LE format - - Outputs: String in US-ASCII format, with \uxxxx escapes for other - characters - - Purpose: - -\*******************************************************************/ - +/// \par parameters: String in UTF-16LE format +/// \return String in US-ASCII format, with \uxxxx escapes for other characters std::string utf16_little_endian_to_ascii(const std::wstring& in) { std::ostringstream result; diff --git a/src/util/unicode.h b/src/util/unicode.h index 15aafe8ae13..93e83c5b64f 100644 --- a/src/util/unicode.h +++ b/src/util/unicode.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_UNICODE_H #define CPROVER_UTIL_UNICODE_H diff --git a/src/util/union_find.cpp b/src/util/union_find.cpp index f37975f32eb..a7084e4d608 100644 --- a/src/util/union_find.cpp +++ b/src/util/union_find.cpp @@ -6,22 +6,11 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "union_find.h" -/*******************************************************************\ - -Function: unsigned_union_find::make_union - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void unsigned_union_find::make_union(size_type j, size_type k) { check_index(j); @@ -50,18 +39,6 @@ void unsigned_union_find::make_union(size_type j, size_type k) } } -/*******************************************************************\ - -Function: unsigned_union_find::isolate - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void unsigned_union_find::isolate(size_type a) { check_index(a); @@ -95,18 +72,6 @@ void unsigned_union_find::isolate(size_type a) nodes[a].count=1; } -/*******************************************************************\ - -Function: unsigned_union_find::re_root - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void unsigned_union_find::re_root(size_type old_root, size_type new_root) { check_index(old_root); @@ -141,18 +106,6 @@ void unsigned_union_find::re_root(size_type old_root, size_type new_root) } } -/*******************************************************************\ - -Function: unsigned_union_find::get_other - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - unsigned_union_find::size_type unsigned_union_find::get_other(size_type a) { check_index(a); @@ -169,18 +122,6 @@ unsigned_union_find::size_type unsigned_union_find::get_other(size_type a) return 0; } -/*******************************************************************\ - -Function: unsigned_union_find::intersection - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void unsigned_union_find::intersection( const unsigned_union_find &other) { @@ -202,18 +143,6 @@ void unsigned_union_find::intersection( swap(new_sets); } -/*******************************************************************\ - -Function: unsigned_union_find::find - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - unsigned_union_find::size_type unsigned_union_find::find(size_type a) const { if(a>=size()) diff --git a/src/util/union_find.h b/src/util/union_find.h index 2fee15e495b..4908bf65a49 100644 --- a/src/util/union_find.h +++ b/src/util/union_find.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_UNION_FIND_H #define CPROVER_UTIL_UNION_FIND_H diff --git a/src/util/xml.cpp b/src/util/xml.cpp index aa784c96604..64f731545e6 100644 --- a/src/util/xml.cpp +++ b/src/util/xml.cpp @@ -6,23 +6,12 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include "string2int.h" #include "xml.h" -/*******************************************************************\ - -Function: xmlt::clear - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void xmlt::clear() { data.clear(); @@ -31,18 +20,6 @@ void xmlt::clear() elements.clear(); } -/*******************************************************************\ - -Function: xmlt::swap - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void xmlt::swap(xmlt &xml) { xml.data.swap(data); @@ -51,18 +28,6 @@ void xmlt::swap(xmlt &xml) xml.name.swap(name); } -/*******************************************************************\ - -Function: xmlt::output - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void xmlt::output(std::ostream &out, unsigned indent) const { // 'name' needs to be set, or we produce mal-formed @@ -109,18 +74,7 @@ void xmlt::output(std::ostream &out, unsigned indent) const out << '<' << '/' << name << '>' << "\n"; } -/*******************************************************************\ - -Function: xmlt::escape - - Inputs: - - Outputs: - - Purpose: escaping for XML elements - -\*******************************************************************/ - +/// escaping for XML elements void xmlt::escape(const std::string &s, std::ostream &out) { for(const auto ch : s) @@ -156,20 +110,8 @@ void xmlt::escape(const std::string &s, std::ostream &out) } } -/*******************************************************************\ - -Function: xmlt::escape_attribute - - Inputs: - - Outputs: - - Purpose: escaping for XML attributes, assuming that - double quotes " are used consistently, - not single quotes - -\*******************************************************************/ - +/// escaping for XML attributes, assuming that double quotes " are used +/// consistently, not single quotes void xmlt::escape_attribute(const std::string &s, std::ostream &out) { for(const auto ch : s) @@ -202,35 +144,11 @@ void xmlt::escape_attribute(const std::string &s, std::ostream &out) } } -/*******************************************************************\ - -Function: xmlt::do_indent - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void xmlt::do_indent(std::ostream &out, unsigned indent) { out << std::string(indent, ' '); } -/*******************************************************************\ - -Function: xmlt::find - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - xmlt::elementst::const_iterator xmlt::find(const std::string &name) const { for(elementst::const_iterator it=elements.begin(); @@ -242,18 +160,6 @@ xmlt::elementst::const_iterator xmlt::find(const std::string &name) const return elements.end(); } -/*******************************************************************\ - -Function: xmlt::find - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - xmlt::elementst::iterator xmlt::find(const std::string &name) { for(elementst::iterator it=elements.begin(); @@ -265,18 +171,6 @@ xmlt::elementst::iterator xmlt::find(const std::string &name) return elements.end(); } -/*******************************************************************\ - -Function: xmlt::set_attribute - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void xmlt::set_attribute( const std::string &attribute, unsigned value) @@ -284,18 +178,6 @@ void xmlt::set_attribute( set_attribute(attribute, std::to_string(value)); } -/*******************************************************************\ - -Function: xmlt::set_attribute - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void xmlt::set_attribute( const std::string &attribute, unsigned long value) @@ -303,18 +185,6 @@ void xmlt::set_attribute( set_attribute(attribute, std::to_string(value)); } -/*******************************************************************\ - -Function: xmlt::set_attribute - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void xmlt::set_attribute( const std::string &attribute, unsigned long long value) @@ -322,18 +192,6 @@ void xmlt::set_attribute( set_attribute(attribute, std::to_string(value)); } -/*******************************************************************\ - -Function: xmlt::set_attribute - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void xmlt::set_attribute( const std::string &attribute, const std::string &value) @@ -349,18 +207,9 @@ void xmlt::set_attribute( } } -/*******************************************************************\ - -Function: xmlt::unescape - - Inputs: a string - - Outputs: the unescaped string - - Purpose: takes a string and unescapes any xml style escaped symbols - -\*******************************************************************/ - +/// takes a string and unescapes any xml style escaped symbols +/// \par parameters: a string +/// \return the unescaped string std::string xmlt::unescape(const std::string &str) { std::string result(""); diff --git a/src/util/xml.h b/src/util/xml.h index 8ca5726df96..fdc1b2a6046 100644 --- a/src/util/xml.h +++ b/src/util/xml.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_XML_H #define CPROVER_UTIL_XML_H diff --git a/src/util/xml_expr.cpp b/src/util/xml_expr.cpp index 236c844f6e5..c027025af82 100644 --- a/src/util/xml_expr.cpp +++ b/src/util/xml_expr.cpp @@ -8,6 +8,9 @@ Author: Daniel Kroening \*******************************************************************/ +/// \file +/// Expressions in XML + #include "namespace.h" #include "expr.h" #include "xml.h" @@ -19,18 +22,6 @@ Author: Daniel Kroening #include "xml_expr.h" -/*******************************************************************\ - -Function: xml - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - xmlt xml(const source_locationt &location) { xmlt result; @@ -52,18 +43,6 @@ xmlt xml(const source_locationt &location) return result; } -/*******************************************************************\ - -Function: xml - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - xmlt xml( const typet &type, const namespacet &ns) @@ -159,18 +138,6 @@ xmlt xml( return result; } -/*******************************************************************\ - -Function: xml - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - xmlt xml( const exprt &expr, const namespacet &ns) diff --git a/src/util/xml_expr.h b/src/util/xml_expr.h index 145c09310be..bc5ccf857d9 100644 --- a/src/util/xml_expr.h +++ b/src/util/xml_expr.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_XML_EXPR_H #define CPROVER_UTIL_XML_EXPR_H diff --git a/src/util/xml_irep.cpp b/src/util/xml_irep.cpp index 92bad4df40c..7fa3d955f27 100644 --- a/src/util/xml_irep.cpp +++ b/src/util/xml_irep.cpp @@ -8,6 +8,7 @@ Author: Daniel Kroening \*******************************************************************/ + #include #include @@ -15,18 +16,6 @@ Author: Daniel Kroening #include "irep.h" #include "xml.h" -/*******************************************************************\ - -Function: convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void convert( const irept &irep, xmlt &xml) @@ -55,18 +44,6 @@ void convert( } } -/*******************************************************************\ - -Function: convert - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void convert( const xmlt &xml, irept &irep) diff --git a/src/util/xml_irep.h b/src/util/xml_irep.h index 2537649356a..3c931cbf5f5 100644 --- a/src/util/xml_irep.h +++ b/src/util/xml_irep.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_UTIL_XML_IREP_H #define CPROVER_UTIL_XML_IREP_H diff --git a/src/xmllang/graphml.cpp b/src/xmllang/graphml.cpp index e96abaa74ee..54d19654ec1 100644 --- a/src/xmllang/graphml.cpp +++ b/src/xmllang/graphml.cpp @@ -6,6 +6,9 @@ Author: Michael Tautschnig, mt@eecs.qmul.ac.uk \*******************************************************************/ +/// \file +/// Read/write graphs as GraphML + #include #include @@ -20,18 +23,6 @@ Author: Michael Tautschnig, mt@eecs.qmul.ac.uk typedef std::map name_mapt; -/*******************************************************************\ - -Function: add_node - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static graphmlt::node_indext add_node( const std::string &name, name_mapt &name_to_node, @@ -45,18 +36,6 @@ static graphmlt::node_indext add_node( return entry.first->second; } -/*******************************************************************\ - -Function: build_graph_rec - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static bool build_graph_rec( const xmlt &xml, name_mapt &name_to_node, @@ -168,18 +147,6 @@ static bool build_graph_rec( return false; } -/*******************************************************************\ - -Function: build_graph - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - static bool build_graph( const xmlt &xml, graphmlt &dest, @@ -214,18 +181,6 @@ static bool build_graph( return err; } -/*******************************************************************\ - -Function: read_graphml - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool read_graphml( std::istream &is, graphmlt &dest, @@ -240,18 +195,6 @@ bool read_graphml( return build_graph(xml, dest, entry); } -/*******************************************************************\ - -Function: read_graphml - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool read_graphml( const std::string &filename, graphmlt &dest, @@ -266,18 +209,6 @@ bool read_graphml( return build_graph(xml, dest, entry); } -/*******************************************************************\ - -Function: write_graphml - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - bool write_graphml(const graphmlt &src, std::ostream &os) { xmlt graphml("graphml"); diff --git a/src/xmllang/graphml.h b/src/xmllang/graphml.h index 1ef5aaedae1..3b399d48c3b 100644 --- a/src/xmllang/graphml.h +++ b/src/xmllang/graphml.h @@ -6,6 +6,9 @@ Author: Michael Tautschnig, mt@eecs.qmul.ac.uk \*******************************************************************/ +/// \file +/// Read/write graphs as GraphML + #ifndef CPROVER_XMLLANG_GRAPHML_H #define CPROVER_XMLLANG_GRAPHML_H diff --git a/src/xmllang/xml_parse_tree.cpp b/src/xmllang/xml_parse_tree.cpp index b18bda862a5..c673f87f034 100644 --- a/src/xmllang/xml_parse_tree.cpp +++ b/src/xmllang/xml_parse_tree.cpp @@ -6,37 +6,14 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -#include "xml_parse_tree.h" - -/*******************************************************************\ - -Function: xml_parse_treet::swap - - Inputs: - Outputs: - - Purpose: - -\*******************************************************************/ +#include "xml_parse_tree.h" void xml_parse_treet::swap(xml_parse_treet &xml_parse_tree) { xml_parse_tree.element.swap(element); } -/*******************************************************************\ - -Function: xml_parse_treet::clear - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - void xml_parse_treet::clear() { xml.clear(); diff --git a/src/xmllang/xml_parse_tree.h b/src/xmllang/xml_parse_tree.h index 4d0ab02b8b7..5aa2f4f6080 100644 --- a/src/xmllang/xml_parse_tree.h +++ b/src/xmllang/xml_parse_tree.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_XMLLANG_XML_PARSE_TREE_H #define CPROVER_XMLLANG_XML_PARSE_TREE_H diff --git a/src/xmllang/xml_parser.cpp b/src/xmllang/xml_parser.cpp index f56ee14e202..8a92480bc22 100644 --- a/src/xmllang/xml_parser.cpp +++ b/src/xmllang/xml_parser.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #include #include #include @@ -14,18 +15,6 @@ Author: Daniel Kroening, kroening@kroening.com xml_parsert xml_parser; -/*******************************************************************\ - -Function: parse_xml - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - // 'do it all' function bool parse_xml( std::istream &in, @@ -49,18 +38,6 @@ bool parse_xml( return result; } -/*******************************************************************\ - -Function: parse_xml - - Inputs: - - Outputs: - - Purpose: - -\*******************************************************************/ - // 'do it all' function bool parse_xml( const std::string &filename, diff --git a/src/xmllang/xml_parser.h b/src/xmllang/xml_parser.h index b4ebd33c3e6..f4659160653 100644 --- a/src/xmllang/xml_parser.h +++ b/src/xmllang/xml_parser.h @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ + #ifndef CPROVER_XMLLANG_XML_PARSER_H #define CPROVER_XMLLANG_XML_PARSER_H