Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parser:add minimal limit for col & lnum #503

Merged
merged 1 commit into from
Jan 18, 2024

Conversation

alexs-sh
Copy link
Contributor

@alexs-sh alexs-sh commented Jan 4, 2024

Hello,

The change helps to avoid col and lnum values less than 0.

I faced problems with cppcheck 2.12.0. It can report zero line/column number if a problem is located at the beginning of a file. After applying offsets, the value(s) can be < 0, triggering errors in other places. For example, in trouble.nvim plugin because it can't jump on an invalid source location. The limiting of minimal values helped with the problem.

Here is example of cppcheck report with line/column = 0

Checking src/hash.cpp ...
src/hash.cpp:0:0: information: Too many #ifdef configurations - cppcheck only checks 12 of 20 configurations. Use --force to check all configurations. [toomanyconfigs]

^
src/hash.cpp:1:0: information: Include file: <noheader.h> not found. Please note: Cppcheck does not need standard library headers to get proper results. [missingIncludeSystem]
#include <noheader.h>

Here is trouble.nvim error message, because it interprets the issue position as line 0 and column 0.
image

image

After applying changes, the position becomes valid. Jumping/navigation works fine.
image_2024-01-04_11-07-54

Please feel free to ask for additional modifications/information.

Thank you

@alexs-sh alexs-sh marked this pull request as ready for review January 4, 2024 11:36
cppcheck 2.12.0 can report zero line/column number if a problem is
located at the beginning of a file. After applying offsets, the value(s)
can be < 0, triggering errors in other places.
@mfussenegger mfussenegger merged commit b32127b into mfussenegger:master Jan 18, 2024
3 checks passed
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