Skip to content

Commit e1adf5e

Browse files
authored
Merge pull request github#5218 from MathiasVP/no-write-side-effects-for-const-pointer-params
C++: Don't generate write side effects for const parameter indirections
2 parents 2c4ba56 + 299f371 commit e1adf5e

File tree

4 files changed

+396
-463
lines changed

4 files changed

+396
-463
lines changed

cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,14 +658,18 @@ newtype TTranslatedElement =
658658
t instanceof ReferenceType
659659
) and
660660
(
661-
isWrite = true or
661+
isWrite = true and
662+
not call.getTarget().getParameter(n).getType().isDeeplyConstBelow()
663+
or
662664
isWrite = false
663665
)
664666
or
665667
not call.getTarget() instanceof SideEffectFunction and
666668
n = -1 and
667669
(
668-
isWrite = true or
670+
isWrite = true and
671+
not call.getTarget() instanceof ConstMemberFunction
672+
or
669673
isWrite = false
670674
)
671675
) and

0 commit comments

Comments
 (0)