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

C++: Add PreprocBlock.qll library #15476

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Conversation

geoffw0
Copy link
Contributor

@geoffw0 geoffw0 commented Jan 30, 2024

The PreprocBlock.qll library offers a view of #if, #elif, #else and 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.expected test 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.

@geoffw0 geoffw0 added the C++ label Jan 30, 2024
@geoffw0 geoffw0 requested a review from a team as a code owner January 30, 2024 17:40
Copy link
Contributor

@MathiasVP MathiasVP left a 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 cached and only re-introduce them if we actually end up seeing expensive re-evaluation.
  • I think we should fix all the implicit this warnings

But other than that this LGTM!

cpp/ql/lib/change-notes/2024-01-30-preproc-block.md Outdated Show resolved Hide resolved
/**
* Gets the file this `PreprocessorBlock` is located in.
*/
cached
Copy link
Contributor

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

@geoffw0
Copy link
Contributor Author

geoffw0 commented Feb 2, 2024

Thanks for the comments. I agree and I've addressed the issues with implicit this and the change note. Still to remove the cached annotations, I want to do that somewhat carefully to make sure performance isn't impacted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants