Skip to content

Catch preprocessor errors possibly issued during loading files#2430

Merged
versat merged 3 commits into
cppcheck-opensource:masterfrom
versat:catch_simplecpp_load_errors
Dec 9, 2019
Merged

Catch preprocessor errors possibly issued during loading files#2430
versat merged 3 commits into
cppcheck-opensource:masterfrom
versat:catch_simplecpp_load_errors

Conversation

@versat
Copy link
Copy Markdown
Collaborator

@versat versat commented Dec 6, 2019

Currently, only errors that are issued during preprocessing are caught.
Related simplecpp issue: cppcheck-opensource/simplecpp#183 simplecpp PR: cppcheck-opensource/simplecpp#184

Currently only errors that are issued during preprocessing are caught.
@versat versat requested a review from danmar December 6, 2019 12:00
Copy link
Copy Markdown
Collaborator

@danmar danmar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking at this!

Comment thread lib/cppcheck.cpp Outdated
Comment thread lib/preprocessor.cpp Outdated
Use return value checking instead of catching an exception for calling
Preprocessor::loadFiles().
Handle new enum value simplecpp::Output::EXPLICIT_INCLUDE_NOT_FOUND
where the corresponding enum is used in Cppcheck.
@versat
Copy link
Copy Markdown
Collaborator Author

versat commented Dec 9, 2019

@danmar I have implemented your suggestions, bumped simplecpp and adapted the code accordingly.
If an explicit include is not found Cppcheck now prints the following:

$ ./cppcheck --include=some_header.h foo.c
Checking foo.c ...
foo.c:1:0: error: Can not open include file 'some_header.h' that is explicitly included. [preprocessorErrorDirective]
int main()
^

@versat versat changed the title Also catch preprocessor errors possibly issued during loading files Catch preprocessor errors possibly issued during loading files Dec 9, 2019
@versat
Copy link
Copy Markdown
Collaborator Author

versat commented Dec 9, 2019

The last commit changes the error output so "noloc" is used instead of a specific filename/location.
Output now looks like this:

$ ./cppcheck --include=some_header.h foo.c
Checking foo.c ...
nofile:0:0: error: Can not open include file 'some_header.h' that is explicitly included. [preprocessorErrorDirective]

Copy link
Copy Markdown
Collaborator

@danmar danmar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for my comment about location.. feel free to merge this!

@versat
Copy link
Copy Markdown
Collaborator Author

versat commented Dec 9, 2019

Thanks

@versat versat merged commit 95696ea into cppcheck-opensource:master Dec 9, 2019
@versat versat deleted the catch_simplecpp_load_errors branch December 10, 2019 07:07
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