|
350 | 350 | "runtime/printf_format", |
351 | 351 | "runtime/references", |
352 | 352 | "runtime/string", |
| 353 | + "runtime/thread_local", |
353 | 354 | "runtime/threadsafe_fn", |
354 | 355 | "runtime/vlog", |
355 | 356 | "runtime/v8_persistent", |
@@ -7446,6 +7447,25 @@ def CheckStringValueUsage(filename, lines, error): |
7446 | 7447 | 'Use node::TwoByteValue instead.') |
7447 | 7448 |
|
7448 | 7449 |
|
| 7450 | +def CheckThreadLocalUsage(filename, lines, error): |
| 7451 | + """Logs an error if thread_local is used in src/. |
| 7452 | + Args: |
| 7453 | + filename: The name of the current file. |
| 7454 | + lines: An array of strings, each representing a line of the file. |
| 7455 | + error: The function to call with any errors found. |
| 7456 | + """ |
| 7457 | + if not (filename.startswith('src/') or filename.startswith('src\\')): |
| 7458 | + return |
| 7459 | + |
| 7460 | + for linenum, line in enumerate(lines): |
| 7461 | + if re.search(r'\bthread_local\b', line.split('//', 1)[0]): |
| 7462 | + error(filename, linenum, 'runtime/thread_local', 5, |
| 7463 | + 'Several Environments can share a thread, so keep state that ' |
| 7464 | + 'belongs to one on the Environment or its BindingData. Mark ' |
| 7465 | + 'intentionally per-thread state with ' |
| 7466 | + 'NOLINTNEXTLINE(runtime/thread_local).') |
| 7467 | + |
| 7468 | + |
7449 | 7469 | def ProcessLine( |
7450 | 7470 | filename, |
7451 | 7471 | file_extension, |
@@ -7609,6 +7629,8 @@ def ProcessFileData(filename, file_extension, lines, error, extra_check_function |
7609 | 7629 |
|
7610 | 7630 | CheckStringValueUsage(filename, lines, error) |
7611 | 7631 |
|
| 7632 | + CheckThreadLocalUsage(filename, lines, error) |
| 7633 | + |
7612 | 7634 |
|
7613 | 7635 | def ProcessConfigOverrides(filename): |
7614 | 7636 | """Loads the configuration files and processes the config overrides. |
|
0 commit comments