|
934 | 934 | "Missing space after ,": r"s/,\([^ ]\)/, \1/g",
|
935 | 935 | }
|
936 | 936 |
|
937 |
| -# {str, set(int)}: a map from error categories to sets of linenumbers |
938 |
| -# on which those errors are expected and should be suppressed. |
939 |
| -_error_suppressions: dict[str, set[int]] = {} |
940 |
| - |
941 | 937 | # The root directory used for deriving header guard CPP variable.
|
942 | 938 | # This is set by --root flag.
|
943 | 939 | _root = None
|
@@ -1036,7 +1032,9 @@ def Clear(self):
|
1036 | 1032 | self._open_block_suppression = None
|
1037 | 1033 |
|
1038 | 1034 |
|
1039 |
| -_error_suppressions = ErrorSuppressions() # type: ignore[assignment] |
| 1035 | +# {str, set(int)}: a map from error categories to sets of linenumbers |
| 1036 | +# on which those errors are expected and should be suppressed. |
| 1037 | +_error_suppressions = ErrorSuppressions() |
1040 | 1038 |
|
1041 | 1039 |
|
1042 | 1040 | def ProcessHppHeadersOption(val):
|
@@ -1166,22 +1164,18 @@ def ProcessCategory(category):
|
1166 | 1164 | )
|
1167 | 1165 |
|
1168 | 1166 |
|
1169 |
| -def ProcessGlobalSuppresions(lines): |
1170 |
| - """Deprecated; use ProcessGlobalSuppressions.""" |
1171 |
| - ProcessGlobalSuppressions(lines) |
1172 |
| - |
1173 |
| - |
1174 |
| -def ProcessGlobalSuppressions(lines): |
| 1167 | +def ProcessGlobalSuppressions(filename: str, lines: list[str]) -> None: |
1175 | 1168 | """Updates the list of global error suppressions.
|
1176 | 1169 |
|
1177 | 1170 | Parses any lint directives in the file that have global effect.
|
1178 | 1171 |
|
1179 | 1172 | Args:
|
1180 | 1173 | lines: An array of strings, each representing a line of the file, with the
|
1181 | 1174 | last element being empty if the file is terminated with a newline.
|
| 1175 | + filename: str, the name of the input file. |
1182 | 1176 | """
|
1183 | 1177 | for line in lines:
|
1184 |
| - if _SEARCH_C_FILE.search(line): |
| 1178 | + if _SEARCH_C_FILE.search(line) or filename.lower().endswith((".c", ".cu")): |
1185 | 1179 | for category in _DEFAULT_C_SUPPRESSED_CATEGORIES:
|
1186 | 1180 | _error_suppressions.AddGlobalSuppression(category)
|
1187 | 1181 | if _SEARCH_KERNEL_FILE.search(line):
|
@@ -7279,7 +7273,7 @@ def ProcessFileData(filename, file_extension, lines, error, extra_check_function
|
7279 | 7273 | ResetNolintSuppressions()
|
7280 | 7274 |
|
7281 | 7275 | CheckForCopyright(filename, lines, error)
|
7282 |
| - ProcessGlobalSuppressions(lines) |
| 7276 | + ProcessGlobalSuppressions(filename, lines) |
7283 | 7277 | RemoveMultiLineComments(filename, lines, error)
|
7284 | 7278 | clean_lines = CleansedLines(lines)
|
7285 | 7279 |
|
|
0 commit comments