mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
C++: support Decltype in suspicious-call-to-memset
This commit is contained in:
@@ -41,11 +41,13 @@ Type stripType(Type t) {
|
||||
result = stripType(t.(ArrayType).getBaseType()) or
|
||||
result = stripType(t.(ReferenceType).getBaseType()) or
|
||||
result = stripType(t.(SpecifiedType).getBaseType()) or
|
||||
result = stripType(t.(Decltype).getBaseType()) or
|
||||
(
|
||||
not t instanceof TypedefType and
|
||||
not t instanceof ArrayType and
|
||||
not t instanceof ReferenceType and
|
||||
not t instanceof SpecifiedType and
|
||||
not t instanceof Decltype and
|
||||
result = t
|
||||
)
|
||||
}
|
||||
|
||||
@@ -171,3 +171,10 @@ void more_tests_2()
|
||||
memset(iapa, 0, sizeof(iapa)); // GOOD
|
||||
memset(iapa, 0, sizeof(intArrayPointer *)); // BAD
|
||||
}
|
||||
|
||||
void more_tests_3()
|
||||
{
|
||||
myStruct ms;
|
||||
decltype(&ms) msPtr = &ms;
|
||||
memset(msPtr, 0, sizeof(myStruct)); // GOOD
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user