Skip to content

Commit

Permalink
Reworked scripts/pretty_asserts.py a bit
Browse files Browse the repository at this point in the history
- Renamed explode_asserts.py -> pretty_asserts.py, this name is
  hopefully a bit more descriptive
- Small cleanup of the parser rules
- Added recognization of memcmp/strcmp => 0 statements and generate
  the relevant memory inspecting assert messages

I attempted to fix the incorrect column numbers for the generated
asserts, but unfortunately this didn't go anywhere and I don't think
it's actually possible.

There is no column control analogous to the #line directive. I thought
you might be able to intermix #line directives to put arguments at the
right column like so:

    assert(a == b);

    __PRETTY_ASSERT_INT_EQ(
    #line 1
           a,
    #line 1
                b);

But this doesn't work as preprocessor directives are not allowed in
macros arguments in standard C. Unfortunately this is probably not
possible to fix without better support in the language.
  • Loading branch information
geky committed Aug 16, 2022
1 parent 92eee8e commit b08463f
Show file tree
Hide file tree
Showing 3 changed files with 428 additions and 393 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,10 @@ $(BUILDDIR)%.s: %.c
$(CC) -S $(CFLAGS) $< -o $@

$(BUILDDIR)%.a.c: %.c
./scripts/explode_asserts.py $< -o $@
./scripts/pretty_asserts.py -p LFS_ASSERT $< -o $@

$(BUILDDIR)%.a.c: $(BUILDDIR)%.c
./scripts/explode_asserts.py $< -o $@
./scripts/pretty_asserts.py -p LFS_ASSERT $< -o $@

$(BUILDDIR)%.t.c: %.toml
./scripts/test.py -c $< $(TESTCFLAGS) -o $@
Expand Down

0 comments on commit b08463f

Please sign in to comment.