소스 검색

Avoid bogus lint complaints from `[[(un)likely]]` attributes.

Bug: 40256217
Change-Id: Ia892985d03fc7b8c2316462d1dfe9a1d38c08cfd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5735954
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Peter Kasting 1 년 전
부모
커밋
cefaeea592
1개의 변경된 파일6개의 추가작업 그리고 4개의 파일을 삭제
  1. 6 4
      cpplint.py

+ 6 - 4
cpplint.py

@@ -4106,10 +4106,12 @@ def CheckBraces(filename, clean_lines, linenum, error):
              endpos) = CloseExpression(clean_lines, linenum, pos)
              endpos) = CloseExpression(clean_lines, linenum, pos)
         # Check for an opening brace, either directly after the if or on the
         # Check for an opening brace, either directly after the if or on the
         # next line. If found, this isn't a single-statement conditional.
         # next line. If found, this isn't a single-statement conditional.
-        if (not Match(r'\s*{', endline[endpos:])
-                and not (Match(r'\s*$', endline[endpos:]) and endlinenum <
-                         (len(clean_lines.elided) - 1) and Match(
-                             r'\s*{', clean_lines.elided[endlinenum + 1]))):
+        if (not Match(r'\s*(?:\[\[(?:un)?likely\]\]\s*)?{', endline[endpos:])
+                and not (Match(r'\s*(?:\[\[(?:un)?likely\]\]\s*)?$',
+                               endline[endpos:])
+                         and endlinenum < (len(clean_lines.elided) - 1)
+                         and Match(r'\s*(?:\[\[(?:un)?likely\]\]\s*)?{',
+                                   clean_lines.elided[endlinenum + 1]))):
             while (endlinenum < len(clean_lines.elided)
             while (endlinenum < len(clean_lines.elided)
                    and ';' not in clean_lines.elided[endlinenum][endpos:]):
                    and ';' not in clean_lines.elided[endlinenum][endpos:]):
                 endlinenum += 1
                 endlinenum += 1