This is an archive of the discontinued LLVM Phabricator instance.

Add check for CERT FLP30-C
ClosedPublic

Authored by aaron.ballman on Feb 18 2016, 9:20 AM.

Details

Summary

This patch adds a check for the CERT secure coding rule: FLP30-C. Do not use floating-point variables as loop counters. It flags any for loop induction expression that has floating-point type.

https://www.securecoding.cert.org/confluence/display/c/FLP30-C.+Do+not+use+floating-point+variables+as+loop+counters

Diff Detail

Event Timeline

aaron.ballman retitled this revision from to Add check for CERT FLP30-C.
aaron.ballman updated this object.
aaron.ballman added reviewers: alexfh, sbenza.
aaron.ballman added a subscriber: cfe-commits.
hokein accepted this revision.Feb 19 2016, 1:34 AM
hokein added a reviewer: hokein.
hokein edited edge metadata.

LGTM with one nit.

test/clang-tidy/cert-flp30-c.c
6

I see in most of testcases, they are using [[@LINE-1]] instead of [[@LINE+1]]. We'd better follow the [[@LINE+1]] way here.

This revision is now accepted and ready to land.Feb 19 2016, 1:36 AM
aaron.ballman closed this revision.Feb 19 2016, 6:08 AM
aaron.ballman marked an inline comment as done.

Thanks! I've commit in r261324.

test/clang-tidy/cert-flp30-c.c
6

I've changed to using -1 instead of +1, but I don't think we have a hard and fast rule on location aside from "whatever makes the most sense." Given the compound blocks, I personally think +1 is more clear than -1, but meh.

alexfh edited edge metadata.Feb 19 2016, 7:07 AM

LG

test/clang-tidy/cert-flp30-c.c
6

Yep, I don't think we're trying to be consistent with placing check lines before or after the checked location. Not that it matters much.