clang – C language family frontend for LLVM

Last Updated on July 10, 2021

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.

Website: clang.llvm.org
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


Popular series
Free and Open Source SoftwareThe largest compilation of the best free and open source software in the universe. Each article is supplied with a legendary ratings chart helping you to make informed decisions.
ReviewsHundreds of in-depth reviews offering our unbiased and expert opinion on software. We offer helpful and impartial information.
Alternatives to Proprietary SoftwareReplace proprietary software with open source alternatives: Google, Microsoft, Apple, Adobe, IBM, Autodesk, Oracle, Atlassian, Corel, Cisco, Intuit, and SAS.
GamesAwesome Free Linux Games Tools showcases a series of tools that making gaming on Linux a more pleasurable experience. This is a new series.
Artificial intelligence iconMachine Learning explores practical applications of machine learning and deep learning from a Linux perspective. This is a new series.
Guide to LinuxNew to Linux? Read our Linux for Starters series. We start right at the basics and teach you everything you need to know to get started with Linux.
Alternatives to popular CLI tools showcases essential tools that are modern replacements for core Linux utilities.
System ToolsEssential Linux system tools focuses on small, indispensable utilities, useful for system administrators as well as regular users.
ProductivityLinux utilities to maximise your productivity. Small, indispensable tools, useful for anyone running a Linux machine.
AudioSurveys popular streaming services from a Linux perspective: Amazon Music Unlimited, Myuzi, Spotify, Deezer, Tidal.
Saving Money with LinuxSaving Money with Linux looks at how you can reduce your energy bills running Linux.
Home ComputersHome 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. It can be a bumpy ride.
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 reveals the lighter side of Linux. Have some fun and escape from the daily drudgery.
DockerGetting Started with Docker helps you master Docker, a set of platform as a service products that delivers software in packages called containers.
Android AppsBest Free Android Apps. We showcase free Android apps that are definitely worth downloading. There's a strict eligibility criteria for inclusion in this series.
Programming BooksThese best free books accelerate your learning of every programming language. Learn a new language today!
Programming TutorialsThese free tutorials offer the perfect tonic to our free programming books series.
Linux Around The WorldLinux Around The World showcases usergroups that are relevant to Linux enthusiasts. Great ways to meet up with fellow enthusiasts.
Stars and StripesStars and Stripes is an occasional series looking at the impact of Linux in the USA.
Subscribe
Notify of
guest

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

0 Comments
Inline Feedbacks
View all comments