Add test for extracting a Java AST with an error expression

Also note that ErrorExpr can occur outside upgrade/downgrade scripts
This commit is contained in:
Chris Smowton
2023-08-16 11:14:04 +01:00
parent 8aeb9b9ae0
commit c0f8973749
5 changed files with 47 additions and 1 deletions

View File

@@ -0,0 +1,30 @@
Test.java:
# 0| [CompilationUnit] Test
# 1| 1: [Class] Test
# 3| 2: [Method] yield
# 3| 3: [TypeAccess] int
#-----| 4: (Parameters)
# 3| 0: [Parameter] x
# 3| 0: [TypeAccess] int
# 3| 5: [BlockStmt] { ... }
# 3| 0: [ReturnStmt] return ...
# 3| 0: [VarAccess] x
# 5| 3: [Method] secondCall
# 5| 3: [TypeAccess] void
# 5| 5: [BlockStmt] { ... }
# 7| 4: [Method] yieldWrapper
# 7| 3: [TypeAccess] int
#-----| 4: (Parameters)
# 7| 0: [Parameter] x
# 7| 0: [TypeAccess] int
# 7| 5: [BlockStmt] { ... }
# 8| 0: [LocalVariableDeclStmt] var ...;
# 8| 0: [TypeAccess] int
# 8| 1: [LocalVariableDeclExpr] ret
# 8| 0: [ErrorExpr] <error expr>
# 8| 0: [MethodAccess] yield(...)
# 8| 0: [VarAccess] x
# 9| 1: [ExprStmt] <Expr>;
# 9| 0: [MethodAccess] secondCall(...)
# 10| 2: [ReturnStmt] return ...
# 10| 0: [VarAccess] ret

View File

@@ -0,0 +1 @@
semmle/code/java/PrintAst.ql

View File

@@ -0,0 +1,13 @@
public class Test {
public int yield(int x) { return x; }
public void secondCall() { }
public int yieldWrapper(int x) {
int ret = yield(x);
secondCall();
return ret;
}
}

View File

@@ -0,0 +1 @@
//semmle-extractor-options: --no-strict-javac-errors --javac-args -source 17 -target 17