| Summary: | Codan confuses fields with methods | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Tools] CDT | Reporter: | Andrew Gvozdev <angvoz.dev> | ||||||
| Component: | cdt-codan | Assignee: | Marc-André Laperle <malaperle> | ||||||
| Status: | RESOLVED FIXED | QA Contact: | Elena Laskavaia <elaskavaia.cdt> | ||||||
| Severity: | normal | ||||||||
| Priority: | P3 | CC: | cdtdoug, malaperle | ||||||
| Version: | 8.0 | ||||||||
| Target Milestone: | 8.0 | ||||||||
| Hardware: | All | ||||||||
| OS: | All | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
Created attachment 190358 [details]
ProblemBinding checker, fields and methods patch
This patch should fix it. We should have tests for this checker. I tried to quickly add one with only this case and did exactly like the other checkers but it didn't work. I'll investigate.
Created attachment 191073 [details]
ProblemBinding checker, fields and methods, patch and test
I figured out the problem with the new test. CheckerTestCase.enableProblems doesn't handle the multiple ids correctly. Also, ProblemBinding checker is not set to be running on FULL_BUILD and since running codan in tests is always FULL_BUILD, we have to override the preferences. For now, I only added 2 tests that covers this bug but we can easily add more now.
Fixed in HEAD. *** cdt cvs genie on behalf of mlaperle *** Bug 338683 - Codan confuses fields with methods [*] ProblemBindingChecker.java 1.8 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ProblemBindingChecker.java?root=Tools_Project&r1=1.7&r2=1.8 [*] AutomatedIntegrationSuite.java 1.17 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/AutomatedIntegrationSuite.java?root=Tools_Project&r1=1.16&r2=1.17 [*] CheckerTestCase.java 1.22 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CheckerTestCase.java?root=Tools_Project&r1=1.21&r2=1.22 [+] ProblemBindingCheckerTest.java http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ProblemBindingCheckerTest.java?root=Tools_Project&revision=1.1&view=markup Thanks, Marc. |
In following snippet Codan is telling "Method 'y' could not be resolved" on the second line: struct X {} x; fun(x.y); // Method 'y' could not be resolved x.y; // Field 'y' could not be resolved Obviously, y looks like a field not a method. Plain x.y complains rightly about the field. Because of bug 337583 I am forced to disable detections of fields in Codan but I'd like to keep the warning about methods.