Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NOSTDINC and NOTORCHINC lintrunner #6693

Merged
merged 4 commits into from
Nov 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions .lintrunner.toml
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,87 @@ command = [
'@{{PATHSFILE}}',
]
is_formatter = true

[[linter]]
code = 'NOSTDINC'
include_patterns = [
"**/*.c",
"**/*.cpp",
"**/*.h",
"**/*.hpp",
]
exclude_patterns = [
'**/devtools/**',
'**/test/**',
'**/testing_util/**',
'**/third-party/**',
'backends/mediatek/**',
'backends/vulkan/**',
'backends/xnnpack/**',
'devtools/**',
'examples/**',
'extension/**',
'kernels/optimized/**',
'scripts/**',
'third-party/**',
'util/**',
]
command = [
'python',
'-m',
'lintrunner_adapters',
'run',
'grep_linter',
'--pattern=([^\\S\r\n]*#include\s*<(deque|exception|forward_list|functional|list|map|multimap|multiset|priority_queue|queue|set|stack|string|unordered_map|unordered_multimap|unordered_multiset|unordered_set|vector)>)',
'--linter-name=NOSTDINC',
'--error-name=Standard C++ container include in core',
"""--error-description=\
Standard library containers should not be included in ExecuTorch core \
because they may call malloc, which is not allowed in core. \
""",
'--',
'@{{PATHSFILE}}',
]

[[linter]]
code = 'NOTORCHINC'
include_patterns = [
"**/*.c",
"**/*.cpp",
"**/*.h",
"**/*.hpp",
]
exclude_patterns = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of exclude, can you just do include for runtime directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of exclude, can you just do include for runtime directory?

directories should be linted for this unless we know that they shouldn't be. We want this to fail closed.

'**/devtools/**',
'**/testing_util/**',
'**/third-party/**',
'backends/mediatek/**',
'backends/vulkan/**',
'backends/xnnpack/**',
'devtools/**',
'examples/**',
'extension/**',
'kernels/optimized/**',
'scripts/**',
'test/**',
'third-party/**',
'util/**',
]
command = [
'python',
'-m',
'lintrunner_adapters',
'run',
'grep_linter',
'--pattern=#include\s+[<"](aten/|ATen/|torch/)',
'--linter-name=NOTORCHINC',
'--error-name=ATen or torch include',
"""--error-description=\
PyTorch includes in ExecuTorch core are prohibited to prevent \
accidentally breaking core's requirements; please make sure this \
header complies (e.g., no streams/malloc/syscalls) and then include \
a patch to update this linter.\
""",
'--',
'@{{PATHSFILE}}',
]
Loading