Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 336396 - Codan Checkers get called too many times from incremental builds
Summary: Codan Checkers get called too many times from incremental builds
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-codan (show other bugs)
Version: 8.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 8.0   Edit
Assignee: Elena Laskavaia CLA
QA Contact: Elena Laskavaia CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-04 16:20 EST by Alex Ruiz CLA
Modified: 2011-02-10 09:12 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Ruiz CLA 2011-02-04 16:20:01 EST
Build Identifier: I20101208-1300

Currently, when the method CodanBuider.incrementalBuild(IResourceDelta, IProgressMonitor) is invoked, checkers are called too many times for a single resource.

The number of times checkers are called is directly proportional to the number of folders up in the hierarchy of a resource. For example, given the resource:

a/b/c/d/e/f.cpp

checkers will process f.cpp 5 times! one time per folder in the hierarchy.

I looked at the source code and this is what I saw. CodanDeltaVisitor visits every resource (which is correct,) then calls 'processResource(IResource, IProgressMonitor)' to process the visited resource (so far so good.) The problem is that 'processResource' checks if the resource is a Container, and if it is, process its children.

In our example, when CodanDeltaVisitor is visiting folder 'a', 'processResource' will process 'a' all the way to f.cpp. Then CodanDeltaVisitor will process 'b' and 'processResource' then again will process b's children.

At least in an incremental build, IMHO, 'processResource' should not recursively process a resource's children, since they are going to be processed anyway when CodanDeltaVisitor visits such children.

Reproducible: Always

Steps to Reproduce:
1. Get CDT source code: http://wiki.eclipse.org/Getting_started_with_CDT_development
2. Set a breakpoint in class org.eclipse.cdt.codan.internal.core.CodanBuilder, in method 'visit' in inner class CodanDeltaVisitor (line 51) and method 'processResource' (line 94.)
3. Debug project org.eclipse.cdt.ui as an "Eclipse Application"
4. In the launched Eclipse, create a C++ project with a single C++ file, within a hierarchy of two folders or more.
5. In the project properties, set up Codan to be ran with build (C++ General -> Code Analysis -> Launching)
6. Make some modifications to the cpp file and see how the behavior described in this bug happens
Comment 1 Elena Laskavaia CLA 2011-02-07 21:26:20 EST
fixed in 8.0. When processing from delta do not run it recursively.
Comment 2 CDT Genie CLA 2011-02-10 09:12:46 EST
*** cdt cvs genie on behalf of elaskavaia ***
Bug 336396: fixed double processing of files on build

[*] CodanBuilder.java 1.14 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanBuilder.java?root=Tools_Project&r1=1.13&r2=1.14