================ @@ -0,0 +1,72 @@ +.. title:: clang-tidy - modernize-use-constexpr + +modernize-use-constexpr +======================= + +Finds functions and variables that can be declared ``constexpr``. + +This check currently supports the ``constexpr`` rule-set of C++11. + +The check analyses any function and variable according to the rules defined +for the language version that the code compiles with. +Changing to a newer language standard may therefore offer additional +opportunities to declare a function or variable as ``constexpr``. +Furthermore, this check can be incremental in terms of its diagnostics. For +example, declaring a function ``constepxr`` might create new opportunities of +marking additional variables or function ``constexpr``, which can only be found +in subsequent runs of this check. + +Before C++23, ``static constexpr`` variables could not be declared inside a +``constexpr`` function. This check prefers adding ``constexpr`` to an enclosing +function over adding ``constexpr`` to a static local variable inside that +function. + +Limitations +----------- + +* Only analyzes variables declared ``const``, because this check would have + to duplicate the expensive analysis of the + :doc:`misc-const-correctness<../misc/const-correctness>` check. + For the best results, enable both `misc-const-correctness` and + `modernize-use-constexpr` together. + +* Only analyzes variable declarations that declare a single variable + +Options +------- + +.. option:: ConservativeLiteralType + + With this option enabled, only literal types that can be constructed at + compile-time are considered to supoprt ``constexpr``. ---------------- EugeneZelenko wrote:
```suggestion compile-time are considered to support ``constexpr``. ``` https://github.com/llvm/llvm-project/pull/162741 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
