This is a collection of examples showing off how to use core Clang and LLVM. It is based directly on two older tutorials which no longer built due to code rot. It will try to make anyone who is interested in LLVM and Clang could dig into them as soon as possible.
This project forked from loarabia / Clang-tutorial, and extend it for not only more Clang tutorial cases, but also plenty of LLVM tutorials cases, and we have also adjust the source code layout.
It contains:
- LLVMQuickStart
- LLVMJIT
- ClangSimple
- ClangCompilerInstance
Status:All the codes have been tested by LLVM SVN Trunk r179830(2013-4-20).
The project webpage is here
This tutorial is for get a first impression of llvm tools like clang, lli, llvm-dis, etc.
This tutorial is used to know how the LLVM IR is created and assemed.
It is used to know how to create a preprocessor, lexer and parser based on Clang Front End. It uses the basic interfaces and classes.
It can help to know how to use the CompilerInstance class for preprocessor, lexer and parser creation.
All these cases comes from, or derived from the following project and web post.
- Getting Started with the LLVM System from LLVM.org
- llvm-tutorials from fabriceleal
- llvm_tutorial from r7kamura
- kaleidoscope from maxsnew
- tutorial 1 by Nico Weber - 9/28/2008
- tutorial 2 by Justin LaPre at Rensselaer Polytechnic Institute - 10/20/2009
- tutorial 3 by Larry Olson - 4/14/2012
This particular set of tutorials tracks the llvm / clang mainline and is updated semi-regularly to account for llvm / clang API changes.
The Clang team has been hard at work making it easier to write tools using Clang. There are 4 options for developing tools using clang and llvm infrastructure.
The master branch tracks recent commits to the clang and llvm svn. The tutorial assumes you have grabbed a copy of both llvm and clang by following these instructions and that have installed the the resulting binaries by running make install
. If you want the latest public release, then checkout the 3.7 branch.
git clone [email protected]:Lingcc/Clang-LLVM-tutorial.git
git checkout 3.7
The tutorials prefixed with CI are the same as the original tutorials but use the CompilerInstance object and its helper methods to perform the same tasks as the original tutorials. For the most part, this makes the code much more compact.
For any questions, you can:
- ping me on github
- email me [email protected]