close
The Wayback Machine - https://web.archive.org/web/20260329164233/https://github.com/github/codeql/issues/4278
Skip to content

C++ Print AST command should more closely align with the underlying AST #4278

@aeisenberg

Description

@aeisenberg

Based on a discussion with @dbartol, we talked about altering the structure of the Print AST query for C++ so that the structure more closely aligns with the underlying AST.

One example is with type casts. Here is a screenshot from the AST Viewer in VSCode.

uboot-mem-queries_ql_—_vscode-codeql-starter__Workspace_●

Notice that the implication of this tree snippet is that the CStyleCast is a child of the AssignExpr, but in reality, the AssignExpr has two children, both are VariableAcceses. The cast node is off to the side and not directly part of the tree structure. In this case, the Print AST query should remove the CStyleCast from the main tree and ensure the AssignExpr's second AST child is the other VariableAccess.

It would still be useful to include this cast in the tree somehow, perhaps as metadata on the VariableAccess, and this information can be displayed in the tree in a different way.

The goal is to provide the most useful information for new users of Code QL. The implication from the tree is that assignExpr.getRValue() instanceof CStyleCast, but it is not.

There may be more examples of this in the C++ AST. This is the first one I came across.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions