const NAMES: &[&str] = &[
"NSObject-attribute",
"abbreviated-auto-in-template-arg",
"abi",
"abi-tag",
"absolute-value",
"address",
"address-of-packed-member",
"aggregate-return",
"aggressive-loop-optimizations",
"aliasing",
"align-commons",
"aligned-new",
"all",
"alloc-size",
"alloc-size-larger-than",
"alloc-zero",
"alloca",
"alloca-larger-than",
"ampersand",
"analyzer-allocation-size",
"analyzer-deref-before-check",
"analyzer-double-fclose",
"analyzer-double-free",
"analyzer-exposure-through-output-file",
"analyzer-exposure-through-uninit-copy",
"analyzer-fd-access-mode-mismatch",
"analyzer-fd-double-close",
"analyzer-fd-leak",
"analyzer-fd-phase-mismatch",
"analyzer-fd-type-mismatch",
"analyzer-fd-use-after-close",
"analyzer-fd-use-without-check",
"analyzer-file-leak",
"analyzer-free-of-non-heap",
"analyzer-imprecise-fp-arithmetic",
"analyzer-infinite-loop",
"analyzer-infinite-recursion",
"analyzer-jump-through-null",
"analyzer-malloc-leak",
"analyzer-mismatching-deallocation",
"analyzer-null-argument",
"analyzer-null-dereference",
"analyzer-out-of-bounds",
"analyzer-overlapping-buffers",
"analyzer-possible-null-argument",
"analyzer-possible-null-dereference",
"analyzer-putenv-of-auto-var",
"analyzer-shift-count-negative",
"analyzer-shift-count-overflow",
"analyzer-stale-setjmp-buffer",
"analyzer-symbol-too-complex",
"analyzer-tainted-allocation-size",
"analyzer-tainted-array-index",
"analyzer-tainted-assertion",
"analyzer-tainted-divisor",
"analyzer-tainted-offset",
"analyzer-tainted-size",
"analyzer-throw-of-unexpected-type",
"analyzer-too-complex",
"analyzer-undefined-behavior-ptrdiff",
"analyzer-undefined-behavior-strtok",
"analyzer-unsafe-call-within-signal-handler",
"analyzer-use-after-free",
"analyzer-use-of-pointer-in-stale-stack-frame",
"analyzer-use-of-uninitialized-value",
"analyzer-va-arg-type-mismatch",
"analyzer-va-list-exhausted",
"analyzer-va-list-leak",
"analyzer-va-list-use-after-va-end",
"analyzer-write-to-const",
"analyzer-write-to-string-literal",
"any-length",
"apply-commit",
"argument-mismatch",
"arith-conversion",
"array-bounds",
"array-compare",
"array-parameter",
"array-temporaries",
"assign-intercept",
"attribute-alias",
"attribute-warning",
"attributes",
"auto-profile",
"bad-function-cast",
"bad-line-directive",
"bad-numeric",
"bidi-chars",
"binary-long-long",
"bool-compare",
"bool-operation",
"builtin-declaration-mismatch",
"builtin-macro-redefined",
"c++-compat",
"c++0x-compat",
"c++11-compat",
"c++11-extensions",
"c++14-compat",
"c++14-extensions",
"c++17-compat",
"c++17-extensions",
"c++1z-compat",
"c++20-compat",
"c++20-extensions",
"c++23-extensions",
"c++26-compat",
"c++26-extensions",
"c++2a-compat",
"c-binding-type",
"c11-c23-compat",
"c11-c2x-compat",
"c23-c2y-compat",
"c90-c99-compat",
"c99-c11-compat",
"call-giving",
"call-literal",
"calloc-transposed-args",
"cannot-profile",
"case-enum",
"cast-align",
"cast-function-type",
"cast-qual",
"cast-result",
"cast-user-defined",
"catch-value",
"cdf-dollar",
"cdf-invalid-parameter",
"cdf-name-not-found",
"changes-meaning",
"char-subscripts",
"character-truncation",
"chkp",
"class-conversion",
"class-memaccess",
"clobbered",
"cobol-eject",
"cobol-resume",
"cobol-volatile",
"comma-subscript",
"comment",
"comments",
"comp-6",
"comp-x",
"compare-distinct-pointer-types",
"compare-reals",
"complain-wrong-lang",
"conditionally-supported",
"conversion",
"conversion-extra",
"conversion-null",
"copybook-found",
"coverage-invalid-line-number",
"coverage-mismatch",
"coverage-too-many-conditions",
"coverage-too-many-paths",
"cpp",
"ctad-maybe-unsupported",
"ctor-dtor-privacy",
"dangling-else",
"dangling-pointer",
"dangling-reference",
"date-time",
"declaration-after-statement",
"declaration-missing-parameter-type",
"defaulted-function-deleted",
"delete-incomplete",
"delete-non-virtual-dtor",
"deprecated",
"deprecated-copy",
"deprecated-copy-dtor",
"deprecated-declarations",
"deprecated-enum-enum-conversion",
"deprecated-enum-float-conversion",
"deprecated-literal-operator",
"deprecated-non-prototype",
"deprecated-openmp",
"deprecated-variadic-comma-omission",
"designated-init",
"disabled-optimization",
"discarded-array-qualifiers",
"discarded-qualifiers",
"div-by-zero",
"do-subscript",
"double-promotion",
"duplicate-decl-specifier",
"duplicated-branches",
"duplicated-cond",
"ec-unknown",
"effc++",
"elaborated-enum-base",
"empty-body",
"endif-labels",
"entry-convention",
"enum-compare",
"enum-conversion",
"enum-int-mismatch",
"equal-assign",
"error",
"error-implicit-function-declaration",
"exceptions",
"expansion-to-defined",
"expose-global-module-tu-local",
"extensions",
"external-argument-mismatch",
"external-tu-local",
"extra",
"extra-semi",
"fatal-errors",
"file-code-set",
"flex-array-member-not-at-end",
"float-conversion",
"float-equal",
"format",
"format-contains-nul",
"format-diag",
"format-extra-args",
"format-nonliteral",
"format-overflow",
"format-overflow<0,2>",
"format-security",
"format-signedness",
"format-truncation",
"format-y2k",
"format-zero-length",
"frame-address",
"frame-larger-than",
"free-labels",
"free-nonheap-object",
"frontend-loop-interchange",
"function-elimination",
"global-module",
"hardened",
"header-guard",
"hidden-declarations",
"high-order-bit",
"hsa",
"iconv-error",
"if-not-aligned",
"ignored-attributes",
"ignored-qualifiers",
"implicit",
"implicit-fallthrough",
"implicit-function-declaration",
"implicit-int",
"implicit-interface",
"implicit-procedure",
"import",
"inaccessible-base",
"include-file-found",
"include-file-not-found",
"incompatible-pointer-types",
"infinite-recursion",
"inherited-variadic-ctor",
"init-list-lifetime",
"init-self",
"inline",
"inspect-trailing",
"int-conversion",
"int-in-bool-context",
"int-to-pointer-cast",
"integer-division",
"interference-size",
"intrinsic-shadow",
"intrinsics-std",
"invalid-constexpr",
"invalid-imported-macros",
"invalid-memory-model",
"invalid-offsetof",
"invalid-pch",
"invalid-utf8",
"jump-misses-init",
"keyword-macro",
"larger-than",
"leading-whitespace",
"length-of",
"level-1-occurs",
"level-78",
"level-78-defined",
"line-truncation",
"literal-concat",
"literal-suffix",
"locale-error",
"logical-not-parentheses",
"logical-op",
"long-long",
"lto-type-mismatch",
"main",
"maybe-musttail-local-addr",
"maybe-uninitialized",
"memset-elt-size",
"memset-transposed-args",
"misleading-indentation",
"mismatched-dealloc",
"mismatched-new-delete",
"mismatched-special-enum",
"mismatched-tags",
"missing-attributes",
"missing-braces",
"missing-declarations",
"missing-field-initializers",
"missing-format-attribute",
"missing-include-dirs",
"missing-noreturn",
"missing-parameter-name",
"missing-parameter-type",
"missing-profile",
"missing-prototypes",
"missing-requires",
"missing-template-keyword",
"missing-variable-declarations",
"move-corresponding",
"move-index",
"move-pointer",
"mudflap",
"multichar",
"multiple-inheritance",
"multiple-parameter-fwd-decl-lists",
"multistatement-macros",
"musttail-local-addr",
"namespaces",
"narrowing",
"nested-externs",
"nllanginfo-error",
"no-alloc-size-larger-than",
"no-alloca-larger-than",
"no-frame-larger-than",
"no-larger-than",
"no-stack-usage",
"no-vla-larger-than",
"noexcept",
"noexcept-type",
"non-c-typedef-for-linkage",
"non-template-friend",
"non-virtual-dtor",
"nonnull",
"nonnull-compare",
"normalized",
"nrvo",
"null-dereference",
"objc-root-class",
"odr",
"old-style-cast",
"old-style-declaration",
"old-style-definition",
"openacc-parallelism",
"openmp",
"openmp-simd",
"operator-space",
"overflow",
"overlength-strings",
"overloaded-virtual",
"override-init",
"override-init-side-effects",
"overwrite-recursive",
"packed",
"packed-bitfield-compat",
"packed-not-aligned",
"padded",
"parentheses",
"pedantic",
"pedantic-cast",
"pedantic-param-names",
"pessimizing-move",
"placement-new",
"pmf-conversions",
"pointer-arith",
"pointer-compare",
"pointer-sign",
"pointer-to-int-cast",
"pragma-once-outside-header",
"pragmas",
"preprocessor-error",
"prio-ctor-dtor",
"procedure-not-found",
"procedure-pointer",
"property-assign-default",
"protocol",
"psabi",
"range-loop-construct",
"real-q-constant",
"realloc-lhs",
"realloc-lhs-all",
"recording-mode",
"redundant-decls",
"redundant-move",
"redundant-tags",
"register",
"reorder",
"replace-error",
"restrict",
"return-local-addr",
"return-mismatch",
"return-type",
"returning-number",
"scalar-storage-order",
"scope",
"segment",
"segment-error",
"segment-negative",
"selector",
"self-move",
"sequence-point",
"set-locale-to",
"set-to-locale",
"sfinae-incomplete",
"shadow",
"shadow-compatible-local",
"shadow-ivar",
"shadow-local",
"shift-count-negative",
"shift-count-overflow",
"shift-negative-value",
"shift-overflow",
"sign-compare",
"sign-conversion",
"sign-promo",
"sized-deallocation",
"sizeof-array-argument",
"sizeof-array-div",
"sizeof-pointer-div",
"sizeof-pointer-memaccess",
"speculative",
"stack-protector",
"stack-usage",
"stop-number",
"stray-indicator",
"strict-aliasing",
"strict-flex-arrays",
"strict-null-sentinel",
"strict-overflow",
"strict-prototypes",
"strict-selector-match",
"string-compare",
"stringop-overflow",
"stringop-overread",
"stringop-truncation",
"style",
"subobject-linkage",
"suggest-attribute",
"suggest-final-methods",
"suggest-final-types",
"suggest-override",
"surprising",
"switch",
"switch-bool",
"switch-default",
"switch-enum",
"switch-outside-range",
"switch-unreachable",
"sync-nand",
"synth",
"system-headers",
"tabs",
"target-lifetime",
"tautological-compare",
"template-body",
"template-id-cdtor",
"template-names-tu-local",
"templates",
"terminate",
"traditional",
"traditional-conversion",
"trailing-whitespace",
"trampolines",
"trigraphs",
"trivial-auto-var-init",
"tsan",
"type-limits",
"undeclared-selector",
"undef",
"undefined-do-loop",
"underflow",
"unicode",
"uninit-variable-checking",
"uninitialized",
"unknown-pragmas",
"unreachable-code",
"unsafe-loop-optimizations",
"unsuffixed-float-constants",
"unterminated-string-initialization",
"unused",
"unused-but-set-parameter",
"unused-but-set-variable",
"unused-const-variable",
"unused-dummy-argument",
"unused-function",
"unused-label",
"unused-local-typedefs",
"unused-macros",
"unused-parameter",
"unused-result",
"unused-value",
"unused-variable",
"usage-typename",
"use-after-free",
"use-without-only",
"useless-cast",
"varargs",
"variadic-macros",
"vector-operation-performance",
"verbose-unbounded",
"vexing-parse",
"virtual-inheritance",
"virtual-move-assign",
"vla",
"vla-larger-than",
"vla-parameter",
"voiding",
"volatile",
"volatile-register-var",
"write-strings",
"xor-used-as-pow",
"zero-as-null-pointer-constant",
"zero-length-bounds",
"zerotrip",
];
const PREFIXES: &[&str] = &["larger-than-"];
pub(crate) fn known(name: &str) -> bool {
let name = name.split_once('=').map_or(name, |(name, _)| name);
NAMES.binary_search(&name).is_ok() || PREFIXES.iter().any(|prefix| name.starts_with(prefix))
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn the_names_are_sorted_so_the_search_finds_them() {
assert!(NAMES.windows(2).all(|pair| pair[0] < pair[1]));
}
#[test]
fn a_name_gcc_knows_is_known_in_each_of_its_spellings() {
for name in [
"all",
"extra",
"format=2",
"cast-align=strict",
"abi-tag",
"larger-than-100",
"no-frame-larger-than",
] {
assert!(known(name), "{name}");
}
}
#[test]
fn a_name_only_clang_knows_is_not() {
for name in [
"cast-function-type-strict",
"compound-token-split-by-macro",
"unguarded-availability-new",
"unused-command-line-argument",
] {
assert!(!known(name), "{name}");
}
}
}