Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions docs/language/learn-ql/go/ast.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
digraph ast {
graph [dpi=300];
"x" [shape=rect];
"y" [shape=rect];
"x + y" [shape=rect];
"(x + y)" [shape=rect];
"z" [shape=rect];
"(x + y) * z" [shape=rect];
invis1 [style=invis];
invis2 [style=invis];
invis3 [style=invis];

"(x + y) * z" -> "(x + y)" [label=" 0"];
"(x + y) * z" -> "z" [label=" 1"];
"(x + y)" -> "x + y" [label=" 0"];
"x + y" -> "x" [label=" 0"];
"x + y" -> "y" [label=" 1"];

"z" -> invis1 [style=invis];
invis1 -> invis2 [style=invis];
invis1 -> invis3 [style=invis];
}
Binary file added docs/language/learn-ql/go/ast.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions docs/language/learn-ql/go/cfg.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
digraph cfg {
graph [dpi=300];
rankdir=LR;
"x := 0" -> "p != nil";
"p != nil" -> "x = p.f";
"p != nil" -> "return x";
"x = p.f" -> "return x";
}
Binary file added docs/language/learn-ql/go/cfg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions docs/language/learn-ql/go/cfg2.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
digraph cfg2 {
graph [dpi=300];
rankdir=LR;

"p != nil is true" [shape=box];
"p != nil is false" [shape=box];

"x := 0" -> "p != nil";
"p != nil" -> "p != nil is true";
"p != nil is true" -> "x = p.f";
"p != nil" -> "p != nil is false";
"p != nil is false" -> "return x";
"x = p.f" -> "return x";
}
Binary file added docs/language/learn-ql/go/cfg2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions docs/language/learn-ql/go/dfg.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
digraph dfg {
graph [dpi=300];
rankdir=LR;

"x" [shape=diamond];
"return x" [label=<return <u>x</u>>];

"0" -> "x";
"p.f" -> "x";
"x" -> "return x";
}
Binary file added docs/language/learn-ql/go/dfg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
621 changes: 621 additions & 0 deletions docs/language/learn-ql/go/introduce-libraries-go.rst

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion docs/language/learn-ql/go/ql-for-go.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@ CodeQL for Go

Experiment and learn how to write effective and efficient queries for CodeQL databases generated from Go codebases.

.. toctree::
:hidden:

introduce-libraries-go

- `Basic Go query <https://lgtm.com/help/lgtm/console/ql-go-basic-example>`__: Learn to write and run a simple CodeQL query using LGTM.

Other resources
- :doc:`CodeQL library for Go <introduce-libraries-go>`: When you're analyzing a Go program, you can make use of the large collection of classes in the CodeQL library for Go.

Further reading
---------------

- For the queries used in LGTM, display a `Go query <https://lgtm.com/search?q=language%3Ago&t=rules>`__ and click **Open in query console** to see the code used to find alerts.
Expand Down
15 changes: 15 additions & 0 deletions docs/language/learn-ql/go/ssa.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
digraph ssa {
graph [dpi=300];
rankdir=LR;

"x1" [shape=diamond,label=<x<sub>1</sub>>];
"x2" [shape=diamond,label=<x<sub>2</sub>>];
"x3" [shape=diamond,label=<x<sub>3</sub>>];
"return x" [label=<return <u>x</u>>];

"0" -> "x1";
"p.f" -> "x2";
"x1" -> "x3";
"x2" -> "x3";
"x3" -> "return x";
}
Binary file added docs/language/learn-ql/go/ssa.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.