|
4 | 4 | Libclang tutorial
|
5 | 5 | =================
|
6 | 6 | The C Interface to Clang provides a relatively small API that exposes facilities for parsing source code into an abstract syntax tree (AST), loading already-parsed ASTs, traversing the AST, associating physical source locations with elements within the AST, and other facilities that support Clang-based development tools.
|
7 |
| -This C interface to Clang will never provide all of the information representation stored in Clang's C++ AST, nor should it: the intent is to maintain an API that is relatively stable from one release to the next, providing only the basic functionality needed to support development tools. |
| 7 | +This C interface to Clang will never provide all of the information representation stored in Clang's C++ AST, nor should it: the intent is to maintain an API that is :ref:`relatively stable <Stability>` from one release to the next, providing only the basic functionality needed to support development tools. |
8 | 8 | The entire C interface of libclang is available in the file `Index.h`_
|
9 | 9 |
|
10 | 10 | Essential types overview
|
@@ -358,3 +358,49 @@ Complete example code
|
358 | 358 |
|
359 | 359 |
|
360 | 360 | .. _Index.h: https://github.com/llvm/llvm-project/blob/main/clang/include/clang-c/Index.h
|
| 361 | + |
| 362 | +.. _Stability: |
| 363 | + |
| 364 | +ABI and API Stability |
| 365 | +--------------------- |
| 366 | + |
| 367 | +The C interfaces in libclang are intended to be relatively stable. This allows |
| 368 | +a programmer to use libclang without having to worry as much about Clang |
| 369 | +upgrades breaking existing code. However, the library is not unchanging. For |
| 370 | +example, the library will gain new interfaces over time as needs arise, |
| 371 | +existing APIs may be deprecated for eventual removal, etc. Also, the underlying |
| 372 | +implementation of the facilities by Clang may change behavior as bugs are |
| 373 | +fixed, features get implemented, etc. |
| 374 | + |
| 375 | +The library should be ABI and API stable over time, but ABI- and API-breaking |
| 376 | +changes can happen in the following (non-exhaustive) situations: |
| 377 | + |
| 378 | +* Adding new enumerator to an enumeration (can be ABI-breaking in C++). |
| 379 | +* Removing an explicitly deprecated API after a suitably long deprecation |
| 380 | + period. |
| 381 | +* Using implementation details, such as names or comments that say something |
| 382 | + is "private", "reserved", "internal", etc. |
| 383 | +* Bug fixes and changes to Clang's internal implementation happen routinely and |
| 384 | + will change the behavior of callers. |
| 385 | +* Rarely, bug fixes to libclang itself. |
| 386 | + |
| 387 | +The library has version macros (``CINDEX_VERSION_MAJOR``, |
| 388 | +``CINDEX_VERSION_MINOR``, and ``CINDEX_VERSION``) which can be used to test for |
| 389 | +specific library versions at compile time. The ``CINDEX_VERSION_MAJOR`` macro |
| 390 | +is only incremented if there are major source- or ABI-breaking changes. Except |
| 391 | +for removing an explicitly deprecated API, the changes listed above are not |
| 392 | +considered major source- or ABI-breaking changes. Historically, the value this |
| 393 | +macro expands to has not changed, but may be incremented in the future should |
| 394 | +the need arise. The ``CINDEX_VERSION_MINOR`` macro is incremented as new APIs |
| 395 | +are added. The ``CINDEX_VERSION`` macro expands to a value based on the major |
| 396 | +and minor version macros. |
| 397 | + |
| 398 | +In an effort to allow the library to be modified as new needs arise, the |
| 399 | +following situations are explicitly unsupported: |
| 400 | + |
| 401 | +* Loading different library versions into the same executable and passing |
| 402 | + objects between the libraries; despite general ABI stability, different |
| 403 | + versions of the library may use different implementation details that are not |
| 404 | + compatible across library versions. |
| 405 | +* For the same reason as above, serializing objects from one version of the |
| 406 | + library and deserializing with a different version is also not supported. |
0 commit comments