1- private import RangeAnalysisStage
21private import RangeAnalysisConstantSpecific
32private import RangeAnalysisRelativeSpecific
43private import semmle.code.cpp.rangeanalysis.new.internal.semantic.analysis.FloatDelta
54private import RangeUtils
5+ private import semmle.code.cpp.rangeanalysis.new.internal.semantic.SemanticExpr
6+ private import semmle.code.cpp.rangeanalysis.new.internal.semantic.SemanticCFG
7+ private import semmle.code.cpp.rangeanalysis.new.internal.semantic.SemanticGuard
68private import semmle.code.cpp.rangeanalysis.new.internal.semantic.SemanticBound as SemanticBound
79private import semmle.code.cpp.rangeanalysis.new.internal.semantic.SemanticLocation
810private import semmle.code.cpp.rangeanalysis.new.internal.semantic.SemanticSSA
11+ private import semmle.code.cpp.rangeanalysis.new.internal.semantic.SemanticType as SemanticType
12+ private import SemanticType
13+ private import codeql.rangeanalysis.RangeAnalysis
14+ private import ConstantAnalysis as ConstantAnalysis
915
10- module ConstantBounds implements BoundSig< FloatDelta > {
16+ module Sem implements Semantic {
17+ class Expr = SemExpr ;
18+
19+ class ConstantIntegerExpr = ConstantAnalysis:: SemConstantIntegerExpr ;
20+
21+ class BinaryExpr = SemBinaryExpr ;
22+
23+ class AddExpr = SemAddExpr ;
24+
25+ class SubExpr = SemSubExpr ;
26+
27+ class MulExpr = SemMulExpr ;
28+
29+ class DivExpr = SemDivExpr ;
30+
31+ class RemExpr = SemRemExpr ;
32+
33+ class BitAndExpr = SemBitAndExpr ;
34+
35+ class BitOrExpr = SemBitOrExpr ;
36+
37+ class ShiftLeftExpr = SemShiftLeftExpr ;
38+
39+ class ShiftRightExpr = SemShiftRightExpr ;
40+
41+ class ShiftRightUnsignedExpr = SemShiftRightUnsignedExpr ;
42+
43+ class RelationalExpr = SemRelationalExpr ;
44+
45+ class UnaryExpr = SemUnaryExpr ;
46+
47+ class ConvertExpr = SemConvertExpr ;
48+
49+ class BoxExpr = SemBoxExpr ;
50+
51+ class UnboxExpr = SemUnboxExpr ;
52+
53+ class NegateExpr = SemNegateExpr ;
54+
55+ class AddOneExpr = SemAddOneExpr ;
56+
57+ class SubOneExpr = SemSubOneExpr ;
58+
59+ class ConditionalExpr = SemConditionalExpr ;
60+
61+ class BasicBlock = SemBasicBlock ;
62+
63+ class Guard = SemGuard ;
64+
65+ predicate implies_v2 = semImplies_v2 / 4 ;
66+
67+ predicate guardDirectlyControlsSsaRead = semGuardDirectlyControlsSsaRead / 3 ;
68+
69+ class Type = SemType ;
70+
71+ class IntegerType = SemIntegerType ;
72+
73+ class FloatingPointType = SemFloatingPointType ;
74+
75+ class AddressType = SemAddressType ;
76+
77+ class SsaVariable = SemSsaVariable ;
78+
79+ class SsaPhiNode = SemSsaPhiNode ;
80+
81+ class SsaExplicitUpdate = SemSsaExplicitUpdate ;
82+
83+ class SsaReadPosition = SemSsaReadPosition ;
84+
85+ class SsaReadPositionPhiInputEdge = SemSsaReadPositionPhiInputEdge ;
86+
87+ class SsaReadPositionBlock = SemSsaReadPositionBlock ;
88+
89+ predicate backEdge = semBackEdge / 3 ;
90+
91+ predicate conversionCannotOverflow ( Type fromType , Type toType ) {
92+ SemanticType:: conversionCannotOverflow ( fromType , toType )
93+ }
94+ }
95+
96+ module SignAnalysis implements SignAnalysisSig< Sem > {
97+ private import SignAnalysisCommon as SA
98+ import SA:: SignAnalysis< FloatDelta , Util >
99+ }
100+
101+ module ConstantBounds implements BoundSig< SemLocation , Sem , FloatDelta > {
11102 class SemBound instanceof SemanticBound:: SemBound {
12103 SemBound ( ) {
13104 this instanceof SemanticBound:: SemZeroBound
@@ -29,7 +120,7 @@ module ConstantBounds implements BoundSig<FloatDelta> {
29120 }
30121}
31122
32- module RelativeBounds implements BoundSig< FloatDelta > {
123+ module RelativeBounds implements BoundSig< SemLocation , Sem , FloatDelta > {
33124 class SemBound instanceof SemanticBound:: SemBound {
34125 SemBound ( ) { not this instanceof SemanticBound:: SemZeroBound }
35126
@@ -47,13 +138,38 @@ module RelativeBounds implements BoundSig<FloatDelta> {
47138 }
48139}
49140
141+ module AllBounds implements BoundSig< SemLocation , Sem , FloatDelta > {
142+ class SemBound instanceof SemanticBound:: SemBound {
143+ string toString ( ) { result = super .toString ( ) }
144+
145+ SemLocation getLocation ( ) { result = super .getLocation ( ) }
146+
147+ SemExpr getExpr ( float delta ) { result = super .getExpr ( delta ) }
148+ }
149+
150+ class SemZeroBound extends SemBound instanceof SemanticBound:: SemZeroBound { }
151+
152+ class SemSsaBound extends SemBound instanceof SemanticBound:: SemSsaBound {
153+ SemSsaVariable getAVariable ( ) { result = this .( SemanticBound:: SemSsaBound ) .getAVariable ( ) }
154+ }
155+ }
156+
157+ private module ModulusAnalysisInstantiated implements ModulusAnalysisSig< Sem > {
158+ class ModBound = AllBounds:: SemBound ;
159+
160+ private import semmle.code.cpp.rangeanalysis.new.internal.semantic.analysis.ModulusAnalysis as MA
161+ import MA:: ModulusAnalysis< FloatDelta , AllBounds , Util >
162+ }
163+
164+ module Util = RangeUtil< FloatDelta , CppLangImplConstant > ;
165+
50166module ConstantStage =
51- RangeStage< FloatDelta , ConstantBounds , FloatOverflow , CppLangImplConstant ,
52- RangeUtil < FloatDelta , CppLangImplConstant > > ;
167+ RangeStage< SemLocation , Sem , FloatDelta , ConstantBounds , FloatOverflow , CppLangImplConstant ,
168+ SignAnalysis , ModulusAnalysisInstantiated , Util > ;
53169
54170module RelativeStage =
55- RangeStage< FloatDelta , RelativeBounds , FloatOverflow , CppLangImplRelative ,
56- RangeUtil < FloatDelta , CppLangImplRelative > > ;
171+ RangeStage< SemLocation , Sem , FloatDelta , RelativeBounds , FloatOverflow , CppLangImplRelative ,
172+ SignAnalysis , ModulusAnalysisInstantiated , Util > ;
57173
58174private newtype TSemReason =
59175 TSemNoReason ( ) or
0 commit comments