{"id":16954027,"url":"https://github.com/amaiorano/hsm-analyze","last_synced_at":"2025-06-13T19:04:57.847Z","repository":{"id":79016529,"uuid":"81574512","full_name":"amaiorano/hsm-analyze","owner":"amaiorano","description":"A tool based on Clang LibTooling that analyzes C++ code that makes use of the HSM library","archived":false,"fork":false,"pushed_at":"2018-06-28T15:00:10.000Z","size":35,"stargazers_count":5,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-13T19:03:53.117Z","etag":null,"topics":["graphviz","hsm-library","libtooling","llvm","state-machine"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amaiorano.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-10T14:46:43.000Z","updated_at":"2024-12-31T06:27:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"dfac43c1-cc30-400b-af94-853c2b14dc45","html_url":"https://github.com/amaiorano/hsm-analyze","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/amaiorano/hsm-analyze","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amaiorano%2Fhsm-analyze","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amaiorano%2Fhsm-analyze/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amaiorano%2Fhsm-analyze/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amaiorano%2Fhsm-analyze/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amaiorano","download_url":"https://codeload.github.com/amaiorano/hsm-analyze/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amaiorano%2Fhsm-analyze/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259704412,"owners_count":22898858,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graphviz","hsm-library","libtooling","llvm","state-machine"],"created_at":"2024-10-13T22:08:34.033Z","updated_at":"2025-06-13T19:04:57.818Z","avatar_url":"https://github.com/amaiorano.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hsm-analyze\n\nhsm-analyze is a tool based on [Clang LibTooling](https://clang.llvm.org/docs/LibTooling.html) that analyzes C++ code that makes use of [the HSM library](https://github.com/amaiorano/hsm). It can be used to:\n\n- Provide useful information about potential problems with a given state machine\n- Output graphs of state machines (e.g. GraphViz dot files)\n\n\n## Usage\n\nThese instructions are for Windows. For Linux or Mac, follow instructions for how to build hsm-analyze (below) and adapt as necessary.\n\n- [Download](https://github.com/amaiorano/hsm-analyze/releases) the latest version of hsm-analyze.\n\n- Install a distribution of LLVM that matches the LLVM version that was used to build hsm-analyze from [here (recommended)](https://sourceforge.net/projects/clangonwin/files/MsvcBuild/) or [here](http://releases.llvm.org/download.html).\n\n- Copy the single hsm-analyze executable to your LLVM/bin directory (e.g. ```C:\\Program Files\\LLVM\\bin```). This is required for most LibTooling-based tools to access Clang's C++ standard headers.\n\n- Install [GraphViz](http://www.graphviz.org/Download.php) to render state machines graphs.\n\nLike all Clang tools based on LibTooling, you can pass compilation arguments to hsm-analyze via command line following a double-dash (\"--\"), or by using a compilation database (read about how to generate and use a compilation database [here](https://clang.llvm.org/docs/HowToSetupToolingForLLVM.html)).\n\nHere's an example of how to output a GraphViz dot file from a cpp file:\n\n```\nhsm-analyze -dot c:\\code\\hsm\\samples\\hsm_book_samples\\source\\ch4\\reusable_states.cpp -- -Ic:\\code\\hsm\\include \u003e reusable_states.dot\n```\n\nwhich produces the following dot file contents:\n\n```\nstrict digraph G {\n  fontname=Helvetica;\n  nodesep=0.6;\n  //rankdir=LR\n  CharacterStates__Alive -\u003e CharacterStates__Stand [style=\"bold\", weight=\"1\", color=\"black\"]\n  CharacterStates__Attack -\u003e CharacterStates__Stand [style=\"dotted\", weight=\"50\", color=\"black\", dir=\"both\"]\n  CharacterStates__Attack -\u003e CharacterStates__PlayAnim [style=\"bold\", weight=\"1\", color=\"black\"]\n  CharacterStates__PlayAnim -\u003e CharacterStates__PlayAnim_Done [style=\"dotted\", weight=\"50\", color=\"black\"]\n  CharacterStates__PlayAnim -\u003e CharacterStates__PlayAnim [style=\"dotted\", weight=\"50\", color=\"black\", dir=\"both\"]\n\n  subgraph cluster_CharacterStates { label = \"CharacterStates\"; labeljust=left;\n    subgraph {\n      rank=same // depth=0\n      CharacterStates__Alive [label=\"Alive\", fontcolor=white, style=filled, color=\"0.033617 0.500000 0.250000\"]\n    }\n  }\n\n  subgraph cluster_CharacterStates { label = \"CharacterStates\"; labeljust=left;\n    subgraph {\n      rank=same // depth=1\n      CharacterStates__Attack [label=\"Attack\", fontcolor=white, style=filled, color=\"0.033617 0.500000 0.475000\"]\n      CharacterStates__Stand [label=\"Stand\", fontcolor=white, style=filled, color=\"0.033617 0.500000 0.475000\"]\n    }\n  }\n\n  subgraph cluster_CharacterStates { label = \"CharacterStates\"; labeljust=left;\n    subgraph {\n      rank=same // depth=2\n      CharacterStates__PlayAnim [label=\"PlayAnim\", fontcolor=white, style=filled, color=\"0.033617 0.500000 0.700000\"]\n      CharacterStates__PlayAnim_Done [label=\"PlayAnim_Done\", fontcolor=white, style=filled, color=\"0.033617 0.500000 0.700000\"]\n    }\n  }\n\n}\n```\n\nTo render it with GraphViz:\n\n```bash\ndot -Tpng -o reusable_states.png reusable_states.dot\n```\n\nwhich produces the following png:\n\n![reusable_states.png](https://github.com/amaiorano/hsm-analyze/wiki/images/reusable_states.png)\n\n\n## How to build\n\nOn Windows:\n\n* Download and install the a binary distribution of [ClangOnWin](https://sourceforge.net/projects/clangonwin/files/MsvcBuild/). **NOTE:** At the time of this writing, hsm-analyze successfully builds with VS2015 and VS2017 against [LLVM-4.0.0svn-r277264-require-python35dll-win64](https://freefr.dl.sourceforge.net/project/clangonwin/MsvcBuild/4.0/LLVM-4.0.0svn-r277264-require-python35dll-win64.exe) and [LLVM-5.0.0svn-r302983-win64](https://ayera.dl.sourceforge.net/project/clangonwin/MsvcBuild/5.0/LLVM-5.0.0svn-r302983-win64.exe).\n\n* Assuming you've installed it to the default location, C:\\Program Files\\LLVM, here's how you'd build hsm-analyze with Visual Studio 2015:\n\n```\ngit clone https://github.com/amaiorano/hsm-analyze.git\ncd hsm-analyze\nmkdir build \u0026\u0026 cd build\ncmake -G \"Visual Studio 14 2015 Win64\" -DCMAKE_PREFIX_PATH=\"C:\\Program Files\\LLVM\\lib\\cmake\" -DUSE_RELEASE_LIBS_IN_DEBUG=On ..\n```\n\n**NOTE:** The CMake variable ```USE_RELEASE_LIBS_IN_DEBUG``` is needed to build hsm-analyze in the Debug configuration against the ClangOnWin libraries since ClangOnWin does not include Debug libs.\n\n**NOTE:** If the LLVM/Clang libs you want to link against use the MSVC CRT static libraries (rather than DLLs), you can enable the CMake variable ```USE_STATIC_CRT```.\n\n* Open the generated sln and build\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famaiorano%2Fhsm-analyze","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famaiorano%2Fhsm-analyze","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famaiorano%2Fhsm-analyze/lists"}