-
Notifications
You must be signed in to change notification settings - Fork 1.8k
C++: Initial telemetry queries #17892
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
Conversation
913056a
to
8035a7c
Compare
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.
Is there are specific reason we're not re-using some of the functionality already present in cpp/ql/src/Diagnostics
?
cpp/ql/test/library-tests/extraction_errors/CompilerErrors.expected
Outdated
Show resolved
Hide resolved
The code in |
Not even the libraries in that directory are of use? |
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.
Some questions about the used tags.
Well, telemetry is a bit simpler because it's a question of dumping counts and raw data, so we don't need to refine them in the same way. |
201f282
to
ac692ee
Compare
4fc90ca
to
8029eb2
Compare
CannotOpenFile() { this.hasTag(["cannot_open_file", "cannot_open_file_reason"]) } | ||
|
||
string getIncludedFile() { | ||
result = this.getMessage().regexpCapture("cannot open source file '([^']+)'", 1) |
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.
Note that this regex does not what you want in the case of cannot_open_file_reason
, i.e., you get the reason as part of the result string.
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.
Yea, I've no real way of testing this as I've never seen the extractor produce this error message. I suppose a .*
at the end of the regex might be reasonable?
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.
Are the file names always quoted? This is non-obvious from the frontend source code.
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.
Yes, I tested this on some real databases. But an integration test is clearly needed then. Qltest cannot test this situation due to the absence of SEMMLE_CPP_MISSING_INCLUDES_NOT_FATAL
.
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 think that having some integration test for this is the only thing that still needs addressing?
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.
Here it is: https://github.com/github/semmle-code/pull/51788
CannotOpenFile() { this.hasTag(["cannot_open_file", "cannot_open_file_reason"]) } | ||
|
||
string getIncludedFile() { | ||
result = this.getMessage().regexpCapture("cannot open source file '([^']+)'", 1) |
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.
Are the file names always quoted? This is non-obvious from the frontend source code.
cpp/ql/test/library-tests/extraction_errors/MissingIncludes.qlref
Outdated
Show resolved
Hide resolved
a4a18be
to
76cfb7b
Compare
76cfb7b
to
317f43d
Compare
This adds new internal telemetry queries, so should not need a changenote.
It loosely follows the examples in https://github.com/github/codeql/tree/main/java/ql/src/Telemetry and https://github.com/github/codeql/tree/main/csharp/ql/src/Telemetry.
As a new idea,
Metrics.qll
uses QL classes a bit more heavily, instead of binary predicates, but obviously they boil down to the same thing.We don't (yet) emit a diagnostic warning about low quality databases.
Note that qltest can't test for missing includes, since these lead to a catastrophic error by default.
Fixes https://github.com/github/codeql-c-team/issues/2471
Pull Request checklist
All query authors
[ ] A change note is added if necessary. See the documentation in this repository.[ ] All new queries have appropriate.qhelp
. See the documentation in this repository.Internal query authors only
[ ] Autofixes generated based on these changes are valid, only needed if this PR makes significant changes to.ql
,.qll
, or.qhelp
files. See the documentation (internal access required).[ ] Adding a new query? Consider also adding the query to autofix.