@@ -709,7 +709,7 @@ class FinalGlobalValue extends Node, TFinalGlobalValue {
709
709
override DataFlowType getType ( ) {
710
710
exists ( int indirectionIndex |
711
711
indirectionIndex = globalUse .getIndirectionIndex ( ) and
712
- result = getTypeImpl ( globalUse .getUnspecifiedType ( ) , indirectionIndex - 1 )
712
+ result = getTypeImpl ( globalUse .getUnderlyingType ( ) , indirectionIndex - 1 )
713
713
)
714
714
}
715
715
@@ -740,7 +740,7 @@ class InitialGlobalValue extends Node, TInitialGlobalValue {
740
740
741
741
override DataFlowType getType ( ) {
742
742
exists ( DataFlowType type |
743
- type = globalDef .getUnspecifiedType ( ) and
743
+ type = globalDef .getUnderlyingType ( ) and
744
744
if this .isGLValue ( )
745
745
then result = type
746
746
else result = getTypeImpl ( type , globalDef .getIndirectionIndex ( ) - 1 )
@@ -943,10 +943,13 @@ private Type getTypeImpl0(Type t, int indirectionIndex) {
943
943
indirectionIndex > 0 and
944
944
exists ( Type stripped |
945
945
stripped = stripPointer ( t .stripTopLevelSpecifiers ( ) ) and
946
- // We need to avoid the case where `stripPointer(t) = t` (which can happen on
947
- // iterators that specify a `value_type` that is the iterator itself). Such a type
948
- // would create an infinite loop otherwise. For these cases we simply don't produce
949
- // a result for `getTypeImpl`.
946
+ // We need to avoid the case where `stripPointer(t) = t` (which can happen
947
+ // on iterators that specify a `value_type` that is the iterator itself).
948
+ // Such a type would create an infinite loop otherwise. For these cases we
949
+ // simply don't produce a result for `getTypeImpl`.
950
+ // To be on the safe side, we check whether the _unspecified_ type has
951
+ // changed since this also prevents an infinite loop when `stripped` and
952
+ // `t` only differ by const'ness or volatile'ness.
950
953
stripped .getUnspecifiedType ( ) != t .getUnspecifiedType ( ) and
951
954
result = getTypeImpl0 ( stripped , indirectionIndex - 1 )
952
955
)
@@ -996,12 +999,14 @@ private module RawIndirectNodes {
996
999
997
1000
override Declaration getEnclosingCallable ( ) { result = this .getFunction ( ) }
998
1001
1002
+ override predicate isGLValue ( ) { this .getOperand ( ) .isGLValue ( ) }
1003
+
999
1004
override DataFlowType getType ( ) {
1000
1005
exists ( int sub , DataFlowType type , boolean isGLValue |
1001
1006
type = getOperandType ( this .getOperand ( ) , isGLValue ) and
1002
1007
if isGLValue = true then sub = 1 else sub = 0
1003
1008
|
1004
- result = getTypeImpl ( type .getUnspecifiedType ( ) , indirectionIndex - sub )
1009
+ result = getTypeImpl ( type .getUnderlyingType ( ) , indirectionIndex - sub )
1005
1010
)
1006
1011
}
1007
1012
@@ -1038,12 +1043,14 @@ private module RawIndirectNodes {
1038
1043
1039
1044
override Declaration getEnclosingCallable ( ) { result = this .getFunction ( ) }
1040
1045
1046
+ override predicate isGLValue ( ) { this .getInstruction ( ) .isGLValue ( ) }
1047
+
1041
1048
override DataFlowType getType ( ) {
1042
1049
exists ( int sub , DataFlowType type , boolean isGLValue |
1043
1050
type = getInstructionType ( this .getInstruction ( ) , isGLValue ) and
1044
1051
if isGLValue = true then sub = 1 else sub = 0
1045
1052
|
1046
- result = getTypeImpl ( type .getUnspecifiedType ( ) , indirectionIndex - sub )
1053
+ result = getTypeImpl ( type .getUnderlyingType ( ) , indirectionIndex - sub )
1047
1054
)
1048
1055
}
1049
1056
@@ -1136,7 +1143,7 @@ class FinalParameterNode extends Node, TFinalParameterNode {
1136
1143
1137
1144
override Declaration getEnclosingCallable ( ) { result = this .getFunction ( ) }
1138
1145
1139
- override DataFlowType getType ( ) { result = getTypeImpl ( p .getUnspecifiedType ( ) , indirectionIndex ) }
1146
+ override DataFlowType getType ( ) { result = getTypeImpl ( p .getUnderlyingType ( ) , indirectionIndex ) }
1140
1147
1141
1148
final override Location getLocationImpl ( ) {
1142
1149
// Parameters can have multiple locations. When there's a unique location we use
@@ -1789,7 +1796,7 @@ class VariableNode extends Node, TVariableNode {
1789
1796
}
1790
1797
1791
1798
override DataFlowType getType ( ) {
1792
- result = getTypeImpl ( v .getUnspecifiedType ( ) , indirectionIndex - 1 )
1799
+ result = getTypeImpl ( v .getUnderlyingType ( ) , indirectionIndex - 1 )
1793
1800
}
1794
1801
1795
1802
final override Location getLocationImpl ( ) {
0 commit comments