2019-07-18 19:51:05 +08:00
|
|
|
====================================================
|
2020-07-15 17:40:53 +08:00
|
|
|
Extra Clang Tools 12.0.0 (In-Progress) Release Notes
|
2019-07-18 19:51:05 +08:00
|
|
|
====================================================
|
2016-03-27 13:06:57 +08:00
|
|
|
|
|
|
|
.. contents::
|
|
|
|
:local:
|
2016-03-30 20:05:33 +08:00
|
|
|
:depth: 3
|
2016-03-27 13:06:57 +08:00
|
|
|
|
2018-09-10 16:52:04 +08:00
|
|
|
Written by the `LLVM Team <https://llvm.org/>`_
|
2016-03-27 13:06:57 +08:00
|
|
|
|
|
|
|
.. warning::
|
|
|
|
|
2020-07-15 17:40:53 +08:00
|
|
|
These are in-progress notes for the upcoming Extra Clang Tools 12 release.
|
2017-02-10 07:25:52 +08:00
|
|
|
Release notes for previous releases can be found on
|
2018-09-10 16:52:04 +08:00
|
|
|
`the Download Page <https://releases.llvm.org/download.html>`_.
|
2016-03-27 13:06:57 +08:00
|
|
|
|
|
|
|
Introduction
|
|
|
|
============
|
|
|
|
|
|
|
|
This document contains the release notes for the Extra Clang Tools, part of the
|
2020-07-15 17:40:53 +08:00
|
|
|
Clang release 12.0.0. Here we describe the status of the Extra Clang Tools in
|
2016-09-07 01:52:44 +08:00
|
|
|
some detail, including major improvements from the previous release and new
|
|
|
|
feature work. All LLVM releases may be downloaded from the `LLVM releases web
|
2018-09-10 16:52:04 +08:00
|
|
|
site <https://llvm.org/releases/>`_.
|
2016-03-27 13:06:57 +08:00
|
|
|
|
|
|
|
For more information about Clang or LLVM, including information about
|
2018-09-10 16:52:04 +08:00
|
|
|
the latest release, please see the `Clang Web Site <https://clang.llvm.org>`_ or
|
|
|
|
the `LLVM Web Site <https://llvm.org>`_.
|
2016-03-27 13:06:57 +08:00
|
|
|
|
2020-01-15 17:02:56 +08:00
|
|
|
Note that if you are reading this file from a Git checkout or the
|
2016-03-27 13:06:57 +08:00
|
|
|
main Clang web page, this document applies to the *next* release, not
|
|
|
|
the current one. To see the release notes for a specific release, please
|
2018-09-10 16:52:04 +08:00
|
|
|
see the `releases page <https://llvm.org/releases/>`_.
|
2016-03-27 13:06:57 +08:00
|
|
|
|
2020-07-15 17:40:53 +08:00
|
|
|
What's New in Extra Clang Tools 12.0.0?
|
2019-07-18 19:51:05 +08:00
|
|
|
=======================================
|
2016-03-27 13:06:57 +08:00
|
|
|
|
|
|
|
Some of the major new features and improvements to Extra Clang Tools are listed
|
|
|
|
here. Generic improvements to Extra Clang Tools as a whole or to its underlying
|
|
|
|
infrastructure are described first, followed by tool-specific sections.
|
|
|
|
|
|
|
|
Major New Features
|
|
|
|
------------------
|
|
|
|
|
2016-07-19 02:08:59 +08:00
|
|
|
...
|
2016-03-27 13:06:57 +08:00
|
|
|
|
2018-10-12 05:40:32 +08:00
|
|
|
Improvements to clangd
|
|
|
|
----------------------
|
|
|
|
|
2020-12-23 05:58:39 +08:00
|
|
|
- clangd's memory usage is significantly reduced on most Linux systems.
|
|
|
|
In particular, memory usage should not increase dramatically over time.
|
|
|
|
|
|
|
|
The standard allocator on most systems is glibc's ptmalloc2, and it creates
|
|
|
|
disproportionately large heaps when handling clangd's allocation patterns.
|
|
|
|
By default, clangd will now periodically call ``malloc_trim`` to release free
|
|
|
|
pages on glibc systems.
|
|
|
|
|
|
|
|
Users of other allocators (such as ``jemalloc`` or ``tcmalloc``) on glibc
|
|
|
|
systems can disable this using ``--malloc_trim=0`` or the CMake flag
|
|
|
|
``-DCLANGD_MALLOC_TRIM=0``.
|
2018-10-12 05:40:32 +08:00
|
|
|
|
|
|
|
Improvements to clang-doc
|
|
|
|
-------------------------
|
|
|
|
|
2020-01-15 17:02:56 +08:00
|
|
|
The improvements are...
|
2018-10-12 05:40:32 +08:00
|
|
|
|
2016-03-30 20:05:33 +08:00
|
|
|
Improvements to clang-query
|
|
|
|
---------------------------
|
2016-03-27 13:06:57 +08:00
|
|
|
|
2020-11-22 02:54:26 +08:00
|
|
|
- The IgnoreImplicitCastsAndParentheses traversal mode has been removed.
|
2016-03-27 13:06:57 +08:00
|
|
|
|
2016-03-30 20:05:33 +08:00
|
|
|
Improvements to clang-rename
|
|
|
|
----------------------------
|
2016-03-27 13:06:57 +08:00
|
|
|
|
2017-01-13 05:58:40 +08:00
|
|
|
The improvements are...
|
2016-03-27 13:06:57 +08:00
|
|
|
|
2016-03-30 20:05:33 +08:00
|
|
|
Improvements to clang-tidy
|
|
|
|
--------------------------
|
2016-03-27 13:06:57 +08:00
|
|
|
|
2020-09-28 20:58:27 +08:00
|
|
|
- Checks that allow configuring names of headers to include now support wrapping
|
|
|
|
the include in angle brackets to create a system include. For example,
|
|
|
|
:doc:`cppcoreguidelines-init-variables
|
|
|
|
<clang-tidy/checks/cppcoreguidelines-init-variables>` and
|
|
|
|
:doc:`modernize-make-unique <clang-tidy/checks/modernize-make-unique>`.
|
|
|
|
|
2020-12-16 05:15:15 +08:00
|
|
|
- CheckOptions that take boolean values now support all spellings supported in
|
|
|
|
the `YAML format <https://yaml.org/type/bool.html>`_.
|
|
|
|
|
2020-09-08 21:35:14 +08:00
|
|
|
New modules
|
|
|
|
^^^^^^^^^^^
|
|
|
|
|
2020-09-10 23:35:10 +08:00
|
|
|
- New ``altera`` module.
|
2020-09-08 21:35:14 +08:00
|
|
|
|
|
|
|
Includes checks related to OpenCL for FPGA coding guidelines, based on the
|
|
|
|
`Altera SDK for OpenCL: Best Practices Guide
|
|
|
|
<https://www.altera.com/en_US/pdfs/literature/hb/opencl-sdk/aocl_optimization_guide.pdf>`_.
|
|
|
|
|
2020-11-30 17:15:01 +08:00
|
|
|
- New ``concurrency`` module.
|
|
|
|
|
|
|
|
Includes checks related to concurrent programming (e.g. threads, fibers,
|
|
|
|
coroutines, etc.).
|
|
|
|
|
2020-09-08 21:35:14 +08:00
|
|
|
New checks
|
|
|
|
^^^^^^^^^^
|
|
|
|
|
2020-11-09 22:20:35 +08:00
|
|
|
- New :doc:`altera-kernel-name-restriction
|
|
|
|
<clang-tidy/checks/altera-kernel-name-restriction>` check.
|
|
|
|
|
|
|
|
Finds kernel files and include directives whose filename is `kernel.cl`,
|
|
|
|
`Verilog.cl`, or `VHDL.cl`.
|
|
|
|
|
2020-12-18 20:49:48 +08:00
|
|
|
- New :doc:`altera-single-work-item-barrier
|
|
|
|
<clang-tidy/checks/altera-single-work-item-barrier>` check.
|
|
|
|
|
|
|
|
Finds OpenCL kernel functions that call a barrier function but do not call
|
|
|
|
an ID function.
|
|
|
|
|
2020-09-08 21:35:14 +08:00
|
|
|
- New :doc:`altera-struct-pack-align
|
|
|
|
<clang-tidy/checks/altera-struct-pack-align>` check.
|
|
|
|
|
|
|
|
Finds structs that are inefficiently packed or aligned, and recommends
|
|
|
|
packing and/or aligning of said structs as needed.
|
|
|
|
|
2020-09-11 16:12:39 +08:00
|
|
|
- New :doc:`cppcoreguidelines-prefer-member-initializer
|
|
|
|
<clang-tidy/checks/cppcoreguidelines-prefer-member-initializer>` check.
|
|
|
|
|
|
|
|
Finds member initializations in the constructor body which can be placed into
|
|
|
|
the initialization list instead.
|
|
|
|
|
2020-09-08 21:35:14 +08:00
|
|
|
- New :doc:`bugprone-misplaced-pointer-arithmetic-in-alloc
|
|
|
|
<clang-tidy/checks/bugprone-misplaced-pointer-arithmetic-in-alloc>` check.
|
|
|
|
|
2020-06-05 19:27:09 +08:00
|
|
|
- New :doc:`bugprone-redundant-branch-condition
|
|
|
|
<clang-tidy/checks/bugprone-redundant-branch-condition>` check.
|
|
|
|
|
|
|
|
Finds condition variables in nested ``if`` statements that were also checked
|
|
|
|
in the outer ``if`` statement and were not changed.
|
2020-08-01 17:35:13 +08:00
|
|
|
|
2020-11-30 17:20:08 +08:00
|
|
|
- New :doc:`concurrency-mt-unsafe <clang-tidy/checks/concurrency-mt-unsafe>`
|
|
|
|
check.
|
|
|
|
|
|
|
|
Finds thread-unsafe functions usage. Currently knows about POSIX and
|
|
|
|
Glibc function sets.
|
|
|
|
|
2020-11-04 22:09:09 +08:00
|
|
|
- New :doc:`bugprone-signal-handler
|
|
|
|
<clang-tidy/checks/bugprone-signal-handler>` check.
|
|
|
|
|
|
|
|
Finds functions registered as signal handlers that call non asynchronous-safe
|
|
|
|
functions.
|
|
|
|
|
|
|
|
- New :doc:`cert-sig30-c
|
|
|
|
<clang-tidy/checks/cert-sig30-c>` check.
|
|
|
|
|
|
|
|
Alias to the :doc:`bugprone-signal-handler
|
|
|
|
<clang-tidy/checks/bugprone-signal-handler>` check.
|
|
|
|
|
[clang-tidy] Introduce misc No Integer To Pointer Cast check
While casting an (integral) pointer to an integer is obvious - you just get
the integral value of the pointer, casting an integer to an (integral) pointer
is deceivingly different. While you will get a pointer with that integral value,
if you got that integral value via a pointer-to-integer cast originally,
the new pointer will lack the provenance information from the original pointer.
So while (integral) pointer to integer casts are effectively no-ops,
and are transparent to the optimizer, integer to (integral) pointer casts
are *NOT* transparent, and may conceal information from optimizer.
While that may be the intention, it is not always so. For example,
let's take a look at a routine to align the pointer up to the multiple of 16:
The obvious, naive implementation for that is:
```
char* src(char* maybe_underbiased_ptr) {
uintptr_t maybe_underbiased_intptr = (uintptr_t)maybe_underbiased_ptr;
uintptr_t aligned_biased_intptr = maybe_underbiased_intptr + 15;
uintptr_t aligned_intptr = aligned_biased_intptr & (~15);
return (char*)aligned_intptr; // warning: avoid integer to pointer casts [misc-no-inttoptr]
}
```
The check will rightfully diagnose that cast.
But when provenance concealment is not the goal of the code, but an accident,
this example can be rewritten as follows, without using integer to pointer cast:
```
char*
tgt(char* maybe_underbiased_ptr) {
uintptr_t maybe_underbiased_intptr = (uintptr_t)maybe_underbiased_ptr;
uintptr_t aligned_biased_intptr = maybe_underbiased_intptr + 15;
uintptr_t aligned_intptr = aligned_biased_intptr & (~15);
uintptr_t bias = aligned_intptr - maybe_underbiased_intptr;
return maybe_underbiased_ptr + bias;
}
```
See also:
* D71499
* [[ https://www.cs.utah.edu/~regehr/oopsla18.pdf | Juneyoung Lee, Chung-Kil Hur, Ralf Jung, Zhengyang Liu, John Regehr, and Nuno P. Lopes. 2018. Reconciling High-Level Optimizations and Low-Level Code in LLVM. Proc. ACM Program. Lang. 2, OOPSLA, Article 125 (November 2018), 28 pages. ]]
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D91055
2020-12-09 03:54:56 +08:00
|
|
|
- New :doc:`performance-no-int-to-ptr
|
|
|
|
<clang-tidy/checks/performance-no-int-to-ptr>` check.
|
|
|
|
|
|
|
|
Diagnoses every integer to pointer cast.
|
|
|
|
|
[clang-tidy] Implement readability-function-cognitive-complexity check
Currently, there is basically just one clang-tidy check to impose
some sanity limits on functions - `clang-tidy-readability-function-size`.
It is nice, allows to limit line count, total number of statements,
number of branches, number of function parameters (not counting
implicit `this`), nesting level.
However, those are simple generic metrics. It is still trivially possible
to write a function, which does not violate any of these metrics,
yet is still rather unreadable.
Thus, some additional, slightly more complicated metric is needed.
There is a well-known [[ https://en.wikipedia.org/wiki/Cyclomatic_complexity | Cyclomatic complexity]], but certainly has its downsides.
And there is a [[ https://www.sonarsource.com/docs/CognitiveComplexity.pdf | COGNITIVE COMPLEXITY by SonarSource ]], which is available for opensource on https://sonarcloud.io/.
This check checks function Cognitive Complexity metric, and flags
the functions with Cognitive Complexity exceeding the configured limit.
The default limit is `25`, same as in 'upstream'.
The metric is implemented as per [[ https://www.sonarsource.com/docs/CognitiveComplexity.pdf | COGNITIVE COMPLEXITY by SonarSource ]] specification version 1.2 (19 April 2017), with two notable exceptions:
* `preprocessor conditionals` (`#ifdef`, `#if`, `#elif`, `#else`,
`#endif`) are not accounted for.
Could be done. Currently, upstream does not account for them either.
* `each method in a recursion cycle` is not accounted for.
It can't be fully implemented, because cross-translational-unit
analysis would be needed, which is not possible in clang-tidy.
Thus, at least right now, i completely avoided implementing it.
There are some further possible improvements:
* Are GNU statement expressions (`BinaryConditionalOperator`) really free?
They should probably cause nesting level increase,
and complexity level increase when they are nested within eachother.
* Microsoft SEH support
* ???
Reviewed By: aaron.ballman, JonasToth, lattner
Differential Revision: https://reviews.llvm.org/D36836
2017-08-17 23:57:00 +08:00
|
|
|
- New :doc:`readability-function-cognitive-complexity
|
|
|
|
<clang-tidy/checks/readability-function-cognitive-complexity>` check.
|
|
|
|
|
|
|
|
Flags functions with Cognitive Complexity metric exceeding the configured limit.
|
|
|
|
|
2020-06-05 19:27:09 +08:00
|
|
|
Changes in existing checks
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
2020-10-16 21:16:28 +08:00
|
|
|
- Improved :doc:`modernize-loop-convert
|
|
|
|
<clang-tidy/checks/modernize-loop-convert>` check.
|
|
|
|
|
|
|
|
Now able to transform iterator loops using ``rbegin`` and ``rend`` methods.
|
|
|
|
|
2020-08-01 17:35:13 +08:00
|
|
|
- Improved :doc:`readability-identifier-naming
|
|
|
|
<clang-tidy/checks/readability-identifier-naming>` check.
|
|
|
|
|
|
|
|
Added an option `GetConfigPerFile` to support including files which use
|
|
|
|
different naming styles.
|
2020-04-11 00:25:31 +08:00
|
|
|
|
2020-10-19 22:21:05 +08:00
|
|
|
Now renames overridden virtual methods if the method they override has a
|
|
|
|
style violation.
|
2020-10-19 22:57:46 +08:00
|
|
|
|
|
|
|
Added support for specifying the style of scoped ``enum`` constants. If
|
|
|
|
unspecified, will fall back to the style for regular ``enum`` constants.
|
2020-10-19 22:21:05 +08:00
|
|
|
|
2020-11-25 09:18:38 +08:00
|
|
|
Added an option `IgnoredRegexp` per identifier type to suppress identifier
|
|
|
|
naming checks for names matching a regular expression.
|
|
|
|
|
2020-10-06 15:25:58 +08:00
|
|
|
- Removed `google-runtime-references` check because the rule it checks does
|
|
|
|
not exist in the Google Style Guide anymore.
|
|
|
|
|
2020-11-08 03:14:08 +08:00
|
|
|
- Improved :doc:`readability-redundant-string-init
|
|
|
|
<clang-tidy/checks/readability-redundant-string-init>` check.
|
|
|
|
|
|
|
|
Added `std::basic_string_view` to default list of ``string``-like types.
|
|
|
|
|
2019-10-31 01:48:26 +08:00
|
|
|
Improvements to include-fixer
|
|
|
|
-----------------------------
|
|
|
|
|
|
|
|
The improvements are...
|
|
|
|
|
2019-03-25 22:09:10 +08:00
|
|
|
Improvements to clang-include-fixer
|
2019-03-26 00:50:24 +08:00
|
|
|
-----------------------------------
|
2016-03-30 20:05:33 +08:00
|
|
|
|
2017-01-13 05:58:40 +08:00
|
|
|
The improvements are...
|
2016-03-30 20:05:33 +08:00
|
|
|
|
|
|
|
Improvements to modularize
|
|
|
|
--------------------------
|
2016-03-27 13:06:57 +08:00
|
|
|
|
|
|
|
The improvements are...
|
[pp-trace] Delete -ignore and add a new option -callbacks
Summary:
-ignore specifies a list of PP callbacks to ignore. It cannot express a
whitelist, which may be more useful than a blacklist.
Add a new option -callbacks to replace it.
-ignore= (default) => -callbacks='*' (default)
-ignore=FileChanged,FileSkipped => -callbacks='*,-FileChanged,-FileSkipped'
-callbacks='Macro*' : print only MacroDefined,MacroExpands,MacroUndefined,...
Reviewers: juliehockett, aaron.ballman, alexfh, ioeric
Reviewed By: aaron.ballman
Subscribers: nemanjai, kbarton, jsji, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D59296
llvm-svn: 356366
2019-03-18 21:30:17 +08:00
|
|
|
|
|
|
|
Improvements to pp-trace
|
|
|
|
------------------------
|
|
|
|
|
2019-07-18 19:51:05 +08:00
|
|
|
The improvements are...
|
2019-08-28 02:36:08 +08:00
|
|
|
|
|
|
|
Clang-tidy visual studio plugin
|
|
|
|
-------------------------------
|