Skip to content

Commit 19b4258

Browse files
authored
[Docs] Some updates to the Clang user's manual (#151702)
* Fills out the terminology section * Removes the basic usage section (we should bring it back someday though!) * Updates the list of supported language versions * Adds information about what versions of Clang are officially supported * Moves some extensions into the intentionally unsupported extensions section. There are likely far more updates that could be done, but this seemed worth posting just to get things moving.
1 parent a24fae3 commit 19b4258

File tree

1 file changed

+71
-48
lines changed

1 file changed

+71
-48
lines changed

clang/docs/UsersManual.rst

Lines changed: 71 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ which includes :ref:`C <c>`, :ref:`Objective-C <objc>`, :ref:`C++ <cxx>`, and
3535
language-specific information, please see the corresponding language
3636
specific section:
3737

38-
- :ref:`C Language <c>`: K&R C, ANSI C89, ISO C90, ISO C94 (C89+AMD1), ISO
39-
C99 (+TC1, TC2, TC3).
38+
- :ref:`C Language <c>`: K&R C, ANSI C89, ISO C90, C94 (C89+AMD1), C99 (+TC1,
39+
TC2, TC3), C11, C17, C23, and C2y.
4040
- :ref:`Objective-C Language <objc>`: ObjC 1, ObjC 2, ObjC 2.1, plus
4141
variants depending on base language.
42-
- :ref:`C++ Language <cxx>`
42+
- :ref:`C++ Language <cxx>`: C++98, C++03, C++11, C++14, C++17, C++20, C++23,
43+
and C++26.
4344
- :ref:`Objective C++ Language <objcxx>`
4445
- :ref:`OpenCL Kernel Language <opencl>`: OpenCL C 1.0, 1.1, 1.2, 2.0, 3.0,
4546
and C++ for OpenCL 1.0 and 2021.
@@ -60,29 +61,55 @@ features that depend on what CPU architecture or operating system is
6061
being compiled for. Please see the :ref:`Target-Specific Features and
6162
Limitations <target_features>` section for more details.
6263

63-
The rest of the introduction introduces some basic :ref:`compiler
64-
terminology <terminology>` that is used throughout this manual and
65-
contains a basic :ref:`introduction to using Clang <basicusage>` as a
66-
command line compiler.
67-
6864
.. _terminology:
6965

7066
Terminology
7167
-----------
68+
* Lexer -- the part of the compiler responsible for converting source code into
69+
abstract representations called tokens.
70+
* Preprocessor -- the part of the compiler responsible for in-place textual
71+
replacement of source constructs. When the lexer is required to produce a
72+
token, it will run the preprocessor while determining which token to produce.
73+
In other words, when the lexer encounters something like `#include` or a macro
74+
name, the preprocessor will be used to perform the inclusion or expand the
75+
macro name into its replacement list, and return the resulting non-preprocessor
76+
token.
77+
* Parser -- the part of the compiler responsible for determining syntactic
78+
correctness of the source code. The parser will request tokens from the lexer
79+
and after performing semantic analysis of the production, generates an
80+
abstract representation of the source called an AST.
81+
* Sema -- the part of the compiler responsible for determining semantic
82+
correctness of the source code. It is closely related to the parser and is
83+
where many diagnostics are produced.
84+
* Diagnostic -- a message to the user about properties of the source code. For
85+
example, errors or warnings and their associated notes.
86+
* Undefined behavior -- behavior for which the standard imposes no requirements
87+
on how the code behaves. Generally speaking, undefined behavior is a bug in
88+
the user's code. However, it can also be a place for the compiler to define
89+
the behavior, called an extension.
90+
* Optimizer -- the part of the compiler responsible for transforming code to
91+
have better performance characteristics without changing the semantics of how
92+
the code behaves. Note, the optimizer assumes the code has no undefined
93+
behavior, so if the code does contain undefined behavior, it will often behave
94+
differently depending on which optimization level is enabled.
95+
* Frontend -- the Lexer, Preprocessor, Parser, Sema, and LLVM IR code generation
96+
parts of the compiler.
97+
* Middle-end -- a term used for the of the subset of the backend that does
98+
(typically not target specific) optimizations prior to assembly code
99+
generation.
100+
* Backend -- the parts of the compiler which run after LLVM IR code generation,
101+
such as the optimizer and generation of assembly code.
102+
103+
See the :doc:`InternalsManual` for more details about the internal construction
104+
of the compiler.
105+
106+
Support
107+
-------
108+
Clang releases happen roughly `every six months <https://llvm.org/docs/HowToReleaseLLVM.html#annual-release-schedule>`_.
109+
Only the current public release is officially supported. Bug-fix releases for
110+
the current release will be produced on an as-needed basis, but bug fixes are
111+
not backported to releases older than the current one.
72112

