Commit Graph

145 Commits

Author SHA1 Message Date
Japheth Lim
eb7734f705 c-parser: add regression test for aa162a0. 2015-04-17 13:44:19 +10:00
Japheth Lim
aa162a06f6 c-parser: fix a bug introduced by 2f611a4. 2015-04-16 18:11:15 +10:00
Japheth Lim
e83be48e84 autocorres: activate regression test for nested struct access (VER-321). 2015-04-10 16:23:31 +10:00
Michael Norrish
9827e78177 Handle cpp in both standalone and Isabelle parsers
Japheth's recent change (6f7c660cb) to error-reporting for the latter
broke the former. Refactor code so that old and new code can coexist.
Would just use Japheth's code in the purely SML version too, but it uses
Isabelle/ML libraries that I can't be bothered to recreate in SML.
2015-04-10 14:51:36 +10:00
Michael Norrish
d66755aa26 Also get tokenizer tool to build given cc996ca 2015-04-10 14:05:16 +10:00
Japheth Lim
8025988556 trivial: autocorres: add some type conversions in light of cc996ca.
TODO: look more closely at the newmunge if it potentially affects VER-351.
2015-04-09 17:42:50 +10:00
Japheth Lim
6f7c660cb5 C-Parser: show cpp error messages if cpp fails. Also clean up output temp files. 2015-04-09 17:39:41 +10:00
Michael Norrish
e4a38b4c65 Fix to GlobalsSwap.thy in light of cc996ca9ca 2015-04-09 16:56:03 +10:00
Michael Norrish
dfa5c16ecf Style change to squash Isabelle/ML warning message 2015-04-09 15:10:04 +10:00
Michael Norrish
cc996ca9ca Properly fix JIRA VER-439
The handling of local static variables is now part of a general
improvement in the handling of all the "munging" that the parser does.

*Munging* is the process of renaming variables so that Isabelle can cope
with them.  There are at least three different forms of munging at the
moment:

- static locals get munged so that multiple static locals (which have to
  be treated as globals) can co-exist with the same source name.
- local variables of the same source name but different types have to be
  able to co-exist
- variables with legitimate C names but illegal Isabelle names have to
  be allowed

The new structure MString implements an opaque version of string
designed to make it clear to the typechecker that certain strings are
"munged".
2015-04-09 15:09:29 +10:00
Michael Norrish
29e525645f Handle local static variables properly.
They are now treated as globals with a specially munged name, derived
from the given name and the name of the function where they occur. The
function NameGeneration.mk_localstatic generates the "munged" name.

As with other globals, initialisation is not handled very well (i.e., at
the moment the initialisation is completely ignored).

Close JIRA VER-439
2015-03-26 16:13:56 +11:00
Japheth Lim
408bf219a0 autocorres: save fn_info at the end, instead of throwing it away. 2015-03-23 15:44:59 +11:00
Michael Norrish
e184eb69de Handle local extern declarations
Closes JIRA VER-440
2015-03-23 15:11:57 +11:00
Japheth Lim
3fe688e05d autocorres: fix "scope" option. 2015-03-21 11:32:46 +11:00
Michael Norrish
94d8a918f2 Refactoring as a prelude to handling static/extern
This is work for both of JIRA VER-439 and VER-440.

Test-suite passes.
2015-03-17 16:42:46 +11:00
Michael Norrish
5c3f79ff3b Remove some unused code (fewer compiler warnings) 2015-03-17 15:43:55 +11:00
Michael Norrish
8de46c42fc Start a test-case for JIRA VER-440 (extern vars) 2015-03-17 09:26:24 +11:00
Michael Norrish
ad9b216c63 Start a test-case for JIRA VER-439 (static vars) 2015-03-17 09:20:32 +11:00
Thomas Sewell
d330c7dff5 Slight adjustment. 2015-03-16 17:25:12 +11:00
Thomas Sewell
dac89a46c1 Adjustments in GraphLang to support CDSL. 2015-03-13 01:21:10 +11:00
Daniel Matichuk
a221a52350 Added new proofcount tool to "tools" and removed old one from "lib".
Removed reference to old proof_counting from proof/ROOT and spec/ROOT
2015-02-11 17:46:34 +11:00
Matthew Fernandez
c042e4dacf autocorres examples: Extended proofs for memcpying a struct.
This extra proof was to validate that the existing word 32 proof generalises to
other, arbitrarily complex, types. The proof script is more or less identical,
which strongly suggests that we can now trivially lift the generic memcpy proof
into a proof for copying any mem_type. It would be nice to generalise the
required properties on is_valid_* into some kind of locale construction, but the
way lifted_globals and friends are constructed make this a little tricky.

Note that the memcpy implementation we're currently reasoning about should
actually work correctly even if the memory regions overlap, as long as the
destination pointer is less than or equal to the source. That is, the
precondition of the Hoare triple for memcpy could be weakened. However, this
does not seem sensible to do as the memcpy spec requires that the input
pointers do not overlap and we don't want users proving properties that they
think will also hold on other memcpy implementations.
2015-02-11 15:50:04 +11:00
Matthew Fernandez
b1423b2a84 autocorres examples: Refer to lifted_globals simps generically.
This avoids proof breakage when changing the list of input types.
2015-02-11 15:50:04 +11:00
Michael Norrish
b452139b91 Handle typedefs of anonymous struct types.
Should have been done in 3cee38ff1.

JIRA VER-434
2015-02-09 14:21:40 +11:00
Thomas Sewell
048365732e Adjust make_spec.sh to handle other working dirs.
Demanding that the tool be run from its own directory was getting
silly considering how far away that is from the resources it operates
on.
2015-02-03 12:36:02 +11:00
Michael Norrish
3cee38ff19 Handle anonymous structs better.
In particular, don't reveal the internal references used during
yacc-ing to the user-level.  Instead, add a referentially transparent
repair of the AST after its been parsed.

