[all-commits] [llvm/llvm-project] cda093: Update coding standards for constexpr if statement...

Aaron Ballman via All-commits all-commits at lists.llvm.org
Fri Aug 19 12:53:39 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: cda093681bad901e64d0f6898d15121ab49cb074
      https://github.com/llvm/llvm-project/commit/cda093681bad901e64d0f6898d15121ab49cb074
  Author: Aaron Ballman <aaron at aaronballman.com>
  Date:   2022-08-19 (Fri, 19 Aug 2022)

  Changed paths:
    M llvm/docs/CodingStandards.rst

  Log Message:
  -----------
  Update coding standards for constexpr if statements; NFC

We currently suggest that users not use an else clause after a return
statement in a prior if branch. e.g.,

if (foo)
  return 1;
else // Should remove this else clause
  return 10;

however, this suggestion is incorrect for a constexpr if statement
because one of the two branches will be a discarded statement and thus
can impact template instantiation behavior. This updates the coding
standard to make it clear that it's okay to have a return after an else
in a constexpr if statement.

I think this is an NFC change to the intent of the rule, which is why
I've not started an RFC for the changes.

Differential Revision: https://reviews.llvm.org/D132232




More information about the All-commits mailing list