Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 338683

Summary: Codan confuses fields with methods
Product: [Tools] CDT Reporter: Andrew Gvozdev <angvoz.dev>
Component: cdt-codanAssignee: 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:
Description Flags
ProblemBinding checker, fields and methods patch
none
ProblemBinding checker, fields and methods, patch and test malaperle: iplog-

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.