[cfe-dev] Divide by zero reporting

Sujit Kamthe Sujit.Kamthe at kpitcummins.com
Wed Dec 12 20:05:49 PST 2012


Hi Jordan,
Thanks for your reply.
I think this is achieved using C.generateSink() method where C is CheckerContext, which stops further exploration of the AST path.
In one of the checkers which is a Pre-stmt<BinaryOperator> checker, I have used C.addTransition(); which should not stop the further analysis, but in my case it stops the further analysis of the AST nodes in same file and only reports the first violation.

Regards,
Sujit Kamthe


From: Jordan Rose [mailto:jordan_rose at apple.com]
Sent: Tuesday, December 11, 2012 10:44 PM
To: Sujit Kamthe
Cc: Clang Developers
Subject: Re: [cfe-dev] Divide by zero reporting

Hi, Sujit. The checkers in the analyzer can choose to treat errors as fatal or non-fatal. In the case of divide-by-zero errors, we treat them as fatal, because (a) they will in fact trap in most runtimes, and (b) it's hard to continue evaluating if the division is used in a larger expression:

int a = 23 / 0;
int b = 34 / a; // ??

Note that the analyzer only stops analyzing a particular path when it sees a fatal error, not the entire file. Both divide-by-zero violations should be reported in compute(), as well as the one in again(), even if both functions are in the same file.

int compute(int a) {
            if (coin()) {
                        a = a / 0;
            } else {
                        a = a / 0;
            }
}

int again() {
            return 24 / 0;
}

Best,
Jordan



On Dec 11, 2012, at 1:36 , Sujit Kamthe <Sujit.Kamthe at kpitcummins.com<mailto:Sujit.Kamthe at kpitcummins.com>> wrote:


Hi,
While running clang tool on a code it was found that if there are multiple divide by zero violations(more than 1) in same file then only the first one is reported and rest of them are not reported.
Even it was found that when a Prestmt<BinaryOperator> check detects/emits a bugreport, it skips the subsequent binary operator nodes from the same file.

Example Code:

int a=23/0; //Detected and reported
int b=34/0; //Not detected

Regards,
Sujit Kamthe


This message contains information that may be privileged or confidential and is the property of the KPIT Cummins Infosystems Ltd. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. KPIT Cummins Infosystems Ltd. does not accept any liability for virus infected mails. _______________________________________________
cfe-dev mailing list
cfe-dev at cs.uiuc.edu<mailto:cfe-dev at cs.uiuc.edu>
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121213/da7a4824/attachment.html>


More information about the cfe-dev mailing list