[Clang] [NFC] Introduce `ConstDynamicRecursiveASTVisitor` (#122991) After some discussion around #116823, it was decided that it would be nice to have a `const` variant of `DynamicRecursiveASTVisitor`, so this pr does exactly that by making the main DRAV implementation a template with a single `bool` template parameter that turns several function parameters from a `T*` or `T&` to a `const T*` or `const T&`. Since that made the implementation of a bunch of DRAV functions quite a bit more verbose, I’ve moved most of them to be stamped out by a macro, which imo makes it easier to understand what’s actually going on there. For functions which already accepted `const` parameters in the original RAV implementation, the parameter is `const` in both versions (e.g. `TraverseTemplateArgument()` always takes a `const TemplateArgument&`); conversely, parameters that are passed by value (e.g. in `TraverseType()`, which takes a `QualType` by value) are *not* `const` in either variant (i.e. the `QualType` argument is always just a `QualType`, never a `const QualType`). As a sanity check, I’ve also migrated some random visitor in the static analyser to the `const` version (and indeed, it ends up simplifying the code around that particular visitor actually). It would make sense to do a pass over all visitors and change all which can be `const` use the `const` version, but that can be done in a follow-up pr. The [performance impact](https://llvm-compile-time-tracker.com/compare.php?from=e3cd88a7be1dfd912bb6e7c7e888e7b442ffb5de&to=d55c5afe4a485b6d0431386e6f45cb44c1fc8883&stat=instructions:u) of this change seems to be negligible. Clang’s binary size went up by 0.5%, but that’s expected considering that this effectively adds an extra instantiation of `RecursiveASTVisitor`. Fortunately, this is of course a one-time cost.
Welcome to the LLVM project!
This repository contains the source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and run-time environments.
The LLVM project has multiple components. The core of the project is itself called “LLVM”. This contains all of the tools, libraries, and header files needed to process intermediate representations and convert them into object files. Tools include an assembler, disassembler, bitcode analyzer, and bitcode optimizer.
C-like languages use the Clang frontend. This component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode -- and from there into object files, using LLVM.
Other components include: the libc++ C++ standard library, the LLD linker, and more.
Consult the Getting Started with LLVM page for information on building and running LLVM.
For information on how to contribute to the LLVM project, please take a look at the Contributing to LLVM guide.
Join the LLVM Discourse forums, Discord chat, LLVM Office Hours or Regular sync-ups.
The LLVM project has adopted a code of conduct for participants to all modes of communication within the project.