Extra Clang Tools 12.0.0 (In-Progress) Release Notes¶
Written by the LLVM Team
These are in-progress notes for the upcoming Extra Clang Tools 12 release. Release notes for previous releases can be found on the Download Page.
This document contains the release notes for the Extra Clang Tools, part of the Clang release 12.0.0. Here we describe the status of the Extra Clang Tools in some detail, including major improvements from the previous release and new feature work. All LLVM releases may be downloaded from the LLVM releases web site.
Note that if you are reading this file from a Git checkout or the 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 see the releases page.
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.
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_trimto release free pages on glibc systems.
Users of other allocators (such as
tcmalloc) on glibc systems can disable this using
--malloc_trim=0or the CMake flag
Added the $/memoryUsage request: an LSP extension. This provides a breakdown of the memory clangd thinks it is using (excluding malloc overhead etc). The clangd VSCode extension supports showing the memory usage tree.
Improved navigation of broken code in C using Recovery AST. (This has been enabled for C++ since clangd 11).
Types are understood more often in broken code. (This is the first release where Recovery AST preserves speculated types).
Heuristic resolution for dependent names in templates.
Higher priority for symbols that were already used in this file, and symbols from namespaces mentioned in this file. (Estimated 3% accuracy improvement)
Introduced a ranking algorithm trained on snippets from a large C++ codebase. Use the flag
--ranking-model=decision_forestto try this (Estimated 6% accuracy improvement). This mode is likely to become the default in future.
Note: this is a generic model, not specialized for your code. clangd does not collect any data from your code to train code completion.
Signature help works with functions with template-dependent parameter types.
decltypekeyword will attempt to navigate to a definition of the deduced type.
Improved handling of aliases: navigate to the underlying entity more often.
Better understanding of declaration vs definition for Objective-C classes and protocols.
Selecting a pure-virtual method shows its overrides.
Indexes are smarter about not returning stale references when code is deleted.
References in implementation files are always indexed, so results should be more complete.
Find-references on a virtual method shows references to overridden methods.
New refactoring: populate
switchstatement with cases. (This acts as a fix for the
Renaming templates is supported, and many other complex cases were fixed.
Attempting to rename to an invalid or conflicting name can produce an error message rather than broken code. (Not all cases are detected!)
The accuracy of many code actions has been improved.
decltypeshow the type in the same style as other hovers.
thisis also now supported.
Displayed type names are more consistent and idiomatic.
Inactive preprocessor regions (
#ifdef) are highlighted as comments.
clangd 12 is the last release with support for the non-standard
textDocument/semanticHighlightsnotification. Clients sholud migrate to the
textDocument/semanticTokensrequest added in LSP 3.16.
clangd can now connect to a remote index server instead of building a project index locally. This saves resources in large codebases that are slow to index.
The server program is
clangd-index-server, and it consumes index files produced by
This feature requires clangd to be built with the CMake flag
-DCLANGD_ENABLE_REMOTE=On, which requires GRPC libraries and is not enabled by default. Unofficial releases of the remote-index-enabled client and server tools are at https://github.com/clangd/clangd/releases
Large projects can deploy a shared server, and check in a
.clangdfile to enable it (in the
Index.Externalsection). We hope to provide such a server for
llvm-projectitself in the near future.
Static and remote indexes can be configured in the
Index.Externalsection. Different static indexes can now be used for different files. (Obsoletes the flag
Diagnostics can be filtered or suppressed in the
Clang-tidy checks can be enabled/disabled in the
Diagnostics.ClangTidysection. (Obsoletes the flag
The compilation database directory can be configured in the
CompileFlagssection. Different compilation databases can now be specified for different files. (Obsoletes the flag
Errors in loaded configuration files are published as LSP diagnostics, and so should be shown in your editor.
compile_flags.txtwill take effect the next time a file is parsed, without restarting clangd.
clangd --check=<filename>can be run on the command-line to simulate opening a file without actually using an editor. This can be useful to reproduce crashes or aother problems.
Various fixes to handle filenames correctly (and case-insensitively) on windows.
If incoming LSP messages are malformed, the logs now contain details.
“Show AST” request (textDocument/ast) added as an LSP extension. This displays a simplified view of the clang AST for selected code. The clangd VSCode extension supports this.
clangd should no longer crash while loading old or corrupt index files.
-suggest-missing-includeshave been retired. These features are now always enabled.
Too many stability and correctness fixes to mention.
Checks that allow configuring names of headers to include now support wrapping the include in angle brackets to create a system include. For example, cppcoreguidelines-init-variables and modernize-make-unique.
CheckOptions that take boolean values now support all spellings supported in the YAML format.
Includes checks related to OpenCL for FPGA coding guidelines, based on the Altera SDK for OpenCL: Best Practices Guide.
Includes checks related to concurrent programming (e.g. threads, fibers, coroutines, etc.).
New altera-kernel-name-restriction check.
Finds kernel files and include directives whose filename is kernel.cl, Verilog.cl, or VHDL.cl.
New altera-single-work-item-barrier check.
Finds OpenCL kernel functions that call a barrier function but do not call an ID function.
New altera-struct-pack-align check.
Finds structs that are inefficiently packed or aligned, and recommends packing and/or aligning of said structs as needed.
New bugprone-redundant-branch-condition check.
Finds condition variables in nested
ifstatements that were also checked in the outer
ifstatement and were not changed.
New concurrency-mt-unsafe check.
Finds thread-unsafe functions usage. Currently knows about POSIX and Glibc function sets.
New bugprone-signal-handler check.
Finds functions registered as signal handlers that call non asynchronous-safe functions.
New cert-sig30-c check.
Alias to the bugprone-signal-handler check.
New performance-no-int-to-ptr check.
Diagnoses every integer to pointer cast.
New readability-function-cognitive-complexity check.
Flags functions with Cognitive Complexity metric exceeding the configured limit.
Improved modernize-loop-convert check.
Now able to transform iterator loops using
Improved readability-identifier-naming check.
Added an option GetConfigPerFile to support including files which use different naming styles.
Now renames overridden virtual methods if the method they override has a style violation.
Added support for specifying the style of scoped
enumconstants. If unspecified, will fall back to the style for regular
Added an option IgnoredRegexp per identifier type to suppress identifier naming checks for names matching a regular expression.
Removed google-runtime-references check because the rule it checks does not exist in the Google Style Guide anymore.
Improved readability-redundant-string-init check.
Added std::basic_string_view to default list of