mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
C++: Print handler parameters in PrintAST
This commit is contained in:
@@ -80,6 +80,8 @@ private Declaration getAnEnclosingDeclaration(Locatable ast) {
|
||||
or
|
||||
result = ast.(Parameter).getFunction()
|
||||
or
|
||||
result = ast.(Parameter).getCatchBlock().getEnclosingFunction()
|
||||
or
|
||||
result = ast.(Expr).getEnclosingDeclaration()
|
||||
or
|
||||
result = ast.(Initializer).getDeclaration()
|
||||
@@ -510,6 +512,22 @@ class DeclStmtNode extends StmtNode {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A node representing a `Handler`.
|
||||
*/
|
||||
class HandlerNode extends ChildStmtNode {
|
||||
Handler handler;
|
||||
|
||||
HandlerNode() { handler = stmt }
|
||||
|
||||
override BaseAstNode getChildInternal(int childIndex) {
|
||||
result = super.getChildInternal(childIndex)
|
||||
or
|
||||
childIndex = -1 and
|
||||
result.getAst() = handler.getParameter()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A node representing a `Parameter`.
|
||||
*/
|
||||
@@ -754,6 +772,8 @@ private predicate namedStmtChildPredicates(Locatable s, Element e, string pred)
|
||||
or
|
||||
s.(ConstexprIfStmt).getElse() = e and pred = "getElse()"
|
||||
or
|
||||
s.(Handler).getParameter() = e and pred = "getParameter()"
|
||||
or
|
||||
s.(IfStmt).getInitialization() = e and pred = "getInitialization()"
|
||||
or
|
||||
s.(IfStmt).getCondition() = e and pred = "getCondition()"
|
||||
|
||||
@@ -870,6 +870,8 @@ Throw.cpp:
|
||||
# 8| Type = [BoolType] bool
|
||||
# 8| ValueCategory = prvalue
|
||||
# 12| getChild(1): [Handler] <handler>
|
||||
# 12| getParameter(): [Parameter] e
|
||||
# 12| Type = [PointerType] E *
|
||||
# 12| getBlock(): [CatchBlock] { ... }
|
||||
# 13| getStmt(0): [ExprStmt] ExprStmt
|
||||
# 13| getExpr(): [ReThrowExpr] re-throw exception
|
||||
|
||||
@@ -9055,6 +9055,8 @@ ir.cpp:
|
||||
# 733| Value = [Literal] 7
|
||||
# 733| ValueCategory = prvalue
|
||||
# 735| getChild(1): [Handler] <handler>
|
||||
# 735| getParameter(): [Parameter] s
|
||||
# 735| Type = [PointerType] const char *
|
||||
# 735| getBlock(): [CatchBlock] { ... }
|
||||
# 736| getStmt(0): [ExprStmt] ExprStmt
|
||||
# 736| getExpr(): [ThrowExpr] throw ...
|
||||
@@ -9067,6 +9069,8 @@ ir.cpp:
|
||||
# 736| Type = [PointerType] const char *
|
||||
# 736| ValueCategory = prvalue(load)
|
||||
# 738| getChild(2): [Handler] <handler>
|
||||
# 738| getParameter(): [Parameter] e
|
||||
# 738| Type = [LValueReferenceType] const String &
|
||||
# 738| getBlock(): [CatchBlock] { ... }
|
||||
# 740| getChild(3): [Handler] <handler>
|
||||
# 740| getBlock(): [CatchAnyBlock] { ... }
|
||||
@@ -12852,6 +12856,8 @@ ir.cpp:
|
||||
# 1200| Value = [Literal] 7
|
||||
# 1200| ValueCategory = prvalue
|
||||
# 1202| getChild(1): [Handler] <handler>
|
||||
# 1202| getParameter(): [Parameter] s
|
||||
# 1202| Type = [PointerType] const char *
|
||||
# 1202| getBlock(): [CatchBlock] { ... }
|
||||
# 1203| getStmt(0): [ExprStmt] ExprStmt
|
||||
# 1203| getExpr(): [ThrowExpr] throw ...
|
||||
@@ -12864,6 +12870,8 @@ ir.cpp:
|
||||
# 1203| Type = [PointerType] const char *
|
||||
# 1203| ValueCategory = prvalue(load)
|
||||
# 1205| getChild(2): [Handler] <handler>
|
||||
# 1205| getParameter(): [Parameter] e
|
||||
# 1205| Type = [LValueReferenceType] const String &
|
||||
# 1205| getBlock(): [CatchBlock] { ... }
|
||||
# 1207| getStmt(1): [ReturnStmt] return ...
|
||||
# 1211| [TopLevelFunction] void VectorTypes(int)
|
||||
@@ -20586,6 +20594,8 @@ ir.cpp:
|
||||
# 2281| Type = [Struct] String
|
||||
# 2281| ValueCategory = lvalue
|
||||
# 2282| getChild(1): [Handler] <handler>
|
||||
# 2282| getParameter(): [Parameter] s
|
||||
# 2282| Type = [PointerType] const char *
|
||||
# 2282| getBlock(): [CatchBlock] { ... }
|
||||
# 2283| getStmt(0): [ExprStmt] ExprStmt
|
||||
# 2283| getExpr(): [ThrowExpr] throw ...
|
||||
@@ -20598,6 +20608,8 @@ ir.cpp:
|
||||
# 2283| Type = [PointerType] const char *
|
||||
# 2283| ValueCategory = prvalue(load)
|
||||
# 2285| getChild(2): [Handler] <handler>
|
||||
# 2285| getParameter(): [Parameter] e
|
||||
# 2285| Type = [LValueReferenceType] const String &
|
||||
# 2285| getBlock(): [CatchBlock] { ... }
|
||||
# 2287| getChild(3): [Handler] <handler>
|
||||
# 2287| getBlock(): [CatchAnyBlock] { ... }
|
||||
@@ -22845,6 +22857,8 @@ ir.cpp:
|
||||
# 2537| Value = [Literal] 42
|
||||
# 2537| ValueCategory = prvalue
|
||||
# 2539| getChild(1): [Handler] <handler>
|
||||
# 2539| getParameter(): [Parameter] (unnamed parameter 0)
|
||||
# 2539| Type = [PlainCharType] char
|
||||
# 2539| getBlock(): [CatchBlock] { ... }
|
||||
# 2541| getImplicitDestructorCall(0): [DestructorCall] call to ~ClassWithDestructor
|
||||
# 2541| Type = [VoidType] void
|
||||
|
||||
Reference in New Issue
Block a user