Skip to content

hohn/codeql-cpp-ast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AST Sample for C++ Source

Create dot output from query and db, and then get a rendered graph in SVG.

# 
export PATH=$HOME/local/vmsync/codeql250:"$PATH"

# Build db
cd ~/w/codeql-cpp/src/
codeql database create -j8 -v --language=cpp --command="clang example.cpp" -s . example.db

# Edit printast.ql in editor to select function

# Create dot graph 
cd ~/w/codeql-cpp/queries/
codeql database analyze                         \
       ~/w/codeql-cpp/src/example.db/           \
       ~/w/codeql-cpp/queries/printast.ql       \
       -j8 -v --ram=16000                       \
       --format=dot                             \
       --output=printast.dot

# Query produced .dot file
cd ~/w/codeql-cpp/
ls queries/printast.dot/cpp/print-ast.dot

# Query produced .bqrs file
ls src/example.db/results/ast-queries-cpp/printast.bqrs 

# Generate SVG
cd ~/w/codeql-cpp/queries/printast.dot/cpp
dot -Tsvg < ./print-ast.dot > ./print-ast.svg
open -a safari ./print-ast.svg

./queries/printast.dot/cpp/print-ast.svg

About

Illustrations of codeql's AST

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published