@@ -709,7 +709,7 @@ class FinalGlobalValue extends Node, TFinalGlobalValue {
709709 override DataFlowType getType ( ) {
710710 exists ( int indirectionIndex |
711711 indirectionIndex = globalUse .getIndirectionIndex ( ) and
712- result = getTypeImpl ( globalUse .getUnspecifiedType ( ) , indirectionIndex - 1 )
712+ result = getTypeImpl ( globalUse .getUnderlyingType ( ) , indirectionIndex - 1 )
713713 )
714714 }
715715
@@ -740,7 +740,7 @@ class InitialGlobalValue extends Node, TInitialGlobalValue {
740740
741741 override DataFlowType getType ( ) {
742742 exists ( DataFlowType type |
743- type = globalDef .getUnspecifiedType ( ) and
743+ type = globalDef .getUnderlyingType ( ) and
744744 if this .isGLValue ( )
745745 then result = type
746746 else result = getTypeImpl ( type , globalDef .getIndirectionIndex ( ) - 1 )
@@ -943,10 +943,13 @@ private Type getTypeImpl0(Type t, int indirectionIndex) {
943943 indirectionIndex > 0 and
944944 exists ( Type stripped |
945945 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.
950953 stripped .getUnspecifiedType ( ) != t .getUnspecifiedType ( ) and
951954 result = getTypeImpl0 ( stripped , indirectionIndex - 1 )
952955 )
@@ -996,12 +999,14 @@ private module RawIndirectNodes {
996999
9971000 override Declaration getEnclosingCallable ( ) { result = this .getFunction ( ) }
9981001
1002+ override predicate isGLValue ( ) { this .getOperand ( ) .isGLValue ( ) }
1003+
9991004 override DataFlowType getType ( ) {
10001005 exists ( int sub , DataFlowType type , boolean isGLValue |
10011006 type = getOperandType ( this .getOperand ( ) , isGLValue ) and
10021007 if isGLValue = true then sub = 1 else sub = 0
10031008 |
1004- result = getTypeImpl ( type .getUnspecifiedType ( ) , indirectionIndex - sub )
1009+ result = getTypeImpl ( type .getUnderlyingType ( ) , indirectionIndex - sub )
10051010 )
10061011 }
10071012
@@ -1038,12 +1043,14 @@ private module RawIndirectNodes {
10381043
10391044 override Declaration getEnclosingCallable ( ) { result = this .getFunction ( ) }
10401045
1046+ override predicate isGLValue ( ) { this .getInstruction ( ) .isGLValue ( ) }
1047+
10411048 override DataFlowType getType ( ) {
10421049 exists ( int sub , DataFlowType type , boolean isGLValue |
10431050 type = getInstructionType ( this .getInstruction ( ) , isGLValue ) and
10441051 if isGLValue = true then sub = 1 else sub = 0
10451052 |
1046- result = getTypeImpl ( type .getUnspecifiedType ( ) , indirectionIndex - sub )
1053+ result = getTypeImpl ( type .getUnderlyingType ( ) , indirectionIndex - sub )
10471054 )
10481055 }
10491056
@@ -1136,7 +1143,7 @@ class FinalParameterNode extends Node, TFinalParameterNode {
11361143
11371144 override Declaration getEnclosingCallable ( ) { result = this .getFunction ( ) }
11381145
1139- override DataFlowType getType ( ) { result = getTypeImpl ( p .getUnspecifiedType ( ) , indirectionIndex ) }
1146+ override DataFlowType getType ( ) { result = getTypeImpl ( p .getUnderlyingType ( ) , indirectionIndex ) }
11401147
11411148 final override Location getLocationImpl ( ) {
11421149 // Parameters can have multiple locations. When there's a unique location we use
@@ -1789,7 +1796,7 @@ class VariableNode extends Node, TVariableNode {
17891796 }
17901797
17911798 override DataFlowType getType ( ) {
1792- result = getTypeImpl ( v .getUnspecifiedType ( ) , indirectionIndex - 1 )
1799+ result = getTypeImpl ( v .getUnderlyingType ( ) , indirectionIndex - 1 )
17931800 }
17941801
17951802 final override Location getLocationImpl ( ) {
0 commit comments