Open Bug 1396531 Opened 7 years ago Updated 2 years ago

Silly cutting when comments put within logical expression

Categories

(Developer Infrastructure :: Source Code Analysis, enhancement)

enhancement

Tracking

(firefox57 affected)

Tracking Status
firefox57 --- affected

People

(Reporter: jya, Unassigned)

Details

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.
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)) {
Product: Core → Firefox Build System
Product: Firefox Build System → Developer Infrastructure
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.