Skip to content

[Feat] Static Conformity Analyzer #41

Description

@brightprogrammer

Motivation

MisraStdC encodes a lot of it's conventions through function calls and macro APIs. The L/R semantics is a good example and is used across the project. L semantics means a container may take ownership of an object that is passed to it during an insertion operation while the R semantics means that the container will make it's own copy if possible.

MisraStdC has conventions that is easier for coding agents or just normal users to ignore, and that should be detectable easily sometimes using simple syntactic analysis + data flow analysis.

Using Conventions In Code As Contracts

So, the question I want to ask is how far can we go in this direction? Leverage the fact that we know the clear contracts each API (function or macro) holds, and use that with data flow analysis to warn the developer about bad move operations or bad ownership handling. Essentially a borrow checker or a CodeQL with some other rules to help autonomous development, designed specifically to work with code that uses MisraStdC.

End Goal

The vision is that once this tool is developed, autonomous coding with agents will be very easy in the sense that the tool will act as an oracle when a bad practice happens in code. An example of this is my implementation of VecForeach as a type-safe for-loop iterator over a Vec container, but AI agents constantly using direct for-loop. While the code is not wrong, it's not idiomatic to me, and I'd rather prefer VecForeach being used for iteration, because it comes with other checks as well, that help catch errors early in development, and hence much better debugging.

Deliverables

The following features are required in the end :

  • A syntactic analyzer to catch non idiomatic ways of doing things.
  • A semantic analyzer that helps catch bad code. Like catching a use after an ownership move (L-semantic), or a pointer aliasing case, when type is known (type-erasure).
  • A data flow analysis part that works paired with semantic analyzer to help facilitate catching the issues.

This whole thing is huge and I want everything in-tree, 0 external dependencies, meaning multiple things need to be implemented and tested before we achieve this goal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions