Skip to content

Commit 43accd3

Browse files
author
AndreiDiaconu1
committed
Address PR comments
1 parent 241a40c commit 43accd3

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ newtype TTranslatedElement =
171171
} or
172172
// A creation expression
173173
TTranslatedCreationExpr(Expr expr) {
174-
not ignoreExpr(expr)
174+
not ignoreExpr(expr) and
175+
(expr instanceof ObjectCreation or expr instanceof DelegateCreation)
175176
} or
176177
// A separate element to handle the lvalue-to-rvalue conversion step of an
177178
// expression.
@@ -231,7 +232,7 @@ newtype TTranslatedElement =
231232
or
232233
expr instanceof ObjectInitializer
233234
or
234-
expr = any(ThrowStmt throwStmt).getExpr()
235+
expr = any(ThrowElement throwElement).getExpr()
235236
or
236237
expr = any(CollectionInitializer colInit).getAnElementInitializer()
237238
or

csharp/ql/src/semmle/code/csharp/ir/implementation/raw/internal/TranslatedExpr.qll

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,12 @@ class TranslatedCollectionInitializer extends TranslatedNonConstantExpr, Initial
532532
override Instruction getChildSuccessor(TranslatedElement child) {
533533
exists(int index |
534534
child = this.getChild(index) and
535-
if exists(this.getChild(index + 1))
536-
then result = this.getChild(index + 1).getFirstInstruction()
537-
else result = this.getParent().getChildSuccessor(this)
535+
(
536+
result = this.getChild(index + 1).getFirstInstruction()
537+
or
538+
not exists(this.getChild(index + 1)) and
539+
result = this.getParent().getChildSuccessor(this)
540+
)
538541
)
539542
}
540543

@@ -2028,14 +2031,11 @@ class TranslatedObjectCreation extends TranslatedCreation {
20282031

20292032
override TranslatedExpr getInitializerExpr() { result = getTranslatedExpr(expr.getInitializer()) }
20302033

2031-
override TranslatedExpr getConstructorCall() {
2034+
override TranslatedConstructorCall getConstructorCall() {
20322035
// Since calls are also expressions, we can't
20332036
// use the predicate getTranslatedExpr (since that would
20342037
// also return `this`).
2035-
exists(TranslatedConstructorCall cc |
2036-
cc.getAST() = this.getAST() and
2037-
result = cc
2038-
)
2038+
result.getAST() = this.getAST()
20392039
}
20402040
}
20412041

0 commit comments

Comments
 (0)