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
C++: Add PreprocBlock.qll library #15476
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments. I'd like to see two things fixed before we merge this:
- I think we should strip away all the
cachedand only re-introduce them if we actually end up seeing expensive re-evaluation. - I think we should fix all the implicit
thiswarnings
But other than that this LGTM!
| /** | ||
| * Gets the file this `PreprocessorBlock` is located in. | ||
| */ | ||
| cached |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm slightly worried about all these cached annotations on all predicates. Other than possibly getPreprocLineFromIndex, none of these predicates look very expensive
|
Thanks for the comments. I agree and I've addressed the issues with implicit this and the change note. Still to remove the |
The
PreprocBlock.qlllibrary offers a view of#if,#elif,#elseand similar directives (and the code they contain) as a tree. That is, there's a parent-child relationship between blocks (identified by their opening directive), as well as the ability to tell what include statements and macro definitions are contained within each block.The
preprocblock.expectedtest is a good place to start if the above isn't crystal clear.This is actually an old library, but until now it's not been available in the codeql repo.