Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 338683 - Codan confuses fields with methods
Summary: Codan confuses fields with methods
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-codan (show other bugs)
Version: 8.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 8.0   Edit
Assignee: Marc-André Laperle CLA
QA Contact: Elena Laskavaia CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-02 10:29 EST by Andrew Gvozdev CLA
Modified: 2011-03-14 11:33 EDT (History)
2 users (show)

See Also:


Attachments
ProblemBinding checker, fields and methods patch (2.02 KB, patch)
2011-03-04 03:02 EST, Marc-André Laperle CLA
no flags Details | Diff
ProblemBinding checker, fields and methods, patch and test (9.84 KB, patch)
2011-03-13 01:00 EST, Marc-André Laperle CLA
malaperle: iplog-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Gvozdev CLA 2011-03-02 10:29:17 EST
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.
Comment 1 Marc-André Laperle CLA 2011-03-04 03:02:16 EST
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.
Comment 2 Marc-André Laperle CLA 2011-03-13 01:00:11 EST
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.
Comment 3 Marc-André Laperle CLA 2011-03-13 01:04:08 EST
Fixed in HEAD.
Comment 5 Andrew Gvozdev CLA 2011-03-14 11:33:48 EDT
Thanks, Marc.