Silly cutting when comments put within logical expression

NEW
Unassigned

Status

Firefox Build System
Source Code Analysis
10 months ago
4 months ago

People

(Reporter: jya, Unassigned)

Tracking

Trunk

Firefox Tracking Flags

(firefox57 affected)

Details

(Reporter)

Description

10 months ago
running clang-format on:

  return aLength > MajorLengthPlus1 // Major + '/' + at least 1 char
         && StartsWithMIMETypeMajor(aString, aMajor, MajorLengthPlus1 - 1)
         && EndsWithMIMESubtype(aString + MajorLengthPlus1,
                                aLength - MajorLengthPlus1);

becomes when running clang-format:
  return aLength > MajorLengthPlus1 // Major + '/' + at least 1 char
         && StartsWithMIMETypeMajor(aString, aMajor, MajorLengthPlus1 - 1) &&
         EndsWithMIMESubtype(aString + MajorLengthPlus1,
                             aLength - MajorLengthPlus1);

note that the && is wrong on the 2nd line.


  if ((aFrame.video_frame_buffer()->DataY() != nullptr)
      // Check that the three planes are ordered
      && (aFrame.video_frame_buffer()->DataY() < aFrame.video_frame_buffer()->DataU())
      && (aFrame.video_frame_buffer()->DataU() < aFrame.video_frame_buffer()->DataV())
      //  Check that the last plane ends at firstPlane[totalsize]
      && (&aFrame.video_frame_buffer()->DataY()[aggregateSize] ==
          &aFrame.video_frame_buffer()->DataV()[((aFrame.video_frame_buffer()->height()+1)/2) *
                                                aFrame.video_frame_buffer()->StrideV()]))
  {
    memcpy(aDestBuffer, aFrame.video_frame_buffer()->DataY(), aggregateSize);
    return;
  }

becomes:
  if ((aFrame.video_frame_buffer()->DataY() != nullptr)
      // Check that the three planes are ordered
      &&
      (aFrame.video_frame_buffer()->DataY() <
       aFrame.video_frame_buffer()->DataU()) &&
      (aFrame.video_frame_buffer()->DataU() <
       aFrame.video_frame_buffer()->DataV())
      //  Check that the last plane ends at firstPlane[totalsize]
      &&
      (&aFrame.video_frame_buffer()->DataY()[aggregateSize] ==
       &aFrame.video_frame_buffer()
          ->DataV()[((aFrame.video_frame_buffer()->height() + 1) / 2) *
                    aFrame.video_frame_buffer()->StrideV()])) {
    memcpy(aDestBuffer, aFrame.video_frame_buffer()->DataY(), aggregateSize);
    return;
  }

(the && is now a single operator on the line.)


Yet:
  return aLength > MajorLengthPlus1 && // Major + '/' + at least 1 char
         StartsWithMIMETypeMajor(aString, aMajor, MajorLengthPlus1 - 1) &&
         EndsWithMIMESubtype(aString + MajorLengthPlus1,
                             aLength - MajorLengthPlus1);

running clang-format again on it, it stays as is.
(Reporter)

Comment 1

10 months ago
Another example:

          if (mp4_demuxer::H264::DecodeSPSFromExtraData(extraData, spsdata)
              && (spsdata.profile_idc == 244 /* Hi444PP */
                  || spsdata.chroma_format_idc == PDMFactory::kYUV444)) {

becomes:

          if (mp4_demuxer::H264::DecodeSPSFromExtraData(extraData, spsdata) &&
              (spsdata.profile_idc == 244 /* Hi444PP */
               ||
               spsdata.chroma_format_idc == PDMFactory::kYUV444)) {

instead of:
          if (mp4_demuxer::H264::DecodeSPSFromExtraData(extraData, spsdata) &&
              (spsdata.profile_idc == 244 /* Hi444PP */ ||
               spsdata.chroma_format_idc == PDMFactory::kYUV444)) {

Updated

4 months ago
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.