pytorch - 💡(How to fix) Fix Stable usage linter doesn't handle multi-line statements [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Fix Action

Fixed

Code Example

// Test a function where the name is longer and the linter
// places the function name on the next line, this resulted in
// 'AOTI_TORCH_EXPORT AOTITorchError' being gobbled up by the
// parser.
#if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_12_0
AOTI_TORCH_EXPORT AOTITorchError
this_is_a_very_long_function(StableIValue** ret_value);
#endif // TORCH_FEATURE_VERSION >= TORCH_VERSION_2_12_0
RAW_BUFFERClick to expand / collapse

Filing a ticket at recommendation of @janeyx99 , based on this comment.

The stable_shim_usage_linter.py script fails to pick exported functions spread out over multiple lines, the example from the comment is;

// Test a function where the name is longer and the linter
// places the function name on the next line, this resulted in
// 'AOTI_TORCH_EXPORT AOTITorchError' being gobbled up by the
// parser.
#if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_12_0
AOTI_TORCH_EXPORT AOTITorchError
this_is_a_very_long_function(StableIValue** ret_value);
#endif // TORCH_FEATURE_VERSION >= TORCH_VERSION_2_12_0

Formatting by clang-format breaks that just before the function line and this prevents the function from being picked up for inclusion in the shim_function_versions.txt file.

In #179421 an clang-format off comment was placed here to ensure the functions were on one line. Once this ticket is resolved that comment should be removed.

The current PreprocessorTracker handles the code line by line, without accumulating information over multiple lines. In a (reverted) exploration during #180135 support was added to handle multi-line macro statements (70862fafb4b7f8cb27aad5d1ce87e7d0662f2ff0), which may provide inspiration.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING