Skip to content

Fix #14113 (Slow analysis: microchip xc16 code)#7838

Draft
glankk wants to merge 1 commit into
cppcheck-opensource:mainfrom
glankk:14113
Draft

Fix #14113 (Slow analysis: microchip xc16 code)#7838
glankk wants to merge 1 commit into
cppcheck-opensource:mainfrom
glankk:14113

Conversation

@glankk

@glankk glankk commented Sep 21, 2025

Copy link
Copy Markdown
Collaborator

Improves check times for sources with many conditionally includes files by implementing lazy loading of headers. Lazy loading is only implemented for single-config checks because cppcheck currently needs to open all possibly included headers in order to discover configs automatically. Lazy loading for automatic configurations is possible by discovering new configurations as files are loaded, and it's something I think should be implemented in the future. I've done preliminary tests showing that it significantly speeds up check times when using -f, but there are some complications that need to be figured out and it's outside the scope of this PR.

Some changes have been made to Preprocessor; since preprocessing has to be done per-file as they are included, many functions have been changed or overloaded to act on a specific file instead of all previously loaded files. Some dumps have been changed to be completed after checking is done, when the full list of included files is known.

A test has been added to test/cli/performance_test.py.

Benchmarks

Test file:

$ cat pic1.c
#include <xc.h>

Before:

$ cppcheck -I"C:\Program Files\Microchip\xc16\v2.10\support\generic\h" -I"C:\Program Files\Microchip\xc16\v2.10\support\dsPIC33E\h" -D __dsPIC33EP128GP504__ pic1.c --showtime=file-total
Checking pic1.c ...
Checking pic1.c: __dsPIC33EP128GP504__=1...
Check time: pic1.c: 2m 22.472s

After:

$ cppcheck -I"C:\Program Files\Microchip\xc16\v2.10\support\generic\h" -I"C:\Program Files\Microchip\xc16\v2.10\support\dsPIC33E\h" -D __dsPIC33EP128GP504__ pic1.c --showtime=file-total
Checking pic1.c ...
Checking pic1.c: __dsPIC33EP128GP504__=1...
Check time: pic1.c: 1.011s

@sonarqubecloud

Copy link
Copy Markdown

@glankk glankk marked this pull request as draft September 25, 2025 17:14
Comment thread lib/cppcheck.cpp Fixed
@sonarqubecloud

Copy link
Copy Markdown

@glankk glankk force-pushed the 14113 branch 2 times, most recently from 423cb76 to 646c05b Compare June 26, 2026 13:41
Comment thread lib/preprocessor.h Fixed
Comment thread lib/preprocessor.h Fixed
Comment thread lib/preprocessor.h Fixed
@glankk glankk force-pushed the 14113 branch 15 times, most recently from cb700d2 to 6d8d7b3 Compare July 2, 2026 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants