From be175aa1a056fdb99196d1bf8fd06cf44d247f6e Mon Sep 17 00:00:00 2001 From: Mathias Vorreiter Pedersen Date: Fri, 9 Aug 2024 15:19:54 +0100 Subject: [PATCH] C#: Prevent bad magic in a few predicates. --- csharp/ql/lib/semmle/code/csharp/commons/ComparisonTest.qll | 1 + csharp/ql/lib/semmle/code/csharp/exprs/Call.qll | 1 + 2 files changed, 2 insertions(+) diff --git a/csharp/ql/lib/semmle/code/csharp/commons/ComparisonTest.qll b/csharp/ql/lib/semmle/code/csharp/commons/ComparisonTest.qll index b4641560892..6a804f54490 100644 --- a/csharp/ql/lib/semmle/code/csharp/commons/ComparisonTest.qll +++ b/csharp/ql/lib/semmle/code/csharp/commons/ComparisonTest.qll @@ -305,6 +305,7 @@ class ComparisonTest extends TComparisonTest { } /** Gets an argument of this comparison test. */ + pragma[nomagic] Expr getAnArgument() { result = this.getFirstArgument() or result = this.getSecondArgument() diff --git a/csharp/ql/lib/semmle/code/csharp/exprs/Call.qll b/csharp/ql/lib/semmle/code/csharp/exprs/Call.qll index 7a3cf0ea8d9..6b34f338d6e 100644 --- a/csharp/ql/lib/semmle/code/csharp/exprs/Call.qll +++ b/csharp/ql/lib/semmle/code/csharp/exprs/Call.qll @@ -40,6 +40,7 @@ class Call extends Expr, @call { Callable getTarget() { none() } /** Gets the `i`th argument to this call, if any. */ + pragma[nomagic] Expr getArgument(int i) { result = this.getChild(i) and i >= 0 } /**