Skip to content
This repository

A collection of code samples showing usage of clang and llvm as a library

branch: master
Octocat-spinner-32 Win Fix Windows Build Break against mainline. March 25, 2012
Octocat-spinner-32 .gitignore Add Tooling example. October 20, 2012
Octocat-spinner-32 CIBasicRecursiveASTVisitor.cpp update mainline to svn 205387 April 03, 2014
Octocat-spinner-32 CIrewriter.cpp update mainline to svn 205387 April 03, 2014
Octocat-spinner-32 CItutorial1.cpp update mainline to svn 205387 April 03, 2014
Octocat-spinner-32 CItutorial2.cpp update mainline to svn 205387 April 03, 2014
Octocat-spinner-32 CItutorial3.cpp update mainline to svn 205387 April 03, 2014
Octocat-spinner-32 CItutorial4.cpp update mainline to svn 205387 April 03, 2014
Octocat-spinner-32 CItutorial6.cpp update mainline to svn 205387 April 03, 2014
Octocat-spinner-32 CREDITS.txt Add credits. December 21, 2011
Octocat-spinner-32 CommentHandling.cpp update mainline to svn 199626 January 20, 2014
Octocat-spinner-32 LICENSE.txt Fix the License. December 21, 2011
Octocat-spinner-32 README.markdown update mainline to svn 205387 April 03, 2014
Octocat-spinner-32 ToolingTutorial.cpp update mainline to svn 199626 January 20, 2014
Octocat-spinner-32 compile_commands.json Add Tooling example. October 20, 2012
Octocat-spinner-32 input04.c Fix tutorial 6 to match the writeups. April 14, 2012
Octocat-spinner-32 invalidInputTest.c Handle outputing parsing error cases November 28, 2010
Octocat-spinner-32 makefile update mainline to svn 205387 April 03, 2014
Octocat-spinner-32 test.c Updated the comments to point to the LICENSE. December 03, 2012
Octocat-spinner-32 testInclude.c Updated the comments to point to the LICENSE. December 03, 2012
Octocat-spinner-32 tutorial1.cpp update mainline to svn 195570 November 24, 2013
Octocat-spinner-32 tutorial2.cpp update mainline to svn 195570 November 24, 2013
Octocat-spinner-32 tutorial3.cpp update mainline to svn 195570 November 24, 2013
Octocat-spinner-32 tutorial4.cpp update mainline to svn 195570 November 24, 2013
Octocat-spinner-32 tutorial6.cpp update mainline to svn 195570 November 24, 2013
README.markdown

About

This is a collection of tutorials showing off how to use core Clang types. It is based directly on two older tutorials which no longer built due to code rot.

  1. tutorial 1 by Nico Weber - 9/28/2008
  2. tutorial 2 by Justin LaPre at Rensselaer Polytechnic Institute - 10/20/2009
  3. 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.

See contents of the links above for a walkthrough of what these tutorials are doing.

Last Update

This was last built on 4/3/2014 against
URL: http://llvm.org/svn/llvm-project/llvm/trunk
Revision:205387

Other Options

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.

Latest Stable LLVM / Clang (v3.4)

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 you have modified the makefile of this project to point to the build's resulting llvm-config. If you want the latest public release, then checkout the 3.4 branch.

git clone git@github.com:loarabia/Clang-tutorial.git
git checkout 3.4

CI tutorials

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.

Tooling tutorials

These tutorials (and the clang tooling infrastrucutre) depend on having a file called compile_commands.json which defines the commands used to compile the input file. You will need to modify this file's directory field to point to the absolute path of the Clang-tutorial on your storage.

Windows Build

Note on the Windows build: Currently the paths are hardcoded. Please see the SharedBuild.targets file inside of the SharedBuild project to update the path for your specific LLVM and CLANG install.

In particular, the LLVMLibsDirs property and the LLVMIncludes property should be updated.

Contact Me

For any questions, please ping me via my github account. Changes and additions are always welcome.

Something went wrong with that request. Please try again.