[RFC] autocheck: A Source Code Analysis Tool based on Clang/LLVM for Automotive

Hi all,

I am happy to share with the community that we’ve implemented the autocheck tool and it is available for free at [0]!

autocheck is a source code analyses tool implemented by using clang API. Its purpose is to check the code against Autosar Automotive Standard. Autosar contains a set of guidelines for the use of the C++ language in critical and safety-related systems and its goal is to improve security, safety and quality of software.

We have presented the overall idea on the 2020 LLVM Developers’ Meeting [1].

We have currently covered most of the rules that apply to the current Autosar Standard, but not all, and our plan is to continue adding more rules. Furthermore, a new standard has recently been published, so we will focus on covering it in the future as well.

The tool is very easy to use and has a bunch of very useful user/command line options [2].

Any comments?

Best regards,
Djordje Todorovic

[0] GitHub - syrmia/autocheck: Following AUTOSAR guidelines can be easy and free!
[1] https://www.youtube.com/watch?v=-6dL-7xkIV0
[2] GitHub - syrmia/autocheck: Following AUTOSAR guidelines can be easy and free!

3 Likes

That’s great, thanks for the great work!

How do you intend to handle the license restrictions? Unlike Autosar, MISRA requires one to purchase a license to view the guidelines. One may not reproduce the guidelines text in a static analysis tool without permission/additional fees to MISRA. That’s the main reason clang-tidy does not have such a module

1 Like

Our focus is on source code analysis and Autosar rules. We need to double check if we would break something, so we are postponing making the project public. Will update you soon.

Sounds good! FYI we had a discussion about adding an Autosar module to clang-tidy, you might want to have a look:

See also:

https://reviews.llvm.org/D112730

Also found this post that you might find relevant:
https://forum.misra.org.uk/showthread.php?tid=884

Hey, I’m curious why the github repository is no longer available. We were interested in evaluating this tool, but the github now serves a 404 for me.

I think it’s private now due to licensing concerns highlighted above.

Given that license issues are going to be resolved, I think this work should go into either clang-tidy or clang static analyzer.
CC @AaronBallman @PiotrZSL @LegalizeAdulthood

1 Like

In what way? The LLVM Foundation Board did not approve of Autosar checks making it into the project (see above). But maybe the discussion is reopened?

It’s a lot harder to do this for MISRA though, also due to way-of-working issues. Both code owner and code reviewer must purchase a copy of the MISRA guidelines to be able to put a patch. So the development process is not as open-source as we’d like it to be. But maybe a solution can be found?

To be clear: I can’t express enough how much I’d love to have Autosar and MISRA checks in clang-tidy :slight_smile:

Now that I read both threads you linked above, I’m afraid that the only thing to reopen here is negotiations with MISRA to allow us to cite their documents.

I’m afraid this is an unacceptable requirement for anything under LLVM project. The closest precedent I can think of is Windows support in Clang. It’s certainly different in nature, but maybe some inspiration can be drawn from it.

1 Like

Yep, very unfortunate. Even if we get past that, we cannot reproduce or paraphrase the rule text in the docs nor in the actual warning. We could only emit a diagnostic like “MISRA rule 1.2.3 violated”, and the user of clang-tidy would need to buy the MISRA document and search the mentioned rule to be able to understand the problem.

There’s this other tool called “cppcheck” that allows users to pass in a text file with the text of the rules. This way they don’t violate the restrictions.

But yes, sadly this is very different from the philosophy of the LLVM project.

1 Like

This might also be challenging, if official publication comes only in PDF, for instance.

Yep, the official docs suggest to select and copy-paste an Annex at the end of the Misra document that summarizes the rules, into a text file. It’s probably doable to write a quick Python tool to do that automatically.