JIRA VER-432
2015-01-28 16:44:16 +11:00
Michael Norrish
9149fe41c7 New option to standalone parser to just test the C grammar.
Without even typechecking, none of the later phases of the analysis
get run.
2015-01-28 14:40:15 +11:00
Michael Norrish
df8a34ae4a Compiler warning made me realise sizeof(_Bool) would fail. 2015-01-28 14:02:49 +11:00
Matthew Fernandez
9dff48dade autocorres examples: Prove a heap-abstracted call to memcpy.
This commit adds a proof over a call to (the non-heap-abstracted) memcpy from
a heap-abstracted context. As a result, our pre- and post-conditions are
expressed on the abstract heap and need to be transfered to the concrete heap
during the proof. Altogether the proof is not so complex and most of the heavy
lifting remains in the original proof of memcpy.
2015-01-23 17:33:22 +11:00
Matthew Fernandez
9e17ccb49b autocorres examples: more generic memcpy_int proof.
The enclosed proof text should more-or-less generalise to showing the
correctness of copying any type.
2015-01-23 16:18:18 +11:00
Matthew Fernandez
a4fa3f8e1d autocorres examples: Show dereferencing a pointer retrieves its bytes. 2015-01-23 14:25:24 +11:00
Michael Norrish
8d2a981007 Ignore a file that might exist locally in tools/c-parser 2015-01-23 10:16:21 +11:00
Michael Norrish
07a8cac0e1 Fix regression test error caused by 72d54eeb 2015-01-23 09:02:32 +11:00
Michael Norrish
72d54eeb0b Allow user to control path to C preprocessor (or not use it entirely).
As per example, syntax is

    declare [[cpp_path="path to file"]]

If the empty string is used as the value, then no preprocessor will be
called.

The standalone parser has also been adjusted so that you can it with

    --cpp=path

or

    --nocpp

options.

Closes JIRA issue VER-337
2015-01-22 14:05:39 +11:00
Matthew Fernandez
25e3d17e06 autocorres examples: Prove memcpying twice in sequence does what it should. 2015-01-20 10:39:05 +11:00
Matthew Fernandez
2fd6545490 autocorres examples: Prove memcpy of an int using the generic lemma. 2015-01-20 10:27:49 +11:00
Matthew Fernandez
6fd287a041 autocorres examples: Prove memcpying from and to and generic type. 2015-01-20 10:17:04 +11:00
Matthew Fernandez
ad8e5895d7 autocorres examples: Use the memcpy lemma to prove something about a caller.
Reasoning about heap equivalence involving mixed types (~= writing to memory
through two differently typed pointers) is very awkward. The enclosed proof
leans heavily on the fact that we know the concrete size of the type of the
memory we're copying, and it still requires a fair bit of sledgehammering. This
is fine for an example, but certainly won't translate to proof generation on
arbitrary types. We may need to take a slightly different tack.
2015-01-19 18:11:29 +11:00
Matthew Fernandez
ad763c1cd0 autocorres examples: Prove exactly what happens to the state during memcpy.
This should enable the proof to be used in a larger context.
2015-01-19 13:23:35 +11:00
Matthew Fernandez
9d896e9d4c autocorres examples: Prove some more memcpy-supporting lemmas.
These should all be lifted to a lib thy.
2015-01-19 10:29:38 +11:00
Matthew Fernandez
1011e78fa5 autocorres examples: Some infrastructure for proving memcpy more comprehensively. 2015-01-16 18:22:31 +11:00
Matthew Fernandez
286435cb7f autocorres: Generalise memcpy lemma to apply to any mem_types/size. 2015-01-16 10:21:50 +11:00
David Greenaway
9703a2dea7 autocorres: Add missing file to set of release files. 2014-12-16 13:25:36 +11:00
Japheth Lim
6fcf397118 autocorres: move L2Unfold rules to L1except,
as L1except suffers from severe performance degradation if one of the rules (L1_seq_assoc) is missing.
2014-12-11 19:08:24 +11:00
Japheth Lim
73e28343ae autocorres: no_opt now disables optimisations in SimplConv and TypeStrengthen.
This moves some mandatory optimisations to the L2unfold attribute, which marks
the first use of this attribute only three years after it was defined.
2014-12-04 20:19:26 +11:00
Japheth Lim
75aac10ea3 autocorres: be even less clever about removing variable binds when no_opt is set.
The downside is that some control flow variables emitted by c-parser would
not be erased any more. But maybe they shouldn't be.
2014-12-04 16:20:43 +11:00
Japheth Lim
8c443bed5f autocorres: do not remove variable binds if no_opt is set.
The aim is that every variable assignment in the input program
(except for control-flow variables) is translated to a bind
in the output program.
2014-12-04 16:05:01 +11:00
David Greenaway
8dd95a344c autocorres: Translate missing functions into constant "FUNCTION_BODY_NOT_IN_INPUT_C_FILE".
Functions that are declared in the C file, called by other C functions,
but are never actually _defined_ are translated simply into a "fail"
monadic statement. This sometimes causes confusion to new users.

We update AutoCorres to instead emit a new constant:

  FUNCTION_BODY_NOT_IN_INPUT_C_FILE

defined simply as "fail" for such functions.
2014-12-03 14:49:12 +11:00
David Greenaway
8c8bb5e67a autocorres: trivial: Remove unused function in "simpl_conv.ML". 2014-12-03 14:49:12 +11:00
David Greenaway
c87d80f06f autocorres: trivial: Tweak incorrect comment in "simpl_conv.ML". 2014-12-03 14:49:12 +11:00