clang-format mishandles constexpr-if

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 4.3.1
    • Affects Version/s: None
    • Component/s: None
    • Fully Compatible
    • v4.2
    • Dev Tools 2019-07-29
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      clang-format produces formatting which would seem to indicate it doesn't actually understand constexpr-if expressions as seen in the following output from clang-format as run on evergreen during the `lint` task.

            * Returns the bounds on the smallest and largest possible plaintext for the ciphertext.
            */
           std::pair<size_t, size_t> expectedPlaintextLen() const {
      -        if constexpr (Header::kMode == aesMode::cbc) {
      -            return {getDataSize() - crypto::aesBlockSize, getDataSize()};
      -        } else {
      +        if
      +            constexpr(Header::kMode == aesMode::cbc) {
      +                return {getDataSize() - crypto::aesBlockSize, getDataSize()};
      +            }
      +        else {
                   invariant(Header::kMode == aesMode::gcm);
                   return {getDataSize(), getDataSize()};
               }
      

            Assignee:
            ADAM Martin (Inactive)
            Reporter:
            Sara Golemon (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: