Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-40160

clang-format mishandles constexpr-if

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

      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@mongodb.com ADAM Martin (Inactive)
            Reporter:
            sara.golemon@mongodb.com Sara Golemon
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: