clang – C language family frontend for LLVM

Clang is a compiler front end for the C, C++, and Objective-C programming languages. It uses the Low Level Virtual Machine (LLVM) as its back end. The combination of clang and LLVM provides the majority of a toolchain, allowing the replacement of the whole GCC stack.

One of clang’s primary goals is to better support incremental compilation to allow the compiler to be more tightly tied to the IDE GUI.

Clang is carefully and thoughtfully designed and built to provide the foundation of a whole new generation of C/C++/Objective C development tools.

Clang supports a broad variety of language extensions. These extensions are provided to be compatible with the GCC, Microsoft, and other popular compilers as well as to improve functionality through clang-specific features. The Clang driver and language features are intentionally designed to be as compatible with the GCC compiler as reasonably possible, easing migration from GCC to Clang.

Features include:

  • Fast compiles and low memory use – the library-based architecture of clang makes it straight-forward to time and profile the cost of each layer of the stack.
  • Expressive diagnostics, making the diagnostics (error and warning messages) generated by the compiler be as useful as possible.
  • GCC compatibility.
  • Modular library based architecture:
    • libsupport – Basic support library, from LLVM.
    • libsystem – System abstraction library, from LLVM.
    • libbasic – Diagnostics, SourceLocations, SourceBuffer abstraction, file system caching for input source files.
    • libast – Provides classes to represent the C AST, the C type system, builtin functions, and various helpers for analyzing and manipulating the AST (visitors, pretty printers, etc).
    • liblex – Lexing and preprocessing, identifier hash table, pragma handling, tokens, and macro expansion.
    • libparse – Parsing. This library invokes coarse-grained ‘Actions’ provided by the client (e.g. libsema builds ASTs) but knows nothing about ASTs or other client-specific data structures.
    • libsema – Semantic Analysis. This provides a set of parser actions to build a standardized AST for programs.
    • libcodegen – Lower the AST to LLVM IR for optimization & code generation.
    • librewrite – Editing of text buffers (important for code rewriting transformation, like refactoring).
    • libanalysis – Static analysis support.
    • libindex – Cross-translation-unit infrastructure and indexing support.
    • clang – A driver program, client of the libraries at various levels.
  • Support diverse clients (refactoring, static analysis, code generation, etc).
  • Allow tight integration with IDEs.
  • A real-world, production quality compiler.
  • A simple and hackable code base.
  • A single unified parser for C, Objective C, C++, and Objective C++.
  • Conformance with C/C++/ObjC and their variants.

Support: Manual
Developer: Chris Lattner and contributors
License: University of Illinois / NCSA Open Source License

Clang is written in C++. Learn C++ with our recommended free books and free tutorials.

Return to Compilers Home Page

Ongoing series
Linux for StartersNew to Linux? Read our Linux for Starters series.
Free and Open Source SoftwareThe largest compilation of the best free and open source software in the universe. Supplied with our legendary ratings charts.
Linux ReviewsHundreds of in-depth reviews offering our unbiased and expert opinion on software.
Alternatives to GoogleAlternatives to Google's Products and Services examines your options to migrate from the Google ecosystem with open source Linux alternatives.
MicrosoftAlternatives to Microsoft's Products and Services recommends open source Linux software.
Linux System ToolsEssential Linux system tools looks at small, indispensable utilities, useful for system administrators as well as regular users.
Linux ProductivityLinux utilities to maximise your productivity. Small, indispensable tools, useful for anyone running a Linux machine.
Home Computer EmulatorsHome computers became commonplace in the 1980s. Emulate home computers including the Commodore 64, Amiga, Atari ST, ZX81, Amstrad CPC, and ZX Spectrum.
Now and ThenNow and Then examines how promising open source software fared over the years.
Linux at HomeLinux at Home looks at a range of home activities where Linux can play its part, making the most of our time at home, keeping active and engaged.
Linux CandyLinux Candy opens up to the lighter side of Linux. Have some fun!
Best Free Android AppsBest Free Android Apps. There's a strict eligibility criteria for inclusion in this series
Programming BooksThese best free books accelerate your learning of every programming language
Programming TutorialsThese free tutorials offer the perfect tonic to the free programming books series
Stars and StripesStars and Stripes is an occasional series looking at the impact of Linux in the USA
Share this article

Share your Thoughts

This site uses Akismet to reduce spam. Learn how your comment data is processed.