[cfe-dev] Checking design-specified range limits on variables
Chris Hamilton via cfe-dev
cfe-dev at lists.llvm.org
Mon Feb 1 11:21:32 PST 2021
Hi all,
Im looking into whether there is an existing mechanism (or one in
development) whereby a specified range might be checked by static analysis.
For example, given a structure definition, might there be a way to annotate
the declaration along these lines, such that static analysis can spot
assignments to this variable that are out of range?
typedef struct Foo {
int x1; // @range=[10:20]
int d2;
int v[20];
} Foo;
void myfunc( Foo *f1 ) {
f1->x1 = 15; // ok, no warning
f1->x1 = 25; // STA warning defined range violation or some such
}
I think this question ventures into Domain Specific Languages for design
verification
but Im not sure what mechanisms might already exist in the
clang analyzer that would approximate or directly support this type of
check. Obviously, there are a lot of possible variations of this idea to
consider, but this example seems like a good starting point for discussion.
Any thoughts would be welcome and appreciated.
Thanks,
Chris
<https://www.ericsson.com/>
Chris Hamilton
Compiler Developer
BNEW DNEW 4G5G BI BBI 10
Mobile: +1-512-955-0143
<mailto:chris.hamilton at ericsson.com> chris.hamilton at ericsson.com
Without inclusion, diversity is only a statistic. -- Börje Ekholm, CEO of
Ericsson
Ericsson
1703 W. 5th Street Suite 600
78703,Austin, Texas
United States
<https://www.ericsson.com/> ericsson.com
<https://www.ericsson.com/current_campaign>
Our commitment to
<https://www.ericsson.com/thecompany/sustainability-corporateresponsibility>
Technology for Good and
<https://www.ericsson.com/thecompany/diversity-inclusion> Diversity and
Inclusion contributes to positive change.
Follow us on: <https://www.facebook.com/ericsson> Facebook
<https://www.linkedin.com/company/ericsson> LinkedIn
<https://twitter.com/Ericsson> Twitter
Legal entity:ERICSSON AB registration number 556056-6258, registered office
in Stockholm.
This communication is confidential. Our email terms:
<https://www.ericsson.com/en/legal/privacy/email-disclaimer>
www.ericsson.com/en/legal/privacy/email-disclaimer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20210201/cb5d03f5/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 6394 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20210201/cb5d03f5/attachment.bin>
More information about the cfe-dev
mailing list