73-
Front end, parser, backend, preprocessor, undefined behavior,
74-
diagnostic, optimizer
75-
76-
.. _basicusage:
77-
78-
Basic Usage
79-
-----------
80-
81-
Intro to how to use a C compiler for newbies.
82-
83-
compile + link compile then link debug info enabling optimizations
84-
picking a language to use, defaults to C17 by default. Autosenses based
85-
on extension. using a makefile
86113

87114
Command Line Options
88115
====================
@@ -3797,8 +3824,8 @@ This environment variable does not affect the options added by the config files.
37973824
C Language Features
37983825
===================
37993826

3800-
The support for standard C in clang is feature-complete except for the
3801-
C99 floating-point pragmas.
3827+
The support for standard C in Clang is mostly feature-complete, see the `C
3828+
status page <https://clang.llvm.org/c_status.html>`_ for more details.
38023829

38033830
Extensions supported by clang
38043831
-----------------------------
@@ -3883,23 +3910,10 @@ GCC extensions not implemented yet
38833910
----------------------------------
38843911

38853912
clang tries to be compatible with gcc as much as possible, but some gcc
3886-
extensions are not implemented yet:
3913+
extensions are not implemented:
38873914

38883915
- clang does not support decimal floating point types (``_Decimal32`` and
38893916
friends) yet.
3890-
- clang does not support nested functions; this is a complex feature
3891-
which is infrequently used, so it is unlikely to be implemented
3892-
anytime soon. In C++11 it can be emulated by assigning lambda
3893-
functions to local variables, e.g:
3894-
3895-
.. code-block:: cpp
3896-
3897-
auto const local_function = [&](int parameter) {
3898-
// Do something
3899-
};
3900-
...
3901-
local_function(1);
3902-
39033917
- clang only supports global register variables when the register specified
39043918
is non-allocatable (e.g. the stack pointer). Support for general global
39053919
register variables is unlikely to be implemented soon because it requires
@@ -3914,18 +3928,13 @@ extensions are not implemented yet:
39143928
that because clang pretends to be like GCC 4.2, and this extension
39153929
was introduced in 4.3, the glibc headers will not try to use this
39163930
extension with clang at the moment.
3917-
- clang does not support the gcc extension for forward-declaring
3918-
function parameters; this has not shown up in any real-world code
3919-
yet, though, so it might never be implemented.
39203931

39213932
This is not a complete list; if you find an unsupported extension
3922-
missing from this list, please send an e-mail to cfe-dev. This list
3923-
currently excludes C++; see :ref:`C++ Language Features <cxx>`. Also, this
3924-
list does not include bugs in mostly-implemented features; please see
3925-
the `bug
3926-
tracker <https://bugs.llvm.org/buglist.cgi?quicksearch=product%3Aclang+component%3A-New%2BBugs%2CAST%2CBasic%2CDriver%2CHeaders%2CLLVM%2BCodeGen%2Cparser%2Cpreprocessor%2CSemantic%2BAnalyzer>`_
3927-
for known existing bugs (FIXME: Is there a section for bug-reporting
3928-
guidelines somewhere?).
3933+
missing from this list, please file a `feature request <https://github.com/llvm/llvm-project/issues/>`_.
3934+
This list currently excludes C++; see :ref:`C++ Language Features <cxx>`. Also,
3935+
this list does not include bugs in mostly-implemented features; please see the
3936+
`issues list <https://github.com/llvm/llvm-project/issues/>`_ for known existing
3937+
bugs.
39293938

39303939
Intentionally unsupported GCC extensions
39313940
----------------------------------------
@@ -3944,6 +3953,20 @@ Intentionally unsupported GCC extensions
39443953
variable) will likely never be accepted by Clang.
39453954
- clang does not support ``__builtin_apply`` and friends; this extension
39463955
is extremely obscure and difficult to implement reliably.
3956+
- clang does not support the gcc extension for forward-declaring
3957+
function parameters.
3958+
- clang does not support nested functions; this is a complex feature which is
3959+
infrequently used, so it is unlikely to be implemented. In C++11 it can be
3960+
emulated by assigning lambda functions to local variables, e.g:
3961+
3962+
.. code-block:: cpp
3963+
3964+
auto const local_function = [&](int parameter) {
3965+
// Do something
3966+
};
3967+
...
3968+
local_function(1);
3969+
39473970
39483971
.. _c_ms:
39493972

@@ -3983,7 +4006,7 @@ C++ Language Features
39834006

39844007
clang fully implements all of standard C++98 except for exported
39854008
templates (which were removed in C++11), all of standard C++11,
3986-
C++14, and C++17, and most of C++20.
4009+
C++14, and C++17, and most of C++20 and C++23.
39874010

39884011
See the `C++ support in Clang <https://clang.llvm.org/cxx_status.html>`_ page
39894012
for detailed information on C++ feature support across Clang versions.

0 commit comments

Comments
 (0)