mirror of
https://github.com/github/codeql.git
synced 2026-05-02 12:15:17 +02:00
C++: Use 'getUnderlyingType' instead of 'getUnspecifiedType'.
This commit is contained in:
@@ -709,7 +709,7 @@ class FinalGlobalValue extends Node, TFinalGlobalValue {
|
||||
override DataFlowType getType() {
|
||||
exists(int indirectionIndex |
|
||||
indirectionIndex = globalUse.getIndirectionIndex() and
|
||||
result = getTypeImpl(globalUse.getUnspecifiedType(), indirectionIndex - 1)
|
||||
result = getTypeImpl(globalUse.getUnderlyingType(), indirectionIndex - 1)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -740,7 +740,7 @@ class InitialGlobalValue extends Node, TInitialGlobalValue {
|
||||
|
||||
override DataFlowType getType() {
|
||||
exists(DataFlowType type |
|
||||
type = globalDef.getUnspecifiedType() and
|
||||
type = globalDef.getUnderlyingType() and
|
||||
if this.isGLValue()
|
||||
then result = type
|
||||
else result = getTypeImpl(type, globalDef.getIndirectionIndex() - 1)
|
||||
@@ -942,11 +942,14 @@ private Type getTypeImpl0(Type t, int indirectionIndex) {
|
||||
or
|
||||
indirectionIndex > 0 and
|
||||
exists(Type stripped |
|
||||
stripped = stripPointer(t.stripTopLevelSpecifiers()) and
|
||||
// We need to avoid the case where `stripPointer(t) = t` (which can happen on
|
||||
// iterators that specify a `value_type` that is the iterator itself). Such a type
|
||||
// would create an infinite loop otherwise. For these cases we simply don't produce
|
||||
// a result for `getTypeImpl`.
|
||||
stripped = stripPointer(t) and
|
||||
// We need to avoid the case where `stripPointer(t) = t` (which can happen
|
||||
// on iterators that specify a `value_type` that is the iterator itself).
|
||||
// Such a type would create an infinite loop otherwise. For these cases we
|
||||
// simply don't produce a result for `getTypeImpl`.
|
||||
// To be on the safe side, we check whether the _unspecified_ type has
|
||||
// changed since this also prevents an infinite loop for occuring when
|
||||
// `stripped` and `t` only differ by const'ness or volatile'ness.
|
||||
stripped.getUnspecifiedType() != t.getUnspecifiedType() and
|
||||
result = getTypeImpl0(stripped, indirectionIndex - 1)
|
||||
)
|
||||
@@ -1001,7 +1004,7 @@ private module RawIndirectNodes {
|
||||
type = getOperandType(this.getOperand(), isGLValue) and
|
||||
if isGLValue = true then sub = 1 else sub = 0
|
||||
|
|
||||
result = getTypeImpl(type.getUnspecifiedType(), indirectionIndex - sub)
|
||||
result = getTypeImpl(type.getUnderlyingType(), indirectionIndex - sub)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1043,7 +1046,7 @@ private module RawIndirectNodes {
|
||||
type = getInstructionType(this.getInstruction(), isGLValue) and
|
||||
if isGLValue = true then sub = 1 else sub = 0
|
||||
|
|
||||
result = getTypeImpl(type.getUnspecifiedType(), indirectionIndex - sub)
|
||||
result = getTypeImpl(type.getUnderlyingType(), indirectionIndex - sub)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1136,7 +1139,7 @@ class FinalParameterNode extends Node, TFinalParameterNode {
|
||||
|
||||
override Declaration getEnclosingCallable() { result = this.getFunction() }
|
||||
|
||||
override DataFlowType getType() { result = getTypeImpl(p.getUnspecifiedType(), indirectionIndex) }
|
||||
override DataFlowType getType() { result = getTypeImpl(p.getUnderlyingType(), indirectionIndex) }
|
||||
|
||||
final override Location getLocationImpl() {
|
||||
// Parameters can have multiple locations. When there's a unique location we use
|
||||
@@ -1789,7 +1792,7 @@ class VariableNode extends Node, TVariableNode {
|
||||
}
|
||||
|
||||
override DataFlowType getType() {
|
||||
result = getTypeImpl(v.getUnspecifiedType(), indirectionIndex - 1)
|
||||
result = getTypeImpl(v.getUnderlyingType(), indirectionIndex - 1)
|
||||
}
|
||||
|
||||
final override Location getLocationImpl() {
|
||||
|
||||
@@ -548,6 +548,11 @@ class GlobalUse extends UseImpl, TGlobalUse {
|
||||
*/
|
||||
Type getUnspecifiedType() { result = global.getUnspecifiedType() }
|
||||
|
||||
/**
|
||||
* Gets the type of this use, after typedefs have been resolved.
|
||||
*/
|
||||
Type getUnderlyingType() { result = global.getUnderlyingType() }
|
||||
|
||||
override predicate isCertain() { any() }
|
||||
|
||||
override BaseSourceVariableInstruction getBase() { none() }
|
||||
@@ -591,11 +596,16 @@ class GlobalDefImpl extends DefOrUseImpl, TGlobalDefImpl {
|
||||
int getIndirection() { result = indirectionIndex }
|
||||
|
||||
/**
|
||||
* Gets the type of this use after specifiers have been deeply stripped
|
||||
* and typedefs have been resolved.
|
||||
* Gets the type of this definition after specifiers have been deeply
|
||||
* stripped and typedefs have been resolved.
|
||||
*/
|
||||
Type getUnspecifiedType() { result = global.getUnspecifiedType() }
|
||||
|
||||
/**
|
||||
* Gets the type of this definition, after typedefs have been resolved.
|
||||
*/
|
||||
Type getUnderlyingType() { result = global.getUnderlyingType() }
|
||||
|
||||
override string toString() { result = "Def of " + this.getSourceVariable() }
|
||||
|
||||
override Location getLocation() { result = f.getLocation() }
|
||||
@@ -1115,6 +1125,11 @@ class GlobalDef extends TGlobalDef, SsaDefOrUse {
|
||||
*/
|
||||
DataFlowType getUnspecifiedType() { result = global.getUnspecifiedType() }
|
||||
|
||||
/**
|
||||
* Gets the type of this definition, after typedefs have been resolved.
|
||||
*/
|
||||
DataFlowType getUnderlyingType() { result = global.getUnderlyingType() }
|
||||
|
||||
/** Gets the `IRFunction` whose body is evaluated after this definition. */
|
||||
IRFunction getIRFunction() { result = global.getIRFunction() }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user