From 7f9ed57a6f2789cef727c2c2dfc62b1502234d38 Mon Sep 17 00:00:00 2001 From: Mike Fairhurst Date: Sun, 1 Mar 2026 13:17:31 -0800 Subject: [PATCH 01/13] Created empty query files --- .../cpp/exclusions/cpp/RuleMetadata.qll | 3 + .../cpp/exclusions/cpp/Toolchain3.qll | 282 ++++++++++++++++++ ...plicitDeclarationOfCopyConstructorAudit.ql | 24 ++ .../RULE-4-1-2/NoexceptSpecifierThrowAudit.ql | 24 ++ ...arationOfStaticConstexprDataMemberAudit.ql | 24 ++ .../UseOfDeprecatedAllocatorVoid.ql | 23 ++ .../RULE-4-1-2/UseOfDeprecatedCHeaders.ql | 22 ++ ...recatedFunctionBinderTypedefMemberAudit.ql | 24 ++ .../UseOfDeprecatedIsLiteralTypeTraits.ql | 23 ++ .../UseOfDeprecatedRawStorageIterator.ql | 23 ++ .../UseOfDeprecatedSharedPtrUnique.ql | 23 ++ .../UseOfDeprecatedStdAllocatorMember.ql | 23 ++ .../UseOfDeprecatedStdIteratorBaseClass.ql | 23 ++ .../UseOfDeprecatedStrStreamClass.ql | 23 ++ .../UseOfDeprecatedTemporaryBuffers.ql | 23 ++ .../UseOfDeprecatedUnaryOrBinaryNegate.ql | 23 ++ .../RULE-4-1-2/UseOfUncaughtException.ql | 23 ++ .../RULE-4-1-2/UseOfWeakResultTypesAudit.ql | 24 ++ ...DeclarationOfCopyConstructorAudit.expected | 1 + ...citDeclarationOfCopyConstructorAudit.qlref | 1 + .../NoexceptSpecifierThrowAudit.expected | 1 + .../NoexceptSpecifierThrowAudit.qlref | 1 + ...nOfStaticConstexprDataMemberAudit.expected | 1 + ...tionOfStaticConstexprDataMemberAudit.qlref | 1 + .../UseOfDeprecatedAllocatorVoid.expected | 1 + .../UseOfDeprecatedAllocatorVoid.qlref | 1 + .../UseOfDeprecatedCHeaders.expected | 1 + .../RULE-4-1-2/UseOfDeprecatedCHeaders.qlref | 1 + ...dFunctionBinderTypedefMemberAudit.expected | 1 + ...atedFunctionBinderTypedefMemberAudit.qlref | 1 + ...seOfDeprecatedIsLiteralTypeTraits.expected | 1 + .../UseOfDeprecatedIsLiteralTypeTraits.qlref | 1 + ...UseOfDeprecatedRawStorageIterator.expected | 1 + .../UseOfDeprecatedRawStorageIterator.qlref | 1 + .../UseOfDeprecatedSharedPtrUnique.expected | 1 + .../UseOfDeprecatedSharedPtrUnique.qlref | 1 + ...UseOfDeprecatedStdAllocatorMember.expected | 1 + .../UseOfDeprecatedStdAllocatorMember.qlref | 1 + ...eOfDeprecatedStdIteratorBaseClass.expected | 1 + .../UseOfDeprecatedStdIteratorBaseClass.qlref | 1 + .../UseOfDeprecatedStrStreamClass.expected | 1 + .../UseOfDeprecatedStrStreamClass.qlref | 1 + .../UseOfDeprecatedTemporaryBuffers.expected | 1 + .../UseOfDeprecatedTemporaryBuffers.qlref | 1 + ...seOfDeprecatedUnaryOrBinaryNegate.expected | 1 + .../UseOfDeprecatedUnaryOrBinaryNegate.qlref | 1 + .../UseOfUncaughtException.expected | 1 + .../RULE-4-1-2/UseOfUncaughtException.qlref | 1 + .../UseOfWeakResultTypesAudit.expected | 1 + .../UseOfWeakResultTypesAudit.qlref | 1 + rule_packages/cpp/Toolchain3.json | 210 +++++++++++++ rules.csv | 2 +- 52 files changed, 900 insertions(+), 1 deletion(-) create mode 100644 cpp/common/src/codingstandards/cpp/exclusions/cpp/Toolchain3.qll create mode 100644 cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.ql create mode 100644 cpp/misra/src/rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.ql create mode 100644 cpp/misra/src/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.ql create mode 100644 cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedAllocatorVoid.ql create mode 100644 cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedCHeaders.ql create mode 100644 cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.ql create mode 100644 cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedIsLiteralTypeTraits.ql create mode 100644 cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedRawStorageIterator.ql create mode 100644 cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedSharedPtrUnique.ql create mode 100644 cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.ql create mode 100644 cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStdIteratorBaseClass.ql create mode 100644 cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStrStreamClass.ql create mode 100644 cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedTemporaryBuffers.ql create mode 100644 cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedUnaryOrBinaryNegate.ql create mode 100644 cpp/misra/src/rules/RULE-4-1-2/UseOfUncaughtException.ql create mode 100644 cpp/misra/src/rules/RULE-4-1-2/UseOfWeakResultTypesAudit.ql create mode 100644 cpp/misra/test/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.expected create mode 100644 cpp/misra/test/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.qlref create mode 100644 cpp/misra/test/rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.expected create mode 100644 cpp/misra/test/rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.qlref create mode 100644 cpp/misra/test/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.expected create mode 100644 cpp/misra/test/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.qlref create mode 100644 cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedAllocatorVoid.expected create mode 100644 cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedAllocatorVoid.qlref create mode 100644 cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedCHeaders.expected create mode 100644 cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedCHeaders.qlref create mode 100644 cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.expected create mode 100644 cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.qlref create mode 100644 cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedIsLiteralTypeTraits.expected create mode 100644 cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedIsLiteralTypeTraits.qlref create mode 100644 cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedRawStorageIterator.expected create mode 100644 cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedRawStorageIterator.qlref create mode 100644 cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedSharedPtrUnique.expected create mode 100644 cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedSharedPtrUnique.qlref create mode 100644 cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.expected create mode 100644 cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.qlref create mode 100644 cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStdIteratorBaseClass.expected create mode 100644 cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStdIteratorBaseClass.qlref create mode 100644 cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStrStreamClass.expected create mode 100644 cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStrStreamClass.qlref create mode 100644 cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedTemporaryBuffers.expected create mode 100644 cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedTemporaryBuffers.qlref create mode 100644 cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedUnaryOrBinaryNegate.expected create mode 100644 cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedUnaryOrBinaryNegate.qlref create mode 100644 cpp/misra/test/rules/RULE-4-1-2/UseOfUncaughtException.expected create mode 100644 cpp/misra/test/rules/RULE-4-1-2/UseOfUncaughtException.qlref create mode 100644 cpp/misra/test/rules/RULE-4-1-2/UseOfWeakResultTypesAudit.expected create mode 100644 cpp/misra/test/rules/RULE-4-1-2/UseOfWeakResultTypesAudit.qlref create mode 100644 rule_packages/cpp/Toolchain3.json diff --git a/cpp/common/src/codingstandards/cpp/exclusions/cpp/RuleMetadata.qll b/cpp/common/src/codingstandards/cpp/exclusions/cpp/RuleMetadata.qll index 4bbcf6d0e..dcf73572e 100644 --- a/cpp/common/src/codingstandards/cpp/exclusions/cpp/RuleMetadata.qll +++ b/cpp/common/src/codingstandards/cpp/exclusions/cpp/RuleMetadata.qll @@ -78,6 +78,7 @@ import Statements import Strings import Templates import Toolchain +import Toolchain3 import Trigraph import TrustBoundaries import TypeRanges @@ -162,6 +163,7 @@ newtype TCPPQuery = TStringsPackageQuery(StringsQuery q) or TTemplatesPackageQuery(TemplatesQuery q) or TToolchainPackageQuery(ToolchainQuery q) or + TToolchain3PackageQuery(Toolchain3Query q) or TTrigraphPackageQuery(TrigraphQuery q) or TTrustBoundariesPackageQuery(TrustBoundariesQuery q) or TTypeRangesPackageQuery(TypeRangesQuery q) or @@ -246,6 +248,7 @@ predicate isQueryMetadata(Query query, string queryId, string ruleId, string cat isStringsQueryMetadata(query, queryId, ruleId, category) or isTemplatesQueryMetadata(query, queryId, ruleId, category) or isToolchainQueryMetadata(query, queryId, ruleId, category) or + isToolchain3QueryMetadata(query, queryId, ruleId, category) or isTrigraphQueryMetadata(query, queryId, ruleId, category) or isTrustBoundariesQueryMetadata(query, queryId, ruleId, category) or isTypeRangesQueryMetadata(query, queryId, ruleId, category) or diff --git a/cpp/common/src/codingstandards/cpp/exclusions/cpp/Toolchain3.qll b/cpp/common/src/codingstandards/cpp/exclusions/cpp/Toolchain3.qll new file mode 100644 index 000000000..4d7ab478c --- /dev/null +++ b/cpp/common/src/codingstandards/cpp/exclusions/cpp/Toolchain3.qll @@ -0,0 +1,282 @@ +//** THIS FILE IS AUTOGENERATED, DO NOT MODIFY DIRECTLY. **/ +import cpp +import RuleMetadata +import codingstandards.cpp.exclusions.RuleMetadata + +newtype Toolchain3Query = + TRedeclarationOfStaticConstexprDataMemberAuditQuery() or + TImplicitDeclarationOfCopyConstructorAuditQuery() or + TNoexceptSpecifierThrowAuditQuery() or + TUseOfDeprecatedCHeadersQuery() or + TUseOfDeprecatedStrStreamClassQuery() or + TUseOfUncaughtExceptionQuery() or + TUseOfWeakResultTypesAuditQuery() or + TUseOfDeprecatedFunctionBinderTypedefMemberAuditQuery() or + TUseOfDeprecatedUnaryOrBinaryNegateQuery() or + TUseOfDeprecatedAllocatorVoidQuery() or + TUseOfDeprecatedStdAllocatorMemberQuery() or + TUseOfDeprecatedRawStorageIteratorQuery() or + TUseOfDeprecatedTemporaryBuffersQuery() or + TUseOfDeprecatedIsLiteralTypeTraitsQuery() or + TUseOfDeprecatedStdIteratorBaseClassQuery() or + TUseOfDeprecatedSharedPtrUniqueQuery() + +predicate isToolchain3QueryMetadata(Query query, string queryId, string ruleId, string category) { + query = + // `Query` instance for the `redeclarationOfStaticConstexprDataMemberAudit` query + Toolchain3Package::redeclarationOfStaticConstexprDataMemberAuditQuery() and + queryId = + // `@id` for the `redeclarationOfStaticConstexprDataMemberAudit` query + "cpp/misra/redeclaration-of-static-constexpr-data-member-audit" and + ruleId = "RULE-4-1-2" and + category = "advisory" + or + query = + // `Query` instance for the `implicitDeclarationOfCopyConstructorAudit` query + Toolchain3Package::implicitDeclarationOfCopyConstructorAuditQuery() and + queryId = + // `@id` for the `implicitDeclarationOfCopyConstructorAudit` query + "cpp/misra/implicit-declaration-of-copy-constructor-audit" and + ruleId = "RULE-4-1-2" and + category = "advisory" + or + query = + // `Query` instance for the `noexceptSpecifierThrowAudit` query + Toolchain3Package::noexceptSpecifierThrowAuditQuery() and + queryId = + // `@id` for the `noexceptSpecifierThrowAudit` query + "cpp/misra/noexcept-specifier-throw-audit" and + ruleId = "RULE-4-1-2" and + category = "advisory" + or + query = + // `Query` instance for the `useOfDeprecatedCHeaders` query + Toolchain3Package::useOfDeprecatedCHeadersQuery() and + queryId = + // `@id` for the `useOfDeprecatedCHeaders` query + "cpp/misra/use-of-deprecated-c-headers" and + ruleId = "RULE-4-1-2" and + category = "advisory" + or + query = + // `Query` instance for the `useOfDeprecatedStrStreamClass` query + Toolchain3Package::useOfDeprecatedStrStreamClassQuery() and + queryId = + // `@id` for the `useOfDeprecatedStrStreamClass` query + "cpp/misra/use-of-deprecated-str-stream-class" and + ruleId = "RULE-4-1-2" and + category = "advisory" + or + query = + // `Query` instance for the `useOfUncaughtException` query + Toolchain3Package::useOfUncaughtExceptionQuery() and + queryId = + // `@id` for the `useOfUncaughtException` query + "cpp/misra/use-of-uncaught-exception" and + ruleId = "RULE-4-1-2" and + category = "advisory" + or + query = + // `Query` instance for the `useOfWeakResultTypesAudit` query + Toolchain3Package::useOfWeakResultTypesAuditQuery() and + queryId = + // `@id` for the `useOfWeakResultTypesAudit` query + "cpp/misra/use-of-weak-result-types-audit" and + ruleId = "RULE-4-1-2" and + category = "advisory" + or + query = + // `Query` instance for the `useOfDeprecatedFunctionBinderTypedefMemberAudit` query + Toolchain3Package::useOfDeprecatedFunctionBinderTypedefMemberAuditQuery() and + queryId = + // `@id` for the `useOfDeprecatedFunctionBinderTypedefMemberAudit` query + "cpp/misra/use-of-deprecated-function-binder-typedef-member-audit" and + ruleId = "RULE-4-1-2" and + category = "advisory" + or + query = + // `Query` instance for the `useOfDeprecatedUnaryOrBinaryNegate` query + Toolchain3Package::useOfDeprecatedUnaryOrBinaryNegateQuery() and + queryId = + // `@id` for the `useOfDeprecatedUnaryOrBinaryNegate` query + "cpp/misra/use-of-deprecated-unary-or-binary-negate" and + ruleId = "RULE-4-1-2" and + category = "advisory" + or + query = + // `Query` instance for the `useOfDeprecatedAllocatorVoid` query + Toolchain3Package::useOfDeprecatedAllocatorVoidQuery() and + queryId = + // `@id` for the `useOfDeprecatedAllocatorVoid` query + "cpp/misra/use-of-deprecated-allocator-void" and + ruleId = "RULE-4-1-2" and + category = "advisory" + or + query = + // `Query` instance for the `useOfDeprecatedStdAllocatorMember` query + Toolchain3Package::useOfDeprecatedStdAllocatorMemberQuery() and + queryId = + // `@id` for the `useOfDeprecatedStdAllocatorMember` query + "cpp/misra/use-of-deprecated-std-allocator-member" and + ruleId = "RULE-4-1-2" and + category = "advisory" + or + query = + // `Query` instance for the `useOfDeprecatedRawStorageIterator` query + Toolchain3Package::useOfDeprecatedRawStorageIteratorQuery() and + queryId = + // `@id` for the `useOfDeprecatedRawStorageIterator` query + "cpp/misra/use-of-deprecated-raw-storage-iterator" and + ruleId = "RULE-4-1-2" and + category = "advisory" + or + query = + // `Query` instance for the `useOfDeprecatedTemporaryBuffers` query + Toolchain3Package::useOfDeprecatedTemporaryBuffersQuery() and + queryId = + // `@id` for the `useOfDeprecatedTemporaryBuffers` query + "cpp/misra/use-of-deprecated-temporary-buffers" and + ruleId = "RULE-4-1-2" and + category = "advisory" + or + query = + // `Query` instance for the `useOfDeprecatedIsLiteralTypeTraits` query + Toolchain3Package::useOfDeprecatedIsLiteralTypeTraitsQuery() and + queryId = + // `@id` for the `useOfDeprecatedIsLiteralTypeTraits` query + "cpp/misra/use-of-deprecated-is-literal-type-traits" and + ruleId = "RULE-4-1-2" and + category = "advisory" + or + query = + // `Query` instance for the `useOfDeprecatedStdIteratorBaseClass` query + Toolchain3Package::useOfDeprecatedStdIteratorBaseClassQuery() and + queryId = + // `@id` for the `useOfDeprecatedStdIteratorBaseClass` query + "cpp/misra/use-of-deprecated-std-iterator-base-class" and + ruleId = "RULE-4-1-2" and + category = "advisory" + or + query = + // `Query` instance for the `useOfDeprecatedSharedPtrUnique` query + Toolchain3Package::useOfDeprecatedSharedPtrUniqueQuery() and + queryId = + // `@id` for the `useOfDeprecatedSharedPtrUnique` query + "cpp/misra/use-of-deprecated-shared-ptr-unique" and + ruleId = "RULE-4-1-2" and + category = "advisory" +} + +module Toolchain3Package { + Query redeclarationOfStaticConstexprDataMemberAuditQuery() { + //autogenerate `Query` type + result = + // `Query` type for `redeclarationOfStaticConstexprDataMemberAudit` query + TQueryCPP(TToolchain3PackageQuery(TRedeclarationOfStaticConstexprDataMemberAuditQuery())) + } + + Query implicitDeclarationOfCopyConstructorAuditQuery() { + //autogenerate `Query` type + result = + // `Query` type for `implicitDeclarationOfCopyConstructorAudit` query + TQueryCPP(TToolchain3PackageQuery(TImplicitDeclarationOfCopyConstructorAuditQuery())) + } + + Query noexceptSpecifierThrowAuditQuery() { + //autogenerate `Query` type + result = + // `Query` type for `noexceptSpecifierThrowAudit` query + TQueryCPP(TToolchain3PackageQuery(TNoexceptSpecifierThrowAuditQuery())) + } + + Query useOfDeprecatedCHeadersQuery() { + //autogenerate `Query` type + result = + // `Query` type for `useOfDeprecatedCHeaders` query + TQueryCPP(TToolchain3PackageQuery(TUseOfDeprecatedCHeadersQuery())) + } + + Query useOfDeprecatedStrStreamClassQuery() { + //autogenerate `Query` type + result = + // `Query` type for `useOfDeprecatedStrStreamClass` query + TQueryCPP(TToolchain3PackageQuery(TUseOfDeprecatedStrStreamClassQuery())) + } + + Query useOfUncaughtExceptionQuery() { + //autogenerate `Query` type + result = + // `Query` type for `useOfUncaughtException` query + TQueryCPP(TToolchain3PackageQuery(TUseOfUncaughtExceptionQuery())) + } + + Query useOfWeakResultTypesAuditQuery() { + //autogenerate `Query` type + result = + // `Query` type for `useOfWeakResultTypesAudit` query + TQueryCPP(TToolchain3PackageQuery(TUseOfWeakResultTypesAuditQuery())) + } + + Query useOfDeprecatedFunctionBinderTypedefMemberAuditQuery() { + //autogenerate `Query` type + result = + // `Query` type for `useOfDeprecatedFunctionBinderTypedefMemberAudit` query + TQueryCPP(TToolchain3PackageQuery(TUseOfDeprecatedFunctionBinderTypedefMemberAuditQuery())) + } + + Query useOfDeprecatedUnaryOrBinaryNegateQuery() { + //autogenerate `Query` type + result = + // `Query` type for `useOfDeprecatedUnaryOrBinaryNegate` query + TQueryCPP(TToolchain3PackageQuery(TUseOfDeprecatedUnaryOrBinaryNegateQuery())) + } + + Query useOfDeprecatedAllocatorVoidQuery() { + //autogenerate `Query` type + result = + // `Query` type for `useOfDeprecatedAllocatorVoid` query + TQueryCPP(TToolchain3PackageQuery(TUseOfDeprecatedAllocatorVoidQuery())) + } + + Query useOfDeprecatedStdAllocatorMemberQuery() { + //autogenerate `Query` type + result = + // `Query` type for `useOfDeprecatedStdAllocatorMember` query + TQueryCPP(TToolchain3PackageQuery(TUseOfDeprecatedStdAllocatorMemberQuery())) + } + + Query useOfDeprecatedRawStorageIteratorQuery() { + //autogenerate `Query` type + result = + // `Query` type for `useOfDeprecatedRawStorageIterator` query + TQueryCPP(TToolchain3PackageQuery(TUseOfDeprecatedRawStorageIteratorQuery())) + } + + Query useOfDeprecatedTemporaryBuffersQuery() { + //autogenerate `Query` type + result = + // `Query` type for `useOfDeprecatedTemporaryBuffers` query + TQueryCPP(TToolchain3PackageQuery(TUseOfDeprecatedTemporaryBuffersQuery())) + } + + Query useOfDeprecatedIsLiteralTypeTraitsQuery() { + //autogenerate `Query` type + result = + // `Query` type for `useOfDeprecatedIsLiteralTypeTraits` query + TQueryCPP(TToolchain3PackageQuery(TUseOfDeprecatedIsLiteralTypeTraitsQuery())) + } + + Query useOfDeprecatedStdIteratorBaseClassQuery() { + //autogenerate `Query` type + result = + // `Query` type for `useOfDeprecatedStdIteratorBaseClass` query + TQueryCPP(TToolchain3PackageQuery(TUseOfDeprecatedStdIteratorBaseClassQuery())) + } + + Query useOfDeprecatedSharedPtrUniqueQuery() { + //autogenerate `Query` type + result = + // `Query` type for `useOfDeprecatedSharedPtrUnique` query + TQueryCPP(TToolchain3PackageQuery(TUseOfDeprecatedSharedPtrUniqueQuery())) + } +} diff --git a/cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.ql b/cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.ql new file mode 100644 index 000000000..973a92b39 --- /dev/null +++ b/cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.ql @@ -0,0 +1,24 @@ +/** + * @id cpp/misra/implicit-declaration-of-copy-constructor-audit + * @name RULE-4-1-2: Implicit declaration of copy constructors is a deprecated language feature should not be used + * @description Deprecated language features such as implicit declarations of copy constructors are + * only supported for backwards compatibility; these are considered bad practice, or + * have been superceded by better alternatives. + * @kind problem + * @precision low + * @problem.severity warning + * @tags external/misra/id/rule-4-1-2 + * scope/single-translation-unit + * maintainability + * audit + * external/misra/enforcement/decidable + * external/misra/obligation/advisory + */ + +import cpp +import codingstandards.cpp.misra + +from +where + not isExcluded(x, Toolchain3Package::implicitDeclarationOfCopyConstructorAuditQuery()) and +select diff --git a/cpp/misra/src/rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.ql b/cpp/misra/src/rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.ql new file mode 100644 index 000000000..d25882e33 --- /dev/null +++ b/cpp/misra/src/rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.ql @@ -0,0 +1,24 @@ +/** + * @id cpp/misra/noexcept-specifier-throw-audit + * @name RULE-4-1-2: The noexcept specifier throw() is a deprecated language feature should not be used + * @description Deprecated language features such as the noexcept specifier throw() are only + * supported for backwards compatibility; these are considered bad practice, or have + * been superceded by better alternatives. + * @kind problem + * @precision low + * @problem.severity warning + * @tags external/misra/id/rule-4-1-2 + * scope/single-translation-unit + * maintainability + * audit + * external/misra/enforcement/decidable + * external/misra/obligation/advisory + */ + +import cpp +import codingstandards.cpp.misra + +from +where + not isExcluded(x, Toolchain3Package::noexceptSpecifierThrowAuditQuery()) and +select diff --git a/cpp/misra/src/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.ql b/cpp/misra/src/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.ql new file mode 100644 index 000000000..febc00226 --- /dev/null +++ b/cpp/misra/src/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.ql @@ -0,0 +1,24 @@ +/** + * @id cpp/misra/redeclaration-of-static-constexpr-data-member-audit + * @name RULE-4-1-2: Redeclaration of static constexpr data members is a deprecated language feature should not be used + * @description Deprecated language features such as redeclaration of static constexpr data members + * are only supported for backwards compatibility; these are considered bad practice, + * or have been superceded by better alternatives. + * @kind problem + * @precision low + * @problem.severity warning + * @tags external/misra/id/rule-4-1-2 + * scope/single-translation-unit + * maintainability + * audit + * external/misra/enforcement/decidable + * external/misra/obligation/advisory + */ + +import cpp +import codingstandards.cpp.misra + +from +where + not isExcluded(x, Toolchain3Package::redeclarationOfStaticConstexprDataMemberAuditQuery()) and +select diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedAllocatorVoid.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedAllocatorVoid.ql new file mode 100644 index 000000000..3b861b1ed --- /dev/null +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedAllocatorVoid.ql @@ -0,0 +1,23 @@ +/** + * @id cpp/misra/use-of-deprecated-allocator-void + * @name RULE-4-1-2: Specialization allocator is a deprecated language feature and should not be used + * @description Deprecated language features such as allocator are only supported for + * backwards compatibility; these are considered bad practice, or have been superceded + * by better alternatives. + * @kind problem + * @precision very-high + * @problem.severity warning + * @tags external/misra/id/rule-4-1-2 + * scope/single-translation-unit + * maintainability + * external/misra/enforcement/decidable + * external/misra/obligation/advisory + */ + +import cpp +import codingstandards.cpp.misra + +from +where + not isExcluded(x, Toolchain3Package::useOfDeprecatedAllocatorVoidQuery()) and +select diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedCHeaders.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedCHeaders.ql new file mode 100644 index 000000000..12585c73e --- /dev/null +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedCHeaders.ql @@ -0,0 +1,22 @@ +/** + * @id cpp/misra/use-of-deprecated-c-headers + * @name RULE-4-1-2: Use of , , and , or is deprecated and therefore these headers should not be used + * @description These C standard library headers are only supported for backwards compatibility; + * these are considered bad practice, or have been superceded by better alternatives. + * @kind problem + * @precision very-high + * @problem.severity warning + * @tags external/misra/id/rule-4-1-2 + * scope/single-translation-unit + * maintainability + * external/misra/enforcement/decidable + * external/misra/obligation/advisory + */ + +import cpp +import codingstandards.cpp.misra + +from +where + not isExcluded(x, Toolchain3Package::useOfDeprecatedCHeadersQuery()) and +select diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.ql new file mode 100644 index 000000000..1ce21ed74 --- /dev/null +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.ql @@ -0,0 +1,24 @@ +/** + * @id cpp/misra/use-of-deprecated-function-binder-typedef-member-audit + * @name RULE-4-1-2: Certain members of function binder typedefs are deprecated language features and should not be used + * @description Deprecated language features such as certain function binder typedef members are + * only supported for backwards compatibility; these are considered bad practice, or + * have been superceded by better alternatives. + * @kind problem + * @precision low + * @problem.severity warning + * @tags external/misra/id/rule-4-1-2 + * scope/single-translation-unit + * maintainability + * audit + * external/misra/enforcement/decidable + * external/misra/obligation/advisory + */ + +import cpp +import codingstandards.cpp.misra + +from +where + not isExcluded(x, Toolchain3Package::useOfDeprecatedFunctionBinderTypedefMemberAuditQuery()) and +select diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedIsLiteralTypeTraits.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedIsLiteralTypeTraits.ql new file mode 100644 index 000000000..3b808ceb2 --- /dev/null +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedIsLiteralTypeTraits.ql @@ -0,0 +1,23 @@ +/** + * @id cpp/misra/use-of-deprecated-is-literal-type-traits + * @name RULE-4-1-2: The is-literal type traits are deprecated language features and should not be used + * @description Deprecated language features such as is-literal type traits are only supported for + * backwards compatibility; these are considered bad practice, or have been superceded + * by better alternatives. + * @kind problem + * @precision very-high + * @problem.severity warning + * @tags external/misra/id/rule-4-1-2 + * scope/single-translation-unit + * maintainability + * external/misra/enforcement/decidable + * external/misra/obligation/advisory + */ + +import cpp +import codingstandards.cpp.misra + +from +where + not isExcluded(x, Toolchain3Package::useOfDeprecatedIsLiteralTypeTraitsQuery()) and +select diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedRawStorageIterator.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedRawStorageIterator.ql new file mode 100644 index 000000000..21760ffd5 --- /dev/null +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedRawStorageIterator.ql @@ -0,0 +1,23 @@ +/** + * @id cpp/misra/use-of-deprecated-raw-storage-iterator + * @name RULE-4-1-2: Class raw_storage_iterator is a deprecated language feature and should not be used + * @description Deprecated language features such as raw_storage_iterator are only supported for + * backwards compatibility; these are considered bad practice, or have been superceded + * by better alternatives. + * @kind problem + * @precision high + * @problem.severity warning + * @tags external/misra/id/rule-4-1-2 + * scope/single-translation-unit + * maintainability + * external/misra/enforcement/decidable + * external/misra/obligation/advisory + */ + +import cpp +import codingstandards.cpp.misra + +from +where + not isExcluded(x, Toolchain3Package::useOfDeprecatedRawStorageIteratorQuery()) and +select diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedSharedPtrUnique.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedSharedPtrUnique.ql new file mode 100644 index 000000000..4f068e5c3 --- /dev/null +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedSharedPtrUnique.ql @@ -0,0 +1,23 @@ +/** + * @id cpp/misra/use-of-deprecated-shared-ptr-unique + * @name RULE-4-1-2: Observer member shared_ptr::unique is a deprecated language feature and should not be used + * @description Deprecated language features such as shared_ptr::unique are only supported for + * backwards compatibility; these are considered bad practice, or have been superceded + * by better alternatives. + * @kind problem + * @precision very-high + * @problem.severity warning + * @tags external/misra/id/rule-4-1-2 + * scope/single-translation-unit + * maintainability + * external/misra/enforcement/decidable + * external/misra/obligation/advisory + */ + +import cpp +import codingstandards.cpp.misra + +from +where + not isExcluded(x, Toolchain3Package::useOfDeprecatedSharedPtrUniqueQuery()) and +select diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.ql new file mode 100644 index 000000000..d3eeb2e87 --- /dev/null +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.ql @@ -0,0 +1,23 @@ +/** + * @id cpp/misra/use-of-deprecated-std-allocator-member + * @name RULE-4-1-2: Certain members of std::allocator are deprecated language features and should not be used + * @description Deprecated language features such as certain members of std::allocator are only + * supported for backwards compatibility; these are considered bad practice, or have + * been superceded by better alternatives. + * @kind problem + * @precision very_high + * @problem.severity warning + * @tags external/misra/id/rule-4-1-2 + * scope/single-translation-unit + * maintainability + * external/misra/enforcement/decidable + * external/misra/obligation/advisory + */ + +import cpp +import codingstandards.cpp.misra + +from +where + not isExcluded(x, Toolchain3Package::useOfDeprecatedStdAllocatorMemberQuery()) and +select diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStdIteratorBaseClass.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStdIteratorBaseClass.ql new file mode 100644 index 000000000..1f7d048e1 --- /dev/null +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStdIteratorBaseClass.ql @@ -0,0 +1,23 @@ +/** + * @id cpp/misra/use-of-deprecated-std-iterator-base-class + * @name RULE-4-1-2: Base class std::iterator is a deprecated language feature and should not be used + * @description Deprecated language features such as extending std::iterator are only supported for + * backwards compatibility; these are considered bad practice, or have been superceded + * by better alternatives. + * @kind problem + * @precision very-high + * @problem.severity warning + * @tags external/misra/id/rule-4-1-2 + * scope/single-translation-unit + * maintainability + * external/misra/enforcement/decidable + * external/misra/obligation/advisory + */ + +import cpp +import codingstandards.cpp.misra + +from +where + not isExcluded(x, Toolchain3Package::useOfDeprecatedStdIteratorBaseClassQuery()) and +select diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStrStreamClass.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStrStreamClass.ql new file mode 100644 index 000000000..7b03456c7 --- /dev/null +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStrStreamClass.ql @@ -0,0 +1,23 @@ +/** + * @id cpp/misra/use-of-deprecated-str-stream-class + * @name RULE-4-1-2: The char* stream classes strstreambuf, istreamstr, ostramstr, and strstream are deprecated and should not be used + * @description Deprecated language features such as the char* stream classes are only supported for + * backwards compatibility; these are considered bad practice, or have been superceded + * by better alternatives. + * @kind problem + * @precision very-high + * @problem.severity warning + * @tags external/misra/id/rule-4-1-2 + * scope/single-translation-unit + * maintainability + * external/misra/enforcement/decidable + * external/misra/obligation/advisory + */ + +import cpp +import codingstandards.cpp.misra + +from +where + not isExcluded(x, Toolchain3Package::useOfDeprecatedStrStreamClassQuery()) and +select diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedTemporaryBuffers.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedTemporaryBuffers.ql new file mode 100644 index 000000000..2705ca695 --- /dev/null +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedTemporaryBuffers.ql @@ -0,0 +1,23 @@ +/** + * @id cpp/misra/use-of-deprecated-temporary-buffers + * @name RULE-4-1-2: Temporary buffers are deprecated language features and should not be used + * @description Deprecated language features such as temporary buffers are only supported for + * backwards compatibility; these are considered bad practice, or have been superceded + * by better alternatives. + * @kind problem + * @precision very-high + * @problem.severity warning + * @tags external/misra/id/rule-4-1-2 + * scope/single-translation-unit + * maintainability + * external/misra/enforcement/decidable + * external/misra/obligation/advisory + */ + +import cpp +import codingstandards.cpp.misra + +from +where + not isExcluded(x, Toolchain3Package::useOfDeprecatedTemporaryBuffersQuery()) and +select diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedUnaryOrBinaryNegate.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedUnaryOrBinaryNegate.ql new file mode 100644 index 000000000..ed41d4c76 --- /dev/null +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedUnaryOrBinaryNegate.ql @@ -0,0 +1,23 @@ +/** + * @id cpp/misra/use-of-deprecated-unary-or-binary-negate + * @name RULE-4-1-2: Typedefs unary_negate and binary_negate are deprecated language features and should not be used + * @description Deprecated language features such as unary_negate and binary_negate are only + * supported for backwards compatibility; these are considered bad practice, or have + * been superceded by better alternatives. + * @kind problem + * @precision very-high + * @problem.severity warning + * @tags external/misra/id/rule-4-1-2 + * scope/single-translation-unit + * maintainability + * external/misra/enforcement/decidable + * external/misra/obligation/advisory + */ + +import cpp +import codingstandards.cpp.misra + +from +where + not isExcluded(x, Toolchain3Package::useOfDeprecatedUnaryOrBinaryNegateQuery()) and +select diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfUncaughtException.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfUncaughtException.ql new file mode 100644 index 000000000..bc6f568a4 --- /dev/null +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfUncaughtException.ql @@ -0,0 +1,23 @@ +/** + * @id cpp/misra/use-of-uncaught-exception + * @name RULE-4-1-2: Function uncaught_exception is a deprecated language feature should not be used + * @description Deprecated language features such as uncaught_exception are only supported for + * backwards compatibility; these are considered bad practice, or have been superceded + * by better alternatives. + * @kind problem + * @precision very-high + * @problem.severity warning + * @tags external/misra/id/rule-4-1-2 + * scope/single-translation-unit + * maintainability + * external/misra/enforcement/decidable + * external/misra/obligation/advisory + */ + +import cpp +import codingstandards.cpp.misra + +from +where + not isExcluded(x, Toolchain3Package::useOfUncaughtExceptionQuery()) and +select diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfWeakResultTypesAudit.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfWeakResultTypesAudit.ql new file mode 100644 index 000000000..7243b1698 --- /dev/null +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfWeakResultTypesAudit.ql @@ -0,0 +1,24 @@ +/** + * @id cpp/misra/use-of-weak-result-types-audit + * @name RULE-4-1-2: Weak result types are a deprecated language feature should not be used + * @description Deprecated language features such as weak result types are only supported for + * backwards compatibility; these are considered bad practice, or have been superceded + * by better alternatives. + * @kind problem + * @precision low + * @problem.severity warning + * @tags external/misra/id/rule-4-1-2 + * scope/single-translation-unit + * maintainability + * audit + * external/misra/enforcement/decidable + * external/misra/obligation/advisory + */ + +import cpp +import codingstandards.cpp.misra + +from +where + not isExcluded(x, Toolchain3Package::useOfWeakResultTypesAuditQuery()) and +select diff --git a/cpp/misra/test/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.expected b/cpp/misra/test/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.expected new file mode 100644 index 000000000..2ec1a0ac6 --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.qlref b/cpp/misra/test/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.qlref new file mode 100644 index 000000000..cd10ab6ab --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.qlref @@ -0,0 +1 @@ +rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.ql \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.expected b/cpp/misra/test/rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.expected new file mode 100644 index 000000000..2ec1a0ac6 --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.qlref b/cpp/misra/test/rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.qlref new file mode 100644 index 000000000..bff1cd5bb --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.qlref @@ -0,0 +1 @@ +rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.ql \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.expected b/cpp/misra/test/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.expected new file mode 100644 index 000000000..2ec1a0ac6 --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.qlref b/cpp/misra/test/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.qlref new file mode 100644 index 000000000..bbd3f15b4 --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.qlref @@ -0,0 +1 @@ +rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.ql \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedAllocatorVoid.expected b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedAllocatorVoid.expected new file mode 100644 index 000000000..2ec1a0ac6 --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedAllocatorVoid.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedAllocatorVoid.qlref b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedAllocatorVoid.qlref new file mode 100644 index 000000000..25aa5dda2 --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedAllocatorVoid.qlref @@ -0,0 +1 @@ +rules/RULE-4-1-2/UseOfDeprecatedAllocatorVoid.ql \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedCHeaders.expected b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedCHeaders.expected new file mode 100644 index 000000000..2ec1a0ac6 --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedCHeaders.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedCHeaders.qlref b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedCHeaders.qlref new file mode 100644 index 000000000..8ac7301da --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedCHeaders.qlref @@ -0,0 +1 @@ +rules/RULE-4-1-2/UseOfDeprecatedCHeaders.ql \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.expected b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.expected new file mode 100644 index 000000000..2ec1a0ac6 --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.qlref b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.qlref new file mode 100644 index 000000000..d664b9dde --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.qlref @@ -0,0 +1 @@ +rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.ql \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedIsLiteralTypeTraits.expected b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedIsLiteralTypeTraits.expected new file mode 100644 index 000000000..2ec1a0ac6 --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedIsLiteralTypeTraits.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedIsLiteralTypeTraits.qlref b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedIsLiteralTypeTraits.qlref new file mode 100644 index 000000000..47217979b --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedIsLiteralTypeTraits.qlref @@ -0,0 +1 @@ +rules/RULE-4-1-2/UseOfDeprecatedIsLiteralTypeTraits.ql \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedRawStorageIterator.expected b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedRawStorageIterator.expected new file mode 100644 index 000000000..2ec1a0ac6 --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedRawStorageIterator.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedRawStorageIterator.qlref b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedRawStorageIterator.qlref new file mode 100644 index 000000000..87d3287ec --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedRawStorageIterator.qlref @@ -0,0 +1 @@ +rules/RULE-4-1-2/UseOfDeprecatedRawStorageIterator.ql \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedSharedPtrUnique.expected b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedSharedPtrUnique.expected new file mode 100644 index 000000000..2ec1a0ac6 --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedSharedPtrUnique.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedSharedPtrUnique.qlref b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedSharedPtrUnique.qlref new file mode 100644 index 000000000..cf1342658 --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedSharedPtrUnique.qlref @@ -0,0 +1 @@ +rules/RULE-4-1-2/UseOfDeprecatedSharedPtrUnique.ql \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.expected b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.expected new file mode 100644 index 000000000..2ec1a0ac6 --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.qlref b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.qlref new file mode 100644 index 000000000..98d4a6cd4 --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.qlref @@ -0,0 +1 @@ +rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.ql \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStdIteratorBaseClass.expected b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStdIteratorBaseClass.expected new file mode 100644 index 000000000..2ec1a0ac6 --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStdIteratorBaseClass.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStdIteratorBaseClass.qlref b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStdIteratorBaseClass.qlref new file mode 100644 index 000000000..a5645ab10 --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStdIteratorBaseClass.qlref @@ -0,0 +1 @@ +rules/RULE-4-1-2/UseOfDeprecatedStdIteratorBaseClass.ql \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStrStreamClass.expected b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStrStreamClass.expected new file mode 100644 index 000000000..2ec1a0ac6 --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStrStreamClass.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStrStreamClass.qlref b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStrStreamClass.qlref new file mode 100644 index 000000000..819f0dab6 --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStrStreamClass.qlref @@ -0,0 +1 @@ +rules/RULE-4-1-2/UseOfDeprecatedStrStreamClass.ql \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedTemporaryBuffers.expected b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedTemporaryBuffers.expected new file mode 100644 index 000000000..2ec1a0ac6 --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedTemporaryBuffers.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedTemporaryBuffers.qlref b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedTemporaryBuffers.qlref new file mode 100644 index 000000000..858027aba --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedTemporaryBuffers.qlref @@ -0,0 +1 @@ +rules/RULE-4-1-2/UseOfDeprecatedTemporaryBuffers.ql \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedUnaryOrBinaryNegate.expected b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedUnaryOrBinaryNegate.expected new file mode 100644 index 000000000..2ec1a0ac6 --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedUnaryOrBinaryNegate.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedUnaryOrBinaryNegate.qlref b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedUnaryOrBinaryNegate.qlref new file mode 100644 index 000000000..91645a933 --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedUnaryOrBinaryNegate.qlref @@ -0,0 +1 @@ +rules/RULE-4-1-2/UseOfDeprecatedUnaryOrBinaryNegate.ql \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfUncaughtException.expected b/cpp/misra/test/rules/RULE-4-1-2/UseOfUncaughtException.expected new file mode 100644 index 000000000..2ec1a0ac6 --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfUncaughtException.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfUncaughtException.qlref b/cpp/misra/test/rules/RULE-4-1-2/UseOfUncaughtException.qlref new file mode 100644 index 000000000..21ae2f4a9 --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfUncaughtException.qlref @@ -0,0 +1 @@ +rules/RULE-4-1-2/UseOfUncaughtException.ql \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfWeakResultTypesAudit.expected b/cpp/misra/test/rules/RULE-4-1-2/UseOfWeakResultTypesAudit.expected new file mode 100644 index 000000000..2ec1a0ac6 --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfWeakResultTypesAudit.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfWeakResultTypesAudit.qlref b/cpp/misra/test/rules/RULE-4-1-2/UseOfWeakResultTypesAudit.qlref new file mode 100644 index 000000000..f22e4853b --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfWeakResultTypesAudit.qlref @@ -0,0 +1 @@ +rules/RULE-4-1-2/UseOfWeakResultTypesAudit.ql \ No newline at end of file diff --git a/rule_packages/cpp/Toolchain3.json b/rule_packages/cpp/Toolchain3.json new file mode 100644 index 000000000..d1eb5d56d --- /dev/null +++ b/rule_packages/cpp/Toolchain3.json @@ -0,0 +1,210 @@ +{ + "MISRA-C++-2023": { + "RULE-4-1-2": { + "properties": { + "enforcement": "decidable", + "obligation": "advisory" + }, + "queries": [ + { + "description": "Deprecated language features such as redeclaration of static constexpr data members are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "kind": "problem", + "name": "Redeclaration of static constexpr data members is a deprecated language feature should not be used", + "precision": "low", + "severity": "warning", + "short_name": "RedeclarationOfStaticConstexprDataMemberAudit", + "tags": [ + "scope/single-translation-unit", + "maintainability", + "audit" + ] + }, + { + "description": "Deprecated language features such as implicit declarations of copy constructors are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "kind": "problem", + "name": "Implicit declaration of copy constructors is a deprecated language feature should not be used", + "precision": "low", + "severity": "warning", + "short_name": "ImplicitDeclarationOfCopyConstructorAudit", + "tags": [ + "scope/single-translation-unit", + "maintainability", + "audit" + ] + }, + { + "description": "Deprecated language features such as the noexcept specifier throw() are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "kind": "problem", + "name": "The noexcept specifier throw() is a deprecated language feature should not be used", + "precision": "low", + "severity": "warning", + "short_name": "NoexceptSpecifierThrowAudit", + "tags": [ + "scope/single-translation-unit", + "maintainability", + "audit" + ] + }, + { + "description": "These C standard library headers are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "kind": "problem", + "name": "Use of , , and , or is deprecated and therefore these headers should not be used", + "precision": "very-high", + "severity": "warning", + "short_name": "UseOfDeprecatedCHeaders", + "tags": [ + "scope/single-translation-unit", + "maintainability" + ] + }, + { + "description": "Deprecated language features such as the char* stream classes are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "kind": "problem", + "name": "The char* stream classes strstreambuf, istreamstr, ostramstr, and strstream are deprecated and should not be used", + "precision": "very-high", + "severity": "warning", + "short_name": "UseOfDeprecatedStrStreamClass", + "tags": [ + "scope/single-translation-unit", + "maintainability" + ] + }, + { + "description": "Deprecated language features such as uncaught_exception are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "kind": "problem", + "name": "Function uncaught_exception is a deprecated language feature should not be used", + "precision": "very-high", + "severity": "warning", + "short_name": "UseOfUncaughtException", + "tags": [ + "scope/single-translation-unit", + "maintainability" + ] + }, + { + "description": "Deprecated language features such as weak result types are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "kind": "problem", + "name": "Weak result types are a deprecated language feature should not be used", + "precision": "low", + "severity": "warning", + "short_name": "UseOfWeakResultTypesAudit", + "tags": [ + "scope/single-translation-unit", + "maintainability", + "audit" + ] + }, + { + "description": "Deprecated language features such as certain function binder typedef members are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "kind": "problem", + "name": "Certain members of function binder typedefs are deprecated language features and should not be used", + "precision": "low", + "severity": "warning", + "short_name": "UseOfDeprecatedFunctionBinderTypedefMemberAudit", + "tags": [ + "scope/single-translation-unit", + "maintainability", + "audit" + ] + }, + { + "description": "Deprecated language features such as unary_negate and binary_negate are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "kind": "problem", + "name": "Typedefs unary_negate and binary_negate are deprecated language features and should not be used", + "precision": "very-high", + "severity": "warning", + "short_name": "UseOfDeprecatedUnaryOrBinaryNegate", + "tags": [ + "scope/single-translation-unit", + "maintainability" + ] + }, + { + "description": "Deprecated language features such as allocator are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "kind": "problem", + "name": "Specialization allocator is a deprecated language feature and should not be used", + "precision": "very-high", + "severity": "warning", + "short_name": "UseOfDeprecatedAllocatorVoid", + "tags": [ + "scope/single-translation-unit", + "maintainability" + ] + }, + { + "description": "Deprecated language features such as certain members of std::allocator are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "kind": "problem", + "name": "Certain members of std::allocator are deprecated language features and should not be used", + "precision": "very_high", + "severity": "warning", + "short_name": "UseOfDeprecatedStdAllocatorMember", + "tags": [ + "scope/single-translation-unit", + "maintainability" + ] + }, + { + "description": "Deprecated language features such as raw_storage_iterator are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "kind": "problem", + "name": "Class raw_storage_iterator is a deprecated language feature and should not be used", + "precision": "high", + "severity": "warning", + "short_name": "UseOfDeprecatedRawStorageIterator", + "tags": [ + "scope/single-translation-unit", + "maintainability" + ] + }, + { + "description": "Deprecated language features such as temporary buffers are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "kind": "problem", + "name": "Temporary buffers are deprecated language features and should not be used", + "precision": "very-high", + "severity": "warning", + "short_name": "UseOfDeprecatedTemporaryBuffers", + "tags": [ + "scope/single-translation-unit", + "maintainability" + ] + }, + { + "description": "Deprecated language features such as is-literal type traits are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "kind": "problem", + "name": "The is-literal type traits are deprecated language features and should not be used", + "precision": "very-high", + "severity": "warning", + "short_name": "UseOfDeprecatedIsLiteralTypeTraits", + "tags": [ + "scope/single-translation-unit", + "maintainability" + ] + }, + { + "description": "Deprecated language features such as extending std::iterator are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "kind": "problem", + "name": "Base class std::iterator is a deprecated language feature and should not be used", + "precision": "very-high", + "severity": "warning", + "short_name": "UseOfDeprecatedStdIteratorBaseClass", + "tags": [ + "scope/single-translation-unit", + "maintainability" + ] + }, + { + "description": "Deprecated language features such as shared_ptr::unique are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "kind": "problem", + "name": "Observer member shared_ptr::unique is a deprecated language feature and should not be used", + "precision": "very-high", + "severity": "warning", + "short_name": "UseOfDeprecatedSharedPtrUnique", + "tags": [ + "scope/single-translation-unit", + "maintainability" + ] + } + ], + "title": "Deprecated features should not be used" + } + } +} \ No newline at end of file diff --git a/rules.csv b/rules.csv index 664b50851..1a4babdb4 100644 --- a/rules.csv +++ b/rules.csv @@ -834,7 +834,7 @@ cpp,MISRA-C++-2023,RULE-0-2-4,Yes,Advisory,Decidable,System,Functions with limit cpp,MISRA-C++-2023,DIR-0-3-1,Yes,Advisory,,,Floating-point arithmetic should be used appropriately,,FloatingPoint,Hard, cpp,MISRA-C++-2023,DIR-0-3-2,Yes,Required,,,A function call shall not violate the function’s preconditions,,Preconditions,Hard, cpp,MISRA-C++-2023,RULE-4-1-1,Yes,Required,Undecidable,System,A program shall conform to ISO/IEC 14882:2017 (C++17),,Toolchain2,Hard, -cpp,MISRA-C++-2023,RULE-4-1-2,Yes,Advisory,Decidable,Single Translation Unit,Deprecated features should not be used,,Toolchain2,Very Hard, +cpp,MISRA-C++-2023,RULE-4-1-2,Yes,Advisory,Decidable,Single Translation Unit,Deprecated features should not be used,,Toolchain3,Very Hard, cpp,MISRA-C++-2023,RULE-4-1-3,Yes,Required,Undecidable,System,There shall be no occurrence of undefined or critical unspecified behaviour,,Undefined,Very Hard, cpp,MISRA-C++-2023,RULE-4-6-1,Yes,Required,Undecidable,System,Operations on a memory location shall be sequenced appropriately,RULE-13-2,SideEffects4,Easy, cpp,MISRA-C++-2023,RULE-5-0-1,Yes,Advisory,Decidable,Single Translation Unit,Trigraph-like sequences should not be used,A2-5-1,Trigraph,Very Hard, From fe37604d1f889d46fd82eb26285780db45fca528 Mon Sep 17 00:00:00 2001 From: Mike Fairhurst Date: Sun, 1 Mar 2026 17:00:48 -0800 Subject: [PATCH 02/13] First few queries implemented --- .../includes/standard-library/functional.h | 15 ++++++ .../test/includes/standard-library/memory.h | 1 + .../RULE-4-1-2/UseOfDeprecatedCHeaders.ql | 8 +-- .../UseOfDeprecatedIsLiteralTypeTraits.ql | 43 +++++++++++++-- .../UseOfDeprecatedSharedPtrUnique.ql | 9 ++-- .../UseOfDeprecatedUnaryOrBinaryNegate.ql | 18 +++++-- .../RULE-4-1-2/UseOfUncaughtException.ql | 7 +-- .../UseOfDeprecatedSharedPtrUnique.expected | 5 +- ...seOfDeprecatedUnaryOrBinaryNegate.expected | 5 +- .../UseOfUncaughtException.expected | 2 +- cpp/misra/test/rules/RULE-4-1-2/test.cpp | 53 +++++++++++++++++++ 11 files changed, 148 insertions(+), 18 deletions(-) create mode 100644 cpp/misra/test/rules/RULE-4-1-2/test.cpp diff --git a/cpp/common/test/includes/standard-library/functional.h b/cpp/common/test/includes/standard-library/functional.h index 40994eaef..7886083d1 100644 --- a/cpp/common/test/includes/standard-library/functional.h +++ b/cpp/common/test/includes/standard-library/functional.h @@ -85,6 +85,21 @@ template struct equal_to { typedef bool result_type; }; +template class unary_negate { +public: + unary_negate() = default; + explicit unary_negate(const Predicate &pred); + bool operator()(const typename Predicate::argument_type &x) const; +}; + +template class binary_negate { +public: + binary_negate() = default; + explicit binary_negate(const Predicate &pred); + bool operator()(const typename Predicate::first_argument_type &x, + const typename Predicate::second_argument_type &y) const; +}; + template class function; template class function { public: diff --git a/cpp/common/test/includes/standard-library/memory.h b/cpp/common/test/includes/standard-library/memory.h index 75bb2c51d..f5beefe7b 100644 --- a/cpp/common/test/includes/standard-library/memory.h +++ b/cpp/common/test/includes/standard-library/memory.h @@ -103,6 +103,7 @@ template class shared_ptr : public __shared_ptr { ~shared_ptr() {} T &operator*() const noexcept; T *operator->() const noexcept; + bool unique() const noexcept; shared_ptr &operator=(const shared_ptr &) {} shared_ptr &operator=(shared_ptr &&) { return *this; } diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedCHeaders.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedCHeaders.ql index 12585c73e..9f2bc6423 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedCHeaders.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedCHeaders.ql @@ -16,7 +16,9 @@ import cpp import codingstandards.cpp.misra -from +from Include include, string includeText where - not isExcluded(x, Toolchain3Package::useOfDeprecatedCHeadersQuery()) and -select + not isExcluded(include, Toolchain3Package::useOfDeprecatedCHeadersQuery()) and + includeText = include.getIncludeText() and + includeText = "" +select include, "Inclusion of deprecated C header '" + includeText + "'." diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedIsLiteralTypeTraits.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedIsLiteralTypeTraits.ql index 3b808ceb2..d8a361d91 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedIsLiteralTypeTraits.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedIsLiteralTypeTraits.ql @@ -17,7 +17,44 @@ import cpp import codingstandards.cpp.misra -from +class IsLiteralTypeTemplate extends TemplateClass { + IsLiteralTypeTemplate() { this.hasQualifiedName("std", "is_literal_type") } +} + +class IsLiteralTypeVariable extends TemplateVariable { + IsLiteralTypeVariable() { this.hasQualifiedName("std", "is_literal_type") } +} + +from Element usage, string type, string useKind where - not isExcluded(x, Toolchain3Package::useOfDeprecatedIsLiteralTypeTraitsQuery()) and -select + not isExcluded(usage, Toolchain3Package::useOfDeprecatedIsLiteralTypeTraitsQuery()) and + ( + exists(ClassTemplateInstantiation c | + c.getTemplate() instanceof IsLiteralTypeTemplate and + usage.(TypeMention).getMentionedType() = c and + type = "std::is_literal_type" and + useKind = "instantiation" + ) + or + exists(VariableTemplateInstantiation v | + v.getTemplate() instanceof IsLiteralTypeVariable and + usage.(VariableAccess).getTarget() = v and + type = "std::is_literal_type" and + useKind = "instantiation" + ) + or + exists(ClassTemplateSpecialization cti | + cti.getPrimaryTemplate() instanceof IsLiteralTypeTemplate and + usage.(TypeMention).getMentionedType() = cti and + type = "std::is_literal_type" and + useKind = "specialization" + ) + or + exists(VariableTemplateSpecialization vts | + vts.getPrimaryTemplate() instanceof IsLiteralTypeVariable and + usage.(VariableAccess).getTarget() = vts and + type = "std::is_literal_type" and + useKind = "specialization" + ) + ) +select usage, "Use of deprecated type trait '" + type + "' through " + useKind + "." diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedSharedPtrUnique.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedSharedPtrUnique.ql index 4f068e5c3..95bd72cfb 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedSharedPtrUnique.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedSharedPtrUnique.ql @@ -17,7 +17,10 @@ import cpp import codingstandards.cpp.misra -from +from MemberFunction mf, FunctionCall fc where - not isExcluded(x, Toolchain3Package::useOfDeprecatedSharedPtrUniqueQuery()) and -select + not isExcluded(fc, Toolchain3Package::useOfDeprecatedSharedPtrUniqueQuery()) and + mf = fc.getTarget() and + mf.hasName("unique") and + mf.getDeclaringType().(ClassTemplateInstantiation).hasQualifiedName("std", "shared_ptr") +select fc, "Call to deprecated member function 'std::shared_ptr::unique'." diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedUnaryOrBinaryNegate.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedUnaryOrBinaryNegate.ql index ed41d4c76..f4616ac59 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedUnaryOrBinaryNegate.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedUnaryOrBinaryNegate.ql @@ -17,7 +17,19 @@ import cpp import codingstandards.cpp.misra -from +predicate isUnaryOrBinaryNegate(ClassTemplateInstantiation c) { + c.hasQualifiedName("std", ["unary_negate", "binary_negate"]) +} + +predicate isUsingUnaryOrBinaryNegate(ClassTemplateInstantiation c) { + isUnaryOrBinaryNegate(c) or + isUsingUnaryOrBinaryNegate(c.getTemplateArgument(_)) +} + +from Variable v, ClassTemplateInstantiation c where - not isExcluded(x, Toolchain3Package::useOfDeprecatedUnaryOrBinaryNegateQuery()) and -select + not isExcluded(v, Toolchain3Package::useOfDeprecatedUnaryOrBinaryNegateQuery()) and + v.getUnderlyingType() = c and + not v.isFromTemplateInstantiation(_) and + isUsingUnaryOrBinaryNegate(c) +select v, "Use of deprecated type 'std::" + c.getSimpleName() + "'." diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfUncaughtException.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfUncaughtException.ql index bc6f568a4..c0861a6b4 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/UseOfUncaughtException.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfUncaughtException.ql @@ -17,7 +17,8 @@ import cpp import codingstandards.cpp.misra -from +from FunctionCall fc where - not isExcluded(x, Toolchain3Package::useOfUncaughtExceptionQuery()) and -select + not isExcluded(fc, Toolchain3Package::useOfUncaughtExceptionQuery()) and + fc.getTarget().hasQualifiedName("std", "uncaught_exception") +select fc, "Call to deprecated function 'std::uncaught_exception'." diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedSharedPtrUnique.expected b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedSharedPtrUnique.expected index 2ec1a0ac6..e9b0d3a7d 100644 --- a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedSharedPtrUnique.expected +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedSharedPtrUnique.expected @@ -1 +1,4 @@ -No expected results have yet been specified \ No newline at end of file +| test.cpp:36:6:36:11 | call to unique | Call to deprecated member function 'std::shared_ptr::unique'. | +| test.cpp:38:12:38:17 | call to unique | Call to deprecated member function 'std::shared_ptr::unique'. | +| test.cpp:39:15:39:20 | call to unique | Call to deprecated member function 'std::shared_ptr::unique'. | +| test.cpp:43:6:43:11 | call to unique | Call to deprecated member function 'std::shared_ptr::unique'. | \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedUnaryOrBinaryNegate.expected b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedUnaryOrBinaryNegate.expected index 2ec1a0ac6..c0444bcf6 100644 --- a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedUnaryOrBinaryNegate.expected +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedUnaryOrBinaryNegate.expected @@ -1 +1,4 @@ -No expected results have yet been specified \ No newline at end of file +| test.cpp:25:27:25:28 | g1 | Use of deprecated type 'std::unary_negate'. | +| test.cpp:26:30:26:31 | g2 | Use of deprecated type 'std::binary_negate'. | +| test.cpp:29:29:29:30 | l1 | Use of deprecated type 'std::unary_negate'. | +| test.cpp:30:32:30:33 | l2 | Use of deprecated type 'std::binary_negate'. | \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfUncaughtException.expected b/cpp/misra/test/rules/RULE-4-1-2/UseOfUncaughtException.expected index 2ec1a0ac6..6851145d9 100644 --- a/cpp/misra/test/rules/RULE-4-1-2/UseOfUncaughtException.expected +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfUncaughtException.expected @@ -1 +1 @@ -No expected results have yet been specified \ No newline at end of file +| test.cpp:12:20:12:42 | call to uncaught_exception | Call to deprecated function 'std::uncaught_exception'. | \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/test.cpp b/cpp/misra/test/rules/RULE-4-1-2/test.cpp new file mode 100644 index 000000000..e88e6e6f0 --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/test.cpp @@ -0,0 +1,53 @@ +#include +#include +#include + +// COMPLIANT - normal exception handling +void f1() { + try { + } catch (const std::exception &) { + } +} + +bool f2() { return std::uncaught_exception(); } // NON_COMPLIANT + +struct IsZero { + typedef int argument_type; + bool operator()(int x) const { return x == 0; } +}; + +struct NotEqual { + typedef int first_argument_type; + typedef int second_argument_type; + bool operator()(int x, int y) const { return x != y; } +}; + +std::unary_negate g1; // NON_COMPLIANT +std::binary_negate g2; // NON_COMPLIANT + +void f3() { + std::unary_negate l1; // NON_COMPLIANT + std::binary_negate l2; // NON_COMPLIANT + std::function l3; // COMPLIANT +} + +void f4() { + std::shared_ptr p1; + p1.unique(); // NON_COMPLIANT + p1.use_count(); // COMPLIANT + (void)p1.unique(); // NON_COMPLIANT + bool b = p1.unique(); // NON_COMPLIANT +} + +void f5(std::shared_ptr p1) { + p1.unique(); // NON_COMPLIANT +} + +#include // NON_COMPLIANT +#include // NON_COMPLIANT +#include // NON_COMPLIANT +#include // NON_COMPLIANT +#include // COMPLIANT +#include // COMPLIANT +#include // COMPLIANT +#include // COMPLIANT \ No newline at end of file From 5532f1317b1be266003916804fa7e11d7b5a4738 Mon Sep 17 00:00:00 2001 From: Mike Fairhurst Date: Sun, 1 Mar 2026 21:03:40 -0800 Subject: [PATCH 03/13] Most cases implemented --- .../cpp/standardlibrary/Memory.qll | 4 + .../types/ImplicitSpecialMemberFunctions.qll | 147 ++++++++++++++++++ .../test/includes/standard-library/ccomplex | 0 .../test/includes/standard-library/complex | 0 .../test/includes/standard-library/cstdalign | 0 .../test/includes/standard-library/cstdbool | 0 .../test/includes/standard-library/ctgmath | 0 .../includes/standard-library/functional.h | 29 +++- .../test/includes/standard-library/memory.h | 41 +++++ .../includes/standard-library/strstream.h | 7 + .../includes/standard-library/type_traits.h | 15 ++ ...plicitDeclarationOfCopyConstructorAudit.ql | 14 +- .../RULE-4-1-2/NoexceptSpecifierThrowAudit.ql | 9 +- .../UseOfDeprecatedAllocatorVoid.ql | 15 +- ...recatedFunctionBinderTypedefMemberAudit.ql | 57 ++++++- .../UseOfDeprecatedIsLiteralTypeTraits.ql | 8 +- .../UseOfDeprecatedRawStorageIterator.ql | 8 +- .../UseOfDeprecatedStdAllocatorMember.ql | 66 +++++++- .../UseOfDeprecatedStdIteratorBaseClass.ql | 10 +- .../UseOfDeprecatedStrStreamClass.ql | 8 +- .../UseOfDeprecatedTemporaryBuffers.ql | 7 +- .../NoexceptSpecifierThrowAudit.expected | 2 +- .../UseOfDeprecatedAllocatorVoid.expected | 2 +- .../UseOfDeprecatedCHeaders.expected | 5 +- ...dFunctionBinderTypedefMemberAudit.expected | 11 +- ...seOfDeprecatedIsLiteralTypeTraits.expected | 5 +- ...UseOfDeprecatedRawStorageIterator.expected | 3 +- ...UseOfDeprecatedStdAllocatorMember.expected | 8 +- ...eOfDeprecatedStdIteratorBaseClass.expected | 2 +- .../UseOfDeprecatedStrStreamClass.expected | 5 +- .../UseOfDeprecatedTemporaryBuffers.expected | 3 +- cpp/misra/test/rules/RULE-4-1-2/test.cpp | 127 +++++++++++++-- rule_packages/cpp/Toolchain3.json | 35 +++-- 33 files changed, 586 insertions(+), 67 deletions(-) create mode 100644 cpp/common/src/codingstandards/cpp/types/ImplicitSpecialMemberFunctions.qll create mode 100644 cpp/common/test/includes/standard-library/ccomplex create mode 100644 cpp/common/test/includes/standard-library/complex create mode 100644 cpp/common/test/includes/standard-library/cstdalign create mode 100644 cpp/common/test/includes/standard-library/cstdbool create mode 100644 cpp/common/test/includes/standard-library/ctgmath diff --git a/cpp/common/src/codingstandards/cpp/standardlibrary/Memory.qll b/cpp/common/src/codingstandards/cpp/standardlibrary/Memory.qll index 688b48dd0..214223110 100644 --- a/cpp/common/src/codingstandards/cpp/standardlibrary/Memory.qll +++ b/cpp/common/src/codingstandards/cpp/standardlibrary/Memory.qll @@ -4,6 +4,10 @@ import cpp +class DefaultAllocator extends TemplateClass { + DefaultAllocator() { this.hasQualifiedName("std", "allocator") } +} + abstract class UninitializedMemoryManagementFunction extends Function { UninitializedMemoryManagementFunction() { this.getADeclarationLocation().getFile().getShortName() = "memory" diff --git a/cpp/common/src/codingstandards/cpp/types/ImplicitSpecialMemberFunctions.qll b/cpp/common/src/codingstandards/cpp/types/ImplicitSpecialMemberFunctions.qll new file mode 100644 index 000000000..349666972 --- /dev/null +++ b/cpp/common/src/codingstandards/cpp/types/ImplicitSpecialMemberFunctions.qll @@ -0,0 +1,147 @@ +import cpp + +predicate mustBeImplicitlyDefined(Function mf) { + // If it exists and its defaulted, it must be implicitly defined + mf.isCompilerGenerated() or mf.isDefaulted() +} + +predicate mustNotBeImplicitlyDefined(Function mf) { + // Sanity check: exclude member functions that are definitely user defined! + not mustBeImplicitlyDefined(mf) and + ( + // If the user wrote a body, it's not implicitly defined + not mf.isCompilerGenerated() + or + // Deleted functions have no definition at all + mf.isDeleted() + ) +} + +predicate mustBeUserDeclared(Function mf) { + exists(FunctionDeclarationEntry fde | fde.getFunction() = mf and not fde.isImplicit()) +} + +predicate mustNotBeUserDeclared(Function mf) { + // use forex: at least one declaration must exist, and all declarations must be implicit + forex(FunctionDeclarationEntry fde | fde.getFunction() = mf | fde.isImplicit()) +} + +private signature class SpecialMember extends Function; + +private signature predicate constraint(Function mf); + +/** + * Implicitly defined copy constructors are deprecated if the class has a user-declared copy + * assignment operator or a user-declared destructor. The same is true for the reverse case + * (implicit copy assignment operators check for copy constructors). + * + * Unfortunately, trivial copy constructors, assignment operators, and destructors are often missing + * from the database, so we can only approximate. + * + * To manage all of the negatives, double negatives, musts, mays, and may nots, the problem is + * broken down into sets as defined below. + * + * Firstly: + * - CC=copy constructor, CA=copy assignment operator, D=destructor + * - IDEF = implicitly defined, UDEC = user declared + * + * and: + * - C_has{X} = set of all classes T for which "class T has a {X}" + * - C_mustHave{X} = set of all classes T for which "class T must have a {X}" + * - C_cannotHave{X} = set of all classes T for which "class T cannot have a {X}" + * - C_mayHave{X} = not C_cannotHave{X} + * + * then we can find all cases we know to be deprecated via: + * - Step 1: find C_mustHave{IDEF CC}, C_mustHave{IDEF CA} + * - Step 2: find C_mustHave{UDEC CC}, C_mustHave{UDEC CA}, C_mustHave{UDEC D} + * - Step 3: All C' are deprecated where C' in C_mustHave{IDEF CC} and (C' in C_mustHave{UDEC CA} or C' in C_mustHave{UDEC D}) + * - Step 4: All C' are deprecated where C' in C_mustHave{IDEF CA} and (C' in C_mustHave{UDEC CC} or C' in C_mustHave{UDEC D}) + * + * And all cases we may consider deprecated via: + * - Step 5: find C_cannotHave{IDEF CC}, C_cannotHave{IDEF CA} + * - Step 6: find C_mayHave{IDEF CC}, C_mayHave{IDEF CA} (by negating the cannot sets) + * - Step 7: find C_cannotHave{UDEC CC}, C_cannotHave{UDEC CA}, C_cannotHave{UDEC D} + * - Step 8: find C_mayHave{UDEC CC}, C_mayHave{UDEC CA}, C_mayHave{UDEC D} (by negating the cannot sets) + * - Step 9: All C' may be deprecated where C' in C_mayHave{IDEF CC} and (C' in C_mayHave{UDEC CA} or C' in C_mayHave{UDEC D}) + * - Step 10: All C' may be deprecated where C' in C_mayHave{IDEF CA} and (C' in C_mayHave{UDEC CC} or C' in C_mayHave{UDEC D}) + * + * This is performed through the various instantiations of this module. + */ +private module ClassesWhere { + final class FinalClass = Class; + + class Matching extends FinalClass { + Matching() { exists(Member member | member.getDeclaringType() = this and pred(member)) } + } + + class NotMatching extends FinalClass { + NotMatching() { not this instanceof Matching } + } +} + +/* Step 1: find C_mustHave{IDEF CC}, C_mustHave{IDEF CA} */ +private class CMustHaveIdefCC = ClassesWhere::Matching; + +private class CMustHaveIdefCA = + ClassesWhere::Matching; + +/* Step 2: find C_mustHave{UDEC CC}, C_mustHave{UDEC CA}, C_mustHave{UDEC D} */ +private class CMustHaveUdecCC = ClassesWhere::Matching; + +private class CMustHaveUdecCA = + ClassesWhere::Matching; + +private class CMustHaveUdecD = ClassesWhere::Matching; + +/* - Step 3: All C' are deprecated where C' in C_mustHave{IDEF CC} and (C' in C_mustHave{UDEC CA} or C' in C_mustHave{UDEC D}) */ +class MustHaveDeprecatedCopyConstructor extends CMustHaveIdefCC { + MustHaveDeprecatedCopyConstructor() { + this instanceof CMustHaveUdecCA or this instanceof CMustHaveUdecD + } +} + +/* - Step 4: All C' are deprecated where C' in C_mustHave{IDEF CA} and (C' in C_mustHave{UDEC CC} or C' in C_mustHave{UDEC D}) */ +class MustHaveDeprecatedCopyAssignmentOperator extends CMustHaveIdefCA { + MustHaveDeprecatedCopyAssignmentOperator() { + this instanceof CMustHaveUdecCC or this instanceof CMustHaveUdecD + } +} + +/** + * Step 5: find C_cannotHave{IDEF CC}, C_cannotHave{IDEF CA} + * Step 6: find C_mayHave{IDEF CC}, C_mayHave{IDEF CA} (by negating the cannot sets) + * + * In our case, `ClassesWhere<...>` performs steps 5 and 6 together via `NotMatching`. + */ +private class CMayHaveIdefCC = + ClassesWhere::NotMatching; + +private class CMayHaveIdefCA = + ClassesWhere::NotMatching; + +/** + * Step 7: find C_cannotHave{UDEC CC}, C_cannotHave{UDEC CA}, C_cannotHave{UDEC D} + * Step 8: find C_mayHave{UDEC CC}, C_mayHave{UDEC CA}, C_mayHave{UDEC D} (by negating the cannot sets) + * + * In our case, `ClassesWhere<...>` performs steps 7 and 8 together via `NotMatching`. + */ +private class CMayHaveUdecCC = ClassesWhere::NotMatching; + +private class CMayHaveUdecCA = + ClassesWhere::NotMatching; + +private class CMayHaveUdecD = ClassesWhere::NotMatching; + +/* - Step 9: All C' may be deprecated where C' in C_mayHave{IDEF CC} and (C' in C_mayHave{UDEC CA} or C' in C_mayHave{UDEC D}) */ +class MayHaveDeprecatedCopyConstructor extends CMayHaveIdefCC { + MayHaveDeprecatedCopyConstructor() { + this instanceof CMayHaveUdecCA or this instanceof CMayHaveUdecD + } +} + +/* - Step 10: All C' may be deprecated where C' in C_mayHave{IDEF CA} and (C' in C_mayHave{UDEC CC} or C' in C_mayHave{UDEC D}) */ +class MayHaveDeprecatedCopyAssignmentOperator extends CMayHaveIdefCA { + MayHaveDeprecatedCopyAssignmentOperator() { + this instanceof CMayHaveUdecCC or this instanceof CMayHaveUdecD + } +} diff --git a/cpp/common/test/includes/standard-library/ccomplex b/cpp/common/test/includes/standard-library/ccomplex new file mode 100644 index 000000000..e69de29bb diff --git a/cpp/common/test/includes/standard-library/complex b/cpp/common/test/includes/standard-library/complex new file mode 100644 index 000000000..e69de29bb diff --git a/cpp/common/test/includes/standard-library/cstdalign b/cpp/common/test/includes/standard-library/cstdalign new file mode 100644 index 000000000..e69de29bb diff --git a/cpp/common/test/includes/standard-library/cstdbool b/cpp/common/test/includes/standard-library/cstdbool new file mode 100644 index 000000000..e69de29bb diff --git a/cpp/common/test/includes/standard-library/ctgmath b/cpp/common/test/includes/standard-library/ctgmath new file mode 100644 index 000000000..e69de29bb diff --git a/cpp/common/test/includes/standard-library/functional.h b/cpp/common/test/includes/standard-library/functional.h index 7886083d1..ed7e0ef31 100644 --- a/cpp/common/test/includes/standard-library/functional.h +++ b/cpp/common/test/includes/standard-library/functional.h @@ -15,6 +15,7 @@ extern const __ph<2> _2; } // namespace placeholders template class binder { public: + using result_type = int; // deprecated in C++17 template constexpr binder(TFn &&f, TArgs &&...args) noexcept {} @@ -57,7 +58,18 @@ template reference_wrapper ref(T &t) noexcept; template void ref(const T &&t) = delete; template reference_wrapper ref(reference_wrapper t) noexcept; -template struct hash { size_t operator()(Ty val) const; }; +template struct hash { + using result_type = size_t; // deprecated in C++17 + using argument_type = Ty; // deprecated in C++17 + size_t operator()(Ty val) const; +}; + +template class mem_fn_result { +public: + using result_type = int; // deprecated in C++17 +}; + +template mem_fn_result mem_fn(F f); template class pointer_to_unary_function : public unary_function { @@ -103,9 +115,24 @@ template class binary_negate { template class function; template class function { public: + using result_type = R; // deprecated in C++17 function(); template function(F&& f); template function &operator=(F &&); }; + +template struct plus { + using result_type = T; // deprecated in C++17 + using first_argument_type = T; // deprecated in C++17 + using second_argument_type = T; // deprecated in C++17 + T operator()(const T &x, const T &y) const; +}; + +template struct negate { + using result_type = T; // deprecated in C++17 + using argument_type = T; // deprecated in C++17 + T operator()(const T &x) const; +}; + } // namespace std #endif diff --git a/cpp/common/test/includes/standard-library/memory.h b/cpp/common/test/includes/standard-library/memory.h index f5beefe7b..86e45a310 100644 --- a/cpp/common/test/includes/standard-library/memory.h +++ b/cpp/common/test/includes/standard-library/memory.h @@ -1,6 +1,7 @@ #ifndef _GHLIBCPP_MEMORY #define _GHLIBCPP_MEMORY #include "exception.h" +#include "iterator.h" #include "stddef.h" #include "utility.h" @@ -135,6 +136,14 @@ template struct allocator { using value_type = T1; using size_type = std::size_t; using difference_type = std::ptrdiff_t; + // deprecated in C++17: + using pointer = T1 *; + using const_pointer = const T1 *; + using reference = T1 &; + using const_reference = const T1 &; + template struct rebind { + using other = allocator; + }; constexpr allocator() noexcept = default; constexpr allocator(const allocator &) noexcept = default; @@ -144,7 +153,14 @@ template struct allocator { ~allocator() = default; T1 *allocate(std::size_t); + T1 *allocate(std::size_t, const void *); void deallocate(T1 *, std::size_t); + // deprecated in C++17: + pointer address(reference r) const noexcept; + const_pointer address(const_reference r) const noexcept; + size_type max_size() const noexcept; + template void construct(U *p, Args &&...args); + template void destroy(U *p); }; template <> struct allocator { @@ -260,6 +276,31 @@ T2 destroy_n(T1&&, T2, T3); template constexpr T1* launder(T1*) noexcept; +// get_temporary_buffer / return_temporary_buffer (deprecated in C++17) +template +pair get_temporary_buffer(ptrdiff_t n) noexcept; + +template +void return_temporary_buffer(T *p); + +// raw_storage_iterator (deprecated in C++17) +template +class raw_storage_iterator { +public: + using iterator_category = output_iterator_tag; + using value_type = void; + using difference_type = void; + using pointer = void; + using reference = void; + explicit raw_storage_iterator(OutputIterator x); + raw_storage_iterator &operator*(); + raw_storage_iterator &operator=(const T &element); + raw_storage_iterator &operator=(T &&element); + raw_storage_iterator &operator++(); + raw_storage_iterator operator++(int); + OutputIterator base() const; +}; + } // namespace std #endif // _GHLIBCPP_MEMORY diff --git a/cpp/common/test/includes/standard-library/strstream.h b/cpp/common/test/includes/standard-library/strstream.h index ec0227e25..42b302a89 100644 --- a/cpp/common/test/includes/standard-library/strstream.h +++ b/cpp/common/test/includes/standard-library/strstream.h @@ -4,6 +4,8 @@ #include namespace std { +typedef basic_iostream iostream; + class strstreambuf : public basic_streambuf {}; class istrstream : public istream { @@ -18,4 +20,9 @@ class ostrstream : public ostream { public: ostrstream(); }; + +class strstream : public iostream { +public: + strstream(); +}; } // namespace std \ No newline at end of file diff --git a/cpp/common/test/includes/standard-library/type_traits.h b/cpp/common/test/includes/standard-library/type_traits.h index c56c5aa7a..f164019b8 100644 --- a/cpp/common/test/includes/standard-library/type_traits.h +++ b/cpp/common/test/includes/standard-library/type_traits.h @@ -82,5 +82,20 @@ template struct is_trivially_move_assignable { constexpr operator bool() { return value; } }; +template struct is_literal_type { + const static bool value = true; + constexpr operator bool() { return value; } +}; + +template struct is_trivially_copyable { + const static bool value = true; + constexpr operator bool() { return value; } +}; + +template inline constexpr bool is_literal_type_v = is_literal_type::value; + +template +inline constexpr bool is_trivially_copyable_v = is_trivially_copyable::value; + } // namespace std #endif // _GHLIBCPP_TYPE_TRAITS \ No newline at end of file diff --git a/cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.ql b/cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.ql index 973a92b39..852ebef89 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.ql @@ -17,8 +17,16 @@ import cpp import codingstandards.cpp.misra +import codingstandards.cpp.types.ImplicitSpecialMemberFunctions -from +from Class c, string specialMemberName where - not isExcluded(x, Toolchain3Package::implicitDeclarationOfCopyConstructorAuditQuery()) and -select + not isExcluded(c, Toolchain3Package::implicitDeclarationOfCopyConstructorAuditQuery()) and + ( + c instanceof MayHaveDeprecatedCopyConstructor and + specialMemberName = "copy constructor" + or + c instanceof MayHaveDeprecatedCopyAssignmentOperator and + specialMemberName = "copy assignment operator" + ) +select c, "Class '" + c.getName() + "' may have a deprecated " + specialMemberName + "." diff --git a/cpp/misra/src/rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.ql b/cpp/misra/src/rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.ql index d25882e33..93c20d6e1 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.ql @@ -18,7 +18,10 @@ import cpp import codingstandards.cpp.misra -from +from Function f where - not isExcluded(x, Toolchain3Package::noexceptSpecifierThrowAuditQuery()) and -select + not isExcluded(f, Toolchain3Package::noexceptSpecifierThrowAuditQuery()) and + f.isNoThrow() and + not f.isCompilerGenerated() +select f, + "Function '" + f.getName() + "' is declared with the deprecated noexcept specifier 'throw()'." diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedAllocatorVoid.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedAllocatorVoid.ql index 3b861b1ed..6dd59ad36 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedAllocatorVoid.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedAllocatorVoid.ql @@ -16,8 +16,17 @@ import cpp import codingstandards.cpp.misra +import codingstandards.cpp.standardlibrary.Memory -from +class DeprecatedDefaultAllocator extends ClassTemplateSpecialization { + DeprecatedDefaultAllocator() { + this.getPrimaryTemplate() instanceof DefaultAllocator and + this.getTemplateArgument(0) instanceof VoidType + } +} + +from TypeMention tm, DeprecatedDefaultAllocator x where - not isExcluded(x, Toolchain3Package::useOfDeprecatedAllocatorVoidQuery()) and -select + not isExcluded(tm, Toolchain3Package::useOfDeprecatedAllocatorVoidQuery()) and + tm.getMentionedType() = x +select tm, "Use of deprecated allocator specialization 'std::allocator'." diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.ql index 1ce21ed74..e878e06ef 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.ql @@ -17,8 +17,59 @@ import cpp import codingstandards.cpp.misra +import codingstandards.cpp.StdNamespace -from +predicate isFunctionTypeName(string s) { + s = + [ + "owner_less", "reference_wrapper", "plus", "minus", "multiplies", "divides", "modulus", + "negate", "equal_to", "not_equal_to", "greater", "less", "greater_equal", "less_equal", + "logical_and", "logical_or", "logical_not", "bit_and", "bit_or", "bit_xor", "bit_not", + "function", "hash" + ] +} + +abstract class FunctionTypeWithBindings extends ClassTemplateInstantiation { } + +class FunctionTypeWithBindingsByName extends FunctionTypeWithBindings { + FunctionTypeWithBindingsByName() { + isFunctionTypeName(getSimpleName()) and + this.getNamespace() instanceof StdNS + } +} + +class FunctionTypeByReturnFromFunction extends FunctionTypeWithBindings { + Function causalType; + + FunctionTypeByReturnFromFunction() { + causalType.hasQualifiedName("std", ["bind", "mem_fn"]) and + // The return types of std::bind and std::mem_fn are function wrapper types. + this = causalType.getType() + } +} + +class FunctionTypeByNestedClass extends FunctionTypeWithBindings { + Class causalType; + + FunctionTypeByNestedClass() { + causalType.getSimpleName() = ["map", "multimap"] and + causalType.getNamespace() instanceof StdNS and + this.(Class).getDeclaringType() = causalType and + this.getName() = "value_compare" + } +} + +class DeprecatedFunctionBinderTypedefMember extends UsingAliasTypedefType { + ClassTemplateInstantiation cti; + + DeprecatedFunctionBinderTypedefMember() { + this.getName() = ["result_type", "argument_type", "first_argument_type", "second_argument_type"] and + this.getDeclaringType() instanceof FunctionTypeWithBindings + } +} + +from TypeMention tm, DeprecatedFunctionBinderTypedefMember member where - not isExcluded(x, Toolchain3Package::useOfDeprecatedFunctionBinderTypedefMemberAuditQuery()) and -select + not isExcluded(tm, Toolchain3Package::useOfDeprecatedFunctionBinderTypedefMemberAuditQuery()) and + tm.getMentionedType() = member +select tm, "Use of deprecated function binder typedef member " + member.toString() diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedIsLiteralTypeTraits.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedIsLiteralTypeTraits.ql index d8a361d91..2b45d360b 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedIsLiteralTypeTraits.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedIsLiteralTypeTraits.ql @@ -22,7 +22,7 @@ class IsLiteralTypeTemplate extends TemplateClass { } class IsLiteralTypeVariable extends TemplateVariable { - IsLiteralTypeVariable() { this.hasQualifiedName("std", "is_literal_type") } + IsLiteralTypeVariable() { this.hasQualifiedName("std", "is_literal_type_v") } } from Element usage, string type, string useKind @@ -45,15 +45,15 @@ where or exists(ClassTemplateSpecialization cti | cti.getPrimaryTemplate() instanceof IsLiteralTypeTemplate and - usage.(TypeMention).getMentionedType() = cti and + usage = cti and type = "std::is_literal_type" and useKind = "specialization" ) or exists(VariableTemplateSpecialization vts | vts.getPrimaryTemplate() instanceof IsLiteralTypeVariable and - usage.(VariableAccess).getTarget() = vts and - type = "std::is_literal_type" and + usage = vts and + type = "std::is_literal_type_v" and useKind = "specialization" ) ) diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedRawStorageIterator.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedRawStorageIterator.ql index 21760ffd5..c8acc52d7 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedRawStorageIterator.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedRawStorageIterator.ql @@ -17,7 +17,9 @@ import cpp import codingstandards.cpp.misra -from +from TypeMention tm, ClassTemplateInstantiation c where - not isExcluded(x, Toolchain3Package::useOfDeprecatedRawStorageIteratorQuery()) and -select + not isExcluded(tm, Toolchain3Package::useOfDeprecatedRawStorageIteratorQuery()) and + tm.getMentionedType() = c and + c.hasQualifiedName("std", "raw_storage_iterator") +select tm, "Use of deprecated type 'std::raw_storage_iterator'." diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.ql index d3eeb2e87..2424c38f0 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.ql @@ -16,8 +16,68 @@ import cpp import codingstandards.cpp.misra +import codingstandards.cpp.standardlibrary.Memory -from +abstract class DeprecatedUse extends Element { + abstract Locatable getAUseLocation(); + + abstract string getAUseDescription(); +} + +class DeprecatedAllocatorUsingMember extends UsingAliasTypedefType, DeprecatedUse { + ClassTemplateInstantiation cti; + + DeprecatedAllocatorUsingMember() { + this.getDeclaringType().isFromTemplateInstantiation(cti) and + cti.getTemplate() instanceof DefaultAllocator and + this.hasName([ + "pointer", "const_pointer", "reference", "const_reference", "value_type", "size_type", + "difference_type" + ]) + } + + override Locatable getAUseLocation() { result.(TypeMention).getMentionedType() = this } + + override string getAUseDescription() { + result = "Use of deprecated allocator member 'std::allocator::pointer'." + } +} + +class DeprecatedAllocatorMemberFunction extends MemberFunction, DeprecatedUse { + ClassTemplateInstantiation cti; + + DeprecatedAllocatorMemberFunction() { + this.getDeclaringType().isFromTemplateInstantiation(cti) and + cti.getTemplate() instanceof DefaultAllocator and + ( + this.hasName(["address", "max_size", "construct", "destroy"]) + or + this.hasName("allocate") and this.getNumberOfParameters() = 2 + ) + } + + override Locatable getAUseLocation() { result.(FunctionCall).getTarget() = this } + + override string getAUseDescription() { + result = "Use of deprecated allocator member 'std::allocator::" + this.getName() + "'." + } +} + +class DeprecatedAllocatorMemberClass extends ClassTemplateInstantiation, DeprecatedUse { + DeprecatedAllocatorMemberClass() { + this.getDeclaringType() instanceof DefaultAllocator and + this.getSimpleName() = "rebind" + } + + override Locatable getAUseLocation() { result.(TypeMention).getMentionedType() = this } + + override string getAUseDescription() { + result = "Use of deprecated allocator member class 'std::allocator::rebind'." + } +} + +from DeprecatedUse deprecated, Locatable use where - not isExcluded(x, Toolchain3Package::useOfDeprecatedStdAllocatorMemberQuery()) and -select + not isExcluded(use, Toolchain3Package::useOfDeprecatedStdAllocatorMemberQuery()) and + use = deprecated.getAUseLocation() +select use, deprecated.getAUseDescription() diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStdIteratorBaseClass.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStdIteratorBaseClass.ql index 1f7d048e1..e94c9050c 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStdIteratorBaseClass.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStdIteratorBaseClass.ql @@ -16,8 +16,12 @@ import cpp import codingstandards.cpp.misra +import codingstandards.cpp.StdNamespace -from +from TypeMention tm, ClassTemplateInstantiation c where - not isExcluded(x, Toolchain3Package::useOfDeprecatedStdIteratorBaseClassQuery()) and -select + not isExcluded(tm, Toolchain3Package::useOfDeprecatedStdIteratorBaseClassQuery()) and + tm.getMentionedType() = c and + c.getNamespace() instanceof StdNS and + c.getSimpleName() = "iterator" +select tm, "Use of deprecated base class 'std::iterator'." diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStrStreamClass.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStrStreamClass.ql index 7b03456c7..6845cb771 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStrStreamClass.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStrStreamClass.ql @@ -17,7 +17,9 @@ import cpp import codingstandards.cpp.misra -from +from TypeMention tm, Class c where - not isExcluded(x, Toolchain3Package::useOfDeprecatedStrStreamClassQuery()) and -select + not isExcluded(tm, Toolchain3Package::useOfDeprecatedStrStreamClassQuery()) and + tm.getMentionedType() = c and + c.hasQualifiedName("std", ["strstreambuf", "istrstream", "ostrstream", "strstream"]) +select tm, "Use of deprecated type 'std::" + c.getName() + "'." diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedTemporaryBuffers.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedTemporaryBuffers.ql index 2705ca695..ec35e3010 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedTemporaryBuffers.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedTemporaryBuffers.ql @@ -17,7 +17,8 @@ import cpp import codingstandards.cpp.misra -from +from FunctionCall fc where - not isExcluded(x, Toolchain3Package::useOfDeprecatedTemporaryBuffersQuery()) and -select + not isExcluded(fc, Toolchain3Package::useOfDeprecatedTemporaryBuffersQuery()) and + fc.getTarget().hasQualifiedName("std", ["get_temporary_buffer", "return_temporary_buffer"]) +select fc, "Call to deprecated function 'std::" + fc.getTarget().getName() + "'." diff --git a/cpp/misra/test/rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.expected b/cpp/misra/test/rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.expected index 2ec1a0ac6..c375ad75c 100644 --- a/cpp/misra/test/rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.expected +++ b/cpp/misra/test/rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.expected @@ -1 +1 @@ -No expected results have yet been specified \ No newline at end of file +| test.cpp:153:6:153:7 | n1 | Function 'n1' is declared with the deprecated noexcept specifier 'throw()'. | diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedAllocatorVoid.expected b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedAllocatorVoid.expected index 2ec1a0ac6..4d59f7622 100644 --- a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedAllocatorVoid.expected +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedAllocatorVoid.expected @@ -1 +1 @@ -No expected results have yet been specified \ No newline at end of file +| test.cpp:99:8:99:16 | type mention | Use of deprecated allocator specialization 'std::allocator'. | diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedCHeaders.expected b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedCHeaders.expected index 2ec1a0ac6..ecadcafa7 100644 --- a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedCHeaders.expected +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedCHeaders.expected @@ -1 +1,4 @@ -No expected results have yet been specified \ No newline at end of file +| test.cpp:46:1:46:19 | #include | Inclusion of deprecated C header ''. | +| test.cpp:48:1:48:20 | #include | Inclusion of deprecated C header ''. | +| test.cpp:49:1:49:19 | #include | Inclusion of deprecated C header ''. | +| test.cpp:50:1:50:18 | #include | Inclusion of deprecated C header ''. | \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.expected b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.expected index 2ec1a0ac6..5f230568c 100644 --- a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.expected +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.expected @@ -1 +1,10 @@ -No expected results have yet been specified \ No newline at end of file +| test.cpp:103:19:103:29 | type mention | Use of deprecated function binder typedef member result_type | +| test.cpp:104:19:104:37 | type mention | Use of deprecated function binder typedef member first_argument_type | +| test.cpp:105:19:105:38 | type mention | Use of deprecated function binder typedef member second_argument_type | +| test.cpp:106:21:106:31 | type mention | Use of deprecated function binder typedef member result_type | +| test.cpp:107:21:107:33 | type mention | Use of deprecated function binder typedef member argument_type | +| test.cpp:108:28:108:38 | type mention | Use of deprecated function binder typedef member result_type | +| test.cpp:145:19:145:29 | type mention | Use of deprecated function binder typedef member result_type | +| test.cpp:146:19:146:31 | type mention | Use of deprecated function binder typedef member argument_type | +| test.cpp:148:16:148:26 | type mention | Use of deprecated function binder typedef member result_type | +| test.cpp:150:16:150:26 | type mention | Use of deprecated function binder typedef member result_type | \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedIsLiteralTypeTraits.expected b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedIsLiteralTypeTraits.expected index 2ec1a0ac6..2ee51de4e 100644 --- a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedIsLiteralTypeTraits.expected +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedIsLiteralTypeTraits.expected @@ -1 +1,4 @@ -No expected results have yet been specified \ No newline at end of file +| test.cpp:57:8:57:22 | type mention | Use of deprecated type trait 'std::is_literal_type' through instantiation. | +| test.cpp:58:17:58:31 | type mention | Use of deprecated type trait 'std::is_literal_type' through instantiation. | +| test.cpp:64:8:64:36 | is_literal_type | Use of deprecated type trait 'std::is_literal_type' through specialization. | +| test.cpp:67:12:67:38 | is_literal_type_v | Use of deprecated type trait 'std::is_literal_type' through instantiation. | diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedRawStorageIterator.expected b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedRawStorageIterator.expected index 2ec1a0ac6..50b7f60c2 100644 --- a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedRawStorageIterator.expected +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedRawStorageIterator.expected @@ -1 +1,2 @@ -No expected results have yet been specified \ No newline at end of file +| test.cpp:78:14:78:33 | type mention | Use of deprecated type 'std::raw_storage_iterator'. | +| test.cpp:79:8:79:27 | type mention | Use of deprecated type 'std::raw_storage_iterator'. | \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.expected b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.expected index 2ec1a0ac6..cd1e34580 100644 --- a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.expected +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.expected @@ -1 +1,7 @@ -No expected results have yet been specified \ No newline at end of file +| test.cpp:86:24:86:30 | type mention | Use of deprecated allocator member 'std::allocator::pointer'. | +| test.cpp:88:9:88:16 | call to allocate | Use of deprecated allocator member 'std::allocator::allocate'. | +| test.cpp:89:5:89:11 | call to address | Use of deprecated allocator member 'std::allocator::address'. | +| test.cpp:90:5:90:13 | call to construct | Use of deprecated allocator member 'std::allocator::construct'. | +| test.cpp:91:5:91:11 | call to destroy | Use of deprecated allocator member 'std::allocator::destroy'. | +| test.cpp:93:5:93:12 | call to max_size | Use of deprecated allocator member 'std::allocator::max_size'. | +| test.cpp:96:30:96:35 | type mention | Use of deprecated allocator member class 'std::allocator::rebind'. | diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStdIteratorBaseClass.expected b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStdIteratorBaseClass.expected index 2ec1a0ac6..734dc77fe 100644 --- a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStdIteratorBaseClass.expected +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStdIteratorBaseClass.expected @@ -1 +1 @@ -No expected results have yet been specified \ No newline at end of file +| test.cpp:123:22:123:29 | type mention | Use of deprecated base class 'std::iterator'. | \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStrStreamClass.expected b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStrStreamClass.expected index 2ec1a0ac6..e16767f26 100644 --- a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStrStreamClass.expected +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStrStreamClass.expected @@ -1 +1,4 @@ -No expected results have yet been specified \ No newline at end of file +| test.cpp:114:15:114:26 | type mention | Use of deprecated type 'std::strstreambuf'. | +| test.cpp:115:8:115:17 | type mention | Use of deprecated type 'std::istrstream'. | +| test.cpp:116:8:116:17 | type mention | Use of deprecated type 'std::ostrstream'. | +| test.cpp:117:8:117:16 | type mention | Use of deprecated type 'std::strstream'. | \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedTemporaryBuffers.expected b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedTemporaryBuffers.expected index 2ec1a0ac6..31163a854 100644 --- a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedTemporaryBuffers.expected +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedTemporaryBuffers.expected @@ -1 +1,2 @@ -No expected results have yet been specified \ No newline at end of file +| test.cpp:72:14:72:43 | call to get_temporary_buffer | Call to deprecated function 'std::get_temporary_buffer'. | +| test.cpp:73:3:73:30 | call to return_temporary_buffer | Call to deprecated function 'std::return_temporary_buffer'. | \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/test.cpp b/cpp/misra/test/rules/RULE-4-1-2/test.cpp index e88e6e6f0..90e3a1187 100644 --- a/cpp/misra/test/rules/RULE-4-1-2/test.cpp +++ b/cpp/misra/test/rules/RULE-4-1-2/test.cpp @@ -22,7 +22,7 @@ struct NotEqual { bool operator()(int x, int y) const { return x != y; } }; -std::unary_negate g1; // NON_COMPLIANT +std::unary_negate g1; // NON_COMPLIANT std::binary_negate g2; // NON_COMPLIANT void f3() { @@ -33,21 +33,124 @@ void f3() { void f4() { std::shared_ptr p1; - p1.unique(); // NON_COMPLIANT - p1.use_count(); // COMPLIANT - (void)p1.unique(); // NON_COMPLIANT - bool b = p1.unique(); // NON_COMPLIANT + p1.unique(); // NON_COMPLIANT + p1.use_count(); // COMPLIANT + (void)p1.unique(); // NON_COMPLIANT + bool b = p1.unique(); // NON_COMPLIANT } void f5(std::shared_ptr p1) { p1.unique(); // NON_COMPLIANT } -#include // NON_COMPLIANT -#include // NON_COMPLIANT -#include // NON_COMPLIANT -#include // NON_COMPLIANT -#include // COMPLIANT +#include // NON_COMPLIANT +#include // COMPLIANT +#include // NON_COMPLIANT +#include // NON_COMPLIANT +#include // NON_COMPLIANT #include // COMPLIANT -#include // COMPLIANT -#include // COMPLIANT \ No newline at end of file +#include // COMPLIANT +#include // COMPLIANT +#include + +void f6() { + std::is_literal_type l1; // NON_COMPLIANT + bool b = std::is_literal_type::value; // NON_COMPLIANT + std::is_trivially_copy_constructible l2; // COMPLIANT +} + +struct my_type; +template <> +struct std::is_literal_type {}; // NON_COMPLIANT - specialization + +void f7() { + bool b = std::is_literal_type_v; // NON_COMPLIANT + bool c = std::is_trivially_copyable_v; // COMPLIANT +} + +void f8() { + auto buf = std::get_temporary_buffer(10); // NON_COMPLIANT + std::return_temporary_buffer(buf.first); // NON_COMPLIANT + int *p = new int[10]; // COMPLIANT + delete[] p; +} + +void f9(std::raw_storage_iterator r) { // NON_COMPLIANT + std::raw_storage_iterator r2 = r; // NON_COMPLIANT + int *p = new int[10]; // COMPLIANT + delete[] p; +} + +void f10() { + std::allocator a; // COMPLIANT + std::allocator::pointer p; // NON_COMPLIANT + p = a.allocate(10); // COMPLIANT + p = a.allocate(10, nullptr); // NON_COMPLIANT + a.address(*p); // NON_COMPLIANT + a.construct(p, 42); // NON_COMPLIANT + a.destroy(p); // NON_COMPLIANT + a.deallocate(p, 10); // COMPLIANT + a.max_size(); // NON_COMPLIANT +} + +typedef std::allocator::rebind::other CharAlloc; // NON_COMPLIANT + +void f11() { + std::allocator av; // NON_COMPLIANT +} + +void f12() { + std::plus::result_type r1; // NON_COMPLIANT + std::plus::first_argument_type r2; // NON_COMPLIANT + std::plus::second_argument_type r3; // NON_COMPLIANT + std::negate::result_type r4; // NON_COMPLIANT + std::negate::argument_type r5; // NON_COMPLIANT + std::function::result_type r6; // NON_COMPLIANT + std::function f; // COMPLIANT +} + +#include + +void f13(std::strstreambuf *sb) { // NON_COMPLIANT + std::istrstream is("hello"); // NON_COMPLIANT + std::ostrstream os; // NON_COMPLIANT + std::strstream ss; // NON_COMPLIANT +} + +#include + +// NON_COMPLIANT - inherits from deprecated std::iterator base class +struct MyIter : std::iterator { + int &operator*(); + MyIter &operator++(); + bool operator==(const MyIter &) const; +}; + +// COMPLIANT - defines iterator typedefs directly without inheriting +// std::iterator +struct MyIter2 { + using iterator_category = std::forward_iterator_tag; + using value_type = int; + using difference_type = std::ptrdiff_t; + using pointer = int *; + using reference = int &; + int &operator*(); + MyIter2 &operator++(); + bool operator==(const MyIter2 &) const; +}; + +int f14_helper(int x); + +void f14() { + std::hash::result_type h1; // NON_COMPLIANT + std::hash::argument_type h2; // NON_COMPLIANT + auto b = std::bind(f14_helper, 1); + decltype(b)::result_type b1; // NON_COMPLIANT + auto m = std::mem_fn(f14_helper); + decltype(m)::result_type m1; // NON_COMPLIANT +} + +void n1() throw() {} // NON_COMPLIANT - deprecated throw() specifier +// void n2() throw(std::exception) {} invalid in C++17 +void n3() noexcept {} // COMPLIANT - noexcept is the correct specifier +void n4() {} // COMPLIANT - no exception specifier \ No newline at end of file diff --git a/rule_packages/cpp/Toolchain3.json b/rule_packages/cpp/Toolchain3.json index d1eb5d56d..bb2874213 100644 --- a/rule_packages/cpp/Toolchain3.json +++ b/rule_packages/cpp/Toolchain3.json @@ -19,6 +19,23 @@ "audit" ] }, + { + "description": "Deprecated language features such as implicit declarations of copy constructors are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "kind": "problem", + "name": "Implicit declaration of copy constructors is a deprecated language feature should not be used", + "precision": "very-high", + "severity": "warning", + "short_name": "ImplicitDeclarationOfCopyConstructor", + "tags": [ + "scope/single-translation-unit", + "maintainability" + ], + "implementation_scope": [ + { + "description": "CodeQL does not have all trivial implicit special member functions in its database. This query aims to catch all knowably deprecated cases." + } + ] + }, { "description": "Deprecated language features such as implicit declarations of copy constructors are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", "kind": "problem", @@ -30,6 +47,11 @@ "scope/single-translation-unit", "maintainability", "audit" + ], + "implementation_scope": [ + { + "description": "CodeQL does not have all trivial implicit special member functions in its database. This query aims to catch all cases that couldn't be proven not to be deprecated." + } ] }, { @@ -81,19 +103,6 @@ "maintainability" ] }, - { - "description": "Deprecated language features such as weak result types are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", - "kind": "problem", - "name": "Weak result types are a deprecated language feature should not be used", - "precision": "low", - "severity": "warning", - "short_name": "UseOfWeakResultTypesAudit", - "tags": [ - "scope/single-translation-unit", - "maintainability", - "audit" - ] - }, { "description": "Deprecated language features such as certain function binder typedef members are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", "kind": "problem", From 67bb9d37821a73d570372682bf4d192808f74f9a Mon Sep 17 00:00:00 2001 From: Mike Fairhurst Date: Sun, 1 Mar 2026 23:18:46 -0800 Subject: [PATCH 04/13] First fully working draft --- .../cpp/exclusions/cpp/Toolchain3.qll | 34 +++--- .../types/ImplicitSpecialMemberFunctions.qll | 24 +++-- .../ImplicitDeclarationOfCopyConstructor.ql | 33 ++++++ ...plicitDeclarationOfCopyConstructorAudit.ql | 4 +- ...arationOfStaticConstexprDataMemberAudit.ql | 19 +++- .../RULE-4-1-2/UseOfWeakResultTypesAudit.ql | 24 ----- ...licitDeclarationOfCopyConstructor.expected | 13 +++ ...ImplicitDeclarationOfCopyConstructor.qlref | 1 + ...DeclarationOfCopyConstructorAudit.expected | 2 +- ...nOfStaticConstexprDataMemberAudit.expected | 2 +- .../UseOfWeakResultTypesAudit.expected | 1 - .../UseOfWeakResultTypesAudit.qlref | 1 - cpp/misra/test/rules/RULE-4-1-2/test.cpp | 102 +++++++++++++++++- 13 files changed, 200 insertions(+), 60 deletions(-) create mode 100644 cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructor.ql delete mode 100644 cpp/misra/src/rules/RULE-4-1-2/UseOfWeakResultTypesAudit.ql create mode 100644 cpp/misra/test/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructor.expected create mode 100644 cpp/misra/test/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructor.qlref delete mode 100644 cpp/misra/test/rules/RULE-4-1-2/UseOfWeakResultTypesAudit.expected delete mode 100644 cpp/misra/test/rules/RULE-4-1-2/UseOfWeakResultTypesAudit.qlref diff --git a/cpp/common/src/codingstandards/cpp/exclusions/cpp/Toolchain3.qll b/cpp/common/src/codingstandards/cpp/exclusions/cpp/Toolchain3.qll index 4d7ab478c..aeadad4e7 100644 --- a/cpp/common/src/codingstandards/cpp/exclusions/cpp/Toolchain3.qll +++ b/cpp/common/src/codingstandards/cpp/exclusions/cpp/Toolchain3.qll @@ -5,12 +5,12 @@ import codingstandards.cpp.exclusions.RuleMetadata newtype Toolchain3Query = TRedeclarationOfStaticConstexprDataMemberAuditQuery() or + TImplicitDeclarationOfCopyConstructorQuery() or TImplicitDeclarationOfCopyConstructorAuditQuery() or TNoexceptSpecifierThrowAuditQuery() or TUseOfDeprecatedCHeadersQuery() or TUseOfDeprecatedStrStreamClassQuery() or TUseOfUncaughtExceptionQuery() or - TUseOfWeakResultTypesAuditQuery() or TUseOfDeprecatedFunctionBinderTypedefMemberAuditQuery() or TUseOfDeprecatedUnaryOrBinaryNegateQuery() or TUseOfDeprecatedAllocatorVoidQuery() or @@ -31,6 +31,15 @@ predicate isToolchain3QueryMetadata(Query query, string queryId, string ruleId, ruleId = "RULE-4-1-2" and category = "advisory" or + query = + // `Query` instance for the `implicitDeclarationOfCopyConstructor` query + Toolchain3Package::implicitDeclarationOfCopyConstructorQuery() and + queryId = + // `@id` for the `implicitDeclarationOfCopyConstructor` query + "cpp/misra/implicit-declaration-of-copy-constructor" and + ruleId = "RULE-4-1-2" and + category = "advisory" + or query = // `Query` instance for the `implicitDeclarationOfCopyConstructorAudit` query Toolchain3Package::implicitDeclarationOfCopyConstructorAuditQuery() and @@ -76,15 +85,6 @@ predicate isToolchain3QueryMetadata(Query query, string queryId, string ruleId, ruleId = "RULE-4-1-2" and category = "advisory" or - query = - // `Query` instance for the `useOfWeakResultTypesAudit` query - Toolchain3Package::useOfWeakResultTypesAuditQuery() and - queryId = - // `@id` for the `useOfWeakResultTypesAudit` query - "cpp/misra/use-of-weak-result-types-audit" and - ruleId = "RULE-4-1-2" and - category = "advisory" - or query = // `Query` instance for the `useOfDeprecatedFunctionBinderTypedefMemberAudit` query Toolchain3Package::useOfDeprecatedFunctionBinderTypedefMemberAuditQuery() and @@ -175,6 +175,13 @@ module Toolchain3Package { TQueryCPP(TToolchain3PackageQuery(TRedeclarationOfStaticConstexprDataMemberAuditQuery())) } + Query implicitDeclarationOfCopyConstructorQuery() { + //autogenerate `Query` type + result = + // `Query` type for `implicitDeclarationOfCopyConstructor` query + TQueryCPP(TToolchain3PackageQuery(TImplicitDeclarationOfCopyConstructorQuery())) + } + Query implicitDeclarationOfCopyConstructorAuditQuery() { //autogenerate `Query` type result = @@ -210,13 +217,6 @@ module Toolchain3Package { TQueryCPP(TToolchain3PackageQuery(TUseOfUncaughtExceptionQuery())) } - Query useOfWeakResultTypesAuditQuery() { - //autogenerate `Query` type - result = - // `Query` type for `useOfWeakResultTypesAudit` query - TQueryCPP(TToolchain3PackageQuery(TUseOfWeakResultTypesAuditQuery())) - } - Query useOfDeprecatedFunctionBinderTypedefMemberAuditQuery() { //autogenerate `Query` type result = diff --git a/cpp/common/src/codingstandards/cpp/types/ImplicitSpecialMemberFunctions.qll b/cpp/common/src/codingstandards/cpp/types/ImplicitSpecialMemberFunctions.qll index 349666972..e7521bf27 100644 --- a/cpp/common/src/codingstandards/cpp/types/ImplicitSpecialMemberFunctions.qll +++ b/cpp/common/src/codingstandards/cpp/types/ImplicitSpecialMemberFunctions.qll @@ -17,13 +17,11 @@ predicate mustNotBeImplicitlyDefined(Function mf) { ) } -predicate mustBeUserDeclared(Function mf) { - exists(FunctionDeclarationEntry fde | fde.getFunction() = mf and not fde.isImplicit()) -} +predicate mustBeUserDeclared(Function mf) { not mf.isCompilerGenerated() } predicate mustNotBeUserDeclared(Function mf) { // use forex: at least one declaration must exist, and all declarations must be implicit - forex(FunctionDeclarationEntry fde | fde.getFunction() = mf | fde.isImplicit()) + mf.isCompilerGenerated() } private signature class SpecialMember extends Function; @@ -125,12 +123,18 @@ private class CMayHaveIdefCA = * * In our case, `ClassesWhere<...>` performs steps 7 and 8 together via `NotMatching`. */ -private class CMayHaveUdecCC = ClassesWhere::NotMatching; - -private class CMayHaveUdecCA = - ClassesWhere::NotMatching; - -private class CMayHaveUdecD = ClassesWhere::NotMatching; +//private class CMayHaveUdecCC = ClassesWhere::NotMatching; +// +//private class CMayHaveUdecCA = +// ClassesWhere::NotMatching; +// +//private class CMayHaveUdecD = ClassesWhere::Matching; +// These are actually 100% known. If there is no dtor, it is not user declared. +private class CMayHaveUdecCC = CMustHaveUdecCC; + +private class CMayHaveUdecCA = CMustHaveUdecCA; + +private class CMayHaveUdecD = CMustHaveUdecD; /* - Step 9: All C' may be deprecated where C' in C_mayHave{IDEF CC} and (C' in C_mayHave{UDEC CA} or C' in C_mayHave{UDEC D}) */ class MayHaveDeprecatedCopyConstructor extends CMayHaveIdefCC { diff --git a/cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructor.ql b/cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructor.ql new file mode 100644 index 000000000..865095f52 --- /dev/null +++ b/cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructor.ql @@ -0,0 +1,33 @@ +/** + * @id cpp/misra/implicit-declaration-of-copy-constructor + * @name RULE-4-1-2: Implicit declaration of copy constructors is a deprecated language feature should not be used + * @description Deprecated language features such as implicit declarations of copy constructors are + * only supported for backwards compatibility; these are considered bad practice, or + * have been superceded by better alternatives. + * @kind problem + * @precision very-high + * @problem.severity warning + * @tags external/misra/id/rule-4-1-2 + * scope/single-translation-unit + * maintainability + * external/misra/enforcement/decidable + * external/misra/obligation/advisory + */ + +import cpp +import codingstandards.cpp.misra +import cpp +import codingstandards.cpp.misra +import codingstandards.cpp.types.ImplicitSpecialMemberFunctions + +from Class c, string specialMemberName +where + not isExcluded(c, Toolchain3Package::implicitDeclarationOfCopyConstructorAuditQuery()) and + ( + c instanceof MustHaveDeprecatedCopyConstructor and + specialMemberName = "copy constructor" + or + c instanceof MustHaveDeprecatedCopyAssignmentOperator and + specialMemberName = "copy assignment operator" + ) +select c, "Class '" + c.getName() + "' has a deprecated implicit " + specialMemberName + "." diff --git a/cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.ql b/cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.ql index 852ebef89..f650b702c 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.ql @@ -24,9 +24,11 @@ where not isExcluded(c, Toolchain3Package::implicitDeclarationOfCopyConstructorAuditQuery()) and ( c instanceof MayHaveDeprecatedCopyConstructor and + not c instanceof MustHaveDeprecatedCopyConstructor and specialMemberName = "copy constructor" or c instanceof MayHaveDeprecatedCopyAssignmentOperator and + not c instanceof MustHaveDeprecatedCopyAssignmentOperator and specialMemberName = "copy assignment operator" ) -select c, "Class '" + c.getName() + "' may have a deprecated " + specialMemberName + "." +select c, "Class '" + c.getName() + "' may have a deprecated implicit " + specialMemberName + "." diff --git a/cpp/misra/src/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.ql b/cpp/misra/src/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.ql index febc00226..73ad6d7ec 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.ql @@ -18,7 +18,20 @@ import cpp import codingstandards.cpp.misra -from +from Variable v, Initializer i where - not isExcluded(x, Toolchain3Package::redeclarationOfStaticConstexprDataMemberAuditQuery()) and -select + not isExcluded(v, Toolchain3Package::redeclarationOfStaticConstexprDataMemberAuditQuery()) and + v.isStatic() and + i.getDeclaration() = v and + v.isConstexpr() and + ( + // The initializer location is in the class, and the varibale location is outside. + // Detect if they're different files: + not v.getLocation().getFile() = i.getLocation().getFile() + or + // Or if the variable is declared after the initializer: + i.getLocation().getEndLine() < v.getLocation().getEndLine() + ) +select v, + "Static constexpr data member '" + v.getName() + + "' is redeclared, which is a deprecated language feature." diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfWeakResultTypesAudit.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfWeakResultTypesAudit.ql deleted file mode 100644 index 7243b1698..000000000 --- a/cpp/misra/src/rules/RULE-4-1-2/UseOfWeakResultTypesAudit.ql +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @id cpp/misra/use-of-weak-result-types-audit - * @name RULE-4-1-2: Weak result types are a deprecated language feature should not be used - * @description Deprecated language features such as weak result types are only supported for - * backwards compatibility; these are considered bad practice, or have been superceded - * by better alternatives. - * @kind problem - * @precision low - * @problem.severity warning - * @tags external/misra/id/rule-4-1-2 - * scope/single-translation-unit - * maintainability - * audit - * external/misra/enforcement/decidable - * external/misra/obligation/advisory - */ - -import cpp -import codingstandards.cpp.misra - -from -where - not isExcluded(x, Toolchain3Package::useOfWeakResultTypesAuditQuery()) and -select diff --git a/cpp/misra/test/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructor.expected b/cpp/misra/test/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructor.expected new file mode 100644 index 000000000..aebc5b20a --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructor.expected @@ -0,0 +1,13 @@ +| test.cpp:167:7:167:8 | C1 | Class 'C1' has a deprecated implicit copy assignment operator. | +| test.cpp:167:7:167:8 | C1 | Class 'C1' has a deprecated implicit copy constructor. | +| test.cpp:174:7:174:8 | C2 | Class 'C2' has a deprecated implicit copy assignment operator. | +| test.cpp:181:7:181:8 | C3 | Class 'C3' has a deprecated implicit copy constructor. | +| test.cpp:188:7:188:8 | C4 | Class 'C4' has a deprecated implicit copy assignment operator. | +| test.cpp:188:7:188:8 | C4 | Class 'C4' has a deprecated implicit copy constructor. | +| test.cpp:196:7:196:8 | C5 | Class 'C5' has a deprecated implicit copy assignment operator. | +| test.cpp:196:7:196:8 | C5 | Class 'C5' has a deprecated implicit copy constructor. | +| test.cpp:214:7:214:8 | C7 | Class 'C7' has a deprecated implicit copy assignment operator. | +| test.cpp:214:7:214:8 | C7 | Class 'C7' has a deprecated implicit copy constructor. | +| test.cpp:223:7:223:8 | C8 | Class 'C8' has a deprecated implicit copy assignment operator. | +| test.cpp:223:7:223:8 | C8 | Class 'C8' has a deprecated implicit copy constructor. | +| test.cpp:231:7:231:8 | C9 | Class 'C9' has a deprecated implicit copy assignment operator. | diff --git a/cpp/misra/test/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructor.qlref b/cpp/misra/test/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructor.qlref new file mode 100644 index 000000000..b7494675a --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructor.qlref @@ -0,0 +1 @@ +rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructor.ql \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.expected b/cpp/misra/test/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.expected index 2ec1a0ac6..186f108a4 100644 --- a/cpp/misra/test/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.expected +++ b/cpp/misra/test/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.expected @@ -1 +1 @@ -No expected results have yet been specified \ No newline at end of file +| test.cpp:231:7:231:8 | C9 | Class 'C9' may have a deprecated implicit copy constructor. | diff --git a/cpp/misra/test/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.expected b/cpp/misra/test/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.expected index 2ec1a0ac6..bf5557485 100644 --- a/cpp/misra/test/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.expected +++ b/cpp/misra/test/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.expected @@ -1 +1 @@ -No expected results have yet been specified \ No newline at end of file +| test.cpp:255:15:255:21 | m2 | Static constexpr data member 'm2' is redeclared, which is a deprecated language feature. | diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfWeakResultTypesAudit.expected b/cpp/misra/test/rules/RULE-4-1-2/UseOfWeakResultTypesAudit.expected deleted file mode 100644 index 2ec1a0ac6..000000000 --- a/cpp/misra/test/rules/RULE-4-1-2/UseOfWeakResultTypesAudit.expected +++ /dev/null @@ -1 +0,0 @@ -No expected results have yet been specified \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfWeakResultTypesAudit.qlref b/cpp/misra/test/rules/RULE-4-1-2/UseOfWeakResultTypesAudit.qlref deleted file mode 100644 index f22e4853b..000000000 --- a/cpp/misra/test/rules/RULE-4-1-2/UseOfWeakResultTypesAudit.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/RULE-4-1-2/UseOfWeakResultTypesAudit.ql \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/test.cpp b/cpp/misra/test/rules/RULE-4-1-2/test.cpp index 90e3a1187..deae94c1b 100644 --- a/cpp/misra/test/rules/RULE-4-1-2/test.cpp +++ b/cpp/misra/test/rules/RULE-4-1-2/test.cpp @@ -153,4 +153,104 @@ void f14() { void n1() throw() {} // NON_COMPLIANT - deprecated throw() specifier // void n2() throw(std::exception) {} invalid in C++17 void n3() noexcept {} // COMPLIANT - noexcept is the correct specifier -void n4() {} // COMPLIANT - no exception specifier \ No newline at end of file +void n4() {} // COMPLIANT - no exception specifier + +class NonTrivial { +public: + NonTrivial() {} + NonTrivial(const NonTrivial &) {} + NonTrivial &operator=(const NonTrivial &) { return *this; } + ~NonTrivial() {} +}; + +// User declared destructor, deprecated CC and assignment. +class C1 { // NON_COMPLIANT + NonTrivial m1; +public: + ~C1()=default; +}; + +// User declared CC results in deprecated +class C2 { // NON_COMPLIANT + NonTrivial m1; +public: + C2(const C2 &)=default; +}; + +// User declared assignment results in deprecated +class C3 { // NON_COMPLIANT + NonTrivial m1; +public: + C3 &operator=(const C3 &)=default; +}; + +// Explicitly defaulted CC and assignment +class C4 { // NON_COMPLIANT + NonTrivial m1; +public: + C4(const C4 &) = default; + C4 &operator=(const C4 &) = default; +}; + +// Explicitly defaulted CC and assignment, user declared dtor +class C5 { // NON_COMPLIANT + NonTrivial m1; +public: + C5(const C5 &) = default; + C5 &operator=(const C5 &) = default; + ~C5() = default; +}; + +// User defined CC and assignment, user declared dtor +class C6 { // COMPLIANT + NonTrivial m1; +public: + C6(const C6 &) {} + C6 &operator=(const C6 &) { return *this; } + ~C6() = default; +}; + +// Trivial with explicitly defaulted CC and assignment, user declared dtor +class C7 { // NON_COMPLIANT + int m1; +public: + C7(const C7 &) = default; + C7 &operator=(const C7 &) = default; + ~C7() = default; +}; + +// Trivial with explicitly defaulted CC and assignment, implicit ctor +class C8 { // NON_COMPLIANT + int m1; +public: + C8(const C8 &) = default; + C8 &operator=(const C8 &) = default; +}; + +// Trivial with user declared dtor +class C9 { // NON_COMPLIANT + int m1; +public: + ~C9() = default; +}; + +// Trivial with rule of zero +class C10 { // COMPLIANT + int m1; +}; + +// Nontrivial with rule of zero +class C11 { // COMPLIANT + NonTrivial m1; +}; + +class C12 { + static constexpr int m1 = 42; // COMPLIANT - static constexpr data member + static constexpr int m2 = 42; // NON_COMPLIANT - redeclaration of static constexpr data member + static const int m3 = 42; // COMPLIANT - static const data member + static const int m4 = 42; // COMPLIANT - static const data member + static const int m5; // COMPLIANT - static const data member +}; + +constexpr int C12::m2; // NON_COMPLIANT - definition of static constexpr data member +const int C12::m4; // COMPLIANT - definition of static const data member \ No newline at end of file From c19988ac0b6934eceae7f54d8dc5724a23152a2d Mon Sep 17 00:00:00 2001 From: Mike Fairhurst Date: Sun, 1 Mar 2026 23:31:20 -0800 Subject: [PATCH 05/13] Update ImplicitSpecialMemberFunctions documentation --- .../types/ImplicitSpecialMemberFunctions.qll | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/cpp/common/src/codingstandards/cpp/types/ImplicitSpecialMemberFunctions.qll b/cpp/common/src/codingstandards/cpp/types/ImplicitSpecialMemberFunctions.qll index e7521bf27..f54bcdf64 100644 --- a/cpp/common/src/codingstandards/cpp/types/ImplicitSpecialMemberFunctions.qll +++ b/cpp/common/src/codingstandards/cpp/types/ImplicitSpecialMemberFunctions.qll @@ -49,6 +49,11 @@ private signature predicate constraint(Function mf); * - C_cannotHave{X} = set of all classes T for which "class T cannot have a {X}" * - C_mayHave{X} = not C_cannotHave{X} * + * Note: We can find UDEF with certainty, just not IDEF. + * - C_cannotHave{UDEC X} = not C_mustHave{UDEC X}, and + * - C_mayHave{UDEC X} = C_mustHave{UDEC X}. + * - This affects step 8 below. + * * then we can find all cases we know to be deprecated via: * - Step 1: find C_mustHave{IDEF CC}, C_mustHave{IDEF CA} * - Step 2: find C_mustHave{UDEC CC}, C_mustHave{UDEC CA}, C_mustHave{UDEC D} @@ -59,11 +64,16 @@ private signature predicate constraint(Function mf); * - Step 5: find C_cannotHave{IDEF CC}, C_cannotHave{IDEF CA} * - Step 6: find C_mayHave{IDEF CC}, C_mayHave{IDEF CA} (by negating the cannot sets) * - Step 7: find C_cannotHave{UDEC CC}, C_cannotHave{UDEC CA}, C_cannotHave{UDEC D} - * - Step 8: find C_mayHave{UDEC CC}, C_mayHave{UDEC CA}, C_mayHave{UDEC D} (by negating the cannot sets) + * - Step 8: find C_mayHave{UDEC CC}, C_mayHave{UDEC CA}, C_mayHave{UDEC D} -- these are actually known with certainty * - Step 9: All C' may be deprecated where C' in C_mayHave{IDEF CC} and (C' in C_mayHave{UDEC CA} or C' in C_mayHave{UDEC D}) * - Step 10: All C' may be deprecated where C' in C_mayHave{IDEF CA} and (C' in C_mayHave{UDEC CC} or C' in C_mayHave{UDEC D}) * * This is performed through the various instantiations of this module. + * + * This module assumes that a missing SpecialMember is neither `mustHave` or `cannotHave`. This is + * the correct behavior for IDEF, but for UDEC, if no special member exists it should be part of the + * `cannotHave` set. This is handled by later defining `C_mayHave{UDEC X} = C_mustHave{UDEC X}`, + * which correctly handled the case where no X exists for that class. */ private module ClassesWhere { final class FinalClass = Class; @@ -121,15 +131,9 @@ private class CMayHaveIdefCA = * Step 7: find C_cannotHave{UDEC CC}, C_cannotHave{UDEC CA}, C_cannotHave{UDEC D} * Step 8: find C_mayHave{UDEC CC}, C_mayHave{UDEC CA}, C_mayHave{UDEC D} (by negating the cannot sets) * - * In our case, `ClassesWhere<...>` performs steps 7 and 8 together via `NotMatching`. + * As noted earlier, we know C_mayHave{UDEC X} with certainty. If there is no X in the database, then + * it is not user-declared. */ -//private class CMayHaveUdecCC = ClassesWhere::NotMatching; -// -//private class CMayHaveUdecCA = -// ClassesWhere::NotMatching; -// -//private class CMayHaveUdecD = ClassesWhere::Matching; -// These are actually 100% known. If there is no dtor, it is not user declared. private class CMayHaveUdecCC = CMustHaveUdecCC; private class CMayHaveUdecCA = CMustHaveUdecCA; From 8f850c31d3b16511a7e22f8f56b38319909d9020 Mon Sep 17 00:00:00 2001 From: Mike Fairhurst Date: Sun, 1 Mar 2026 23:37:17 -0800 Subject: [PATCH 06/13] Double check metadata --- .../cpp/exclusions/cpp/Toolchain3.qll | 48 +++++++++---------- .../ImplicitDeclarationOfCopyConstructor.ql | 2 +- ...hrowAudit.ql => NoexceptSpecifierThrow.ql} | 6 +-- ...declarationOfStaticConstexprDataMember.ql} | 7 ++- ...fDeprecatedFunctionBinderTypedefMember.ql} | 7 ++- .../UseOfDeprecatedStdAllocatorMember.ql | 2 +- ...pected => NoexceptSpecifierThrow.expected} | 0 .../RULE-4-1-2/NoexceptSpecifierThrow.qlref | 1 + .../NoexceptSpecifierThrowAudit.qlref | 1 - ...ationOfStaticConstexprDataMember.expected} | 0 ...clarationOfStaticConstexprDataMember.qlref | 1 + ...tionOfStaticConstexprDataMemberAudit.qlref | 1 - ...catedFunctionBinderTypedefMember.expected} | 0 ...eprecatedFunctionBinderTypedefMember.qlref | 1 + ...atedFunctionBinderTypedefMemberAudit.qlref | 1 - rule_packages/cpp/Toolchain3.json | 20 ++++---- 16 files changed, 47 insertions(+), 51 deletions(-) rename cpp/misra/src/rules/RULE-4-1-2/{NoexceptSpecifierThrowAudit.ql => NoexceptSpecifierThrow.ql} (85%) rename cpp/misra/src/rules/RULE-4-1-2/{RedeclarationOfStaticConstexprDataMemberAudit.ql => RedeclarationOfStaticConstexprDataMember.ql} (90%) rename cpp/misra/src/rules/RULE-4-1-2/{UseOfDeprecatedFunctionBinderTypedefMemberAudit.ql => UseOfDeprecatedFunctionBinderTypedefMember.ql} (97%) rename cpp/misra/test/rules/RULE-4-1-2/{NoexceptSpecifierThrowAudit.expected => NoexceptSpecifierThrow.expected} (100%) create mode 100644 cpp/misra/test/rules/RULE-4-1-2/NoexceptSpecifierThrow.qlref delete mode 100644 cpp/misra/test/rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.qlref rename cpp/misra/test/rules/RULE-4-1-2/{RedeclarationOfStaticConstexprDataMemberAudit.expected => RedeclarationOfStaticConstexprDataMember.expected} (100%) create mode 100644 cpp/misra/test/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMember.qlref delete mode 100644 cpp/misra/test/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.qlref rename cpp/misra/test/rules/RULE-4-1-2/{UseOfDeprecatedFunctionBinderTypedefMemberAudit.expected => UseOfDeprecatedFunctionBinderTypedefMember.expected} (100%) create mode 100644 cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMember.qlref delete mode 100644 cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.qlref diff --git a/cpp/common/src/codingstandards/cpp/exclusions/cpp/Toolchain3.qll b/cpp/common/src/codingstandards/cpp/exclusions/cpp/Toolchain3.qll index aeadad4e7..1d52e71c7 100644 --- a/cpp/common/src/codingstandards/cpp/exclusions/cpp/Toolchain3.qll +++ b/cpp/common/src/codingstandards/cpp/exclusions/cpp/Toolchain3.qll @@ -4,14 +4,14 @@ import RuleMetadata import codingstandards.cpp.exclusions.RuleMetadata newtype Toolchain3Query = - TRedeclarationOfStaticConstexprDataMemberAuditQuery() or + TRedeclarationOfStaticConstexprDataMemberQuery() or TImplicitDeclarationOfCopyConstructorQuery() or TImplicitDeclarationOfCopyConstructorAuditQuery() or - TNoexceptSpecifierThrowAuditQuery() or + TNoexceptSpecifierThrowQuery() or TUseOfDeprecatedCHeadersQuery() or TUseOfDeprecatedStrStreamClassQuery() or TUseOfUncaughtExceptionQuery() or - TUseOfDeprecatedFunctionBinderTypedefMemberAuditQuery() or + TUseOfDeprecatedFunctionBinderTypedefMemberQuery() or TUseOfDeprecatedUnaryOrBinaryNegateQuery() or TUseOfDeprecatedAllocatorVoidQuery() or TUseOfDeprecatedStdAllocatorMemberQuery() or @@ -23,11 +23,11 @@ newtype Toolchain3Query = predicate isToolchain3QueryMetadata(Query query, string queryId, string ruleId, string category) { query = - // `Query` instance for the `redeclarationOfStaticConstexprDataMemberAudit` query - Toolchain3Package::redeclarationOfStaticConstexprDataMemberAuditQuery() and + // `Query` instance for the `redeclarationOfStaticConstexprDataMember` query + Toolchain3Package::redeclarationOfStaticConstexprDataMemberQuery() and queryId = - // `@id` for the `redeclarationOfStaticConstexprDataMemberAudit` query - "cpp/misra/redeclaration-of-static-constexpr-data-member-audit" and + // `@id` for the `redeclarationOfStaticConstexprDataMember` query + "cpp/misra/redeclaration-of-static-constexpr-data-member" and ruleId = "RULE-4-1-2" and category = "advisory" or @@ -50,11 +50,11 @@ predicate isToolchain3QueryMetadata(Query query, string queryId, string ruleId, category = "advisory" or query = - // `Query` instance for the `noexceptSpecifierThrowAudit` query - Toolchain3Package::noexceptSpecifierThrowAuditQuery() and + // `Query` instance for the `noexceptSpecifierThrow` query + Toolchain3Package::noexceptSpecifierThrowQuery() and queryId = - // `@id` for the `noexceptSpecifierThrowAudit` query - "cpp/misra/noexcept-specifier-throw-audit" and + // `@id` for the `noexceptSpecifierThrow` query + "cpp/misra/noexcept-specifier-throw" and ruleId = "RULE-4-1-2" and category = "advisory" or @@ -86,11 +86,11 @@ predicate isToolchain3QueryMetadata(Query query, string queryId, string ruleId, category = "advisory" or query = - // `Query` instance for the `useOfDeprecatedFunctionBinderTypedefMemberAudit` query - Toolchain3Package::useOfDeprecatedFunctionBinderTypedefMemberAuditQuery() and + // `Query` instance for the `useOfDeprecatedFunctionBinderTypedefMember` query + Toolchain3Package::useOfDeprecatedFunctionBinderTypedefMemberQuery() and queryId = - // `@id` for the `useOfDeprecatedFunctionBinderTypedefMemberAudit` query - "cpp/misra/use-of-deprecated-function-binder-typedef-member-audit" and + // `@id` for the `useOfDeprecatedFunctionBinderTypedefMember` query + "cpp/misra/use-of-deprecated-function-binder-typedef-member" and ruleId = "RULE-4-1-2" and category = "advisory" or @@ -168,11 +168,11 @@ predicate isToolchain3QueryMetadata(Query query, string queryId, string ruleId, } module Toolchain3Package { - Query redeclarationOfStaticConstexprDataMemberAuditQuery() { + Query redeclarationOfStaticConstexprDataMemberQuery() { //autogenerate `Query` type result = - // `Query` type for `redeclarationOfStaticConstexprDataMemberAudit` query - TQueryCPP(TToolchain3PackageQuery(TRedeclarationOfStaticConstexprDataMemberAuditQuery())) + // `Query` type for `redeclarationOfStaticConstexprDataMember` query + TQueryCPP(TToolchain3PackageQuery(TRedeclarationOfStaticConstexprDataMemberQuery())) } Query implicitDeclarationOfCopyConstructorQuery() { @@ -189,11 +189,11 @@ module Toolchain3Package { TQueryCPP(TToolchain3PackageQuery(TImplicitDeclarationOfCopyConstructorAuditQuery())) } - Query noexceptSpecifierThrowAuditQuery() { + Query noexceptSpecifierThrowQuery() { //autogenerate `Query` type result = - // `Query` type for `noexceptSpecifierThrowAudit` query - TQueryCPP(TToolchain3PackageQuery(TNoexceptSpecifierThrowAuditQuery())) + // `Query` type for `noexceptSpecifierThrow` query + TQueryCPP(TToolchain3PackageQuery(TNoexceptSpecifierThrowQuery())) } Query useOfDeprecatedCHeadersQuery() { @@ -217,11 +217,11 @@ module Toolchain3Package { TQueryCPP(TToolchain3PackageQuery(TUseOfUncaughtExceptionQuery())) } - Query useOfDeprecatedFunctionBinderTypedefMemberAuditQuery() { + Query useOfDeprecatedFunctionBinderTypedefMemberQuery() { //autogenerate `Query` type result = - // `Query` type for `useOfDeprecatedFunctionBinderTypedefMemberAudit` query - TQueryCPP(TToolchain3PackageQuery(TUseOfDeprecatedFunctionBinderTypedefMemberAuditQuery())) + // `Query` type for `useOfDeprecatedFunctionBinderTypedefMember` query + TQueryCPP(TToolchain3PackageQuery(TUseOfDeprecatedFunctionBinderTypedefMemberQuery())) } Query useOfDeprecatedUnaryOrBinaryNegateQuery() { diff --git a/cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructor.ql b/cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructor.ql index 865095f52..4b9ec5a89 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructor.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructor.ql @@ -22,7 +22,7 @@ import codingstandards.cpp.types.ImplicitSpecialMemberFunctions from Class c, string specialMemberName where - not isExcluded(c, Toolchain3Package::implicitDeclarationOfCopyConstructorAuditQuery()) and + not isExcluded(c, Toolchain3Package::implicitDeclarationOfCopyConstructorQuery()) and ( c instanceof MustHaveDeprecatedCopyConstructor and specialMemberName = "copy constructor" diff --git a/cpp/misra/src/rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.ql b/cpp/misra/src/rules/RULE-4-1-2/NoexceptSpecifierThrow.ql similarity index 85% rename from cpp/misra/src/rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.ql rename to cpp/misra/src/rules/RULE-4-1-2/NoexceptSpecifierThrow.ql index 93c20d6e1..ebc1112c8 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/NoexceptSpecifierThrow.ql @@ -1,11 +1,11 @@ /** - * @id cpp/misra/noexcept-specifier-throw-audit + * @id cpp/misra/noexcept-specifier-throw * @name RULE-4-1-2: The noexcept specifier throw() is a deprecated language feature should not be used * @description Deprecated language features such as the noexcept specifier throw() are only * supported for backwards compatibility; these are considered bad practice, or have * been superceded by better alternatives. * @kind problem - * @precision low + * @precision high * @problem.severity warning * @tags external/misra/id/rule-4-1-2 * scope/single-translation-unit @@ -20,7 +20,7 @@ import codingstandards.cpp.misra from Function f where - not isExcluded(f, Toolchain3Package::noexceptSpecifierThrowAuditQuery()) and + not isExcluded(f, Toolchain3Package::noexceptSpecifierThrowQuery()) and f.isNoThrow() and not f.isCompilerGenerated() select f, diff --git a/cpp/misra/src/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.ql b/cpp/misra/src/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMember.ql similarity index 90% rename from cpp/misra/src/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.ql rename to cpp/misra/src/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMember.ql index 73ad6d7ec..21c543c56 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMember.ql @@ -1,16 +1,15 @@ /** - * @id cpp/misra/redeclaration-of-static-constexpr-data-member-audit + * @id cpp/misra/redeclaration-of-static-constexpr-data-member * @name RULE-4-1-2: Redeclaration of static constexpr data members is a deprecated language feature should not be used * @description Deprecated language features such as redeclaration of static constexpr data members * are only supported for backwards compatibility; these are considered bad practice, * or have been superceded by better alternatives. * @kind problem - * @precision low + * @precision high * @problem.severity warning * @tags external/misra/id/rule-4-1-2 * scope/single-translation-unit * maintainability - * audit * external/misra/enforcement/decidable * external/misra/obligation/advisory */ @@ -20,7 +19,7 @@ import codingstandards.cpp.misra from Variable v, Initializer i where - not isExcluded(v, Toolchain3Package::redeclarationOfStaticConstexprDataMemberAuditQuery()) and + not isExcluded(v, Toolchain3Package::redeclarationOfStaticConstexprDataMemberQuery()) and v.isStatic() and i.getDeclaration() = v and v.isConstexpr() and diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMember.ql similarity index 97% rename from cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.ql rename to cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMember.ql index e878e06ef..c901e933c 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMember.ql @@ -1,16 +1,15 @@ /** - * @id cpp/misra/use-of-deprecated-function-binder-typedef-member-audit + * @id cpp/misra/use-of-deprecated-function-binder-typedef-member * @name RULE-4-1-2: Certain members of function binder typedefs are deprecated language features and should not be used * @description Deprecated language features such as certain function binder typedef members are * only supported for backwards compatibility; these are considered bad practice, or * have been superceded by better alternatives. * @kind problem - * @precision low + * @precision high * @problem.severity warning * @tags external/misra/id/rule-4-1-2 * scope/single-translation-unit * maintainability - * audit * external/misra/enforcement/decidable * external/misra/obligation/advisory */ @@ -70,6 +69,6 @@ class DeprecatedFunctionBinderTypedefMember extends UsingAliasTypedefType { from TypeMention tm, DeprecatedFunctionBinderTypedefMember member where - not isExcluded(tm, Toolchain3Package::useOfDeprecatedFunctionBinderTypedefMemberAuditQuery()) and + not isExcluded(tm, Toolchain3Package::useOfDeprecatedFunctionBinderTypedefMemberQuery()) and tm.getMentionedType() = member select tm, "Use of deprecated function binder typedef member " + member.toString() diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.ql index 2424c38f0..a6153bef2 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.ql @@ -5,7 +5,7 @@ * supported for backwards compatibility; these are considered bad practice, or have * been superceded by better alternatives. * @kind problem - * @precision very_high + * @precision very-high * @problem.severity warning * @tags external/misra/id/rule-4-1-2 * scope/single-translation-unit diff --git a/cpp/misra/test/rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.expected b/cpp/misra/test/rules/RULE-4-1-2/NoexceptSpecifierThrow.expected similarity index 100% rename from cpp/misra/test/rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.expected rename to cpp/misra/test/rules/RULE-4-1-2/NoexceptSpecifierThrow.expected diff --git a/cpp/misra/test/rules/RULE-4-1-2/NoexceptSpecifierThrow.qlref b/cpp/misra/test/rules/RULE-4-1-2/NoexceptSpecifierThrow.qlref new file mode 100644 index 000000000..d6e898b2a --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/NoexceptSpecifierThrow.qlref @@ -0,0 +1 @@ +rules/RULE-4-1-2/NoexceptSpecifierThrow.ql \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.qlref b/cpp/misra/test/rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.qlref deleted file mode 100644 index bff1cd5bb..000000000 --- a/cpp/misra/test/rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/RULE-4-1-2/NoexceptSpecifierThrowAudit.ql \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.expected b/cpp/misra/test/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMember.expected similarity index 100% rename from cpp/misra/test/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.expected rename to cpp/misra/test/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMember.expected diff --git a/cpp/misra/test/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMember.qlref b/cpp/misra/test/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMember.qlref new file mode 100644 index 000000000..fbefd6801 --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMember.qlref @@ -0,0 +1 @@ +rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMember.ql \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.qlref b/cpp/misra/test/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.qlref deleted file mode 100644 index bbd3f15b4..000000000 --- a/cpp/misra/test/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMemberAudit.ql \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.expected b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMember.expected similarity index 100% rename from cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.expected rename to cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMember.expected diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMember.qlref b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMember.qlref new file mode 100644 index 000000000..1df2c49e3 --- /dev/null +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMember.qlref @@ -0,0 +1 @@ +rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMember.ql \ No newline at end of file diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.qlref b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.qlref deleted file mode 100644 index d664b9dde..000000000 --- a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMemberAudit.ql \ No newline at end of file diff --git a/rule_packages/cpp/Toolchain3.json b/rule_packages/cpp/Toolchain3.json index bb2874213..8ea7f5ded 100644 --- a/rule_packages/cpp/Toolchain3.json +++ b/rule_packages/cpp/Toolchain3.json @@ -10,13 +10,12 @@ "description": "Deprecated language features such as redeclaration of static constexpr data members are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", "kind": "problem", "name": "Redeclaration of static constexpr data members is a deprecated language feature should not be used", - "precision": "low", + "precision": "high", "severity": "warning", - "short_name": "RedeclarationOfStaticConstexprDataMemberAudit", + "short_name": "RedeclarationOfStaticConstexprDataMember", "tags": [ "scope/single-translation-unit", - "maintainability", - "audit" + "maintainability" ] }, { @@ -58,9 +57,9 @@ "description": "Deprecated language features such as the noexcept specifier throw() are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", "kind": "problem", "name": "The noexcept specifier throw() is a deprecated language feature should not be used", - "precision": "low", + "precision": "high", "severity": "warning", - "short_name": "NoexceptSpecifierThrowAudit", + "short_name": "NoexceptSpecifierThrow", "tags": [ "scope/single-translation-unit", "maintainability", @@ -107,13 +106,12 @@ "description": "Deprecated language features such as certain function binder typedef members are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", "kind": "problem", "name": "Certain members of function binder typedefs are deprecated language features and should not be used", - "precision": "low", + "precision": "high", "severity": "warning", - "short_name": "UseOfDeprecatedFunctionBinderTypedefMemberAudit", + "short_name": "UseOfDeprecatedFunctionBinderTypedefMember", "tags": [ "scope/single-translation-unit", - "maintainability", - "audit" + "maintainability" ] }, { @@ -144,7 +142,7 @@ "description": "Deprecated language features such as certain members of std::allocator are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", "kind": "problem", "name": "Certain members of std::allocator are deprecated language features and should not be used", - "precision": "very_high", + "precision": "very-high", "severity": "warning", "short_name": "UseOfDeprecatedStdAllocatorMember", "tags": [ From 421ee9631abbd4278beed323a1bc574a4dd2eaf9 Mon Sep 17 00:00:00 2001 From: Mike Fairhurst Date: Sun, 1 Mar 2026 23:39:51 -0800 Subject: [PATCH 07/13] format test.cpp --- ...licitDeclarationOfCopyConstructor.expected | 22 ++++++++-------- ...DeclarationOfCopyConstructorAudit.expected | 2 +- ...rationOfStaticConstexprDataMember.expected | 2 +- cpp/misra/test/rules/RULE-4-1-2/test.cpp | 25 +++++++++++++------ 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/cpp/misra/test/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructor.expected b/cpp/misra/test/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructor.expected index aebc5b20a..367cb24da 100644 --- a/cpp/misra/test/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructor.expected +++ b/cpp/misra/test/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructor.expected @@ -1,13 +1,13 @@ | test.cpp:167:7:167:8 | C1 | Class 'C1' has a deprecated implicit copy assignment operator. | | test.cpp:167:7:167:8 | C1 | Class 'C1' has a deprecated implicit copy constructor. | -| test.cpp:174:7:174:8 | C2 | Class 'C2' has a deprecated implicit copy assignment operator. | -| test.cpp:181:7:181:8 | C3 | Class 'C3' has a deprecated implicit copy constructor. | -| test.cpp:188:7:188:8 | C4 | Class 'C4' has a deprecated implicit copy assignment operator. | -| test.cpp:188:7:188:8 | C4 | Class 'C4' has a deprecated implicit copy constructor. | -| test.cpp:196:7:196:8 | C5 | Class 'C5' has a deprecated implicit copy assignment operator. | -| test.cpp:196:7:196:8 | C5 | Class 'C5' has a deprecated implicit copy constructor. | -| test.cpp:214:7:214:8 | C7 | Class 'C7' has a deprecated implicit copy assignment operator. | -| test.cpp:214:7:214:8 | C7 | Class 'C7' has a deprecated implicit copy constructor. | -| test.cpp:223:7:223:8 | C8 | Class 'C8' has a deprecated implicit copy assignment operator. | -| test.cpp:223:7:223:8 | C8 | Class 'C8' has a deprecated implicit copy constructor. | -| test.cpp:231:7:231:8 | C9 | Class 'C9' has a deprecated implicit copy assignment operator. | +| test.cpp:175:7:175:8 | C2 | Class 'C2' has a deprecated implicit copy assignment operator. | +| test.cpp:183:7:183:8 | C3 | Class 'C3' has a deprecated implicit copy constructor. | +| test.cpp:191:7:191:8 | C4 | Class 'C4' has a deprecated implicit copy assignment operator. | +| test.cpp:191:7:191:8 | C4 | Class 'C4' has a deprecated implicit copy constructor. | +| test.cpp:200:7:200:8 | C5 | Class 'C5' has a deprecated implicit copy assignment operator. | +| test.cpp:200:7:200:8 | C5 | Class 'C5' has a deprecated implicit copy constructor. | +| test.cpp:220:7:220:8 | C7 | Class 'C7' has a deprecated implicit copy assignment operator. | +| test.cpp:220:7:220:8 | C7 | Class 'C7' has a deprecated implicit copy constructor. | +| test.cpp:230:7:230:8 | C8 | Class 'C8' has a deprecated implicit copy assignment operator. | +| test.cpp:230:7:230:8 | C8 | Class 'C8' has a deprecated implicit copy constructor. | +| test.cpp:239:7:239:8 | C9 | Class 'C9' has a deprecated implicit copy assignment operator. | diff --git a/cpp/misra/test/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.expected b/cpp/misra/test/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.expected index 186f108a4..b28a66f8d 100644 --- a/cpp/misra/test/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.expected +++ b/cpp/misra/test/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.expected @@ -1 +1 @@ -| test.cpp:231:7:231:8 | C9 | Class 'C9' may have a deprecated implicit copy constructor. | +| test.cpp:239:7:239:8 | C9 | Class 'C9' may have a deprecated implicit copy constructor. | diff --git a/cpp/misra/test/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMember.expected b/cpp/misra/test/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMember.expected index bf5557485..5a69e62ee 100644 --- a/cpp/misra/test/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMember.expected +++ b/cpp/misra/test/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMember.expected @@ -1 +1 @@ -| test.cpp:255:15:255:21 | m2 | Static constexpr data member 'm2' is redeclared, which is a deprecated language feature. | +| test.cpp:266:5:266:11 | m2 | Static constexpr data member 'm2' is redeclared, which is a deprecated language feature. | diff --git a/cpp/misra/test/rules/RULE-4-1-2/test.cpp b/cpp/misra/test/rules/RULE-4-1-2/test.cpp index deae94c1b..b91254477 100644 --- a/cpp/misra/test/rules/RULE-4-1-2/test.cpp +++ b/cpp/misra/test/rules/RULE-4-1-2/test.cpp @@ -166,27 +166,31 @@ class NonTrivial { // User declared destructor, deprecated CC and assignment. class C1 { // NON_COMPLIANT NonTrivial m1; + public: - ~C1()=default; + ~C1() = default; }; -// User declared CC results in deprecated +// User declared CC results in deprecated class C2 { // NON_COMPLIANT NonTrivial m1; + public: - C2(const C2 &)=default; + C2(const C2 &) = default; }; // User declared assignment results in deprecated class C3 { // NON_COMPLIANT NonTrivial m1; + public: - C3 &operator=(const C3 &)=default; + C3 &operator=(const C3 &) = default; }; // Explicitly defaulted CC and assignment class C4 { // NON_COMPLIANT NonTrivial m1; + public: C4(const C4 &) = default; C4 &operator=(const C4 &) = default; @@ -195,6 +199,7 @@ class C4 { // NON_COMPLIANT // Explicitly defaulted CC and assignment, user declared dtor class C5 { // NON_COMPLIANT NonTrivial m1; + public: C5(const C5 &) = default; C5 &operator=(const C5 &) = default; @@ -204,6 +209,7 @@ class C5 { // NON_COMPLIANT // User defined CC and assignment, user declared dtor class C6 { // COMPLIANT NonTrivial m1; + public: C6(const C6 &) {} C6 &operator=(const C6 &) { return *this; } @@ -213,6 +219,7 @@ class C6 { // COMPLIANT // Trivial with explicitly defaulted CC and assignment, user declared dtor class C7 { // NON_COMPLIANT int m1; + public: C7(const C7 &) = default; C7 &operator=(const C7 &) = default; @@ -222,6 +229,7 @@ class C7 { // NON_COMPLIANT // Trivial with explicitly defaulted CC and assignment, implicit ctor class C8 { // NON_COMPLIANT int m1; + public: C8(const C8 &) = default; C8 &operator=(const C8 &) = default; @@ -230,6 +238,7 @@ class C8 { // NON_COMPLIANT // Trivial with user declared dtor class C9 { // NON_COMPLIANT int m1; + public: ~C9() = default; }; @@ -246,11 +255,13 @@ class C11 { // COMPLIANT class C12 { static constexpr int m1 = 42; // COMPLIANT - static constexpr data member - static constexpr int m2 = 42; // NON_COMPLIANT - redeclaration of static constexpr data member + static constexpr int m2 = + 42; // NON_COMPLIANT - redeclaration of static constexpr data member static const int m3 = 42; // COMPLIANT - static const data member static const int m4 = 42; // COMPLIANT - static const data member - static const int m5; // COMPLIANT - static const data member + static const int m5; // COMPLIANT - static const data member }; -constexpr int C12::m2; // NON_COMPLIANT - definition of static constexpr data member +constexpr int + C12::m2; // NON_COMPLIANT - definition of static constexpr data member const int C12::m4; // COMPLIANT - definition of static const data member \ No newline at end of file From 4fddc3898aa1338257b8a2bdb5f65c23e4954d3e Mon Sep 17 00:00:00 2001 From: Mike Fairhurst Date: Mon, 2 Mar 2026 08:15:39 -0800 Subject: [PATCH 08/13] Fix audit flag, external/misra/audit --- .../ImplicitDeclarationOfCopyConstructorAudit.ql | 2 +- cpp/misra/src/rules/RULE-4-1-2/NoexceptSpecifierThrow.ql | 1 - rule_packages/cpp/Toolchain3.json | 7 +++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.ql b/cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.ql index f650b702c..2820a7890 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.ql @@ -9,8 +9,8 @@ * @problem.severity warning * @tags external/misra/id/rule-4-1-2 * scope/single-translation-unit + * external/misra/audit * maintainability - * audit * external/misra/enforcement/decidable * external/misra/obligation/advisory */ diff --git a/cpp/misra/src/rules/RULE-4-1-2/NoexceptSpecifierThrow.ql b/cpp/misra/src/rules/RULE-4-1-2/NoexceptSpecifierThrow.ql index ebc1112c8..ba60f1690 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/NoexceptSpecifierThrow.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/NoexceptSpecifierThrow.ql @@ -10,7 +10,6 @@ * @tags external/misra/id/rule-4-1-2 * scope/single-translation-unit * maintainability - * audit * external/misra/enforcement/decidable * external/misra/obligation/advisory */ diff --git a/rule_packages/cpp/Toolchain3.json b/rule_packages/cpp/Toolchain3.json index 8ea7f5ded..8db2f2b58 100644 --- a/rule_packages/cpp/Toolchain3.json +++ b/rule_packages/cpp/Toolchain3.json @@ -44,8 +44,8 @@ "short_name": "ImplicitDeclarationOfCopyConstructorAudit", "tags": [ "scope/single-translation-unit", - "maintainability", - "audit" + "external/misra/audit", + "maintainability" ], "implementation_scope": [ { @@ -62,8 +62,7 @@ "short_name": "NoexceptSpecifierThrow", "tags": [ "scope/single-translation-unit", - "maintainability", - "audit" + "maintainability" ] }, { From 4bdd14198cd7217bcb4d6a3cf4bf7cee79c24ec5 Mon Sep 17 00:00:00 2001 From: Mike Fairhurst Date: Mon, 2 Mar 2026 09:16:50 -0800 Subject: [PATCH 09/13] Fix address-of overloaded member function std::allocator::allocate --- .../DynamicMemoryManagedManually.expected | 36 +++++++++---------- cpp/misra/test/rules/RULE-21-6-2/test.cpp | 3 +- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/cpp/misra/test/rules/RULE-21-6-2/DynamicMemoryManagedManually.expected b/cpp/misra/test/rules/RULE-21-6-2/DynamicMemoryManagedManually.expected index e057f7b38..83a3a542b 100644 --- a/cpp/misra/test/rules/RULE-21-6-2/DynamicMemoryManagedManually.expected +++ b/cpp/misra/test/rules/RULE-21-6-2/DynamicMemoryManagedManually.expected @@ -64,21 +64,21 @@ | test.cpp:229:7:229:26 | operator delete[] | Taking the address of banned `operator delete[]`. | | test.cpp:233:7:233:24 | operator delete | Taking the address of banned `operator delete`. | | test.cpp:235:7:235:26 | operator delete[] | Taking the address of banned `operator delete[]`. | -| test.cpp:243:13:243:41 | allocate | Taking the address of banned `std::allocator::allocate`. | -| test.cpp:245:13:245:43 | deallocate | Taking the address of banned `std::allocator::deallocate`. | -| test.cpp:251:7:251:23 | allocate | Taking the address of banned `std::allocator_traits>::allocate`. | -| test.cpp:254:8:254:25 | deallocate | Taking the address of banned `std::allocator_traits>::deallocate`. | -| test.cpp:258:13:258:48 | allocate | Taking the address of banned `std::pmr::memory_resource::allocate`. | -| test.cpp:261:7:261:44 | deallocate | Taking the address of banned `std::pmr::memory_resource::deallocate`. | -| test.cpp:265:13:266:19 | allocate | Taking the address of banned `std::pmr::polymorphic_allocator::allocate`. | -| test.cpp:268:13:269:21 | deallocate | Taking the address of banned `std::pmr::polymorphic_allocator::deallocate`. | -| test.cpp:273:13:274:24 | allocate | Taking the address of banned `std::pmr::memory_resource::allocate`. | -| test.cpp:276:14:277:27 | deallocate | Taking the address of banned `std::pmr::memory_resource::deallocate`. | -| test.cpp:281:14:282:25 | allocate | Taking the address of banned `std::pmr::memory_resource::allocate`. | -| test.cpp:284:14:285:27 | deallocate | Taking the address of banned `std::pmr::memory_resource::deallocate`. | -| test.cpp:289:14:290:25 | allocate | Taking the address of banned `std::pmr::memory_resource::allocate`. | -| test.cpp:292:14:293:27 | deallocate | Taking the address of banned `std::pmr::memory_resource::deallocate`. | -| test.cpp:299:7:299:28 | allocate | Taking the address of banned `std::scoped_allocator_adaptor>::allocate`. | -| test.cpp:302:7:302:30 | deallocate | Taking the address of banned `std::scoped_allocator_adaptor>::deallocate`. | -| test.cpp:309:13:309:41 | release | Taking the address of banned `std::unique_ptr>::release`. | -| test.cpp:312:7:312:37 | release | Taking the address of banned `std::unique_ptr>::release`. | +| test.cpp:244:7:244:35 | allocate | Taking the address of banned `std::allocator::allocate`. | +| test.cpp:246:13:246:43 | deallocate | Taking the address of banned `std::allocator::deallocate`. | +| test.cpp:252:7:252:23 | allocate | Taking the address of banned `std::allocator_traits>::allocate`. | +| test.cpp:255:8:255:25 | deallocate | Taking the address of banned `std::allocator_traits>::deallocate`. | +| test.cpp:259:13:259:48 | allocate | Taking the address of banned `std::pmr::memory_resource::allocate`. | +| test.cpp:262:7:262:44 | deallocate | Taking the address of banned `std::pmr::memory_resource::deallocate`. | +| test.cpp:266:13:267:19 | allocate | Taking the address of banned `std::pmr::polymorphic_allocator::allocate`. | +| test.cpp:269:13:270:21 | deallocate | Taking the address of banned `std::pmr::polymorphic_allocator::deallocate`. | +| test.cpp:274:13:275:24 | allocate | Taking the address of banned `std::pmr::memory_resource::allocate`. | +| test.cpp:277:14:278:27 | deallocate | Taking the address of banned `std::pmr::memory_resource::deallocate`. | +| test.cpp:282:14:283:25 | allocate | Taking the address of banned `std::pmr::memory_resource::allocate`. | +| test.cpp:285:14:286:27 | deallocate | Taking the address of banned `std::pmr::memory_resource::deallocate`. | +| test.cpp:290:14:291:25 | allocate | Taking the address of banned `std::pmr::memory_resource::allocate`. | +| test.cpp:293:14:294:27 | deallocate | Taking the address of banned `std::pmr::memory_resource::deallocate`. | +| test.cpp:300:7:300:28 | allocate | Taking the address of banned `std::scoped_allocator_adaptor>::allocate`. | +| test.cpp:303:7:303:30 | deallocate | Taking the address of banned `std::scoped_allocator_adaptor>::deallocate`. | +| test.cpp:310:13:310:41 | release | Taking the address of banned `std::unique_ptr>::release`. | +| test.cpp:313:7:313:37 | release | Taking the address of banned `std::unique_ptr>::release`. | diff --git a/cpp/misra/test/rules/RULE-21-6-2/test.cpp b/cpp/misra/test/rules/RULE-21-6-2/test.cpp index 72c98a878..4666e3c6f 100644 --- a/cpp/misra/test/rules/RULE-21-6-2/test.cpp +++ b/cpp/misra/test/rules/RULE-21-6-2/test.cpp @@ -240,7 +240,8 @@ void take_address_of_operator_delete() { void take_address_of_allocate_deallocate() { // std::allocator - auto p1 = &std::allocator::allocate; // NON_COMPLIANT: address of + C1 *(std::allocator::*p1)(std::size_t) = + &std::allocator::allocate; // NON_COMPLIANT: address of // std::allocator::allocate auto p2 = &std::allocator::deallocate; // NON_COMPLIANT: address of // std::allocator::deallocate From 445b0f6f7c923a2f1ed15ca293a97426f7e2424a Mon Sep 17 00:00:00 2001 From: Mike Fairhurst Date: Mon, 2 Mar 2026 09:19:13 -0800 Subject: [PATCH 10/13] Fix implementation scope schema --- rule_packages/cpp/Toolchain3.json | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/rule_packages/cpp/Toolchain3.json b/rule_packages/cpp/Toolchain3.json index 8db2f2b58..62fc8f9ae 100644 --- a/rule_packages/cpp/Toolchain3.json +++ b/rule_packages/cpp/Toolchain3.json @@ -29,11 +29,9 @@ "scope/single-translation-unit", "maintainability" ], - "implementation_scope": [ - { - "description": "CodeQL does not have all trivial implicit special member functions in its database. This query aims to catch all knowably deprecated cases." - } - ] + "implementation_scope": { + "description": "CodeQL does not have all trivial implicit special member functions in its database. This query aims to catch all knowably deprecated cases." + } }, { "description": "Deprecated language features such as implicit declarations of copy constructors are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", @@ -47,11 +45,9 @@ "external/misra/audit", "maintainability" ], - "implementation_scope": [ - { - "description": "CodeQL does not have all trivial implicit special member functions in its database. This query aims to catch all cases that couldn't be proven not to be deprecated." - } - ] + "implementation_scope": { + "description": "CodeQL does not have all trivial implicit special member functions in its database. This query aims to catch all cases that couldn't be proven not to be deprecated." + } }, { "description": "Deprecated language features such as the noexcept specifier throw() are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", From 5c6355632854d4b3b4c729da59a78321e67ee55a Mon Sep 17 00:00:00 2001 From: Mike Fairhurst Date: Mon, 2 Mar 2026 12:22:50 -0800 Subject: [PATCH 11/13] Copilot feedback --- .../ImplicitDeclarationOfCopyConstructor.ql | 4 +-- ...plicitDeclarationOfCopyConstructorAudit.ql | 2 +- .../RULE-4-1-2/NoexceptSpecifierThrow.ql | 2 +- ...edeclarationOfStaticConstexprDataMember.ql | 2 +- .../UseOfDeprecatedAllocatorVoid.ql | 2 +- .../RULE-4-1-2/UseOfDeprecatedCHeaders.ql | 2 +- ...OfDeprecatedFunctionBinderTypedefMember.ql | 2 +- .../UseOfDeprecatedIsLiteralTypeTraits.ql | 2 +- .../UseOfDeprecatedRawStorageIterator.ql | 2 +- .../UseOfDeprecatedSharedPtrUnique.ql | 2 +- .../UseOfDeprecatedStdAllocatorMember.ql | 6 ++-- .../UseOfDeprecatedStdIteratorBaseClass.ql | 2 +- .../UseOfDeprecatedStrStreamClass.ql | 4 +-- .../UseOfDeprecatedTemporaryBuffers.ql | 2 +- .../UseOfDeprecatedUnaryOrBinaryNegate.ql | 2 +- .../RULE-4-1-2/UseOfUncaughtException.ql | 2 +- ...UseOfDeprecatedStdAllocatorMember.expected | 12 +++---- rule_packages/cpp/Toolchain3.json | 34 +++++++++---------- 18 files changed, 42 insertions(+), 44 deletions(-) diff --git a/cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructor.ql b/cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructor.ql index 4b9ec5a89..5b5c1e7ed 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructor.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructor.ql @@ -3,7 +3,7 @@ * @name RULE-4-1-2: Implicit declaration of copy constructors is a deprecated language feature should not be used * @description Deprecated language features such as implicit declarations of copy constructors are * only supported for backwards compatibility; these are considered bad practice, or - * have been superceded by better alternatives. + * have been superseded by better alternatives. * @kind problem * @precision very-high * @problem.severity warning @@ -14,8 +14,6 @@ * external/misra/obligation/advisory */ -import cpp -import codingstandards.cpp.misra import cpp import codingstandards.cpp.misra import codingstandards.cpp.types.ImplicitSpecialMemberFunctions diff --git a/cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.ql b/cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.ql index 2820a7890..35a3c4e3e 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/ImplicitDeclarationOfCopyConstructorAudit.ql @@ -3,7 +3,7 @@ * @name RULE-4-1-2: Implicit declaration of copy constructors is a deprecated language feature should not be used * @description Deprecated language features such as implicit declarations of copy constructors are * only supported for backwards compatibility; these are considered bad practice, or - * have been superceded by better alternatives. + * have been superseded by better alternatives. * @kind problem * @precision low * @problem.severity warning diff --git a/cpp/misra/src/rules/RULE-4-1-2/NoexceptSpecifierThrow.ql b/cpp/misra/src/rules/RULE-4-1-2/NoexceptSpecifierThrow.ql index ba60f1690..131524ada 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/NoexceptSpecifierThrow.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/NoexceptSpecifierThrow.ql @@ -3,7 +3,7 @@ * @name RULE-4-1-2: The noexcept specifier throw() is a deprecated language feature should not be used * @description Deprecated language features such as the noexcept specifier throw() are only * supported for backwards compatibility; these are considered bad practice, or have - * been superceded by better alternatives. + * been superseded by better alternatives. * @kind problem * @precision high * @problem.severity warning diff --git a/cpp/misra/src/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMember.ql b/cpp/misra/src/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMember.ql index 21c543c56..cedbf5c71 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMember.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/RedeclarationOfStaticConstexprDataMember.ql @@ -3,7 +3,7 @@ * @name RULE-4-1-2: Redeclaration of static constexpr data members is a deprecated language feature should not be used * @description Deprecated language features such as redeclaration of static constexpr data members * are only supported for backwards compatibility; these are considered bad practice, - * or have been superceded by better alternatives. + * or have been superseded by better alternatives. * @kind problem * @precision high * @problem.severity warning diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedAllocatorVoid.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedAllocatorVoid.ql index 6dd59ad36..2095e8996 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedAllocatorVoid.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedAllocatorVoid.ql @@ -2,7 +2,7 @@ * @id cpp/misra/use-of-deprecated-allocator-void * @name RULE-4-1-2: Specialization allocator is a deprecated language feature and should not be used * @description Deprecated language features such as allocator are only supported for - * backwards compatibility; these are considered bad practice, or have been superceded + * backwards compatibility; these are considered bad practice, or have been superseded * by better alternatives. * @kind problem * @precision very-high diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedCHeaders.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedCHeaders.ql index 9f2bc6423..b639186ae 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedCHeaders.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedCHeaders.ql @@ -2,7 +2,7 @@ * @id cpp/misra/use-of-deprecated-c-headers * @name RULE-4-1-2: Use of , , and , or is deprecated and therefore these headers should not be used * @description These C standard library headers are only supported for backwards compatibility; - * these are considered bad practice, or have been superceded by better alternatives. + * these are considered bad practice, or have been superseded by better alternatives. * @kind problem * @precision very-high * @problem.severity warning diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMember.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMember.ql index c901e933c..92776b829 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMember.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMember.ql @@ -3,7 +3,7 @@ * @name RULE-4-1-2: Certain members of function binder typedefs are deprecated language features and should not be used * @description Deprecated language features such as certain function binder typedef members are * only supported for backwards compatibility; these are considered bad practice, or - * have been superceded by better alternatives. + * have been superseded by better alternatives. * @kind problem * @precision high * @problem.severity warning diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedIsLiteralTypeTraits.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedIsLiteralTypeTraits.ql index 2b45d360b..66f56af5b 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedIsLiteralTypeTraits.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedIsLiteralTypeTraits.ql @@ -2,7 +2,7 @@ * @id cpp/misra/use-of-deprecated-is-literal-type-traits * @name RULE-4-1-2: The is-literal type traits are deprecated language features and should not be used * @description Deprecated language features such as is-literal type traits are only supported for - * backwards compatibility; these are considered bad practice, or have been superceded + * backwards compatibility; these are considered bad practice, or have been superseded * by better alternatives. * @kind problem * @precision very-high diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedRawStorageIterator.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedRawStorageIterator.ql index c8acc52d7..13c24feee 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedRawStorageIterator.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedRawStorageIterator.ql @@ -2,7 +2,7 @@ * @id cpp/misra/use-of-deprecated-raw-storage-iterator * @name RULE-4-1-2: Class raw_storage_iterator is a deprecated language feature and should not be used * @description Deprecated language features such as raw_storage_iterator are only supported for - * backwards compatibility; these are considered bad practice, or have been superceded + * backwards compatibility; these are considered bad practice, or have been superseded * by better alternatives. * @kind problem * @precision high diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedSharedPtrUnique.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedSharedPtrUnique.ql index 95bd72cfb..3bdfbd6fa 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedSharedPtrUnique.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedSharedPtrUnique.ql @@ -2,7 +2,7 @@ * @id cpp/misra/use-of-deprecated-shared-ptr-unique * @name RULE-4-1-2: Observer member shared_ptr::unique is a deprecated language feature and should not be used * @description Deprecated language features such as shared_ptr::unique are only supported for - * backwards compatibility; these are considered bad practice, or have been superceded + * backwards compatibility; these are considered bad practice, or have been superseded * by better alternatives. * @kind problem * @precision very-high diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.ql index a6153bef2..72a73a9b8 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.ql @@ -3,7 +3,7 @@ * @name RULE-4-1-2: Certain members of std::allocator are deprecated language features and should not be used * @description Deprecated language features such as certain members of std::allocator are only * supported for backwards compatibility; these are considered bad practice, or have - * been superceded by better alternatives. + * been superseded by better alternatives. * @kind problem * @precision very-high * @problem.severity warning @@ -39,7 +39,7 @@ class DeprecatedAllocatorUsingMember extends UsingAliasTypedefType, DeprecatedUs override Locatable getAUseLocation() { result.(TypeMention).getMentionedType() = this } override string getAUseDescription() { - result = "Use of deprecated allocator member 'std::allocator::pointer'." + result = "Use of deprecated allocator member 'std::allocator::" + this.getName() + "'." } } @@ -59,7 +59,7 @@ class DeprecatedAllocatorMemberFunction extends MemberFunction, DeprecatedUse { override Locatable getAUseLocation() { result.(FunctionCall).getTarget() = this } override string getAUseDescription() { - result = "Use of deprecated allocator member 'std::allocator::" + this.getName() + "'." + result = "Use of deprecated allocator member 'std::allocator::" + this.getName() + "'." } } diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStdIteratorBaseClass.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStdIteratorBaseClass.ql index e94c9050c..8db3b82e5 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStdIteratorBaseClass.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStdIteratorBaseClass.ql @@ -2,7 +2,7 @@ * @id cpp/misra/use-of-deprecated-std-iterator-base-class * @name RULE-4-1-2: Base class std::iterator is a deprecated language feature and should not be used * @description Deprecated language features such as extending std::iterator are only supported for - * backwards compatibility; these are considered bad practice, or have been superceded + * backwards compatibility; these are considered bad practice, or have been superseded * by better alternatives. * @kind problem * @precision very-high diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStrStreamClass.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStrStreamClass.ql index 6845cb771..5785da61c 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStrStreamClass.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedStrStreamClass.ql @@ -1,8 +1,8 @@ /** * @id cpp/misra/use-of-deprecated-str-stream-class - * @name RULE-4-1-2: The char* stream classes strstreambuf, istreamstr, ostramstr, and strstream are deprecated and should not be used + * @name RULE-4-1-2: The char* stream classes strstreambuf, istrstream, ostrstream, and strstream are deprecated and should not be used * @description Deprecated language features such as the char* stream classes are only supported for - * backwards compatibility; these are considered bad practice, or have been superceded + * backwards compatibility; these are considered bad practice, or have been superseded * by better alternatives. * @kind problem * @precision very-high diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedTemporaryBuffers.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedTemporaryBuffers.ql index ec35e3010..7da261f80 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedTemporaryBuffers.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedTemporaryBuffers.ql @@ -2,7 +2,7 @@ * @id cpp/misra/use-of-deprecated-temporary-buffers * @name RULE-4-1-2: Temporary buffers are deprecated language features and should not be used * @description Deprecated language features such as temporary buffers are only supported for - * backwards compatibility; these are considered bad practice, or have been superceded + * backwards compatibility; these are considered bad practice, or have been superseded * by better alternatives. * @kind problem * @precision very-high diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedUnaryOrBinaryNegate.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedUnaryOrBinaryNegate.ql index f4616ac59..324e984dd 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedUnaryOrBinaryNegate.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedUnaryOrBinaryNegate.ql @@ -3,7 +3,7 @@ * @name RULE-4-1-2: Typedefs unary_negate and binary_negate are deprecated language features and should not be used * @description Deprecated language features such as unary_negate and binary_negate are only * supported for backwards compatibility; these are considered bad practice, or have - * been superceded by better alternatives. + * been superseded by better alternatives. * @kind problem * @precision very-high * @problem.severity warning diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfUncaughtException.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfUncaughtException.ql index c0861a6b4..c4da86863 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/UseOfUncaughtException.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfUncaughtException.ql @@ -2,7 +2,7 @@ * @id cpp/misra/use-of-uncaught-exception * @name RULE-4-1-2: Function uncaught_exception is a deprecated language feature should not be used * @description Deprecated language features such as uncaught_exception are only supported for - * backwards compatibility; these are considered bad practice, or have been superceded + * backwards compatibility; these are considered bad practice, or have been superseded * by better alternatives. * @kind problem * @precision very-high diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.expected b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.expected index cd1e34580..f92110c4d 100644 --- a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.expected +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedStdAllocatorMember.expected @@ -1,7 +1,7 @@ -| test.cpp:86:24:86:30 | type mention | Use of deprecated allocator member 'std::allocator::pointer'. | -| test.cpp:88:9:88:16 | call to allocate | Use of deprecated allocator member 'std::allocator::allocate'. | -| test.cpp:89:5:89:11 | call to address | Use of deprecated allocator member 'std::allocator::address'. | -| test.cpp:90:5:90:13 | call to construct | Use of deprecated allocator member 'std::allocator::construct'. | -| test.cpp:91:5:91:11 | call to destroy | Use of deprecated allocator member 'std::allocator::destroy'. | -| test.cpp:93:5:93:12 | call to max_size | Use of deprecated allocator member 'std::allocator::max_size'. | +| test.cpp:86:24:86:30 | type mention | Use of deprecated allocator member 'std::allocator::pointer'. | +| test.cpp:88:9:88:16 | call to allocate | Use of deprecated allocator member 'std::allocator::allocate'. | +| test.cpp:89:5:89:11 | call to address | Use of deprecated allocator member 'std::allocator::address'. | +| test.cpp:90:5:90:13 | call to construct | Use of deprecated allocator member 'std::allocator::construct'. | +| test.cpp:91:5:91:11 | call to destroy | Use of deprecated allocator member 'std::allocator::destroy'. | +| test.cpp:93:5:93:12 | call to max_size | Use of deprecated allocator member 'std::allocator::max_size'. | | test.cpp:96:30:96:35 | type mention | Use of deprecated allocator member class 'std::allocator::rebind'. | diff --git a/rule_packages/cpp/Toolchain3.json b/rule_packages/cpp/Toolchain3.json index 62fc8f9ae..106b75efd 100644 --- a/rule_packages/cpp/Toolchain3.json +++ b/rule_packages/cpp/Toolchain3.json @@ -7,7 +7,7 @@ }, "queries": [ { - "description": "Deprecated language features such as redeclaration of static constexpr data members are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "description": "Deprecated language features such as redeclaration of static constexpr data members are only supported for backwards compatibility; these are considered bad practice, or have been superseded by better alternatives.", "kind": "problem", "name": "Redeclaration of static constexpr data members is a deprecated language feature should not be used", "precision": "high", @@ -19,7 +19,7 @@ ] }, { - "description": "Deprecated language features such as implicit declarations of copy constructors are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "description": "Deprecated language features such as implicit declarations of copy constructors are only supported for backwards compatibility; these are considered bad practice, or have been superseded by better alternatives.", "kind": "problem", "name": "Implicit declaration of copy constructors is a deprecated language feature should not be used", "precision": "very-high", @@ -34,7 +34,7 @@ } }, { - "description": "Deprecated language features such as implicit declarations of copy constructors are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "description": "Deprecated language features such as implicit declarations of copy constructors are only supported for backwards compatibility; these are considered bad practice, or have been superseded by better alternatives.", "kind": "problem", "name": "Implicit declaration of copy constructors is a deprecated language feature should not be used", "precision": "low", @@ -50,7 +50,7 @@ } }, { - "description": "Deprecated language features such as the noexcept specifier throw() are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "description": "Deprecated language features such as the noexcept specifier throw() are only supported for backwards compatibility; these are considered bad practice, or have been superseded by better alternatives.", "kind": "problem", "name": "The noexcept specifier throw() is a deprecated language feature should not be used", "precision": "high", @@ -62,7 +62,7 @@ ] }, { - "description": "These C standard library headers are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "description": "These C standard library headers are only supported for backwards compatibility; these are considered bad practice, or have been superseded by better alternatives.", "kind": "problem", "name": "Use of , , and , or is deprecated and therefore these headers should not be used", "precision": "very-high", @@ -74,9 +74,9 @@ ] }, { - "description": "Deprecated language features such as the char* stream classes are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "description": "Deprecated language features such as the char* stream classes are only supported for backwards compatibility; these are considered bad practice, or have been superseded by better alternatives.", "kind": "problem", - "name": "The char* stream classes strstreambuf, istreamstr, ostramstr, and strstream are deprecated and should not be used", + "name": "The char* stream classes strstreambuf, istrstream, ostrstream, and strstream are deprecated and should not be used", "precision": "very-high", "severity": "warning", "short_name": "UseOfDeprecatedStrStreamClass", @@ -86,7 +86,7 @@ ] }, { - "description": "Deprecated language features such as uncaught_exception are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "description": "Deprecated language features such as uncaught_exception are only supported for backwards compatibility; these are considered bad practice, or have been superseded by better alternatives.", "kind": "problem", "name": "Function uncaught_exception is a deprecated language feature should not be used", "precision": "very-high", @@ -98,7 +98,7 @@ ] }, { - "description": "Deprecated language features such as certain function binder typedef members are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "description": "Deprecated language features such as certain function binder typedef members are only supported for backwards compatibility; these are considered bad practice, or have been superseded by better alternatives.", "kind": "problem", "name": "Certain members of function binder typedefs are deprecated language features and should not be used", "precision": "high", @@ -110,7 +110,7 @@ ] }, { - "description": "Deprecated language features such as unary_negate and binary_negate are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "description": "Deprecated language features such as unary_negate and binary_negate are only supported for backwards compatibility; these are considered bad practice, or have been superseded by better alternatives.", "kind": "problem", "name": "Typedefs unary_negate and binary_negate are deprecated language features and should not be used", "precision": "very-high", @@ -122,7 +122,7 @@ ] }, { - "description": "Deprecated language features such as allocator are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "description": "Deprecated language features such as allocator are only supported for backwards compatibility; these are considered bad practice, or have been superseded by better alternatives.", "kind": "problem", "name": "Specialization allocator is a deprecated language feature and should not be used", "precision": "very-high", @@ -134,7 +134,7 @@ ] }, { - "description": "Deprecated language features such as certain members of std::allocator are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "description": "Deprecated language features such as certain members of std::allocator are only supported for backwards compatibility; these are considered bad practice, or have been superseded by better alternatives.", "kind": "problem", "name": "Certain members of std::allocator are deprecated language features and should not be used", "precision": "very-high", @@ -146,7 +146,7 @@ ] }, { - "description": "Deprecated language features such as raw_storage_iterator are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "description": "Deprecated language features such as raw_storage_iterator are only supported for backwards compatibility; these are considered bad practice, or have been superseded by better alternatives.", "kind": "problem", "name": "Class raw_storage_iterator is a deprecated language feature and should not be used", "precision": "high", @@ -158,7 +158,7 @@ ] }, { - "description": "Deprecated language features such as temporary buffers are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "description": "Deprecated language features such as temporary buffers are only supported for backwards compatibility; these are considered bad practice, or have been superseded by better alternatives.", "kind": "problem", "name": "Temporary buffers are deprecated language features and should not be used", "precision": "very-high", @@ -170,7 +170,7 @@ ] }, { - "description": "Deprecated language features such as is-literal type traits are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "description": "Deprecated language features such as is-literal type traits are only supported for backwards compatibility; these are considered bad practice, or have been superseded by better alternatives.", "kind": "problem", "name": "The is-literal type traits are deprecated language features and should not be used", "precision": "very-high", @@ -182,7 +182,7 @@ ] }, { - "description": "Deprecated language features such as extending std::iterator are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "description": "Deprecated language features such as extending std::iterator are only supported for backwards compatibility; these are considered bad practice, or have been superseded by better alternatives.", "kind": "problem", "name": "Base class std::iterator is a deprecated language feature and should not be used", "precision": "very-high", @@ -194,7 +194,7 @@ ] }, { - "description": "Deprecated language features such as shared_ptr::unique are only supported for backwards compatibility; these are considered bad practice, or have been superceded by better alternatives.", + "description": "Deprecated language features such as shared_ptr::unique are only supported for backwards compatibility; these are considered bad practice, or have been superseded by better alternatives.", "kind": "problem", "name": "Observer member shared_ptr::unique is a deprecated language feature and should not be used", "precision": "very-high", From d2a326e8447bd0e48ad80917b9d49e4a69193fea Mon Sep 17 00:00:00 2001 From: Michael R Fairhurst Date: Tue, 3 Mar 2026 17:32:28 -0800 Subject: [PATCH 12/13] Add full stop to alert message Co-authored-by: Mauro Baluda --- .../RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMember.ql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMember.ql b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMember.ql index 92776b829..b31d217b7 100644 --- a/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMember.ql +++ b/cpp/misra/src/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMember.ql @@ -71,4 +71,4 @@ from TypeMention tm, DeprecatedFunctionBinderTypedefMember member where not isExcluded(tm, Toolchain3Package::useOfDeprecatedFunctionBinderTypedefMemberQuery()) and tm.getMentionedType() = member -select tm, "Use of deprecated function binder typedef member " + member.toString() +select tm, "Use of deprecated function binder typedef member " + member.toString() + "." From d156ec26a871c098a58794a91ac4ef71e4194988 Mon Sep 17 00:00:00 2001 From: Mike Fairhurst Date: Tue, 3 Mar 2026 23:34:17 -0800 Subject: [PATCH 13/13] Fix test expectations --- ...ecatedFunctionBinderTypedefMember.expected | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMember.expected b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMember.expected index 5f230568c..64d45cfac 100644 --- a/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMember.expected +++ b/cpp/misra/test/rules/RULE-4-1-2/UseOfDeprecatedFunctionBinderTypedefMember.expected @@ -1,10 +1,10 @@ -| test.cpp:103:19:103:29 | type mention | Use of deprecated function binder typedef member result_type | -| test.cpp:104:19:104:37 | type mention | Use of deprecated function binder typedef member first_argument_type | -| test.cpp:105:19:105:38 | type mention | Use of deprecated function binder typedef member second_argument_type | -| test.cpp:106:21:106:31 | type mention | Use of deprecated function binder typedef member result_type | -| test.cpp:107:21:107:33 | type mention | Use of deprecated function binder typedef member argument_type | -| test.cpp:108:28:108:38 | type mention | Use of deprecated function binder typedef member result_type | -| test.cpp:145:19:145:29 | type mention | Use of deprecated function binder typedef member result_type | -| test.cpp:146:19:146:31 | type mention | Use of deprecated function binder typedef member argument_type | -| test.cpp:148:16:148:26 | type mention | Use of deprecated function binder typedef member result_type | -| test.cpp:150:16:150:26 | type mention | Use of deprecated function binder typedef member result_type | \ No newline at end of file +| test.cpp:103:19:103:29 | type mention | Use of deprecated function binder typedef member result_type. | +| test.cpp:104:19:104:37 | type mention | Use of deprecated function binder typedef member first_argument_type. | +| test.cpp:105:19:105:38 | type mention | Use of deprecated function binder typedef member second_argument_type. | +| test.cpp:106:21:106:31 | type mention | Use of deprecated function binder typedef member result_type. | +| test.cpp:107:21:107:33 | type mention | Use of deprecated function binder typedef member argument_type. | +| test.cpp:108:28:108:38 | type mention | Use of deprecated function binder typedef member result_type. | +| test.cpp:145:19:145:29 | type mention | Use of deprecated function binder typedef member result_type. | +| test.cpp:146:19:146:31 | type mention | Use of deprecated function binder typedef member argument_type. | +| test.cpp:148:16:148:26 | type mention | Use of deprecated function binder typedef member result_type. | +| test.cpp:150:16:150:26 | type mention | Use of deprecated function binder typedef member result_type. |