C++: Resolve typedef
s when matching MaD parameters
#18386
+313
−14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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::insert
as:while others do this instead:
these are completely identical since containers are required to declare
value_type
as 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_type
which is platform dependent).Our
Type
class 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: