You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#nosec is an effective tool in making a codebase gas-clean, but it's not expressive enough. It disables every gas diagnostic (now and forever) but doesn't provide any auditable documentation to the annotated code.
Proposal
I propose per-diagnostic AST node annotations. Through gas adding support for disabling specific diagnostics on a set of AST nodes, annotated code becomes self-documenting. It also opens up the suppressed code to diagnostics gas may add in the future.
funca() {
// gas(-G101, -G102)ifx<y {
// code that is not safe for G101, G102// code that may become a diagnostic error in a future version of gas
}
}
NB: syntax not fleshed out; what would it mean to have gas(+G1, -G1, invalidchars)? Would we need to implement a custom parser? We could probably make the grammar simpler to avoid doing too much work here.
Prior Art
Clang, a popular C and C++ compiler, offers scoped diagnostic suppression on a per-diagnostic basis:
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wbitwise-op-parentheses"
1 << 3 << 4==5 << 6; // no warning issued due to ignoring bitwise-op-parentheses#pragma clang diagnostic pop
I believe Visual C++ and GCC offer similar.
The text was updated successfully, but these errors were encountered:
It might be interesting to re-use go's parser + ast to do this. e.g. using a subset of golang simple expressions. proof of concept idea here - https://play.golang.org/p/c1yfMxvTbrw
ccojocar
changed the title
[Feature Request] Per-diagnostic annotation
Per-diagnostic annotation
Sep 10, 2019
#nosec
is an effective tool in making a codebase gas-clean, but it's not expressive enough. It disables every gas diagnostic (now and forever) but doesn't provide any auditable documentation to the annotated code.Proposal
I propose per-diagnostic AST node annotations. Through gas adding support for disabling specific diagnostics on a set of AST nodes, annotated code becomes self-documenting. It also opens up the suppressed code to diagnostics gas may add in the future.
NB: syntax not fleshed out; what would it mean to have
gas(+G1, -G1, invalidchars)
? Would we need to implement a custom parser? We could probably make the grammar simpler to avoid doing too much work here.Prior Art
Clang, a popular C and C++ compiler, offers scoped diagnostic suppression on a per-diagnostic basis:
I believe Visual C++ and GCC offer similar.
The text was updated successfully, but these errors were encountered: