C++: Resolve typedefs when matching MaD parameters#18386
C++: Resolve typedefs when matching MaD parameters#18386MathiasVP merged 8 commits intogithub:mainfrom
typedefs when matching MaD parameters#18386Conversation
…d-write' by about 8%.
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
Files not reviewed (6)
- cpp/ql/lib/semmle/code/cpp/dataflow/ExternalFlow.qll: Language not supported
- cpp/ql/test/library-tests/dataflow/models-as-data/FlowSummaryNode.expected: Language not supported
- cpp/ql/test/library-tests/dataflow/models-as-data/SummaryCall.expected: Language not supported
- cpp/ql/test/library-tests/dataflow/models-as-data/testModels.qll: Language not supported
- cpp/ql/test/library-tests/dataflow/models-as-data/tests.cpp: Language not supported
- cpp/ql/test/library-tests/dataflow/taint-tests/test_mad-signatures.expected: Language not supported
Tip: Copilot only keeps its highest confidence comments to reduce noise and keep you focused. Learn more
geoffw0
left a comment
There was a problem hiding this comment.
LGTM, some very minor corrections.
| ) | ||
| or | ||
| not t instanceof DerivedType and | ||
| not t instanceof TypedefType and |
There was a problem hiding this comment.
I'm trying to convince myself ArrayType doesn't need to be a special case here. Because getName already handles it adequately???
There was a problem hiding this comment.
We could add ArrayType as well. I didn't bother with it because very very few parameters are actually declared as array types (since they decay to pointers anyway). But we can add them just to be safe in case we ever want to model some strange function that has an array as a parameter.
There was a problem hiding this comment.
Might be better to address it now and avoid surprises in future then - but I don't feel strongly about this.
Co-authored-by: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Co-authored-by: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Co-authored-by: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Co-authored-by: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
The various implementations of the STL differ on the exact name of the types of some of the parameters. For example, some implementations specify
std::vector::insertas:while others do this instead:
these are completely identical since containers are required to declare
value_typeas a synonym forT. However, until this PR we would match the parameter type name against whatever type name is specified. With the current MaD models, this meant we only matched against the implementations that pickedconst T&, but not the ones that pickedconst value_type&.This PR fixes this by allowing both the unresolved and the typedef-resolved type name. This ensures that we can continue to use the typedef'ed name when it's convenient (for example, when a parameter must have type
size_typewhich is platform dependent).Our
Typeclass actually comes with a perfectly reasonable predicate for resolving typedefs while retaining whatever specifiers are attached to the type:codeql/cpp/ql/lib/semmle/code/cpp/Type.qll
Lines 279 to 284 in f23e56b
Commit-by-commit review recommended: