mirror of
https://github.com/github/codeql.git
synced 2026-04-22 07:15:15 +02:00
Merge pull request #15626 from MathiasVP/fix-constness-checking
C++: Don't strip specifiers away in `TFinalParameterUse`
This commit is contained in:
@@ -142,7 +142,7 @@ private newtype TDefOrUseImpl =
|
||||
exists(SsaInternals0::Def def |
|
||||
def.getSourceVariable().getBaseVariable().(BaseIRVariable).getIRVariable().getAst() = p and
|
||||
not def.getValue().asInstruction() instanceof InitializeParameterInstruction and
|
||||
unspecifiedTypeIsModifiableAt(p.getUnspecifiedType(), indirectionIndex)
|
||||
underlyingTypeIsModifiableAt(p.getUnderlyingType(), indirectionIndex)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -172,11 +172,13 @@ private predicate isGlobalDefImpl(
|
||||
)
|
||||
}
|
||||
|
||||
private predicate unspecifiedTypeIsModifiableAt(Type unspecified, int indirectionIndex) {
|
||||
indirectionIndex = [1 .. getIndirectionForUnspecifiedType(unspecified).getNumberOfIndirections()] and
|
||||
private predicate underlyingTypeIsModifiableAt(Type underlying, int indirectionIndex) {
|
||||
indirectionIndex =
|
||||
[1 .. getIndirectionForUnspecifiedType(underlying.getUnspecifiedType())
|
||||
.getNumberOfIndirections()] and
|
||||
exists(CppType cppType |
|
||||
cppType.hasUnspecifiedType(unspecified, _) and
|
||||
isModifiableAt(cppType, indirectionIndex + 1)
|
||||
cppType.hasUnderlyingType(underlying, false) and
|
||||
isModifiableAt(cppType, indirectionIndex)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -452,7 +452,7 @@ private module IsModifiableAtImpl {
|
||||
private predicate impl(CppType cppType, int indirectionIndex) {
|
||||
exists(Type pointerType, Type base |
|
||||
isUnderlyingIndirectionType(pointerType) and
|
||||
cppType.hasUnderlyingType(pointerType, _) and
|
||||
cppType.hasUnderlyingType(pointerType, false) and
|
||||
base = getTypeImpl(pointerType, indirectionIndex)
|
||||
|
|
||||
// The value cannot be modified if it has a const specifier,
|
||||
|
||||
Reference in New Issue
Block a user