From 696111bc2dc8642ba9a03ceaf41ccffb28b682d8 Mon Sep 17 00:00:00 2001 From: Jeongsoo Lee Date: Wed, 25 Jan 2023 10:30:38 -0800 Subject: [PATCH 01/23] Add rule_packages/c/Types.json and add description for RULE-6-1 and RULE-6-2 --- rule_packages/c/Types.json | 516 +++++++++++++++++++++++++++++++++++++ 1 file changed, 516 insertions(+) create mode 100644 rule_packages/c/Types.json diff --git a/rule_packages/c/Types.json b/rule_packages/c/Types.json new file mode 100644 index 0000000000..c7d4e6e2ae --- /dev/null +++ b/rule_packages/c/Types.json @@ -0,0 +1,516 @@ +{ + "CERT-C": { + "FLP32-C": { + "properties": { + "obligation": "rule" + }, + "queries": [ + { + "description": "", + "kind": "problem", + "name": "Prevent or detect domain and range errors in math functions", + "precision": "very-high", + "severity": "error", + "short_name": "PreventOrDetectDomainAndRangeErrorsInMathFunctions", + "tags": [] + } + ], + "title": "Prevent or detect domain and range errors in math functions" + }, + "FLP34-C": { + "properties": { + "obligation": "rule" + }, + "queries": [ + { + "description": "", + "kind": "problem", + "name": "Ensure that floating-point conversions are within range of the new type", + "precision": "very-high", + "severity": "error", + "short_name": "EnsureThatFloatingPointConversionsAreWithinRangeOfTheNewType", + "tags": [] + } + ], + "title": "Ensure that floating-point conversions are within range of the new type" + }, + "FLP36-C": { + "properties": { + "obligation": "rule" + }, + "queries": [ + { + "description": "", + "kind": "problem", + "name": "Preserve precision when converting integral values to floating-point type", + "precision": "very-high", + "severity": "error", + "short_name": "PreservePrecisionWhenConvertingIntegralValuesToFloatingPointType", + "tags": [] + } + ], + "title": "Preserve precision when converting integral values to floating-point type" + }, + "FLP37-C": { + "properties": { + "obligation": "rule" + }, + "queries": [ + { + "description": "", + "kind": "problem", + "name": "Do not use object representations to compare floating-point values", + "precision": "very-high", + "severity": "error", + "short_name": "DoNotUseObjectRepresentationsToCompareFloatingPointValues", + "tags": [] + } + ], + "title": "Do not use object representations to compare floating-point values" + }, + "INT30-C": { + "properties": { + "obligation": "rule" + }, + "queries": [ + { + "description": "", + "kind": "problem", + "name": "Ensure that unsigned integer operations do not wrap", + "precision": "high", + "severity": "error", + "short_name": "EnsureThatUnsignedIntegerOperationsDoNotWrap", + "tags": [] + } + ], + "title": "Ensure that unsigned integer operations do not wrap" + }, + "INT31-C": { + "properties": { + "obligation": "rule" + }, + "queries": [ + { + "description": "", + "kind": "problem", + "name": "Ensure that integer conversions do not result in lost or misinterpreted data", + "precision": "high", + "severity": "error", + "short_name": "EnsureThatIntegerConversionsDoNotResultInLostOrMisinterpretedData", + "tags": [] + } + ], + "title": "Ensure that integer conversions do not result in lost or misinterpreted data" + }, + "INT32-C": { + "properties": { + "obligation": "rule" + }, + "queries": [ + { + "description": "", + "kind": "problem", + "name": "Ensure that operations on signed integers do not result in overflow", + "precision": "high", + "severity": "error", + "short_name": "EnsureThatOperationsOnSignedIntegersDoNotResultInOverflow", + "tags": [] + } + ], + "title": "Ensure that operations on signed integers do not result in overflow" + }, + "INT33-C": { + "properties": { + "obligation": "rule" + }, + "queries": [ + { + "description": "", + "kind": "problem", + "name": "Ensure that division and remainder operations do not result in divide-by-zero errors", + "precision": "high", + "severity": "error", + "short_name": "EnsureThatDivisionAndRemainderOperationsDoNotResultInDivideByZeroErrors", + "tags": [] + } + ], + "title": "Ensure that division and remainder operations do not result in divide-by-zero errors" + }, + "INT34-C": { + "properties": { + "obligation": "rule" + }, + "queries": [ + { + "description": "Do not shift an expression by a negative number of bits or by greater than or equal to the number of bits that exist in the operand", + "kind": "problem", + "name": "Do not shift an expression by a negative number of bits or by greater than or equal to the number of", + "precision": "very-high", + "severity": "error", + "short_name": "DoNotShiftAnExpressionByANegativeNumberOfBitsOrByGreaterThanOrEqualToTheNumberOfBitsThatExistInTheOperand", + "tags": [] + } + ], + "title": "Do not shift an expression by a negative number of bits or by greater than or equal to the number of bits that exist in the operand" + }, + "INT35-C": { + "properties": { + "obligation": "rule" + }, + "queries": [ + { + "description": "", + "kind": "problem", + "name": "Use correct integer precisions", + "precision": "high", + "severity": "error", + "short_name": "UseCorrectIntegerPrecisions", + "tags": [] + } + ], + "title": "Use correct integer precisions" + }, + "INT36-C": { + "properties": { + "obligation": "rule" + }, + "queries": [ + { + "description": "", + "kind": "problem", + "name": "Converting a pointer to integer or integer to pointer", + "precision": "very-high", + "severity": "error", + "short_name": "ConvertingAPointerToIntegerOrIntegerToPointer", + "tags": [] + } + ], + "title": "Converting a pointer to integer or integer to pointer" + } + }, + "MISRA-C-2012": { + "DIR-4-6": { + "properties": { + "obligation": "advisory" + }, + "queries": [ + { + "description": "", + "kind": "problem", + "name": "typedefs that indicate size and signedness should be used in place of the basic numerical types", + "precision": "high", + "severity": "error", + "short_name": "TypedefsThatIndicateSizeAndSignednessShouldBeUsedInPlaceOfTheBasicNumericalTypes", + "tags": [] + } + ], + "title": "typedefs that indicate size and signedness should be used in place of the basic numerical types" + }, + "RULE-10-1": { + "properties": { + "obligation": "required" + }, + "queries": [ + { + "description": "", + "kind": "problem", + "name": "Operands shall not be of an inappropriate essential type", + "precision": "high", + "severity": "error", + "short_name": "OperandsOfAnInappropriateEssentialType", + "tags": [] + } + ], + "title": "Operands shall not be of an inappropriate essential type" + }, + "RULE-10-2": { + "properties": { + "obligation": "required" + }, + "queries": [ + { + "description": "Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations", + "kind": "problem", + "name": "Expressions of essentially character type shall not be used inappropriately in addition and", + "precision": "very-high", + "severity": "error", + "short_name": "ExpressionsOfEssentiallyCharacterTypeUsedInappropriatelyInAdditionAndSubtractionOperations", + "tags": [] + } + ], + "title": "Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations" + }, + "RULE-10-3": { + "properties": { + "obligation": "required" + }, + "queries": [ + { + "description": "The value of an expression shall not be assigned to an object with a narrower essential type or of a different essential type category", + "kind": "problem", + "name": "The value of an expression shall not be assigned to an object with a narrower essential type or of a", + "precision": "high", + "severity": "error", + "short_name": "ValueOfAnExpressionAssignedToAnObjectWithANarrowerEssentialTypeOrOfADifferentEssentialTypeCategory", + "tags": [] + } + ], + "title": "The value of an expression shall not be assigned to an object with a narrower essential type or of a different essential type category" + }, + "RULE-10-4": { + "properties": { + "obligation": "required" + }, + "queries": [ + { + "description": "Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category", + "kind": "problem", + "name": "Both operands of an operator in which the usual arithmetic conversions are performed shall have the", + "precision": "very-high", + "severity": "error", + "short_name": "BothOperandsOfAnOperatorInWhichTheUsualArithmeticConversionsArePerformedShallHaveTheSameEssentialTypeCategory", + "tags": [] + } + ], + "title": "Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category" + }, + "RULE-10-5": { + "properties": { + "obligation": "advisory" + }, + "queries": [ + { + "description": "", + "kind": "problem", + "name": "The value of an expression should not be cast to an inappropriate essential type", + "precision": "very-high", + "severity": "error", + "short_name": "ValueOfAnExpressionShouldNotBeCastToAnInappropriateEssentialType", + "tags": [] + } + ], + "title": "The value of an expression should not be cast to an inappropriate essential type" + }, + "RULE-10-6": { + "properties": { + "obligation": "required" + }, + "queries": [ + { + "description": "", + "kind": "problem", + "name": "The value of a composite expression shall not be assigned to an object with wider essential type", + "precision": "very-high", + "severity": "error", + "short_name": "ValueOfACompositeExpressionAssignedToAnObjectWithWiderEssentialType", + "tags": [] + } + ], + "title": "The value of a composite expression shall not be assigned to an object with wider essential type" + }, + "RULE-10-7": { + "properties": { + "obligation": "required" + }, + "queries": [ + { + "description": "If a composite expression is used as one operand of an operator in which the usual arithmetic conversions are performed then the other operand shall not have wider essential type", + "kind": "problem", + "name": "If a composite expression is used as one operand of an operator in which the usual arithmetic", + "precision": "very-high", + "severity": "error", + "short_name": "IfACompositeExpressionIsUsedAsOneOperandOfAnOperatorInWhichTheUsualArithmeticConversionsArePerformedThenTheOtherOperandHaveWiderEssentialType", + "tags": [] + } + ], + "title": "If a composite expression is used as one operand of an operator in which the usual arithmetic conversions are performed then the other operand shall not have wider essential type" + }, + "RULE-10-8": { + "properties": { + "obligation": "required" + }, + "queries": [ + { + "description": "The value of a composite expression shall not be cast to a different essential type category or a wider essential type", + "kind": "problem", + "name": "The value of a composite expression shall not be cast to a different essential type category or a", + "precision": "very-high", + "severity": "error", + "short_name": "ValueOfACompositeExpressionCastToADifferentEssentialTypeCategoryOrAWiderEssentialType", + "tags": [] + } + ], + "title": "The value of a composite expression shall not be cast to a different essential type category or a wider essential type" + }, + "RULE-12-4": { + "properties": { + "obligation": "advisory" + }, + "queries": [ + { + "description": "", + "kind": "problem", + "name": "Evaluation of constant expressions should not lead to unsigned integer wrap-around", + "precision": "very-high", + "severity": "error", + "short_name": "EvaluationOfConstantExpressionsShouldNotLeadToUnsignedIntegerWrapAround", + "tags": [] + } + ], + "title": "Evaluation of constant expressions should not lead to unsigned integer wrap-around" + }, + "RULE-12-5": { + "properties": { + "obligation": "mandatory" + }, + "queries": [ + { + "description": "The sizeof operator shall not have an operand which is a function parameter declared as \ufffdarray of type\ufffd", + "kind": "problem", + "name": "The sizeof operator shall not have an operand which is a function parameter declared as \ufffdarray of", + "precision": "very-high", + "severity": "error", + "short_name": "SizeofOperatorHaveAnOperandWhichIsAFunctionParameterDeclaredAsArrayOfType", + "tags": [] + } + ], + "title": "The sizeof operator shall not have an operand which is a function parameter declared as \ufffdarray of type\ufffd" + }, + "RULE-14-1": { + "properties": { + "obligation": "required" + }, + "queries": [ + { + "description": "", + "kind": "problem", + "name": "A loop counter shall not have essentially floating type", + "precision": "high", + "severity": "error", + "short_name": "LoopCounterHaveEssentiallyFloatingType", + "tags": [] + } + ], + "title": "A loop counter shall not have essentially floating type" + }, + "RULE-21-13": { + "properties": { + "obligation": "mandatory" + }, + "queries": [ + { + "description": "Any value passed to a function in shall be representable as an unsigned char or be the value EOF", + "kind": "problem", + "name": "Any value passed to a function in shall be representable as an unsigned char or be the", + "precision": "very-high", + "severity": "error", + "short_name": "ValuePassedToAFunctionInCtypehNotRepresentableAsUnsignedCharOrBeTheValueEof", + "tags": [] + } + ], + "title": "Any value passed to a function in shall be representable as an unsigned char or be the value EOF" + }, + "RULE-21-14": { + "properties": { + "obligation": "required" + }, + "queries": [ + { + "description": "", + "kind": "problem", + "name": "The Standard Library function memcmp shall not be used to compare null terminated strings", + "precision": "high", + "severity": "error", + "short_name": "StandardLibraryFunctionMemcmpUsedToCompareNullTerminatedStrings", + "tags": [] + } + ], + "title": "The Standard Library function memcmp shall not be used to compare null terminated strings" + }, + "RULE-21-15": { + "properties": { + "obligation": "required" + }, + "queries": [ + { + "description": "The pointer arguments to the Standard Library functions memcpy, memmove and memcmp shall be pointers to qualified or unqualified versions of compatible types", + "kind": "problem", + "name": "The pointer arguments to the Standard Library functions memcpy, memmove and memcmp shall be pointers", + "precision": "very-high", + "severity": "error", + "short_name": "PointerArgumentsToTheStandardLibraryFunctionsMemcpyMemmoveAndMemcmpNotPointersToQualifiedOrUnqualifiedVersionsOfCompatibleTypes", + "tags": [] + } + ], + "title": "The pointer arguments to the Standard Library functions memcpy, memmove and memcmp shall be pointers to qualified or unqualified versions of compatible types" + }, + "RULE-21-16": { + "properties": { + "obligation": "required" + }, + "queries": [ + { + "description": "The pointer arguments to the Standard Library function memcmp shall point to either a pointer type, an essentially signed type, an essentially unsigned type, an essentially Boolean type or an essentially enum type", + "kind": "problem", + "name": "The pointer arguments to the Standard Library function memcmp shall point to either a pointer type,", + "precision": "very-high", + "severity": "error", + "short_name": "PointerArgumentsToTheStandardLibraryFunctionMemcmpShallPointToEitherAPointerTypeAnEssentiallySignedTypeAnEssentiallyUnsignedTypeAnEssentiallyBooleanTypeOrAnEssentiallyEnumType", + "tags": [] + } + ], + "title": "The pointer arguments to the Standard Library function memcmp shall point to either a pointer type, an essentially signed type, an essentially unsigned type, an essentially Boolean type or an essentially enum type" + }, + "RULE-6-1": { + "properties": { + "obligation": "required" + }, + "queries": [ + { + "description": "Using types other than appropriate ones causes to implementation-specific or undefined behavior.", + "kind": "problem", + "name": "Bit-fields shall only be declared with an appropriate type", + "precision": "very-high", + "severity": "error", + "short_name": "BitFieldsShallOnlyBeDeclaredWithAnAppropriateType", + "tags": [] + } + ], + "title": "Bit-fields shall only be declared with an appropriate type" + }, + "RULE-6-2": { + "properties": { + "obligation": "required" + }, + "queries": [ + { + "description": "Single-bit named bit fields carry no useful information and therefore should not be declared or used.", + "kind": "problem", + "name": "Single-bit named bit fields shall not be of a signed type", + "precision": "very-high", + "severity": "error", + "short_name": "SingleBitNamedBitFieldsOfASignedType", + "tags": [] + } + ], + "title": "Single-bit named bit fields shall not be of a signed type" + }, + "RULE-7-4": { + "properties": { + "obligation": "required" + }, + "queries": [ + { + "description": "A string literal shall not be assigned to an object unless the object\ufffds type is \ufffdpointer to const-qualified char\ufffd", + "kind": "problem", + "name": "A string literal shall not be assigned to an object unless the object\ufffds type is \ufffdpointer to", + "precision": "very-high", + "severity": "error", + "short_name": "StringLiteralAssignedToAnObjectUnlessTheObjectsTypeIsPointerToConstQualifiedChar", + "tags": [] + } + ], + "title": "A string literal shall not be assigned to an object unless the object\ufffds type is \ufffdpointer to const-qualified char\ufffd" + } + } +} From d511157bba5ecb42a54a13b91509874ba0b1664c Mon Sep 17 00:00:00 2001 From: Jeongsoo Lee Date: Wed, 25 Jan 2023 10:37:17 -0800 Subject: [PATCH 02/23] Better polish description for RULE-6-1 --- rule_packages/c/Types.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rule_packages/c/Types.json b/rule_packages/c/Types.json index c7d4e6e2ae..02135821f9 100644 --- a/rule_packages/c/Types.json +++ b/rule_packages/c/Types.json @@ -467,7 +467,7 @@ }, "queries": [ { - "description": "Using types other than appropriate ones causes to implementation-specific or undefined behavior.", + "description": "Declaring bit-fields on types other than appropriate ones causes implementation-specific or undefined behavior.", "kind": "problem", "name": "Bit-fields shall only be declared with an appropriate type", "precision": "very-high", From 41e755f88c3dcd51934e7a343b295596af1204bc Mon Sep 17 00:00:00 2001 From: Jeongsoo Lee Date: Wed, 25 Jan 2023 12:32:26 -0800 Subject: [PATCH 03/23] make rule_packages/c/Types.json valid --- rule_packages/c/Types.json | 110 ++++++++++++++++++------------------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/rule_packages/c/Types.json b/rule_packages/c/Types.json index 02135821f9..cefcd6fec5 100644 --- a/rule_packages/c/Types.json +++ b/rule_packages/c/Types.json @@ -6,7 +6,7 @@ }, "queries": [ { - "description": "", + "description": "TODO.", "kind": "problem", "name": "Prevent or detect domain and range errors in math functions", "precision": "very-high", @@ -23,12 +23,12 @@ }, "queries": [ { - "description": "", + "description": "TODO.", "kind": "problem", "name": "Ensure that floating-point conversions are within range of the new type", "precision": "very-high", "severity": "error", - "short_name": "EnsureThatFloatingPointConversionsAreWithinRangeOfTheNewType", + "short_name": "FloatingPointConversionsNotWithinRangeOfNewType", "tags": [] } ], @@ -40,12 +40,12 @@ }, "queries": [ { - "description": "", + "description": "TODO.", "kind": "problem", "name": "Preserve precision when converting integral values to floating-point type", "precision": "very-high", "severity": "error", - "short_name": "PreservePrecisionWhenConvertingIntegralValuesToFloatingPointType", + "short_name": "FloatingPointOfIntegralValuesLosePrecision", "tags": [] } ], @@ -57,12 +57,12 @@ }, "queries": [ { - "description": "", + "description": "TODO.", "kind": "problem", "name": "Do not use object representations to compare floating-point values", "precision": "very-high", "severity": "error", - "short_name": "DoNotUseObjectRepresentationsToCompareFloatingPointValues", + "short_name": "ObjectReprUsedForComparingFloatingPointValues", "tags": [] } ], @@ -74,7 +74,7 @@ }, "queries": [ { - "description": "", + "description": "TODO.", "kind": "problem", "name": "Ensure that unsigned integer operations do not wrap", "precision": "high", @@ -91,12 +91,12 @@ }, "queries": [ { - "description": "", + "description": "TODO.", "kind": "problem", "name": "Ensure that integer conversions do not result in lost or misinterpreted data", "precision": "high", "severity": "error", - "short_name": "EnsureThatIntegerConversionsDoNotResultInLostOrMisinterpretedData", + "short_name": "IntConversionCausesLostOrMisinterpretedData", "tags": [] } ], @@ -108,12 +108,12 @@ }, "queries": [ { - "description": "", + "description": "TODO.", "kind": "problem", "name": "Ensure that operations on signed integers do not result in overflow", "precision": "high", "severity": "error", - "short_name": "EnsureThatOperationsOnSignedIntegersDoNotResultInOverflow", + "short_name": "OperationsOnSignedIntegersResultsInOverflow", "tags": [] } ], @@ -125,12 +125,12 @@ }, "queries": [ { - "description": "", + "description": "TODO.", "kind": "problem", "name": "Ensure that division and remainder operations do not result in divide-by-zero errors", "precision": "high", "severity": "error", - "short_name": "EnsureThatDivisionAndRemainderOperationsDoNotResultInDivideByZeroErrors", + "short_name": "DivAndModOperationResultsInDivByZero", "tags": [] } ], @@ -142,12 +142,12 @@ }, "queries": [ { - "description": "Do not shift an expression by a negative number of bits or by greater than or equal to the number of bits that exist in the operand", + "description": "Do not shift an expression by a negative number of bits or by greater than or equal to the number of bits that exist in the operand.", "kind": "problem", "name": "Do not shift an expression by a negative number of bits or by greater than or equal to the number of", "precision": "very-high", "severity": "error", - "short_name": "DoNotShiftAnExpressionByANegativeNumberOfBitsOrByGreaterThanOrEqualToTheNumberOfBitsThatExistInTheOperand", + "short_name": "ExprShiftedByNegativeBitsOrGreaterThanOperand", "tags": [] } ], @@ -159,7 +159,7 @@ }, "queries": [ { - "description": "", + "description": "TODO.", "kind": "problem", "name": "Use correct integer precisions", "precision": "high", @@ -176,7 +176,7 @@ }, "queries": [ { - "description": "", + "description": "TODO.", "kind": "problem", "name": "Converting a pointer to integer or integer to pointer", "precision": "very-high", @@ -195,12 +195,12 @@ }, "queries": [ { - "description": "", + "description": "TODO.", "kind": "problem", "name": "typedefs that indicate size and signedness should be used in place of the basic numerical types", "precision": "high", "severity": "error", - "short_name": "TypedefsThatIndicateSizeAndSignednessShouldBeUsedInPlaceOfTheBasicNumericalTypes", + "short_name": "NumericTypedefsNotUsedInPlaceOfBasicNumericalTypes", "tags": [] } ], @@ -212,7 +212,7 @@ }, "queries": [ { - "description": "", + "description": "TODO.", "kind": "problem", "name": "Operands shall not be of an inappropriate essential type", "precision": "high", @@ -229,12 +229,12 @@ }, "queries": [ { - "description": "Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations", + "description": "Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations.", "kind": "problem", "name": "Expressions of essentially character type shall not be used inappropriately in addition and", "precision": "very-high", "severity": "error", - "short_name": "ExpressionsOfEssentiallyCharacterTypeUsedInappropriatelyInAdditionAndSubtractionOperations", + "short_name": "CharTypeExprsUsedInAddOrSub", "tags": [] } ], @@ -246,12 +246,12 @@ }, "queries": [ { - "description": "The value of an expression shall not be assigned to an object with a narrower essential type or of a different essential type category", + "description": "The value of an expression shall not be assigned to an object with a narrower essential type or of a different essential type category.", "kind": "problem", "name": "The value of an expression shall not be assigned to an object with a narrower essential type or of a", "precision": "high", "severity": "error", - "short_name": "ValueOfAnExpressionAssignedToAnObjectWithANarrowerEssentialTypeOrOfADifferentEssentialTypeCategory", + "short_name": "AssignmentToIncompatibleEssentialType", "tags": [] } ], @@ -263,12 +263,12 @@ }, "queries": [ { - "description": "Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category", + "description": "Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category.", "kind": "problem", "name": "Both operands of an operator in which the usual arithmetic conversions are performed shall have the", "precision": "very-high", "severity": "error", - "short_name": "BothOperandsOfAnOperatorInWhichTheUsualArithmeticConversionsArePerformedShallHaveTheSameEssentialTypeCategory", + "short_name": "ArithConversionOperandHasDifferentEssTypeCategory", "tags": [] } ], @@ -280,12 +280,12 @@ }, "queries": [ { - "description": "", + "description": "TODO.", "kind": "problem", "name": "The value of an expression should not be cast to an inappropriate essential type", "precision": "very-high", "severity": "error", - "short_name": "ValueOfAnExpressionShouldNotBeCastToAnInappropriateEssentialType", + "short_name": "ValueCastToInappropriateEssentialType", "tags": [] } ], @@ -297,12 +297,12 @@ }, "queries": [ { - "description": "", + "description": "TODO.", "kind": "problem", "name": "The value of a composite expression shall not be assigned to an object with wider essential type", "precision": "very-high", "severity": "error", - "short_name": "ValueOfACompositeExpressionAssignedToAnObjectWithWiderEssentialType", + "short_name": "CompositeExprValueAssignedToObjWithWiderEssType", "tags": [] } ], @@ -314,12 +314,12 @@ }, "queries": [ { - "description": "If a composite expression is used as one operand of an operator in which the usual arithmetic conversions are performed then the other operand shall not have wider essential type", + "description": "If a composite expression is used as one operand of an operator in which the usual arithmetic conversions are performed then the other operand shall not have wider essential type.", "kind": "problem", "name": "If a composite expression is used as one operand of an operator in which the usual arithmetic", "precision": "very-high", "severity": "error", - "short_name": "IfACompositeExpressionIsUsedAsOneOperandOfAnOperatorInWhichTheUsualArithmeticConversionsArePerformedThenTheOtherOperandHaveWiderEssentialType", + "short_name": "ConvertedCompExprOperandHasWiderEssTypeThanOther", "tags": [] } ], @@ -331,12 +331,12 @@ }, "queries": [ { - "description": "The value of a composite expression shall not be cast to a different essential type category or a wider essential type", + "description": "The value of a composite expression shall not be cast to a different essential type category or a wider essential type.", "kind": "problem", "name": "The value of a composite expression shall not be cast to a different essential type category or a", "precision": "very-high", "severity": "error", - "short_name": "ValueOfACompositeExpressionCastToADifferentEssentialTypeCategoryOrAWiderEssentialType", + "short_name": "CompExprValCastToIncompatEssType", "tags": [] } ], @@ -348,12 +348,12 @@ }, "queries": [ { - "description": "", + "description": "TODO.", "kind": "problem", "name": "Evaluation of constant expressions should not lead to unsigned integer wrap-around", "precision": "very-high", "severity": "error", - "short_name": "EvaluationOfConstantExpressionsShouldNotLeadToUnsignedIntegerWrapAround", + "short_name": "ConstExprEvalCausesUnsignedIntWraparound", "tags": [] } ], @@ -365,16 +365,16 @@ }, "queries": [ { - "description": "The sizeof operator shall not have an operand which is a function parameter declared as \ufffdarray of type\ufffd", + "description": "The sizeof operator shall not have an operand which is a function parameter declared as 'array of type'.", "kind": "problem", - "name": "The sizeof operator shall not have an operand which is a function parameter declared as \ufffdarray of", + "name": "The sizeof operator shall not have an operand which is a function parameter declared as 'array of", "precision": "very-high", "severity": "error", - "short_name": "SizeofOperatorHaveAnOperandWhichIsAFunctionParameterDeclaredAsArrayOfType", + "short_name": "ArrayTypeParamAtSizeofOperand", "tags": [] } ], - "title": "The sizeof operator shall not have an operand which is a function parameter declared as \ufffdarray of type\ufffd" + "title": "The sizeof operator shall not have an operand which is a function parameter declared as 'array of type'" }, "RULE-14-1": { "properties": { @@ -382,7 +382,7 @@ }, "queries": [ { - "description": "", + "description": "TODO.", "kind": "problem", "name": "A loop counter shall not have essentially floating type", "precision": "high", @@ -399,12 +399,12 @@ }, "queries": [ { - "description": "Any value passed to a function in shall be representable as an unsigned char or be the value EOF", + "description": "Any value passed to a function in shall be representable as an unsigned char or be the value EOF.", "kind": "problem", "name": "Any value passed to a function in shall be representable as an unsigned char or be the", "precision": "very-high", "severity": "error", - "short_name": "ValuePassedToAFunctionInCtypehNotRepresentableAsUnsignedCharOrBeTheValueEof", + "short_name": "CtypeFuncNeitherReprAsUnsignedCharNorEOF", "tags": [] } ], @@ -416,12 +416,12 @@ }, "queries": [ { - "description": "", + "description": "TODO.", "kind": "problem", "name": "The Standard Library function memcmp shall not be used to compare null terminated strings", "precision": "high", "severity": "error", - "short_name": "StandardLibraryFunctionMemcmpUsedToCompareNullTerminatedStrings", + "short_name": "MemcmpUsedToCompareNullTerminatedStrings", "tags": [] } ], @@ -433,12 +433,12 @@ }, "queries": [ { - "description": "The pointer arguments to the Standard Library functions memcpy, memmove and memcmp shall be pointers to qualified or unqualified versions of compatible types", + "description": "The pointer arguments to the Standard Library functions memcpy, memmove and memcmp shall be pointers to qualified or unqualified versions of compatible types.", "kind": "problem", "name": "The pointer arguments to the Standard Library functions memcpy, memmove and memcmp shall be pointers", "precision": "very-high", "severity": "error", - "short_name": "PointerArgumentsToTheStandardLibraryFunctionsMemcpyMemmoveAndMemcmpNotPointersToQualifiedOrUnqualifiedVersionsOfCompatibleTypes", + "short_name": "MemcpyMemmoveMemcmpArgNotPointerToCompatTypes", "tags": [] } ], @@ -450,16 +450,16 @@ }, "queries": [ { - "description": "The pointer arguments to the Standard Library function memcmp shall point to either a pointer type, an essentially signed type, an essentially unsigned type, an essentially Boolean type or an essentially enum type", + "description": "The pointer arguments to the Standard Library function memcmp shall point to either a pointer type, an essentially signed type, an essentially unsigned type, an essentially Boolean type or an essentially enum type.", "kind": "problem", "name": "The pointer arguments to the Standard Library function memcmp shall point to either a pointer type,", "precision": "very-high", "severity": "error", - "short_name": "PointerArgumentsToTheStandardLibraryFunctionMemcmpShallPointToEitherAPointerTypeAnEssentiallySignedTypeAnEssentiallyUnsignedTypeAnEssentiallyBooleanTypeOrAnEssentiallyEnumType", + "short_name": "MemcmpArgNotPtsToSignedUnsignedBooleanEnumEssType", "tags": [] } ], - "title": "The pointer arguments to the Standard Library function memcmp shall point to either a pointer type, an essentially signed type, an essentially unsigned type, an essentially Boolean type or an essentially enum type" + "title": "The pointer arguments to the Standard Library function memcmp shall point to either a pointer type, an essentially signed type, an essentially unsigned type, an essentially Boolean type or an essentially enum type." }, "RULE-6-1": { "properties": { @@ -501,16 +501,16 @@ }, "queries": [ { - "description": "A string literal shall not be assigned to an object unless the object\ufffds type is \ufffdpointer to const-qualified char\ufffd", + "description": "A string literal shall not be assigned to an object unless the object's type is 'pointer to const-qualified char'.", "kind": "problem", - "name": "A string literal shall not be assigned to an object unless the object\ufffds type is \ufffdpointer to", + "name": "A string literal shall not be assigned to an object unless the object's type is 'pointer to", "precision": "very-high", "severity": "error", - "short_name": "StringLiteralAssignedToAnObjectUnlessTheObjectsTypeIsPointerToConstQualifiedChar", + "short_name": "StringLiteralAssignedToObjPtrToConstQualifiedChar", "tags": [] } ], - "title": "A string literal shall not be assigned to an object unless the object\ufffds type is \ufffdpointer to const-qualified char\ufffd" + "title": "A string literal shall not be assigned to an object unless the object's type is 'pointer to const-qualified char'" } } } From 82dadd9324fce9511abcb387c1527e6ada0fc7dc Mon Sep 17 00:00:00 2001 From: Jeongsoo Lee Date: Wed, 25 Jan 2023 12:37:10 -0800 Subject: [PATCH 04/23] generate rule package files for c/Types.json --- ...tectDomainAndRangeErrorsInMathFunctions.md | 18 + ...tectDomainAndRangeErrorsInMathFunctions.ql | 18 + ...PointConversionsNotWithinRangeOfNewType.md | 16 + ...PointConversionsNotWithinRangeOfNewType.ql | 18 + ...atingPointOfIntegralValuesLosePrecision.md | 16 + ...atingPointOfIntegralValuesLosePrecision.ql | 18 + ...ReprUsedForComparingFloatingPointValues.md | 16 + ...ReprUsedForComparingFloatingPointValues.ql | 18 + ...eThatUnsignedIntegerOperationsDoNotWrap.md | 16 + ...eThatUnsignedIntegerOperationsDoNotWrap.ql | 18 + ...onversionCausesLostOrMisinterpretedData.md | 16 + ...onversionCausesLostOrMisinterpretedData.ql | 18 + ...ationsOnSignedIntegersResultsInOverflow.md | 16 + ...ationsOnSignedIntegersResultsInOverflow.ql | 18 + .../DivAndModOperationResultsInDivByZero.md | 16 + .../DivAndModOperationResultsInDivByZero.ql | 18 + ...iftedByNegativeBitsOrGreaterThanOperand.md | 16 + ...iftedByNegativeBitsOrGreaterThanOperand.ql | 19 + .../INT35-C/UseCorrectIntegerPrecisions.md | 16 + .../INT35-C/UseCorrectIntegerPrecisions.ql | 18 + ...tingAPointerToIntegerOrIntegerToPointer.md | 16 + ...tingAPointerToIntegerOrIntegerToPointer.ql | 18 + ...mainAndRangeErrorsInMathFunctions.expected | 1 + ...tDomainAndRangeErrorsInMathFunctions.qlref | 1 + ...onversionsNotWithinRangeOfNewType.expected | 1 + ...ntConversionsNotWithinRangeOfNewType.qlref | 1 + ...ointOfIntegralValuesLosePrecision.expected | 1 + ...ngPointOfIntegralValuesLosePrecision.qlref | 1 + ...edForComparingFloatingPointValues.expected | 1 + ...rUsedForComparingFloatingPointValues.qlref | 1 + ...nsignedIntegerOperationsDoNotWrap.expected | 1 + ...atUnsignedIntegerOperationsDoNotWrap.qlref | 1 + ...ionCausesLostOrMisinterpretedData.expected | 1 + ...ersionCausesLostOrMisinterpretedData.qlref | 1 + ...OnSignedIntegersResultsInOverflow.expected | 1 + ...onsOnSignedIntegersResultsInOverflow.qlref | 1 + ...AndModOperationResultsInDivByZero.expected | 1 + ...DivAndModOperationResultsInDivByZero.qlref | 1 + ...yNegativeBitsOrGreaterThanOperand.expected | 1 + ...edByNegativeBitsOrGreaterThanOperand.qlref | 1 + .../UseCorrectIntegerPrecisions.expected | 1 + .../INT35-C/UseCorrectIntegerPrecisions.qlref | 1 + ...ointerToIntegerOrIntegerToPointer.expected | 1 + ...gAPointerToIntegerOrIntegerToPointer.qlref | 1 + ...defsNotUsedInPlaceOfBasicNumericalTypes.ql | 18 + .../OperandsOfAnInappropriateEssentialType.ql | 18 + .../RULE-10-2/CharTypeExprsUsedInAddOrSub.ql | 19 + .../AssignmentToIncompatibleEssentialType.ql | 19 + ...rsionOperandHasDifferentEssTypeCategory.ql | 19 + .../ValueCastToInappropriateEssentialType.ql | 18 + ...eExprValueAssignedToObjWithWiderEssType.ql | 18 + ...CompExprOperandHasWiderEssTypeThanOther.ql | 20 + .../CompExprValCastToIncompatEssType.ql | 19 + ...onstExprEvalCausesUnsignedIntWraparound.ql | 18 + .../ArrayTypeParamAtSizeofOperand.ql | 19 + .../LoopCounterHaveEssentiallyFloatingType.ql | 18 + ...typeFuncNeitherReprAsUnsignedCharNorEOF.ql | 19 + ...emcmpUsedToCompareNullTerminatedStrings.ql | 18 + ...MemmoveMemcmpArgNotPointerToCompatTypes.ql | 19 + ...otPtsToSignedUnsignedBooleanEnumEssType.ql | 20 + ...hallOnlyBeDeclaredWithAnAppropriateType.ql | 19 + .../SingleBitNamedBitFieldsOfASignedType.ql | 19 + ...ralAssignedToObjPtrToConstQualifiedChar.ql | 19 + ...tUsedInPlaceOfBasicNumericalTypes.expected | 1 + ...sNotUsedInPlaceOfBasicNumericalTypes.qlref | 1 + ...ndsOfAnInappropriateEssentialType.expected | 1 + ...erandsOfAnInappropriateEssentialType.qlref | 1 + .../CharTypeExprsUsedInAddOrSub.expected | 1 + .../CharTypeExprsUsedInAddOrSub.qlref | 1 + ...gnmentToIncompatibleEssentialType.expected | 1 + ...ssignmentToIncompatibleEssentialType.qlref | 1 + ...perandHasDifferentEssTypeCategory.expected | 1 + ...onOperandHasDifferentEssTypeCategory.qlref | 1 + ...eCastToInappropriateEssentialType.expected | 1 + ...alueCastToInappropriateEssentialType.qlref | 1 + ...alueAssignedToObjWithWiderEssType.expected | 1 + ...prValueAssignedToObjWithWiderEssType.qlref | 1 + ...prOperandHasWiderEssTypeThanOther.expected | 1 + ...pExprOperandHasWiderEssTypeThanOther.qlref | 1 + .../CompExprValCastToIncompatEssType.expected | 1 + .../CompExprValCastToIncompatEssType.qlref | 1 + ...prEvalCausesUnsignedIntWraparound.expected | 1 + ...tExprEvalCausesUnsignedIntWraparound.qlref | 1 + .../ArrayTypeParamAtSizeofOperand.expected | 1 + .../ArrayTypeParamAtSizeofOperand.qlref | 1 + ...ounterHaveEssentiallyFloatingType.expected | 1 + ...opCounterHaveEssentiallyFloatingType.qlref | 1 + ...ncNeitherReprAsUnsignedCharNorEOF.expected | 1 + ...eFuncNeitherReprAsUnsignedCharNorEOF.qlref | 1 + ...sedToCompareNullTerminatedStrings.expected | 1 + ...mpUsedToCompareNullTerminatedStrings.qlref | 1 + ...eMemcmpArgNotPointerToCompatTypes.expected | 1 + ...moveMemcmpArgNotPointerToCompatTypes.qlref | 1 + ...oSignedUnsignedBooleanEnumEssType.expected | 1 + ...tsToSignedUnsignedBooleanEnumEssType.qlref | 1 + ...lyBeDeclaredWithAnAppropriateType.expected | 1 + ...lOnlyBeDeclaredWithAnAppropriateType.qlref | 1 + ...gleBitNamedBitFieldsOfASignedType.expected | 1 + ...SingleBitNamedBitFieldsOfASignedType.qlref | 1 + ...ignedToObjPtrToConstQualifiedChar.expected | 1 + ...AssignedToObjPtrToConstQualifiedChar.qlref | 1 + .../cpp/exclusions/c/RuleMetadata.qll | 7 +- .../cpp/exclusions/c/Types.qll | 520 ++++++++++++++++++ 103 files changed, 1318 insertions(+), 2 deletions(-) create mode 100644 c/cert/src/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.md create mode 100644 c/cert/src/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.ql create mode 100644 c/cert/src/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.md create mode 100644 c/cert/src/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.ql create mode 100644 c/cert/src/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.md create mode 100644 c/cert/src/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.ql create mode 100644 c/cert/src/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.md create mode 100644 c/cert/src/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.ql create mode 100644 c/cert/src/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.md create mode 100644 c/cert/src/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.ql create mode 100644 c/cert/src/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.md create mode 100644 c/cert/src/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.ql create mode 100644 c/cert/src/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.md create mode 100644 c/cert/src/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.ql create mode 100644 c/cert/src/rules/INT33-C/DivAndModOperationResultsInDivByZero.md create mode 100644 c/cert/src/rules/INT33-C/DivAndModOperationResultsInDivByZero.ql create mode 100644 c/cert/src/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.md create mode 100644 c/cert/src/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.ql create mode 100644 c/cert/src/rules/INT35-C/UseCorrectIntegerPrecisions.md create mode 100644 c/cert/src/rules/INT35-C/UseCorrectIntegerPrecisions.ql create mode 100644 c/cert/src/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.md create mode 100644 c/cert/src/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.ql create mode 100644 c/cert/test/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.expected create mode 100644 c/cert/test/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.qlref create mode 100644 c/cert/test/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.expected create mode 100644 c/cert/test/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.qlref create mode 100644 c/cert/test/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.expected create mode 100644 c/cert/test/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.qlref create mode 100644 c/cert/test/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.expected create mode 100644 c/cert/test/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.qlref create mode 100644 c/cert/test/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.expected create mode 100644 c/cert/test/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.qlref create mode 100644 c/cert/test/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.expected create mode 100644 c/cert/test/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.qlref create mode 100644 c/cert/test/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.expected create mode 100644 c/cert/test/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.qlref create mode 100644 c/cert/test/rules/INT33-C/DivAndModOperationResultsInDivByZero.expected create mode 100644 c/cert/test/rules/INT33-C/DivAndModOperationResultsInDivByZero.qlref create mode 100644 c/cert/test/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.expected create mode 100644 c/cert/test/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.qlref create mode 100644 c/cert/test/rules/INT35-C/UseCorrectIntegerPrecisions.expected create mode 100644 c/cert/test/rules/INT35-C/UseCorrectIntegerPrecisions.qlref create mode 100644 c/cert/test/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.expected create mode 100644 c/cert/test/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.qlref create mode 100644 c/misra/src/rules/DIR-4-6/NumericTypedefsNotUsedInPlaceOfBasicNumericalTypes.ql create mode 100644 c/misra/src/rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.ql create mode 100644 c/misra/src/rules/RULE-10-2/CharTypeExprsUsedInAddOrSub.ql create mode 100644 c/misra/src/rules/RULE-10-3/AssignmentToIncompatibleEssentialType.ql create mode 100644 c/misra/src/rules/RULE-10-4/ArithConversionOperandHasDifferentEssTypeCategory.ql create mode 100644 c/misra/src/rules/RULE-10-5/ValueCastToInappropriateEssentialType.ql create mode 100644 c/misra/src/rules/RULE-10-6/CompositeExprValueAssignedToObjWithWiderEssType.ql create mode 100644 c/misra/src/rules/RULE-10-7/ConvertedCompExprOperandHasWiderEssTypeThanOther.ql create mode 100644 c/misra/src/rules/RULE-10-8/CompExprValCastToIncompatEssType.ql create mode 100644 c/misra/src/rules/RULE-12-4/ConstExprEvalCausesUnsignedIntWraparound.ql create mode 100644 c/misra/src/rules/RULE-12-5/ArrayTypeParamAtSizeofOperand.ql create mode 100644 c/misra/src/rules/RULE-14-1/LoopCounterHaveEssentiallyFloatingType.ql create mode 100644 c/misra/src/rules/RULE-21-13/CtypeFuncNeitherReprAsUnsignedCharNorEOF.ql create mode 100644 c/misra/src/rules/RULE-21-14/MemcmpUsedToCompareNullTerminatedStrings.ql create mode 100644 c/misra/src/rules/RULE-21-15/MemcpyMemmoveMemcmpArgNotPointerToCompatTypes.ql create mode 100644 c/misra/src/rules/RULE-21-16/MemcmpArgNotPtsToSignedUnsignedBooleanEnumEssType.ql create mode 100644 c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql create mode 100644 c/misra/src/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql create mode 100644 c/misra/src/rules/RULE-7-4/StringLiteralAssignedToObjPtrToConstQualifiedChar.ql create mode 100644 c/misra/test/rules/DIR-4-6/NumericTypedefsNotUsedInPlaceOfBasicNumericalTypes.expected create mode 100644 c/misra/test/rules/DIR-4-6/NumericTypedefsNotUsedInPlaceOfBasicNumericalTypes.qlref create mode 100644 c/misra/test/rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.expected create mode 100644 c/misra/test/rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.qlref create mode 100644 c/misra/test/rules/RULE-10-2/CharTypeExprsUsedInAddOrSub.expected create mode 100644 c/misra/test/rules/RULE-10-2/CharTypeExprsUsedInAddOrSub.qlref create mode 100644 c/misra/test/rules/RULE-10-3/AssignmentToIncompatibleEssentialType.expected create mode 100644 c/misra/test/rules/RULE-10-3/AssignmentToIncompatibleEssentialType.qlref create mode 100644 c/misra/test/rules/RULE-10-4/ArithConversionOperandHasDifferentEssTypeCategory.expected create mode 100644 c/misra/test/rules/RULE-10-4/ArithConversionOperandHasDifferentEssTypeCategory.qlref create mode 100644 c/misra/test/rules/RULE-10-5/ValueCastToInappropriateEssentialType.expected create mode 100644 c/misra/test/rules/RULE-10-5/ValueCastToInappropriateEssentialType.qlref create mode 100644 c/misra/test/rules/RULE-10-6/CompositeExprValueAssignedToObjWithWiderEssType.expected create mode 100644 c/misra/test/rules/RULE-10-6/CompositeExprValueAssignedToObjWithWiderEssType.qlref create mode 100644 c/misra/test/rules/RULE-10-7/ConvertedCompExprOperandHasWiderEssTypeThanOther.expected create mode 100644 c/misra/test/rules/RULE-10-7/ConvertedCompExprOperandHasWiderEssTypeThanOther.qlref create mode 100644 c/misra/test/rules/RULE-10-8/CompExprValCastToIncompatEssType.expected create mode 100644 c/misra/test/rules/RULE-10-8/CompExprValCastToIncompatEssType.qlref create mode 100644 c/misra/test/rules/RULE-12-4/ConstExprEvalCausesUnsignedIntWraparound.expected create mode 100644 c/misra/test/rules/RULE-12-4/ConstExprEvalCausesUnsignedIntWraparound.qlref create mode 100644 c/misra/test/rules/RULE-12-5/ArrayTypeParamAtSizeofOperand.expected create mode 100644 c/misra/test/rules/RULE-12-5/ArrayTypeParamAtSizeofOperand.qlref create mode 100644 c/misra/test/rules/RULE-14-1/LoopCounterHaveEssentiallyFloatingType.expected create mode 100644 c/misra/test/rules/RULE-14-1/LoopCounterHaveEssentiallyFloatingType.qlref create mode 100644 c/misra/test/rules/RULE-21-13/CtypeFuncNeitherReprAsUnsignedCharNorEOF.expected create mode 100644 c/misra/test/rules/RULE-21-13/CtypeFuncNeitherReprAsUnsignedCharNorEOF.qlref create mode 100644 c/misra/test/rules/RULE-21-14/MemcmpUsedToCompareNullTerminatedStrings.expected create mode 100644 c/misra/test/rules/RULE-21-14/MemcmpUsedToCompareNullTerminatedStrings.qlref create mode 100644 c/misra/test/rules/RULE-21-15/MemcpyMemmoveMemcmpArgNotPointerToCompatTypes.expected create mode 100644 c/misra/test/rules/RULE-21-15/MemcpyMemmoveMemcmpArgNotPointerToCompatTypes.qlref create mode 100644 c/misra/test/rules/RULE-21-16/MemcmpArgNotPtsToSignedUnsignedBooleanEnumEssType.expected create mode 100644 c/misra/test/rules/RULE-21-16/MemcmpArgNotPtsToSignedUnsignedBooleanEnumEssType.qlref create mode 100644 c/misra/test/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.expected create mode 100644 c/misra/test/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.qlref create mode 100644 c/misra/test/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.expected create mode 100644 c/misra/test/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.qlref create mode 100644 c/misra/test/rules/RULE-7-4/StringLiteralAssignedToObjPtrToConstQualifiedChar.expected create mode 100644 c/misra/test/rules/RULE-7-4/StringLiteralAssignedToObjPtrToConstQualifiedChar.qlref create mode 100644 cpp/common/src/codingstandards/cpp/exclusions/c/Types.qll diff --git a/c/cert/src/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.md b/c/cert/src/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.md new file mode 100644 index 0000000000..4083d3f36b --- /dev/null +++ b/c/cert/src/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.md @@ -0,0 +1,18 @@ +# FLP32-C: Prevent or detect domain and range errors in math functions + +This query implements the CERT-C rule FLP32-C: + +> Prevent or detect domain and range errors in math functions + + +## CERT + +** REPLACE THIS BY RUNNING THE SCRIPT `scripts/help/cert-help-extraction.py` ** + +## Implementation notes + +None + +## References + +* CERT-C: [FLP32-C: Prevent or detect domain and range errors in math functions](https://wiki.sei.cmu.edu/confluence/display/c) diff --git a/c/cert/src/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.ql b/c/cert/src/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.ql new file mode 100644 index 0000000000..5b86641326 --- /dev/null +++ b/c/cert/src/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.ql @@ -0,0 +1,18 @@ +/** + * @id c/cert/prevent-or-detect-domain-and-range-errors-in-math-functions + * @name FLP32-C: Prevent or detect domain and range errors in math functions + * @description TODO. + * @kind problem + * @precision very-high + * @problem.severity error + * @tags external/cert/id/flp32-c + * external/cert/obligation/rule + */ + +import cpp +import codingstandards.c.cert + +from +where + not isExcluded(x, TypesPackage::preventOrDetectDomainAndRangeErrorsInMathFunctionsQuery()) and +select diff --git a/c/cert/src/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.md b/c/cert/src/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.md new file mode 100644 index 0000000000..8b22986f7d --- /dev/null +++ b/c/cert/src/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.md @@ -0,0 +1,16 @@ +# FLP34-C: Ensure that floating-point conversions are within range of the new type + +This query implements the CERT-C rule FLP34-C: + +> Ensure that floating-point conversions are within range of the new type +## CERT + +** REPLACE THIS BY RUNNING THE SCRIPT `scripts/help/cert-help-extraction.py` ** + +## Implementation notes + +None + +## References + +* CERT-C: [FLP34-C: Ensure that floating-point conversions are within range of the new type](https://wiki.sei.cmu.edu/confluence/display/c) diff --git a/c/cert/src/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.ql b/c/cert/src/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.ql new file mode 100644 index 0000000000..fe7a1b581a --- /dev/null +++ b/c/cert/src/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.ql @@ -0,0 +1,18 @@ +/** + * @id c/cert/floating-point-conversions-not-within-range-of-new-type + * @name FLP34-C: Ensure that floating-point conversions are within range of the new type + * @description TODO. + * @kind problem + * @precision very-high + * @problem.severity error + * @tags external/cert/id/flp34-c + * external/cert/obligation/rule + */ + +import cpp +import codingstandards.c.cert + +from +where + not isExcluded(x, TypesPackage::floatingPointConversionsNotWithinRangeOfNewTypeQuery()) and +select diff --git a/c/cert/src/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.md b/c/cert/src/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.md new file mode 100644 index 0000000000..bac78b4ddd --- /dev/null +++ b/c/cert/src/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.md @@ -0,0 +1,16 @@ +# FLP36-C: Preserve precision when converting integral values to floating-point type + +This query implements the CERT-C rule FLP36-C: + +> Preserve precision when converting integral values to floating-point type +## CERT + +** REPLACE THIS BY RUNNING THE SCRIPT `scripts/help/cert-help-extraction.py` ** + +## Implementation notes + +None + +## References + +* CERT-C: [FLP36-C: Preserve precision when converting integral values to floating-point type](https://wiki.sei.cmu.edu/confluence/display/c) diff --git a/c/cert/src/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.ql b/c/cert/src/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.ql new file mode 100644 index 0000000000..6d61c6aff7 --- /dev/null +++ b/c/cert/src/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.ql @@ -0,0 +1,18 @@ +/** + * @id c/cert/floating-point-of-integral-values-lose-precision + * @name FLP36-C: Preserve precision when converting integral values to floating-point type + * @description TODO. + * @kind problem + * @precision very-high + * @problem.severity error + * @tags external/cert/id/flp36-c + * external/cert/obligation/rule + */ + +import cpp +import codingstandards.c.cert + +from +where + not isExcluded(x, TypesPackage::floatingPointOfIntegralValuesLosePrecisionQuery()) and +select diff --git a/c/cert/src/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.md b/c/cert/src/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.md new file mode 100644 index 0000000000..8b738b87cd --- /dev/null +++ b/c/cert/src/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.md @@ -0,0 +1,16 @@ +# FLP37-C: Do not use object representations to compare floating-point values + +This query implements the CERT-C rule FLP37-C: + +> Do not use object representations to compare floating-point values +## CERT + +** REPLACE THIS BY RUNNING THE SCRIPT `scripts/help/cert-help-extraction.py` ** + +## Implementation notes + +None + +## References + +* CERT-C: [FLP37-C: Do not use object representations to compare floating-point values](https://wiki.sei.cmu.edu/confluence/display/c) diff --git a/c/cert/src/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.ql b/c/cert/src/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.ql new file mode 100644 index 0000000000..24fdd70dc4 --- /dev/null +++ b/c/cert/src/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.ql @@ -0,0 +1,18 @@ +/** + * @id c/cert/object-repr-used-for-comparing-floating-point-values + * @name FLP37-C: Do not use object representations to compare floating-point values + * @description TODO. + * @kind problem + * @precision very-high + * @problem.severity error + * @tags external/cert/id/flp37-c + * external/cert/obligation/rule + */ + +import cpp +import codingstandards.c.cert + +from +where + not isExcluded(x, TypesPackage::objectReprUsedForComparingFloatingPointValuesQuery()) and +select diff --git a/c/cert/src/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.md b/c/cert/src/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.md new file mode 100644 index 0000000000..402fd7f64a --- /dev/null +++ b/c/cert/src/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.md @@ -0,0 +1,16 @@ +# INT30-C: Ensure that unsigned integer operations do not wrap + +This query implements the CERT-C rule INT30-C: + +> Ensure that unsigned integer operations do not wrap +## CERT + +** REPLACE THIS BY RUNNING THE SCRIPT `scripts/help/cert-help-extraction.py` ** + +## Implementation notes + +None + +## References + +* CERT-C: [INT30-C: Ensure that unsigned integer operations do not wrap](https://wiki.sei.cmu.edu/confluence/display/c) diff --git a/c/cert/src/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.ql b/c/cert/src/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.ql new file mode 100644 index 0000000000..c6901a73b1 --- /dev/null +++ b/c/cert/src/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.ql @@ -0,0 +1,18 @@ +/** + * @id c/cert/ensure-that-unsigned-integer-operations-do-not-wrap + * @name INT30-C: Ensure that unsigned integer operations do not wrap + * @description TODO. + * @kind problem + * @precision high + * @problem.severity error + * @tags external/cert/id/int30-c + * external/cert/obligation/rule + */ + +import cpp +import codingstandards.c.cert + +from +where + not isExcluded(x, TypesPackage::ensureThatUnsignedIntegerOperationsDoNotWrapQuery()) and +select diff --git a/c/cert/src/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.md b/c/cert/src/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.md new file mode 100644 index 0000000000..3c475e4a77 --- /dev/null +++ b/c/cert/src/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.md @@ -0,0 +1,16 @@ +# INT31-C: Ensure that integer conversions do not result in lost or misinterpreted data + +This query implements the CERT-C rule INT31-C: + +> Ensure that integer conversions do not result in lost or misinterpreted data +## CERT + +** REPLACE THIS BY RUNNING THE SCRIPT `scripts/help/cert-help-extraction.py` ** + +## Implementation notes + +None + +## References + +* CERT-C: [INT31-C: Ensure that integer conversions do not result in lost or misinterpreted data](https://wiki.sei.cmu.edu/confluence/display/c) diff --git a/c/cert/src/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.ql b/c/cert/src/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.ql new file mode 100644 index 0000000000..0e994c017f --- /dev/null +++ b/c/cert/src/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.ql @@ -0,0 +1,18 @@ +/** + * @id c/cert/int-conversion-causes-lost-or-misinterpreted-data + * @name INT31-C: Ensure that integer conversions do not result in lost or misinterpreted data + * @description TODO. + * @kind problem + * @precision high + * @problem.severity error + * @tags external/cert/id/int31-c + * external/cert/obligation/rule + */ + +import cpp +import codingstandards.c.cert + +from +where + not isExcluded(x, TypesPackage::intConversionCausesLostOrMisinterpretedDataQuery()) and +select diff --git a/c/cert/src/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.md b/c/cert/src/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.md new file mode 100644 index 0000000000..84dc8fe143 --- /dev/null +++ b/c/cert/src/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.md @@ -0,0 +1,16 @@ +# INT32-C: Ensure that operations on signed integers do not result in overflow + +This query implements the CERT-C rule INT32-C: + +> Ensure that operations on signed integers do not result in overflow +## CERT + +** REPLACE THIS BY RUNNING THE SCRIPT `scripts/help/cert-help-extraction.py` ** + +## Implementation notes + +None + +## References + +* CERT-C: [INT32-C: Ensure that operations on signed integers do not result in overflow](https://wiki.sei.cmu.edu/confluence/display/c) diff --git a/c/cert/src/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.ql b/c/cert/src/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.ql new file mode 100644 index 0000000000..2495050987 --- /dev/null +++ b/c/cert/src/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.ql @@ -0,0 +1,18 @@ +/** + * @id c/cert/operations-on-signed-integers-results-in-overflow + * @name INT32-C: Ensure that operations on signed integers do not result in overflow + * @description TODO. + * @kind problem + * @precision high + * @problem.severity error + * @tags external/cert/id/int32-c + * external/cert/obligation/rule + */ + +import cpp +import codingstandards.c.cert + +from +where + not isExcluded(x, TypesPackage::operationsOnSignedIntegersResultsInOverflowQuery()) and +select diff --git a/c/cert/src/rules/INT33-C/DivAndModOperationResultsInDivByZero.md b/c/cert/src/rules/INT33-C/DivAndModOperationResultsInDivByZero.md new file mode 100644 index 0000000000..6a86d3e88d --- /dev/null +++ b/c/cert/src/rules/INT33-C/DivAndModOperationResultsInDivByZero.md @@ -0,0 +1,16 @@ +# INT33-C: Ensure that division and remainder operations do not result in divide-by-zero errors + +This query implements the CERT-C rule INT33-C: + +> Ensure that division and remainder operations do not result in divide-by-zero errors +## CERT + +** REPLACE THIS BY RUNNING THE SCRIPT `scripts/help/cert-help-extraction.py` ** + +## Implementation notes + +None + +## References + +* CERT-C: [INT33-C: Ensure that division and remainder operations do not result in divide-by-zero errors](https://wiki.sei.cmu.edu/confluence/display/c) diff --git a/c/cert/src/rules/INT33-C/DivAndModOperationResultsInDivByZero.ql b/c/cert/src/rules/INT33-C/DivAndModOperationResultsInDivByZero.ql new file mode 100644 index 0000000000..4385d79f2e --- /dev/null +++ b/c/cert/src/rules/INT33-C/DivAndModOperationResultsInDivByZero.ql @@ -0,0 +1,18 @@ +/** + * @id c/cert/div-and-mod-operation-results-in-div-by-zero + * @name INT33-C: Ensure that division and remainder operations do not result in divide-by-zero errors + * @description TODO. + * @kind problem + * @precision high + * @problem.severity error + * @tags external/cert/id/int33-c + * external/cert/obligation/rule + */ + +import cpp +import codingstandards.c.cert + +from +where + not isExcluded(x, TypesPackage::divAndModOperationResultsInDivByZeroQuery()) and +select diff --git a/c/cert/src/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.md b/c/cert/src/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.md new file mode 100644 index 0000000000..66c3d5a7a0 --- /dev/null +++ b/c/cert/src/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.md @@ -0,0 +1,16 @@ +# INT34-C: Do not shift an expression by a negative number of bits or by greater than or equal to the number of + +This query implements the CERT-C rule INT34-C: + +> Do not shift an expression by a negative number of bits or by greater than or equal to the number of bits that exist in the operand +## CERT + +** REPLACE THIS BY RUNNING THE SCRIPT `scripts/help/cert-help-extraction.py` ** + +## Implementation notes + +None + +## References + +* CERT-C: [INT34-C: Do not shift an expression by a negative number of bits or by greater than or equal to the number of bits that exist in the operand](https://wiki.sei.cmu.edu/confluence/display/c) diff --git a/c/cert/src/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.ql b/c/cert/src/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.ql new file mode 100644 index 0000000000..f7a0759b6c --- /dev/null +++ b/c/cert/src/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.ql @@ -0,0 +1,19 @@ +/** + * @id c/cert/expr-shifted-by-negative-bits-or-greater-than-operand + * @name INT34-C: Do not shift an expression by a negative number of bits or by greater than or equal to the number of + * @description Do not shift an expression by a negative number of bits or by greater than or equal + * to the number of bits that exist in the operand. + * @kind problem + * @precision very-high + * @problem.severity error + * @tags external/cert/id/int34-c + * external/cert/obligation/rule + */ + +import cpp +import codingstandards.c.cert + +from +where + not isExcluded(x, TypesPackage::exprShiftedByNegativeBitsOrGreaterThanOperandQuery()) and +select diff --git a/c/cert/src/rules/INT35-C/UseCorrectIntegerPrecisions.md b/c/cert/src/rules/INT35-C/UseCorrectIntegerPrecisions.md new file mode 100644 index 0000000000..aaf89abe74 --- /dev/null +++ b/c/cert/src/rules/INT35-C/UseCorrectIntegerPrecisions.md @@ -0,0 +1,16 @@ +# INT35-C: Use correct integer precisions + +This query implements the CERT-C rule INT35-C: + +> Use correct integer precisions +## CERT + +** REPLACE THIS BY RUNNING THE SCRIPT `scripts/help/cert-help-extraction.py` ** + +## Implementation notes + +None + +## References + +* CERT-C: [INT35-C: Use correct integer precisions](https://wiki.sei.cmu.edu/confluence/display/c) diff --git a/c/cert/src/rules/INT35-C/UseCorrectIntegerPrecisions.ql b/c/cert/src/rules/INT35-C/UseCorrectIntegerPrecisions.ql new file mode 100644 index 0000000000..41c25374e1 --- /dev/null +++ b/c/cert/src/rules/INT35-C/UseCorrectIntegerPrecisions.ql @@ -0,0 +1,18 @@ +/** + * @id c/cert/use-correct-integer-precisions + * @name INT35-C: Use correct integer precisions + * @description TODO. + * @kind problem + * @precision high + * @problem.severity error + * @tags external/cert/id/int35-c + * external/cert/obligation/rule + */ + +import cpp +import codingstandards.c.cert + +from +where + not isExcluded(x, TypesPackage::useCorrectIntegerPrecisionsQuery()) and +select diff --git a/c/cert/src/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.md b/c/cert/src/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.md new file mode 100644 index 0000000000..6df9d2afff --- /dev/null +++ b/c/cert/src/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.md @@ -0,0 +1,16 @@ +# INT36-C: Converting a pointer to integer or integer to pointer + +This query implements the CERT-C rule INT36-C: + +> Converting a pointer to integer or integer to pointer +## CERT + +** REPLACE THIS BY RUNNING THE SCRIPT `scripts/help/cert-help-extraction.py` ** + +## Implementation notes + +None + +## References + +* CERT-C: [INT36-C: Converting a pointer to integer or integer to pointer](https://wiki.sei.cmu.edu/confluence/display/c) diff --git a/c/cert/src/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.ql b/c/cert/src/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.ql new file mode 100644 index 0000000000..8fc0096b6e --- /dev/null +++ b/c/cert/src/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.ql @@ -0,0 +1,18 @@ +/** + * @id c/cert/converting-a-pointer-to-integer-or-integer-to-pointer + * @name INT36-C: Converting a pointer to integer or integer to pointer + * @description TODO. + * @kind problem + * @precision very-high + * @problem.severity error + * @tags external/cert/id/int36-c + * external/cert/obligation/rule + */ + +import cpp +import codingstandards.c.cert + +from +where + not isExcluded(x, TypesPackage::convertingAPointerToIntegerOrIntegerToPointerQuery()) and +select diff --git a/c/cert/test/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.expected b/c/cert/test/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.expected new file mode 100644 index 0000000000..2ec1a0ac6c --- /dev/null +++ b/c/cert/test/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/c/cert/test/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.qlref b/c/cert/test/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.qlref new file mode 100644 index 0000000000..7cd938b44b --- /dev/null +++ b/c/cert/test/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.qlref @@ -0,0 +1 @@ +rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.ql \ No newline at end of file diff --git a/c/cert/test/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.expected b/c/cert/test/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.expected new file mode 100644 index 0000000000..2ec1a0ac6c --- /dev/null +++ b/c/cert/test/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/c/cert/test/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.qlref b/c/cert/test/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.qlref new file mode 100644 index 0000000000..fba8b90bf0 --- /dev/null +++ b/c/cert/test/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.qlref @@ -0,0 +1 @@ +rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.ql \ No newline at end of file diff --git a/c/cert/test/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.expected b/c/cert/test/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.expected new file mode 100644 index 0000000000..2ec1a0ac6c --- /dev/null +++ b/c/cert/test/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/c/cert/test/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.qlref b/c/cert/test/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.qlref new file mode 100644 index 0000000000..7500c056d2 --- /dev/null +++ b/c/cert/test/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.qlref @@ -0,0 +1 @@ +rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.ql \ No newline at end of file diff --git a/c/cert/test/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.expected b/c/cert/test/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.expected new file mode 100644 index 0000000000..2ec1a0ac6c --- /dev/null +++ b/c/cert/test/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/c/cert/test/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.qlref b/c/cert/test/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.qlref new file mode 100644 index 0000000000..6c9287e855 --- /dev/null +++ b/c/cert/test/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.qlref @@ -0,0 +1 @@ +rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.ql \ No newline at end of file diff --git a/c/cert/test/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.expected b/c/cert/test/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.expected new file mode 100644 index 0000000000..2ec1a0ac6c --- /dev/null +++ b/c/cert/test/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/c/cert/test/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.qlref b/c/cert/test/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.qlref new file mode 100644 index 0000000000..c6dde9ace2 --- /dev/null +++ b/c/cert/test/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.qlref @@ -0,0 +1 @@ +rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.ql \ No newline at end of file diff --git a/c/cert/test/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.expected b/c/cert/test/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.expected new file mode 100644 index 0000000000..2ec1a0ac6c --- /dev/null +++ b/c/cert/test/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/c/cert/test/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.qlref b/c/cert/test/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.qlref new file mode 100644 index 0000000000..b95535183b --- /dev/null +++ b/c/cert/test/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.qlref @@ -0,0 +1 @@ +rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.ql \ No newline at end of file diff --git a/c/cert/test/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.expected b/c/cert/test/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.expected new file mode 100644 index 0000000000..2ec1a0ac6c --- /dev/null +++ b/c/cert/test/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/c/cert/test/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.qlref b/c/cert/test/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.qlref new file mode 100644 index 0000000000..91ae574c44 --- /dev/null +++ b/c/cert/test/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.qlref @@ -0,0 +1 @@ +rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.ql \ No newline at end of file diff --git a/c/cert/test/rules/INT33-C/DivAndModOperationResultsInDivByZero.expected b/c/cert/test/rules/INT33-C/DivAndModOperationResultsInDivByZero.expected new file mode 100644 index 0000000000..2ec1a0ac6c --- /dev/null +++ b/c/cert/test/rules/INT33-C/DivAndModOperationResultsInDivByZero.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/c/cert/test/rules/INT33-C/DivAndModOperationResultsInDivByZero.qlref b/c/cert/test/rules/INT33-C/DivAndModOperationResultsInDivByZero.qlref new file mode 100644 index 0000000000..529fa9a43a --- /dev/null +++ b/c/cert/test/rules/INT33-C/DivAndModOperationResultsInDivByZero.qlref @@ -0,0 +1 @@ +rules/INT33-C/DivAndModOperationResultsInDivByZero.ql \ No newline at end of file diff --git a/c/cert/test/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.expected b/c/cert/test/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.expected new file mode 100644 index 0000000000..2ec1a0ac6c --- /dev/null +++ b/c/cert/test/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/c/cert/test/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.qlref b/c/cert/test/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.qlref new file mode 100644 index 0000000000..b5349c3054 --- /dev/null +++ b/c/cert/test/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.qlref @@ -0,0 +1 @@ +rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.ql \ No newline at end of file diff --git a/c/cert/test/rules/INT35-C/UseCorrectIntegerPrecisions.expected b/c/cert/test/rules/INT35-C/UseCorrectIntegerPrecisions.expected new file mode 100644 index 0000000000..2ec1a0ac6c --- /dev/null +++ b/c/cert/test/rules/INT35-C/UseCorrectIntegerPrecisions.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/c/cert/test/rules/INT35-C/UseCorrectIntegerPrecisions.qlref b/c/cert/test/rules/INT35-C/UseCorrectIntegerPrecisions.qlref new file mode 100644 index 0000000000..c408baf78d --- /dev/null +++ b/c/cert/test/rules/INT35-C/UseCorrectIntegerPrecisions.qlref @@ -0,0 +1 @@ +rules/INT35-C/UseCorrectIntegerPrecisions.ql \ No newline at end of file diff --git a/c/cert/test/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.expected b/c/cert/test/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.expected new file mode 100644 index 0000000000..2ec1a0ac6c --- /dev/null +++ b/c/cert/test/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/c/cert/test/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.qlref b/c/cert/test/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.qlref new file mode 100644 index 0000000000..70ae157f74 --- /dev/null +++ b/c/cert/test/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.qlref @@ -0,0 +1 @@ +rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.ql \ No newline at end of file diff --git a/c/misra/src/rules/DIR-4-6/NumericTypedefsNotUsedInPlaceOfBasicNumericalTypes.ql b/c/misra/src/rules/DIR-4-6/NumericTypedefsNotUsedInPlaceOfBasicNumericalTypes.ql new file mode 100644 index 0000000000..0b9a284e56 --- /dev/null +++ b/c/misra/src/rules/DIR-4-6/NumericTypedefsNotUsedInPlaceOfBasicNumericalTypes.ql @@ -0,0 +1,18 @@ +/** + * @id c/misra/numeric-typedefs-not-used-in-place-of-basic-numerical-types + * @name DIR-4-6: typedefs that indicate size and signedness should be used in place of the basic numerical types + * @description TODO. + * @kind problem + * @precision high + * @problem.severity error + * @tags external/misra/id/dir-4-6 + * external/misra/obligation/advisory + */ + +import cpp +import codingstandards.c.misra + +from +where + not isExcluded(x, TypesPackage::numericTypedefsNotUsedInPlaceOfBasicNumericalTypesQuery()) and +select diff --git a/c/misra/src/rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.ql b/c/misra/src/rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.ql new file mode 100644 index 0000000000..65e515a87d --- /dev/null +++ b/c/misra/src/rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.ql @@ -0,0 +1,18 @@ +/** + * @id c/misra/operands-of-an-inappropriate-essential-type + * @name RULE-10-1: Operands shall not be of an inappropriate essential type + * @description TODO. + * @kind problem + * @precision high + * @problem.severity error + * @tags external/misra/id/rule-10-1 + * external/misra/obligation/required + */ + +import cpp +import codingstandards.c.misra + +from +where + not isExcluded(x, TypesPackage::operandsOfAnInappropriateEssentialTypeQuery()) and +select diff --git a/c/misra/src/rules/RULE-10-2/CharTypeExprsUsedInAddOrSub.ql b/c/misra/src/rules/RULE-10-2/CharTypeExprsUsedInAddOrSub.ql new file mode 100644 index 0000000000..f64bdcc980 --- /dev/null +++ b/c/misra/src/rules/RULE-10-2/CharTypeExprsUsedInAddOrSub.ql @@ -0,0 +1,19 @@ +/** + * @id c/misra/char-type-exprs-used-in-add-or-sub + * @name RULE-10-2: Expressions of essentially character type shall not be used inappropriately in addition and + * @description Expressions of essentially character type shall not be used inappropriately in + * addition and subtraction operations. + * @kind problem + * @precision very-high + * @problem.severity error + * @tags external/misra/id/rule-10-2 + * external/misra/obligation/required + */ + +import cpp +import codingstandards.c.misra + +from +where + not isExcluded(x, TypesPackage::charTypeExprsUsedInAddOrSubQuery()) and +select diff --git a/c/misra/src/rules/RULE-10-3/AssignmentToIncompatibleEssentialType.ql b/c/misra/src/rules/RULE-10-3/AssignmentToIncompatibleEssentialType.ql new file mode 100644 index 0000000000..6d0a0c5aba --- /dev/null +++ b/c/misra/src/rules/RULE-10-3/AssignmentToIncompatibleEssentialType.ql @@ -0,0 +1,19 @@ +/** + * @id c/misra/assignment-to-incompatible-essential-type + * @name RULE-10-3: The value of an expression shall not be assigned to an object with a narrower essential type or of a + * @description The value of an expression shall not be assigned to an object with a narrower + * essential type or of a different essential type category. + * @kind problem + * @precision high + * @problem.severity error + * @tags external/misra/id/rule-10-3 + * external/misra/obligation/required + */ + +import cpp +import codingstandards.c.misra + +from +where + not isExcluded(x, TypesPackage::assignmentToIncompatibleEssentialTypeQuery()) and +select diff --git a/c/misra/src/rules/RULE-10-4/ArithConversionOperandHasDifferentEssTypeCategory.ql b/c/misra/src/rules/RULE-10-4/ArithConversionOperandHasDifferentEssTypeCategory.ql new file mode 100644 index 0000000000..cc27e5b693 --- /dev/null +++ b/c/misra/src/rules/RULE-10-4/ArithConversionOperandHasDifferentEssTypeCategory.ql @@ -0,0 +1,19 @@ +/** + * @id c/misra/arith-conversion-operand-has-different-ess-type-category + * @name RULE-10-4: Both operands of an operator in which the usual arithmetic conversions are performed shall have the + * @description Both operands of an operator in which the usual arithmetic conversions are performed + * shall have the same essential type category. + * @kind problem + * @precision very-high + * @problem.severity error + * @tags external/misra/id/rule-10-4 + * external/misra/obligation/required + */ + +import cpp +import codingstandards.c.misra + +from +where + not isExcluded(x, TypesPackage::arithConversionOperandHasDifferentEssTypeCategoryQuery()) and +select diff --git a/c/misra/src/rules/RULE-10-5/ValueCastToInappropriateEssentialType.ql b/c/misra/src/rules/RULE-10-5/ValueCastToInappropriateEssentialType.ql new file mode 100644 index 0000000000..ebdddc2910 --- /dev/null +++ b/c/misra/src/rules/RULE-10-5/ValueCastToInappropriateEssentialType.ql @@ -0,0 +1,18 @@ +/** + * @id c/misra/value-cast-to-inappropriate-essential-type + * @name RULE-10-5: The value of an expression should not be cast to an inappropriate essential type + * @description TODO. + * @kind problem + * @precision very-high + * @problem.severity error + * @tags external/misra/id/rule-10-5 + * external/misra/obligation/advisory + */ + +import cpp +import codingstandards.c.misra + +from +where + not isExcluded(x, TypesPackage::valueCastToInappropriateEssentialTypeQuery()) and +select diff --git a/c/misra/src/rules/RULE-10-6/CompositeExprValueAssignedToObjWithWiderEssType.ql b/c/misra/src/rules/RULE-10-6/CompositeExprValueAssignedToObjWithWiderEssType.ql new file mode 100644 index 0000000000..968edd026a --- /dev/null +++ b/c/misra/src/rules/RULE-10-6/CompositeExprValueAssignedToObjWithWiderEssType.ql @@ -0,0 +1,18 @@ +/** + * @id c/misra/composite-expr-value-assigned-to-obj-with-wider-ess-type + * @name RULE-10-6: The value of a composite expression shall not be assigned to an object with wider essential type + * @description TODO. + * @kind problem + * @precision very-high + * @problem.severity error + * @tags external/misra/id/rule-10-6 + * external/misra/obligation/required + */ + +import cpp +import codingstandards.c.misra + +from +where + not isExcluded(x, TypesPackage::compositeExprValueAssignedToObjWithWiderEssTypeQuery()) and +select diff --git a/c/misra/src/rules/RULE-10-7/ConvertedCompExprOperandHasWiderEssTypeThanOther.ql b/c/misra/src/rules/RULE-10-7/ConvertedCompExprOperandHasWiderEssTypeThanOther.ql new file mode 100644 index 0000000000..73d5fd0d30 --- /dev/null +++ b/c/misra/src/rules/RULE-10-7/ConvertedCompExprOperandHasWiderEssTypeThanOther.ql @@ -0,0 +1,20 @@ +/** + * @id c/misra/converted-comp-expr-operand-has-wider-ess-type-than-other + * @name RULE-10-7: If a composite expression is used as one operand of an operator in which the usual arithmetic + * @description If a composite expression is used as one operand of an operator in which the usual + * arithmetic conversions are performed then the other operand shall not have wider + * essential type. + * @kind problem + * @precision very-high + * @problem.severity error + * @tags external/misra/id/rule-10-7 + * external/misra/obligation/required + */ + +import cpp +import codingstandards.c.misra + +from +where + not isExcluded(x, TypesPackage::convertedCompExprOperandHasWiderEssTypeThanOtherQuery()) and +select diff --git a/c/misra/src/rules/RULE-10-8/CompExprValCastToIncompatEssType.ql b/c/misra/src/rules/RULE-10-8/CompExprValCastToIncompatEssType.ql new file mode 100644 index 0000000000..5937b33bd4 --- /dev/null +++ b/c/misra/src/rules/RULE-10-8/CompExprValCastToIncompatEssType.ql @@ -0,0 +1,19 @@ +/** + * @id c/misra/comp-expr-val-cast-to-incompat-ess-type + * @name RULE-10-8: The value of a composite expression shall not be cast to a different essential type category or a + * @description The value of a composite expression shall not be cast to a different essential type + * category or a wider essential type. + * @kind problem + * @precision very-high + * @problem.severity error + * @tags external/misra/id/rule-10-8 + * external/misra/obligation/required + */ + +import cpp +import codingstandards.c.misra + +from +where + not isExcluded(x, TypesPackage::compExprValCastToIncompatEssTypeQuery()) and +select diff --git a/c/misra/src/rules/RULE-12-4/ConstExprEvalCausesUnsignedIntWraparound.ql b/c/misra/src/rules/RULE-12-4/ConstExprEvalCausesUnsignedIntWraparound.ql new file mode 100644 index 0000000000..86001f7cfb --- /dev/null +++ b/c/misra/src/rules/RULE-12-4/ConstExprEvalCausesUnsignedIntWraparound.ql @@ -0,0 +1,18 @@ +/** + * @id c/misra/const-expr-eval-causes-unsigned-int-wraparound + * @name RULE-12-4: Evaluation of constant expressions should not lead to unsigned integer wrap-around + * @description TODO. + * @kind problem + * @precision very-high + * @problem.severity error + * @tags external/misra/id/rule-12-4 + * external/misra/obligation/advisory + */ + +import cpp +import codingstandards.c.misra + +from +where + not isExcluded(x, TypesPackage::constExprEvalCausesUnsignedIntWraparoundQuery()) and +select diff --git a/c/misra/src/rules/RULE-12-5/ArrayTypeParamAtSizeofOperand.ql b/c/misra/src/rules/RULE-12-5/ArrayTypeParamAtSizeofOperand.ql new file mode 100644 index 0000000000..2c67b24759 --- /dev/null +++ b/c/misra/src/rules/RULE-12-5/ArrayTypeParamAtSizeofOperand.ql @@ -0,0 +1,19 @@ +/** + * @id c/misra/array-type-param-at-sizeof-operand + * @name RULE-12-5: The sizeof operator shall not have an operand which is a function parameter declared as 'array of + * @description The sizeof operator shall not have an operand which is a function parameter declared + * as 'array of type'. + * @kind problem + * @precision very-high + * @problem.severity error + * @tags external/misra/id/rule-12-5 + * external/misra/obligation/mandatory + */ + +import cpp +import codingstandards.c.misra + +from +where + not isExcluded(x, TypesPackage::arrayTypeParamAtSizeofOperandQuery()) and +select diff --git a/c/misra/src/rules/RULE-14-1/LoopCounterHaveEssentiallyFloatingType.ql b/c/misra/src/rules/RULE-14-1/LoopCounterHaveEssentiallyFloatingType.ql new file mode 100644 index 0000000000..9b0b57148d --- /dev/null +++ b/c/misra/src/rules/RULE-14-1/LoopCounterHaveEssentiallyFloatingType.ql @@ -0,0 +1,18 @@ +/** + * @id c/misra/loop-counter-have-essentially-floating-type + * @name RULE-14-1: A loop counter shall not have essentially floating type + * @description TODO. + * @kind problem + * @precision high + * @problem.severity error + * @tags external/misra/id/rule-14-1 + * external/misra/obligation/required + */ + +import cpp +import codingstandards.c.misra + +from +where + not isExcluded(x, TypesPackage::loopCounterHaveEssentiallyFloatingTypeQuery()) and +select diff --git a/c/misra/src/rules/RULE-21-13/CtypeFuncNeitherReprAsUnsignedCharNorEOF.ql b/c/misra/src/rules/RULE-21-13/CtypeFuncNeitherReprAsUnsignedCharNorEOF.ql new file mode 100644 index 0000000000..ea070a1aa9 --- /dev/null +++ b/c/misra/src/rules/RULE-21-13/CtypeFuncNeitherReprAsUnsignedCharNorEOF.ql @@ -0,0 +1,19 @@ +/** + * @id c/misra/ctype-func-neither-repr-as-unsigned-char-nor-eof + * @name RULE-21-13: Any value passed to a function in shall be representable as an unsigned char or be the + * @description Any value passed to a function in shall be representable as an unsigned + * char or be the value EOF. + * @kind problem + * @precision very-high + * @problem.severity error + * @tags external/misra/id/rule-21-13 + * external/misra/obligation/mandatory + */ + +import cpp +import codingstandards.c.misra + +from +where + not isExcluded(x, TypesPackage::ctypeFuncNeitherReprAsUnsignedCharNorEOFQuery()) and +select diff --git a/c/misra/src/rules/RULE-21-14/MemcmpUsedToCompareNullTerminatedStrings.ql b/c/misra/src/rules/RULE-21-14/MemcmpUsedToCompareNullTerminatedStrings.ql new file mode 100644 index 0000000000..362985892f --- /dev/null +++ b/c/misra/src/rules/RULE-21-14/MemcmpUsedToCompareNullTerminatedStrings.ql @@ -0,0 +1,18 @@ +/** + * @id c/misra/memcmp-used-to-compare-null-terminated-strings + * @name RULE-21-14: The Standard Library function memcmp shall not be used to compare null terminated strings + * @description TODO. + * @kind problem + * @precision high + * @problem.severity error + * @tags external/misra/id/rule-21-14 + * external/misra/obligation/required + */ + +import cpp +import codingstandards.c.misra + +from +where + not isExcluded(x, TypesPackage::memcmpUsedToCompareNullTerminatedStringsQuery()) and +select diff --git a/c/misra/src/rules/RULE-21-15/MemcpyMemmoveMemcmpArgNotPointerToCompatTypes.ql b/c/misra/src/rules/RULE-21-15/MemcpyMemmoveMemcmpArgNotPointerToCompatTypes.ql new file mode 100644 index 0000000000..857f066615 --- /dev/null +++ b/c/misra/src/rules/RULE-21-15/MemcpyMemmoveMemcmpArgNotPointerToCompatTypes.ql @@ -0,0 +1,19 @@ +/** + * @id c/misra/memcpy-memmove-memcmp-arg-not-pointer-to-compat-types + * @name RULE-21-15: The pointer arguments to the Standard Library functions memcpy, memmove and memcmp shall be pointers + * @description The pointer arguments to the Standard Library functions memcpy, memmove and memcmp + * shall be pointers to qualified or unqualified versions of compatible types. + * @kind problem + * @precision very-high + * @problem.severity error + * @tags external/misra/id/rule-21-15 + * external/misra/obligation/required + */ + +import cpp +import codingstandards.c.misra + +from +where + not isExcluded(x, TypesPackage::memcpyMemmoveMemcmpArgNotPointerToCompatTypesQuery()) and +select diff --git a/c/misra/src/rules/RULE-21-16/MemcmpArgNotPtsToSignedUnsignedBooleanEnumEssType.ql b/c/misra/src/rules/RULE-21-16/MemcmpArgNotPtsToSignedUnsignedBooleanEnumEssType.ql new file mode 100644 index 0000000000..b78ac3715f --- /dev/null +++ b/c/misra/src/rules/RULE-21-16/MemcmpArgNotPtsToSignedUnsignedBooleanEnumEssType.ql @@ -0,0 +1,20 @@ +/** + * @id c/misra/memcmp-arg-not-pts-to-signed-unsigned-boolean-enum-ess-type + * @name RULE-21-16: The pointer arguments to the Standard Library function memcmp shall point to either a pointer type, + * @description The pointer arguments to the Standard Library function memcmp shall point to either + * a pointer type, an essentially signed type, an essentially unsigned type, an + * essentially Boolean type or an essentially enum type. + * @kind problem + * @precision very-high + * @problem.severity error + * @tags external/misra/id/rule-21-16 + * external/misra/obligation/required + */ + +import cpp +import codingstandards.c.misra + +from +where + not isExcluded(x, TypesPackage::memcmpArgNotPtsToSignedUnsignedBooleanEnumEssTypeQuery()) and +select diff --git a/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql b/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql new file mode 100644 index 0000000000..ee3c03d559 --- /dev/null +++ b/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql @@ -0,0 +1,19 @@ +/** + * @id c/misra/bit-fields-shall-only-be-declared-with-an-appropriate-type + * @name RULE-6-1: Bit-fields shall only be declared with an appropriate type + * @description Declaring bit-fields on types other than appropriate ones causes + * implementation-specific or undefined behavior. + * @kind problem + * @precision very-high + * @problem.severity error + * @tags external/misra/id/rule-6-1 + * external/misra/obligation/required + */ + +import cpp +import codingstandards.c.misra + +from +where + not isExcluded(x, TypesPackage::bitFieldsShallOnlyBeDeclaredWithAnAppropriateTypeQuery()) and +select diff --git a/c/misra/src/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql b/c/misra/src/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql new file mode 100644 index 0000000000..436d7efab7 --- /dev/null +++ b/c/misra/src/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql @@ -0,0 +1,19 @@ +/** + * @id c/misra/single-bit-named-bit-fields-of-a-signed-type + * @name RULE-6-2: Single-bit named bit fields shall not be of a signed type + * @description Single-bit named bit fields carry no useful information and therefore should not be + * declared or used. + * @kind problem + * @precision very-high + * @problem.severity error + * @tags external/misra/id/rule-6-2 + * external/misra/obligation/required + */ + +import cpp +import codingstandards.c.misra + +from +where + not isExcluded(x, TypesPackage::singleBitNamedBitFieldsOfASignedTypeQuery()) and +select diff --git a/c/misra/src/rules/RULE-7-4/StringLiteralAssignedToObjPtrToConstQualifiedChar.ql b/c/misra/src/rules/RULE-7-4/StringLiteralAssignedToObjPtrToConstQualifiedChar.ql new file mode 100644 index 0000000000..54328526d4 --- /dev/null +++ b/c/misra/src/rules/RULE-7-4/StringLiteralAssignedToObjPtrToConstQualifiedChar.ql @@ -0,0 +1,19 @@ +/** + * @id c/misra/string-literal-assigned-to-obj-ptr-to-const-qualified-char + * @name RULE-7-4: A string literal shall not be assigned to an object unless the object's type is 'pointer to + * @description A string literal shall not be assigned to an object unless the object's type is + * 'pointer to const-qualified char'. + * @kind problem + * @precision very-high + * @problem.severity error + * @tags external/misra/id/rule-7-4 + * external/misra/obligation/required + */ + +import cpp +import codingstandards.c.misra + +from +where + not isExcluded(x, TypesPackage::stringLiteralAssignedToObjPtrToConstQualifiedCharQuery()) and +select diff --git a/c/misra/test/rules/DIR-4-6/NumericTypedefsNotUsedInPlaceOfBasicNumericalTypes.expected b/c/misra/test/rules/DIR-4-6/NumericTypedefsNotUsedInPlaceOfBasicNumericalTypes.expected new file mode 100644 index 0000000000..2ec1a0ac6c --- /dev/null +++ b/c/misra/test/rules/DIR-4-6/NumericTypedefsNotUsedInPlaceOfBasicNumericalTypes.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/DIR-4-6/NumericTypedefsNotUsedInPlaceOfBasicNumericalTypes.qlref b/c/misra/test/rules/DIR-4-6/NumericTypedefsNotUsedInPlaceOfBasicNumericalTypes.qlref new file mode 100644 index 0000000000..81fd5998d5 --- /dev/null +++ b/c/misra/test/rules/DIR-4-6/NumericTypedefsNotUsedInPlaceOfBasicNumericalTypes.qlref @@ -0,0 +1 @@ +rules/DIR-4-6/NumericTypedefsNotUsedInPlaceOfBasicNumericalTypes.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.expected b/c/misra/test/rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.expected new file mode 100644 index 0000000000..2ec1a0ac6c --- /dev/null +++ b/c/misra/test/rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.qlref b/c/misra/test/rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.qlref new file mode 100644 index 0000000000..f3120fd81f --- /dev/null +++ b/c/misra/test/rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.qlref @@ -0,0 +1 @@ +rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-2/CharTypeExprsUsedInAddOrSub.expected b/c/misra/test/rules/RULE-10-2/CharTypeExprsUsedInAddOrSub.expected new file mode 100644 index 0000000000..2ec1a0ac6c --- /dev/null +++ b/c/misra/test/rules/RULE-10-2/CharTypeExprsUsedInAddOrSub.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-2/CharTypeExprsUsedInAddOrSub.qlref b/c/misra/test/rules/RULE-10-2/CharTypeExprsUsedInAddOrSub.qlref new file mode 100644 index 0000000000..a0912cc8e9 --- /dev/null +++ b/c/misra/test/rules/RULE-10-2/CharTypeExprsUsedInAddOrSub.qlref @@ -0,0 +1 @@ +rules/RULE-10-2/CharTypeExprsUsedInAddOrSub.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-3/AssignmentToIncompatibleEssentialType.expected b/c/misra/test/rules/RULE-10-3/AssignmentToIncompatibleEssentialType.expected new file mode 100644 index 0000000000..2ec1a0ac6c --- /dev/null +++ b/c/misra/test/rules/RULE-10-3/AssignmentToIncompatibleEssentialType.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-3/AssignmentToIncompatibleEssentialType.qlref b/c/misra/test/rules/RULE-10-3/AssignmentToIncompatibleEssentialType.qlref new file mode 100644 index 0000000000..d75ee46cd9 --- /dev/null +++ b/c/misra/test/rules/RULE-10-3/AssignmentToIncompatibleEssentialType.qlref @@ -0,0 +1 @@ +rules/RULE-10-3/AssignmentToIncompatibleEssentialType.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-4/ArithConversionOperandHasDifferentEssTypeCategory.expected b/c/misra/test/rules/RULE-10-4/ArithConversionOperandHasDifferentEssTypeCategory.expected new file mode 100644 index 0000000000..2ec1a0ac6c --- /dev/null +++ b/c/misra/test/rules/RULE-10-4/ArithConversionOperandHasDifferentEssTypeCategory.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-4/ArithConversionOperandHasDifferentEssTypeCategory.qlref b/c/misra/test/rules/RULE-10-4/ArithConversionOperandHasDifferentEssTypeCategory.qlref new file mode 100644 index 0000000000..fdafde4779 --- /dev/null +++ b/c/misra/test/rules/RULE-10-4/ArithConversionOperandHasDifferentEssTypeCategory.qlref @@ -0,0 +1 @@ +rules/RULE-10-4/ArithConversionOperandHasDifferentEssTypeCategory.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-5/ValueCastToInappropriateEssentialType.expected b/c/misra/test/rules/RULE-10-5/ValueCastToInappropriateEssentialType.expected new file mode 100644 index 0000000000..2ec1a0ac6c --- /dev/null +++ b/c/misra/test/rules/RULE-10-5/ValueCastToInappropriateEssentialType.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-5/ValueCastToInappropriateEssentialType.qlref b/c/misra/test/rules/RULE-10-5/ValueCastToInappropriateEssentialType.qlref new file mode 100644 index 0000000000..226c29d9c0 --- /dev/null +++ b/c/misra/test/rules/RULE-10-5/ValueCastToInappropriateEssentialType.qlref @@ -0,0 +1 @@ +rules/RULE-10-5/ValueCastToInappropriateEssentialType.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-6/CompositeExprValueAssignedToObjWithWiderEssType.expected b/c/misra/test/rules/RULE-10-6/CompositeExprValueAssignedToObjWithWiderEssType.expected new file mode 100644 index 0000000000..2ec1a0ac6c --- /dev/null +++ b/c/misra/test/rules/RULE-10-6/CompositeExprValueAssignedToObjWithWiderEssType.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-6/CompositeExprValueAssignedToObjWithWiderEssType.qlref b/c/misra/test/rules/RULE-10-6/CompositeExprValueAssignedToObjWithWiderEssType.qlref new file mode 100644 index 0000000000..258caa5497 --- /dev/null +++ b/c/misra/test/rules/RULE-10-6/CompositeExprValueAssignedToObjWithWiderEssType.qlref @@ -0,0 +1 @@ +rules/RULE-10-6/CompositeExprValueAssignedToObjWithWiderEssType.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-7/ConvertedCompExprOperandHasWiderEssTypeThanOther.expected b/c/misra/test/rules/RULE-10-7/ConvertedCompExprOperandHasWiderEssTypeThanOther.expected new file mode 100644 index 0000000000..2ec1a0ac6c --- /dev/null +++ b/c/misra/test/rules/RULE-10-7/ConvertedCompExprOperandHasWiderEssTypeThanOther.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-7/ConvertedCompExprOperandHasWiderEssTypeThanOther.qlref b/c/misra/test/rules/RULE-10-7/ConvertedCompExprOperandHasWiderEssTypeThanOther.qlref new file mode 100644 index 0000000000..ffcbf37d96 --- /dev/null +++ b/c/misra/test/rules/RULE-10-7/ConvertedCompExprOperandHasWiderEssTypeThanOther.qlref @@ -0,0 +1 @@ +rules/RULE-10-7/ConvertedCompExprOperandHasWiderEssTypeThanOther.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-8/CompExprValCastToIncompatEssType.expected b/c/misra/test/rules/RULE-10-8/CompExprValCastToIncompatEssType.expected new file mode 100644 index 0000000000..2ec1a0ac6c --- /dev/null +++ b/c/misra/test/rules/RULE-10-8/CompExprValCastToIncompatEssType.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-8/CompExprValCastToIncompatEssType.qlref b/c/misra/test/rules/RULE-10-8/CompExprValCastToIncompatEssType.qlref new file mode 100644 index 0000000000..92e74b5640 --- /dev/null +++ b/c/misra/test/rules/RULE-10-8/CompExprValCastToIncompatEssType.qlref @@ -0,0 +1 @@ +rules/RULE-10-8/CompExprValCastToIncompatEssType.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-12-4/ConstExprEvalCausesUnsignedIntWraparound.expected b/c/misra/test/rules/RULE-12-4/ConstExprEvalCausesUnsignedIntWraparound.expected new file mode 100644 index 0000000000..2ec1a0ac6c --- /dev/null +++ b/c/misra/test/rules/RULE-12-4/ConstExprEvalCausesUnsignedIntWraparound.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-12-4/ConstExprEvalCausesUnsignedIntWraparound.qlref b/c/misra/test/rules/RULE-12-4/ConstExprEvalCausesUnsignedIntWraparound.qlref new file mode 100644 index 0000000000..8f483e64f3 --- /dev/null +++ b/c/misra/test/rules/RULE-12-4/ConstExprEvalCausesUnsignedIntWraparound.qlref @@ -0,0 +1 @@ +rules/RULE-12-4/ConstExprEvalCausesUnsignedIntWraparound.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-12-5/ArrayTypeParamAtSizeofOperand.expected b/c/misra/test/rules/RULE-12-5/ArrayTypeParamAtSizeofOperand.expected new file mode 100644 index 0000000000..2ec1a0ac6c --- /dev/null +++ b/c/misra/test/rules/RULE-12-5/ArrayTypeParamAtSizeofOperand.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-12-5/ArrayTypeParamAtSizeofOperand.qlref b/c/misra/test/rules/RULE-12-5/ArrayTypeParamAtSizeofOperand.qlref new file mode 100644 index 0000000000..b083a10d31 --- /dev/null +++ b/c/misra/test/rules/RULE-12-5/ArrayTypeParamAtSizeofOperand.qlref @@ -0,0 +1 @@ +rules/RULE-12-5/ArrayTypeParamAtSizeofOperand.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-14-1/LoopCounterHaveEssentiallyFloatingType.expected b/c/misra/test/rules/RULE-14-1/LoopCounterHaveEssentiallyFloatingType.expected new file mode 100644 index 0000000000..2ec1a0ac6c --- /dev/null +++ b/c/misra/test/rules/RULE-14-1/LoopCounterHaveEssentiallyFloatingType.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-14-1/LoopCounterHaveEssentiallyFloatingType.qlref b/c/misra/test/rules/RULE-14-1/LoopCounterHaveEssentiallyFloatingType.qlref new file mode 100644 index 0000000000..befc44a33a --- /dev/null +++ b/c/misra/test/rules/RULE-14-1/LoopCounterHaveEssentiallyFloatingType.qlref @@ -0,0 +1 @@ +rules/RULE-14-1/LoopCounterHaveEssentiallyFloatingType.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-21-13/CtypeFuncNeitherReprAsUnsignedCharNorEOF.expected b/c/misra/test/rules/RULE-21-13/CtypeFuncNeitherReprAsUnsignedCharNorEOF.expected new file mode 100644 index 0000000000..2ec1a0ac6c --- /dev/null +++ b/c/misra/test/rules/RULE-21-13/CtypeFuncNeitherReprAsUnsignedCharNorEOF.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-21-13/CtypeFuncNeitherReprAsUnsignedCharNorEOF.qlref b/c/misra/test/rules/RULE-21-13/CtypeFuncNeitherReprAsUnsignedCharNorEOF.qlref new file mode 100644 index 0000000000..60f87891a1 --- /dev/null +++ b/c/misra/test/rules/RULE-21-13/CtypeFuncNeitherReprAsUnsignedCharNorEOF.qlref @@ -0,0 +1 @@ +rules/RULE-21-13/CtypeFuncNeitherReprAsUnsignedCharNorEOF.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-21-14/MemcmpUsedToCompareNullTerminatedStrings.expected b/c/misra/test/rules/RULE-21-14/MemcmpUsedToCompareNullTerminatedStrings.expected new file mode 100644 index 0000000000..2ec1a0ac6c --- /dev/null +++ b/c/misra/test/rules/RULE-21-14/MemcmpUsedToCompareNullTerminatedStrings.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-21-14/MemcmpUsedToCompareNullTerminatedStrings.qlref b/c/misra/test/rules/RULE-21-14/MemcmpUsedToCompareNullTerminatedStrings.qlref new file mode 100644 index 0000000000..99017569aa --- /dev/null +++ b/c/misra/test/rules/RULE-21-14/MemcmpUsedToCompareNullTerminatedStrings.qlref @@ -0,0 +1 @@ +rules/RULE-21-14/MemcmpUsedToCompareNullTerminatedStrings.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-21-15/MemcpyMemmoveMemcmpArgNotPointerToCompatTypes.expected b/c/misra/test/rules/RULE-21-15/MemcpyMemmoveMemcmpArgNotPointerToCompatTypes.expected new file mode 100644 index 0000000000..2ec1a0ac6c --- /dev/null +++ b/c/misra/test/rules/RULE-21-15/MemcpyMemmoveMemcmpArgNotPointerToCompatTypes.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-21-15/MemcpyMemmoveMemcmpArgNotPointerToCompatTypes.qlref b/c/misra/test/rules/RULE-21-15/MemcpyMemmoveMemcmpArgNotPointerToCompatTypes.qlref new file mode 100644 index 0000000000..e0ff446916 --- /dev/null +++ b/c/misra/test/rules/RULE-21-15/MemcpyMemmoveMemcmpArgNotPointerToCompatTypes.qlref @@ -0,0 +1 @@ +rules/RULE-21-15/MemcpyMemmoveMemcmpArgNotPointerToCompatTypes.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-21-16/MemcmpArgNotPtsToSignedUnsignedBooleanEnumEssType.expected b/c/misra/test/rules/RULE-21-16/MemcmpArgNotPtsToSignedUnsignedBooleanEnumEssType.expected new file mode 100644 index 0000000000..2ec1a0ac6c --- /dev/null +++ b/c/misra/test/rules/RULE-21-16/MemcmpArgNotPtsToSignedUnsignedBooleanEnumEssType.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-21-16/MemcmpArgNotPtsToSignedUnsignedBooleanEnumEssType.qlref b/c/misra/test/rules/RULE-21-16/MemcmpArgNotPtsToSignedUnsignedBooleanEnumEssType.qlref new file mode 100644 index 0000000000..ade809ada5 --- /dev/null +++ b/c/misra/test/rules/RULE-21-16/MemcmpArgNotPtsToSignedUnsignedBooleanEnumEssType.qlref @@ -0,0 +1 @@ +rules/RULE-21-16/MemcmpArgNotPtsToSignedUnsignedBooleanEnumEssType.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.expected b/c/misra/test/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.expected new file mode 100644 index 0000000000..2ec1a0ac6c --- /dev/null +++ b/c/misra/test/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.qlref b/c/misra/test/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.qlref new file mode 100644 index 0000000000..7000f50ab1 --- /dev/null +++ b/c/misra/test/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.qlref @@ -0,0 +1 @@ +rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.expected b/c/misra/test/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.expected new file mode 100644 index 0000000000..2ec1a0ac6c --- /dev/null +++ b/c/misra/test/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.qlref b/c/misra/test/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.qlref new file mode 100644 index 0000000000..50c34f70a7 --- /dev/null +++ b/c/misra/test/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.qlref @@ -0,0 +1 @@ +rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-7-4/StringLiteralAssignedToObjPtrToConstQualifiedChar.expected b/c/misra/test/rules/RULE-7-4/StringLiteralAssignedToObjPtrToConstQualifiedChar.expected new file mode 100644 index 0000000000..2ec1a0ac6c --- /dev/null +++ b/c/misra/test/rules/RULE-7-4/StringLiteralAssignedToObjPtrToConstQualifiedChar.expected @@ -0,0 +1 @@ +No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-7-4/StringLiteralAssignedToObjPtrToConstQualifiedChar.qlref b/c/misra/test/rules/RULE-7-4/StringLiteralAssignedToObjPtrToConstQualifiedChar.qlref new file mode 100644 index 0000000000..d886f5a94a --- /dev/null +++ b/c/misra/test/rules/RULE-7-4/StringLiteralAssignedToObjPtrToConstQualifiedChar.qlref @@ -0,0 +1 @@ +rules/RULE-7-4/StringLiteralAssignedToObjPtrToConstQualifiedChar.ql \ No newline at end of file diff --git a/cpp/common/src/codingstandards/cpp/exclusions/c/RuleMetadata.qll b/cpp/common/src/codingstandards/cpp/exclusions/c/RuleMetadata.qll index f06e6c3a49..9ee95dd2dd 100644 --- a/cpp/common/src/codingstandards/cpp/exclusions/c/RuleMetadata.qll +++ b/cpp/common/src/codingstandards/cpp/exclusions/c/RuleMetadata.qll @@ -42,6 +42,7 @@ import Strings1 import Strings2 import Strings3 import Syntax +import Types /** The TQuery type representing this language * */ newtype TCQuery = @@ -84,7 +85,8 @@ newtype TCQuery = TStrings1PackageQuery(Strings1Query q) or TStrings2PackageQuery(Strings2Query q) or TStrings3PackageQuery(Strings3Query q) or - TSyntaxPackageQuery(SyntaxQuery q) + TSyntaxPackageQuery(SyntaxQuery q) or + TTypesPackageQuery(TypesQuery q) /** The metadata predicate * */ predicate isQueryMetadata(Query query, string queryId, string ruleId, string category) { @@ -127,5 +129,6 @@ predicate isQueryMetadata(Query query, string queryId, string ruleId, string cat isStrings1QueryMetadata(query, queryId, ruleId, category) or isStrings2QueryMetadata(query, queryId, ruleId, category) or isStrings3QueryMetadata(query, queryId, ruleId, category) or - isSyntaxQueryMetadata(query, queryId, ruleId, category) + isSyntaxQueryMetadata(query, queryId, ruleId, category) or + isTypesQueryMetadata(query, queryId, ruleId, category) } diff --git a/cpp/common/src/codingstandards/cpp/exclusions/c/Types.qll b/cpp/common/src/codingstandards/cpp/exclusions/c/Types.qll new file mode 100644 index 0000000000..79cf3550b1 --- /dev/null +++ b/cpp/common/src/codingstandards/cpp/exclusions/c/Types.qll @@ -0,0 +1,520 @@ +//** THIS FILE IS AUTOGENERATED, DO NOT MODIFY DIRECTLY. **/ +import cpp +import RuleMetadata +import codingstandards.cpp.exclusions.RuleMetadata + +newtype TypesQuery = + TPreventOrDetectDomainAndRangeErrorsInMathFunctionsQuery() or + TFloatingPointConversionsNotWithinRangeOfNewTypeQuery() or + TFloatingPointOfIntegralValuesLosePrecisionQuery() or + TObjectReprUsedForComparingFloatingPointValuesQuery() or + TEnsureThatUnsignedIntegerOperationsDoNotWrapQuery() or + TIntConversionCausesLostOrMisinterpretedDataQuery() or + TOperationsOnSignedIntegersResultsInOverflowQuery() or + TDivAndModOperationResultsInDivByZeroQuery() or + TExprShiftedByNegativeBitsOrGreaterThanOperandQuery() or + TUseCorrectIntegerPrecisionsQuery() or + TConvertingAPointerToIntegerOrIntegerToPointerQuery() or + TNumericTypedefsNotUsedInPlaceOfBasicNumericalTypesQuery() or + TOperandsOfAnInappropriateEssentialTypeQuery() or + TCharTypeExprsUsedInAddOrSubQuery() or + TAssignmentToIncompatibleEssentialTypeQuery() or + TArithConversionOperandHasDifferentEssTypeCategoryQuery() or + TValueCastToInappropriateEssentialTypeQuery() or + TCompositeExprValueAssignedToObjWithWiderEssTypeQuery() or + TConvertedCompExprOperandHasWiderEssTypeThanOtherQuery() or + TCompExprValCastToIncompatEssTypeQuery() or + TConstExprEvalCausesUnsignedIntWraparoundQuery() or + TArrayTypeParamAtSizeofOperandQuery() or + TLoopCounterHaveEssentiallyFloatingTypeQuery() or + TCtypeFuncNeitherReprAsUnsignedCharNorEOFQuery() or + TMemcmpUsedToCompareNullTerminatedStringsQuery() or + TMemcpyMemmoveMemcmpArgNotPointerToCompatTypesQuery() or + TMemcmpArgNotPtsToSignedUnsignedBooleanEnumEssTypeQuery() or + TBitFieldsShallOnlyBeDeclaredWithAnAppropriateTypeQuery() or + TSingleBitNamedBitFieldsOfASignedTypeQuery() or + TStringLiteralAssignedToObjPtrToConstQualifiedCharQuery() + +predicate isTypesQueryMetadata(Query query, string queryId, string ruleId, string category) { + query = + // `Query` instance for the `preventOrDetectDomainAndRangeErrorsInMathFunctions` query + TypesPackage::preventOrDetectDomainAndRangeErrorsInMathFunctionsQuery() and + queryId = + // `@id` for the `preventOrDetectDomainAndRangeErrorsInMathFunctions` query + "c/cert/prevent-or-detect-domain-and-range-errors-in-math-functions" and + ruleId = "FLP32-C" and + category = "rule" + or + query = + // `Query` instance for the `floatingPointConversionsNotWithinRangeOfNewType` query + TypesPackage::floatingPointConversionsNotWithinRangeOfNewTypeQuery() and + queryId = + // `@id` for the `floatingPointConversionsNotWithinRangeOfNewType` query + "c/cert/floating-point-conversions-not-within-range-of-new-type" and + ruleId = "FLP34-C" and + category = "rule" + or + query = + // `Query` instance for the `floatingPointOfIntegralValuesLosePrecision` query + TypesPackage::floatingPointOfIntegralValuesLosePrecisionQuery() and + queryId = + // `@id` for the `floatingPointOfIntegralValuesLosePrecision` query + "c/cert/floating-point-of-integral-values-lose-precision" and + ruleId = "FLP36-C" and + category = "rule" + or + query = + // `Query` instance for the `objectReprUsedForComparingFloatingPointValues` query + TypesPackage::objectReprUsedForComparingFloatingPointValuesQuery() and + queryId = + // `@id` for the `objectReprUsedForComparingFloatingPointValues` query + "c/cert/object-repr-used-for-comparing-floating-point-values" and + ruleId = "FLP37-C" and + category = "rule" + or + query = + // `Query` instance for the `ensureThatUnsignedIntegerOperationsDoNotWrap` query + TypesPackage::ensureThatUnsignedIntegerOperationsDoNotWrapQuery() and + queryId = + // `@id` for the `ensureThatUnsignedIntegerOperationsDoNotWrap` query + "c/cert/ensure-that-unsigned-integer-operations-do-not-wrap" and + ruleId = "INT30-C" and + category = "rule" + or + query = + // `Query` instance for the `intConversionCausesLostOrMisinterpretedData` query + TypesPackage::intConversionCausesLostOrMisinterpretedDataQuery() and + queryId = + // `@id` for the `intConversionCausesLostOrMisinterpretedData` query + "c/cert/int-conversion-causes-lost-or-misinterpreted-data" and + ruleId = "INT31-C" and + category = "rule" + or + query = + // `Query` instance for the `operationsOnSignedIntegersResultsInOverflow` query + TypesPackage::operationsOnSignedIntegersResultsInOverflowQuery() and + queryId = + // `@id` for the `operationsOnSignedIntegersResultsInOverflow` query + "c/cert/operations-on-signed-integers-results-in-overflow" and + ruleId = "INT32-C" and + category = "rule" + or + query = + // `Query` instance for the `divAndModOperationResultsInDivByZero` query + TypesPackage::divAndModOperationResultsInDivByZeroQuery() and + queryId = + // `@id` for the `divAndModOperationResultsInDivByZero` query + "c/cert/div-and-mod-operation-results-in-div-by-zero" and + ruleId = "INT33-C" and + category = "rule" + or + query = + // `Query` instance for the `exprShiftedByNegativeBitsOrGreaterThanOperand` query + TypesPackage::exprShiftedByNegativeBitsOrGreaterThanOperandQuery() and + queryId = + // `@id` for the `exprShiftedByNegativeBitsOrGreaterThanOperand` query + "c/cert/expr-shifted-by-negative-bits-or-greater-than-operand" and + ruleId = "INT34-C" and + category = "rule" + or + query = + // `Query` instance for the `useCorrectIntegerPrecisions` query + TypesPackage::useCorrectIntegerPrecisionsQuery() and + queryId = + // `@id` for the `useCorrectIntegerPrecisions` query + "c/cert/use-correct-integer-precisions" and + ruleId = "INT35-C" and + category = "rule" + or + query = + // `Query` instance for the `convertingAPointerToIntegerOrIntegerToPointer` query + TypesPackage::convertingAPointerToIntegerOrIntegerToPointerQuery() and + queryId = + // `@id` for the `convertingAPointerToIntegerOrIntegerToPointer` query + "c/cert/converting-a-pointer-to-integer-or-integer-to-pointer" and + ruleId = "INT36-C" and + category = "rule" + or + query = + // `Query` instance for the `numericTypedefsNotUsedInPlaceOfBasicNumericalTypes` query + TypesPackage::numericTypedefsNotUsedInPlaceOfBasicNumericalTypesQuery() and + queryId = + // `@id` for the `numericTypedefsNotUsedInPlaceOfBasicNumericalTypes` query + "c/misra/numeric-typedefs-not-used-in-place-of-basic-numerical-types" and + ruleId = "DIR-4-6" and + category = "advisory" + or + query = + // `Query` instance for the `operandsOfAnInappropriateEssentialType` query + TypesPackage::operandsOfAnInappropriateEssentialTypeQuery() and + queryId = + // `@id` for the `operandsOfAnInappropriateEssentialType` query + "c/misra/operands-of-an-inappropriate-essential-type" and + ruleId = "RULE-10-1" and + category = "required" + or + query = + // `Query` instance for the `charTypeExprsUsedInAddOrSub` query + TypesPackage::charTypeExprsUsedInAddOrSubQuery() and + queryId = + // `@id` for the `charTypeExprsUsedInAddOrSub` query + "c/misra/char-type-exprs-used-in-add-or-sub" and + ruleId = "RULE-10-2" and + category = "required" + or + query = + // `Query` instance for the `assignmentToIncompatibleEssentialType` query + TypesPackage::assignmentToIncompatibleEssentialTypeQuery() and + queryId = + // `@id` for the `assignmentToIncompatibleEssentialType` query + "c/misra/assignment-to-incompatible-essential-type" and + ruleId = "RULE-10-3" and + category = "required" + or + query = + // `Query` instance for the `arithConversionOperandHasDifferentEssTypeCategory` query + TypesPackage::arithConversionOperandHasDifferentEssTypeCategoryQuery() and + queryId = + // `@id` for the `arithConversionOperandHasDifferentEssTypeCategory` query + "c/misra/arith-conversion-operand-has-different-ess-type-category" and + ruleId = "RULE-10-4" and + category = "required" + or + query = + // `Query` instance for the `valueCastToInappropriateEssentialType` query + TypesPackage::valueCastToInappropriateEssentialTypeQuery() and + queryId = + // `@id` for the `valueCastToInappropriateEssentialType` query + "c/misra/value-cast-to-inappropriate-essential-type" and + ruleId = "RULE-10-5" and + category = "advisory" + or + query = + // `Query` instance for the `compositeExprValueAssignedToObjWithWiderEssType` query + TypesPackage::compositeExprValueAssignedToObjWithWiderEssTypeQuery() and + queryId = + // `@id` for the `compositeExprValueAssignedToObjWithWiderEssType` query + "c/misra/composite-expr-value-assigned-to-obj-with-wider-ess-type" and + ruleId = "RULE-10-6" and + category = "required" + or + query = + // `Query` instance for the `convertedCompExprOperandHasWiderEssTypeThanOther` query + TypesPackage::convertedCompExprOperandHasWiderEssTypeThanOtherQuery() and + queryId = + // `@id` for the `convertedCompExprOperandHasWiderEssTypeThanOther` query + "c/misra/converted-comp-expr-operand-has-wider-ess-type-than-other" and + ruleId = "RULE-10-7" and + category = "required" + or + query = + // `Query` instance for the `compExprValCastToIncompatEssType` query + TypesPackage::compExprValCastToIncompatEssTypeQuery() and + queryId = + // `@id` for the `compExprValCastToIncompatEssType` query + "c/misra/comp-expr-val-cast-to-incompat-ess-type" and + ruleId = "RULE-10-8" and + category = "required" + or + query = + // `Query` instance for the `constExprEvalCausesUnsignedIntWraparound` query + TypesPackage::constExprEvalCausesUnsignedIntWraparoundQuery() and + queryId = + // `@id` for the `constExprEvalCausesUnsignedIntWraparound` query + "c/misra/const-expr-eval-causes-unsigned-int-wraparound" and + ruleId = "RULE-12-4" and + category = "advisory" + or + query = + // `Query` instance for the `arrayTypeParamAtSizeofOperand` query + TypesPackage::arrayTypeParamAtSizeofOperandQuery() and + queryId = + // `@id` for the `arrayTypeParamAtSizeofOperand` query + "c/misra/array-type-param-at-sizeof-operand" and + ruleId = "RULE-12-5" and + category = "mandatory" + or + query = + // `Query` instance for the `loopCounterHaveEssentiallyFloatingType` query + TypesPackage::loopCounterHaveEssentiallyFloatingTypeQuery() and + queryId = + // `@id` for the `loopCounterHaveEssentiallyFloatingType` query + "c/misra/loop-counter-have-essentially-floating-type" and + ruleId = "RULE-14-1" and + category = "required" + or + query = + // `Query` instance for the `ctypeFuncNeitherReprAsUnsignedCharNorEOF` query + TypesPackage::ctypeFuncNeitherReprAsUnsignedCharNorEOFQuery() and + queryId = + // `@id` for the `ctypeFuncNeitherReprAsUnsignedCharNorEOF` query + "c/misra/ctype-func-neither-repr-as-unsigned-char-nor-eof" and + ruleId = "RULE-21-13" and + category = "mandatory" + or + query = + // `Query` instance for the `memcmpUsedToCompareNullTerminatedStrings` query + TypesPackage::memcmpUsedToCompareNullTerminatedStringsQuery() and + queryId = + // `@id` for the `memcmpUsedToCompareNullTerminatedStrings` query + "c/misra/memcmp-used-to-compare-null-terminated-strings" and + ruleId = "RULE-21-14" and + category = "required" + or + query = + // `Query` instance for the `memcpyMemmoveMemcmpArgNotPointerToCompatTypes` query + TypesPackage::memcpyMemmoveMemcmpArgNotPointerToCompatTypesQuery() and + queryId = + // `@id` for the `memcpyMemmoveMemcmpArgNotPointerToCompatTypes` query + "c/misra/memcpy-memmove-memcmp-arg-not-pointer-to-compat-types" and + ruleId = "RULE-21-15" and + category = "required" + or + query = + // `Query` instance for the `memcmpArgNotPtsToSignedUnsignedBooleanEnumEssType` query + TypesPackage::memcmpArgNotPtsToSignedUnsignedBooleanEnumEssTypeQuery() and + queryId = + // `@id` for the `memcmpArgNotPtsToSignedUnsignedBooleanEnumEssType` query + "c/misra/memcmp-arg-not-pts-to-signed-unsigned-boolean-enum-ess-type" and + ruleId = "RULE-21-16" and + category = "required" + or + query = + // `Query` instance for the `bitFieldsShallOnlyBeDeclaredWithAnAppropriateType` query + TypesPackage::bitFieldsShallOnlyBeDeclaredWithAnAppropriateTypeQuery() and + queryId = + // `@id` for the `bitFieldsShallOnlyBeDeclaredWithAnAppropriateType` query + "c/misra/bit-fields-shall-only-be-declared-with-an-appropriate-type" and + ruleId = "RULE-6-1" and + category = "required" + or + query = + // `Query` instance for the `singleBitNamedBitFieldsOfASignedType` query + TypesPackage::singleBitNamedBitFieldsOfASignedTypeQuery() and + queryId = + // `@id` for the `singleBitNamedBitFieldsOfASignedType` query + "c/misra/single-bit-named-bit-fields-of-a-signed-type" and + ruleId = "RULE-6-2" and + category = "required" + or + query = + // `Query` instance for the `stringLiteralAssignedToObjPtrToConstQualifiedChar` query + TypesPackage::stringLiteralAssignedToObjPtrToConstQualifiedCharQuery() and + queryId = + // `@id` for the `stringLiteralAssignedToObjPtrToConstQualifiedChar` query + "c/misra/string-literal-assigned-to-obj-ptr-to-const-qualified-char" and + ruleId = "RULE-7-4" and + category = "required" +} + +module TypesPackage { + Query preventOrDetectDomainAndRangeErrorsInMathFunctionsQuery() { + //autogenerate `Query` type + result = + // `Query` type for `preventOrDetectDomainAndRangeErrorsInMathFunctions` query + TQueryC(TTypesPackageQuery(TPreventOrDetectDomainAndRangeErrorsInMathFunctionsQuery())) + } + + Query floatingPointConversionsNotWithinRangeOfNewTypeQuery() { + //autogenerate `Query` type + result = + // `Query` type for `floatingPointConversionsNotWithinRangeOfNewType` query + TQueryC(TTypesPackageQuery(TFloatingPointConversionsNotWithinRangeOfNewTypeQuery())) + } + + Query floatingPointOfIntegralValuesLosePrecisionQuery() { + //autogenerate `Query` type + result = + // `Query` type for `floatingPointOfIntegralValuesLosePrecision` query + TQueryC(TTypesPackageQuery(TFloatingPointOfIntegralValuesLosePrecisionQuery())) + } + + Query objectReprUsedForComparingFloatingPointValuesQuery() { + //autogenerate `Query` type + result = + // `Query` type for `objectReprUsedForComparingFloatingPointValues` query + TQueryC(TTypesPackageQuery(TObjectReprUsedForComparingFloatingPointValuesQuery())) + } + + Query ensureThatUnsignedIntegerOperationsDoNotWrapQuery() { + //autogenerate `Query` type + result = + // `Query` type for `ensureThatUnsignedIntegerOperationsDoNotWrap` query + TQueryC(TTypesPackageQuery(TEnsureThatUnsignedIntegerOperationsDoNotWrapQuery())) + } + + Query intConversionCausesLostOrMisinterpretedDataQuery() { + //autogenerate `Query` type + result = + // `Query` type for `intConversionCausesLostOrMisinterpretedData` query + TQueryC(TTypesPackageQuery(TIntConversionCausesLostOrMisinterpretedDataQuery())) + } + + Query operationsOnSignedIntegersResultsInOverflowQuery() { + //autogenerate `Query` type + result = + // `Query` type for `operationsOnSignedIntegersResultsInOverflow` query + TQueryC(TTypesPackageQuery(TOperationsOnSignedIntegersResultsInOverflowQuery())) + } + + Query divAndModOperationResultsInDivByZeroQuery() { + //autogenerate `Query` type + result = + // `Query` type for `divAndModOperationResultsInDivByZero` query + TQueryC(TTypesPackageQuery(TDivAndModOperationResultsInDivByZeroQuery())) + } + + Query exprShiftedByNegativeBitsOrGreaterThanOperandQuery() { + //autogenerate `Query` type + result = + // `Query` type for `exprShiftedByNegativeBitsOrGreaterThanOperand` query + TQueryC(TTypesPackageQuery(TExprShiftedByNegativeBitsOrGreaterThanOperandQuery())) + } + + Query useCorrectIntegerPrecisionsQuery() { + //autogenerate `Query` type + result = + // `Query` type for `useCorrectIntegerPrecisions` query + TQueryC(TTypesPackageQuery(TUseCorrectIntegerPrecisionsQuery())) + } + + Query convertingAPointerToIntegerOrIntegerToPointerQuery() { + //autogenerate `Query` type + result = + // `Query` type for `convertingAPointerToIntegerOrIntegerToPointer` query + TQueryC(TTypesPackageQuery(TConvertingAPointerToIntegerOrIntegerToPointerQuery())) + } + + Query numericTypedefsNotUsedInPlaceOfBasicNumericalTypesQuery() { + //autogenerate `Query` type + result = + // `Query` type for `numericTypedefsNotUsedInPlaceOfBasicNumericalTypes` query + TQueryC(TTypesPackageQuery(TNumericTypedefsNotUsedInPlaceOfBasicNumericalTypesQuery())) + } + + Query operandsOfAnInappropriateEssentialTypeQuery() { + //autogenerate `Query` type + result = + // `Query` type for `operandsOfAnInappropriateEssentialType` query + TQueryC(TTypesPackageQuery(TOperandsOfAnInappropriateEssentialTypeQuery())) + } + + Query charTypeExprsUsedInAddOrSubQuery() { + //autogenerate `Query` type + result = + // `Query` type for `charTypeExprsUsedInAddOrSub` query + TQueryC(TTypesPackageQuery(TCharTypeExprsUsedInAddOrSubQuery())) + } + + Query assignmentToIncompatibleEssentialTypeQuery() { + //autogenerate `Query` type + result = + // `Query` type for `assignmentToIncompatibleEssentialType` query + TQueryC(TTypesPackageQuery(TAssignmentToIncompatibleEssentialTypeQuery())) + } + + Query arithConversionOperandHasDifferentEssTypeCategoryQuery() { + //autogenerate `Query` type + result = + // `Query` type for `arithConversionOperandHasDifferentEssTypeCategory` query + TQueryC(TTypesPackageQuery(TArithConversionOperandHasDifferentEssTypeCategoryQuery())) + } + + Query valueCastToInappropriateEssentialTypeQuery() { + //autogenerate `Query` type + result = + // `Query` type for `valueCastToInappropriateEssentialType` query + TQueryC(TTypesPackageQuery(TValueCastToInappropriateEssentialTypeQuery())) + } + + Query compositeExprValueAssignedToObjWithWiderEssTypeQuery() { + //autogenerate `Query` type + result = + // `Query` type for `compositeExprValueAssignedToObjWithWiderEssType` query + TQueryC(TTypesPackageQuery(TCompositeExprValueAssignedToObjWithWiderEssTypeQuery())) + } + + Query convertedCompExprOperandHasWiderEssTypeThanOtherQuery() { + //autogenerate `Query` type + result = + // `Query` type for `convertedCompExprOperandHasWiderEssTypeThanOther` query + TQueryC(TTypesPackageQuery(TConvertedCompExprOperandHasWiderEssTypeThanOtherQuery())) + } + + Query compExprValCastToIncompatEssTypeQuery() { + //autogenerate `Query` type + result = + // `Query` type for `compExprValCastToIncompatEssType` query + TQueryC(TTypesPackageQuery(TCompExprValCastToIncompatEssTypeQuery())) + } + + Query constExprEvalCausesUnsignedIntWraparoundQuery() { + //autogenerate `Query` type + result = + // `Query` type for `constExprEvalCausesUnsignedIntWraparound` query + TQueryC(TTypesPackageQuery(TConstExprEvalCausesUnsignedIntWraparoundQuery())) + } + + Query arrayTypeParamAtSizeofOperandQuery() { + //autogenerate `Query` type + result = + // `Query` type for `arrayTypeParamAtSizeofOperand` query + TQueryC(TTypesPackageQuery(TArrayTypeParamAtSizeofOperandQuery())) + } + + Query loopCounterHaveEssentiallyFloatingTypeQuery() { + //autogenerate `Query` type + result = + // `Query` type for `loopCounterHaveEssentiallyFloatingType` query + TQueryC(TTypesPackageQuery(TLoopCounterHaveEssentiallyFloatingTypeQuery())) + } + + Query ctypeFuncNeitherReprAsUnsignedCharNorEOFQuery() { + //autogenerate `Query` type + result = + // `Query` type for `ctypeFuncNeitherReprAsUnsignedCharNorEOF` query + TQueryC(TTypesPackageQuery(TCtypeFuncNeitherReprAsUnsignedCharNorEOFQuery())) + } + + Query memcmpUsedToCompareNullTerminatedStringsQuery() { + //autogenerate `Query` type + result = + // `Query` type for `memcmpUsedToCompareNullTerminatedStrings` query + TQueryC(TTypesPackageQuery(TMemcmpUsedToCompareNullTerminatedStringsQuery())) + } + + Query memcpyMemmoveMemcmpArgNotPointerToCompatTypesQuery() { + //autogenerate `Query` type + result = + // `Query` type for `memcpyMemmoveMemcmpArgNotPointerToCompatTypes` query + TQueryC(TTypesPackageQuery(TMemcpyMemmoveMemcmpArgNotPointerToCompatTypesQuery())) + } + + Query memcmpArgNotPtsToSignedUnsignedBooleanEnumEssTypeQuery() { + //autogenerate `Query` type + result = + // `Query` type for `memcmpArgNotPtsToSignedUnsignedBooleanEnumEssType` query + TQueryC(TTypesPackageQuery(TMemcmpArgNotPtsToSignedUnsignedBooleanEnumEssTypeQuery())) + } + + Query bitFieldsShallOnlyBeDeclaredWithAnAppropriateTypeQuery() { + //autogenerate `Query` type + result = + // `Query` type for `bitFieldsShallOnlyBeDeclaredWithAnAppropriateType` query + TQueryC(TTypesPackageQuery(TBitFieldsShallOnlyBeDeclaredWithAnAppropriateTypeQuery())) + } + + Query singleBitNamedBitFieldsOfASignedTypeQuery() { + //autogenerate `Query` type + result = + // `Query` type for `singleBitNamedBitFieldsOfASignedType` query + TQueryC(TTypesPackageQuery(TSingleBitNamedBitFieldsOfASignedTypeQuery())) + } + + Query stringLiteralAssignedToObjPtrToConstQualifiedCharQuery() { + //autogenerate `Query` type + result = + // `Query` type for `stringLiteralAssignedToObjPtrToConstQualifiedChar` query + TQueryC(TTypesPackageQuery(TStringLiteralAssignedToObjPtrToConstQualifiedCharQuery())) + } +} From dcda9b626f391017eda2e494c8ff1b19212763bd Mon Sep 17 00:00:00 2001 From: Jeongsoo Lee Date: Thu, 26 Jan 2023 11:38:18 -0800 Subject: [PATCH 05/23] implement MISRA RULE-6-1 --- ...hallOnlyBeDeclaredWithAnAppropriateType.ql | 26 ++++++++++++++++--- ...lyBeDeclaredWithAnAppropriateType.expected | 5 +++- c/misra/test/rules/RULE-6-1/test.c | 15 +++++++++++ 3 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 c/misra/test/rules/RULE-6-1/test.c diff --git a/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql b/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql index ee3c03d559..52ee55699e 100644 --- a/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql +++ b/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql @@ -13,7 +13,27 @@ import cpp import codingstandards.c.misra -from +predicate isSignedOrUnsignedInt(Type type) { + type instanceof IntType and + (type.(IntegralType).isExplicitlySigned() or + type.(IntegralType).isExplicitlyUnsigned()) +} + +predicate isAppropriatePrimitive(Type type) { + isSignedOrUnsignedInt(type) or type instanceof BoolType +} + +predicate isAppropriateTypedef(Type type) { + type instanceof TypedefType and + isAppropriatePrimitive(type.(TypedefType).resolveTypedefs()) +} + +predicate isInappropriateType(Type type) { + not (isAppropriatePrimitive(type) or isAppropriateTypedef(type)) +} + +from BitField bitField where - not isExcluded(x, TypesPackage::bitFieldsShallOnlyBeDeclaredWithAnAppropriateTypeQuery()) and -select +not isExcluded(bitField, TypesPackage::bitFieldsShallOnlyBeDeclaredWithAnAppropriateTypeQuery()) and + isInappropriateType(bitField.getType()) +select bitField, "Type " + bitField.getType() + " should not have a bit-field declaration at " + bitField + "." \ No newline at end of file diff --git a/c/misra/test/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.expected b/c/misra/test/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.expected index 2ec1a0ac6c..50f1994c4a 100644 --- a/c/misra/test/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.expected +++ b/c/misra/test/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.expected @@ -1 +1,4 @@ -No expected results have yet been specified \ No newline at end of file +| test.c:8:7:8:8 | b3 | Type int should not have a bit-field declaration at b3. | +| test.c:11:15:11:16 | b5 | Type signed long should not have a bit-field declaration at b5. | +| test.c:13:15:13:16 | b6 | Type signed char should not have a bit-field declaration at b6. | +| test.c:14:14:14:15 | b7 | Type Color should not have a bit-field declaration at b7. | diff --git a/c/misra/test/rules/RULE-6-1/test.c b/c/misra/test/rules/RULE-6-1/test.c new file mode 100644 index 0000000000..7fbde78b57 --- /dev/null +++ b/c/misra/test/rules/RULE-6-1/test.c @@ -0,0 +1,15 @@ +typedef unsigned int UINT_16; + +enum Color { R, G, B }; + +struct SampleStruct { + unsigned int b1 : 2; // COMPILANT - explicitly unsigned (example in the doc) + signed int b2 : 2; // COMPILANT - explicitly signed + int b3 : 2; // NON_COMPLIANT - plain int not permitted (example in the doc) + UINT_16 b4 : 2; // COMPLIANT - typedef designating unsigned int (example in + // the doc) + signed long b5 : 2; // NON_COMPLIANT - even if long and int are the same size + // (example in the doc) + signed char b6 : 2; // NON_COMPILANT - cannot declare bit field for char + enum Color b7 : 3; // NON_COMPILANT - cannot declare bit field for enum +} sample_struct; \ No newline at end of file From 26c8f62cbdf13ed6c4b4c82881de9acd8d0c57d5 Mon Sep 17 00:00:00 2001 From: Jeongsoo Lee Date: Thu, 26 Jan 2023 11:45:36 -0800 Subject: [PATCH 06/23] Update the alert message in the select statement Using factual statements rather than a modal one, in this case `should`. --- .../BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql b/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql index 52ee55699e..1503b39184 100644 --- a/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql +++ b/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql @@ -36,4 +36,4 @@ from BitField bitField where not isExcluded(bitField, TypesPackage::bitFieldsShallOnlyBeDeclaredWithAnAppropriateTypeQuery()) and isInappropriateType(bitField.getType()) -select bitField, "Type " + bitField.getType() + " should not have a bit-field declaration at " + bitField + "." \ No newline at end of file +select bitField, "Bit-field " + bitField + " is declared on type " + bitField + "." \ No newline at end of file From 17b1ef9e666fe0a54e2bace8b2874a02f1b8a77b Mon Sep 17 00:00:00 2001 From: Jeongsoo Lee Date: Thu, 26 Jan 2023 11:55:26 -0800 Subject: [PATCH 07/23] Inline isInappropriateType and fix .expected --- .../BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql | 6 +----- ...ieldsShallOnlyBeDeclaredWithAnAppropriateType.expected | 8 ++++---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql b/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql index 1503b39184..29c662ca19 100644 --- a/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql +++ b/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql @@ -28,12 +28,8 @@ predicate isAppropriateTypedef(Type type) { isAppropriatePrimitive(type.(TypedefType).resolveTypedefs()) } -predicate isInappropriateType(Type type) { - not (isAppropriatePrimitive(type) or isAppropriateTypedef(type)) -} - from BitField bitField where not isExcluded(bitField, TypesPackage::bitFieldsShallOnlyBeDeclaredWithAnAppropriateTypeQuery()) and - isInappropriateType(bitField.getType()) +not (isAppropriatePrimitive(bitField.getType()) or isAppropriateTypedef(bitField.getType())) select bitField, "Bit-field " + bitField + " is declared on type " + bitField + "." \ No newline at end of file diff --git a/c/misra/test/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.expected b/c/misra/test/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.expected index 50f1994c4a..cb80395588 100644 --- a/c/misra/test/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.expected +++ b/c/misra/test/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.expected @@ -1,4 +1,4 @@ -| test.c:8:7:8:8 | b3 | Type int should not have a bit-field declaration at b3. | -| test.c:11:15:11:16 | b5 | Type signed long should not have a bit-field declaration at b5. | -| test.c:13:15:13:16 | b6 | Type signed char should not have a bit-field declaration at b6. | -| test.c:14:14:14:15 | b7 | Type Color should not have a bit-field declaration at b7. | +| test.c:8:7:8:8 | b3 | Bit-field b3 is declared on type b3. | +| test.c:11:15:11:16 | b5 | Bit-field b5 is declared on type b5. | +| test.c:13:15:13:16 | b6 | Bit-field b6 is declared on type b6. | +| test.c:14:14:14:15 | b7 | Bit-field b7 is declared on type b7. | From 50049bfc3172c946ae999180534d5e43e08dc146 Mon Sep 17 00:00:00 2001 From: Jeongsoo Lee Date: Thu, 26 Jan 2023 13:10:04 -0800 Subject: [PATCH 08/23] Add some inline comments --- .../BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql b/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql index 29c662ca19..741e1824eb 100644 --- a/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql +++ b/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql @@ -20,16 +20,19 @@ predicate isSignedOrUnsignedInt(Type type) { } predicate isAppropriatePrimitive(Type type) { + /* An appropriate primitive types to which a bit-field can be declared. */ isSignedOrUnsignedInt(type) or type instanceof BoolType } predicate isAppropriateTypedef(Type type) { type instanceof TypedefType and + /* An appropriate typedef should be an alias to an appropriate primitive type. */ isAppropriatePrimitive(type.(TypedefType).resolveTypedefs()) } from BitField bitField where not isExcluded(bitField, TypesPackage::bitFieldsShallOnlyBeDeclaredWithAnAppropriateTypeQuery()) and +/* A violation would neither an appropriate primitive type nor an appropriate typedef. */ not (isAppropriatePrimitive(bitField.getType()) or isAppropriateTypedef(bitField.getType())) select bitField, "Bit-field " + bitField + " is declared on type " + bitField + "." \ No newline at end of file From 326534f3558d9c6fca5426e4c17feae0993e9d48 Mon Sep 17 00:00:00 2001 From: Jeongsoo Lee Date: Thu, 26 Jan 2023 16:35:11 -0800 Subject: [PATCH 09/23] add test.c and sketch query --- .../SingleBitNamedBitFieldsOfASignedType.ql | 35 +++++++++++++++++-- c/misra/test/rules/RULE-6-2/test.c | 17 +++++++++ 2 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 c/misra/test/rules/RULE-6-2/test.c diff --git a/c/misra/src/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql b/c/misra/src/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql index 436d7efab7..04a66535ad 100644 --- a/c/misra/src/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql +++ b/c/misra/src/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql @@ -13,7 +13,36 @@ import cpp import codingstandards.c.misra -from +predicate isSigned(Type type) { + /* Check if it's a fixed number type, because declaring fixed number types like int8_t as 1 bit is obviously absurd */ + type instanceof FixedWidthIntegralType or +/* Check if it's EXPLICITLY signed, because according to Rule 6.1, 'int' may be either signed or unsigned depending on the implementation. In the latter case, the query would lead to false positives. */ + type instanceof IntegralType and + type.(IntegralType).isExplicitlySigned() +} + +/* Check if the DECLARED bit-fields is a single bit, because Rule 6.2 also intends to catch confusion on the programmers' part. Consider: + +struct S { + int32_t x: 1; +} + +In this case, field x is essentially of 32 bits, but is declared as 1 bit and its type int32_t is signed. Therefore, it indicates confusion by the programmer, which is exactly what this rule intends to find. */ +predicate isSingleBit(BitField bitField) { + bitField.getDeclaredNumBits() = 1 +} + +// predicate isNamedBitField(BitField bitField) { +// bitField.getName().length() != 0 +// bitField.hasName(_) +// bitField.hasDefinition() +// wat +// } + +from BitField bitField where - not isExcluded(x, TypesPackage::singleBitNamedBitFieldsOfASignedTypeQuery()) and -select + not isExcluded(bitField, TypesPackage::singleBitNamedBitFieldsOfASignedTypeQuery()) and + isSingleBit(bitField) and // Single-bit, + // isNamedBitField(bitField) and // named, + isSigned(bitField.getType()) // but its type is signed. +select bitField, "Single-bit bit-field named " + bitField.toString() + " has a signed type " + bitField.getType() + "." \ No newline at end of file diff --git a/c/misra/test/rules/RULE-6-2/test.c b/c/misra/test/rules/RULE-6-2/test.c new file mode 100644 index 0000000000..9b18e986b9 --- /dev/null +++ b/c/misra/test/rules/RULE-6-2/test.c @@ -0,0 +1,17 @@ +#include + +struct SampleStruct { + int x1 : 1; // compilant: single-bit named field without signed declaration + signed int x2 : 1; // non_compilant: single-bit named field with a signed type + signed char + x3 : 1; // non_compilant: single-bit named field with a signed type + signed short + x4 : 1; // non_compilant: single-bit named field with a signed type + unsigned int + x5 : 1; // compilant: single-bit named field but with an unsigned type + signed int x6 : 2; // compilant: named field with a signed type but declared + // to carry more than 1 bit + int32_t x7 : 1; // non_compilant: single-bit named field that has single-bit + // bit-field, even though technically it has 32 bits + signed char : 1; // compilant: single-bit bit-field but unnamed +} sample_struct; \ No newline at end of file From abb35fc666be17aee585fff0d95fadbea2e93db0 Mon Sep 17 00:00:00 2001 From: Jeongsoo Lee Date: Fri, 27 Jan 2023 08:57:53 -0800 Subject: [PATCH 10/23] update --- .../RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql | 9 +-------- .../SingleBitNamedBitFieldsOfASignedType.expected | 5 ++++- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/c/misra/src/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql b/c/misra/src/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql index 04a66535ad..07e276b6ef 100644 --- a/c/misra/src/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql +++ b/c/misra/src/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql @@ -32,17 +32,10 @@ predicate isSingleBit(BitField bitField) { bitField.getDeclaredNumBits() = 1 } -// predicate isNamedBitField(BitField bitField) { -// bitField.getName().length() != 0 -// bitField.hasName(_) -// bitField.hasDefinition() -// wat -// } - from BitField bitField where not isExcluded(bitField, TypesPackage::singleBitNamedBitFieldsOfASignedTypeQuery()) and isSingleBit(bitField) and // Single-bit, - // isNamedBitField(bitField) and // named, + not bitField.isAnonymous() and // named, isSigned(bitField.getType()) // but its type is signed. select bitField, "Single-bit bit-field named " + bitField.toString() + " has a signed type " + bitField.getType() + "." \ No newline at end of file diff --git a/c/misra/test/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.expected b/c/misra/test/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.expected index 2ec1a0ac6c..c54bbafb38 100644 --- a/c/misra/test/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.expected +++ b/c/misra/test/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.expected @@ -1 +1,4 @@ -No expected results have yet been specified \ No newline at end of file +| test.c:5:14:5:15 | x2 | Single-bit bit-field named x2 has a signed type signed int. | +| test.c:7:7:7:8 | x3 | Single-bit bit-field named x3 has a signed type signed char. | +| test.c:9:7:9:8 | x4 | Single-bit bit-field named x4 has a signed type signed short. | +| test.c:14:11:14:12 | x7 | Single-bit bit-field named x7 has a signed type int32_t. | \ No newline at end of file From 77a4c55cb3303d50326d0df988b9ad31f76e555b Mon Sep 17 00:00:00 2001 From: Jeongsoo Lee Date: Fri, 27 Jan 2023 09:05:40 -0800 Subject: [PATCH 11/23] really minor formatting --- .../src/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/misra/src/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql b/c/misra/src/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql index 07e276b6ef..5950290fb7 100644 --- a/c/misra/src/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql +++ b/c/misra/src/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql @@ -16,7 +16,7 @@ import codingstandards.c.misra predicate isSigned(Type type) { /* Check if it's a fixed number type, because declaring fixed number types like int8_t as 1 bit is obviously absurd */ type instanceof FixedWidthIntegralType or -/* Check if it's EXPLICITLY signed, because according to Rule 6.1, 'int' may be either signed or unsigned depending on the implementation. In the latter case, the query would lead to false positives. */ + /* Check if it's EXPLICITLY signed, because according to Rule 6.1, 'int' may be either signed or unsigned depending on the implementation. In the latter case, the query would lead to false positives. */ type instanceof IntegralType and type.(IntegralType).isExplicitlySigned() } From 7796fdd27387bd82c54fc0862aff8286586b9b8b Mon Sep 17 00:00:00 2001 From: Jeongsoo Lee Date: Fri, 27 Jan 2023 09:47:48 -0800 Subject: [PATCH 12/23] separate out BitfieldTypes Update rules.csv, move 6-1 and 6-2 from Types.json to new file BitfieldTypes.json --- rule_packages/c/BitfieldTypes.json | 38 ++++++++++++++++++++++++++++++ rule_packages/c/Types.json | 34 -------------------------- rules.csv | 4 ++-- 3 files changed, 40 insertions(+), 36 deletions(-) create mode 100644 rule_packages/c/BitfieldTypes.json diff --git a/rule_packages/c/BitfieldTypes.json b/rule_packages/c/BitfieldTypes.json new file mode 100644 index 0000000000..4e93f3371a --- /dev/null +++ b/rule_packages/c/BitfieldTypes.json @@ -0,0 +1,38 @@ +{ + "MISRA-C-2012": { + "RULE-6-1": { + "properties": { + "obligation": "required" + }, + "queries": [ + { + "description": "Declaring bit-fields on types other than appropriate ones causes implementation-specific or undefined behavior.", + "kind": "problem", + "name": "Bit-fields shall only be declared with an appropriate type", + "precision": "very-high", + "severity": "error", + "short_name": "BitFieldsShallOnlyBeDeclaredWithAnAppropriateType", + "tags": [] + } + ], + "title": "Bit-fields shall only be declared with an appropriate type" + }, + "RULE-6-2": { + "properties": { + "obligation": "required" + }, + "queries": [ + { + "description": "Single-bit named bit fields carry no useful information and therefore should not be declared or used.", + "kind": "problem", + "name": "Single-bit named bit fields shall not be of a signed type", + "precision": "very-high", + "severity": "error", + "short_name": "SingleBitNamedBitFieldsOfASignedType", + "tags": [] + } + ], + "title": "Single-bit named bit fields shall not be of a signed type" + } + } +} \ No newline at end of file diff --git a/rule_packages/c/Types.json b/rule_packages/c/Types.json index cefcd6fec5..68b873dacd 100644 --- a/rule_packages/c/Types.json +++ b/rule_packages/c/Types.json @@ -461,40 +461,6 @@ ], "title": "The pointer arguments to the Standard Library function memcmp shall point to either a pointer type, an essentially signed type, an essentially unsigned type, an essentially Boolean type or an essentially enum type." }, - "RULE-6-1": { - "properties": { - "obligation": "required" - }, - "queries": [ - { - "description": "Declaring bit-fields on types other than appropriate ones causes implementation-specific or undefined behavior.", - "kind": "problem", - "name": "Bit-fields shall only be declared with an appropriate type", - "precision": "very-high", - "severity": "error", - "short_name": "BitFieldsShallOnlyBeDeclaredWithAnAppropriateType", - "tags": [] - } - ], - "title": "Bit-fields shall only be declared with an appropriate type" - }, - "RULE-6-2": { - "properties": { - "obligation": "required" - }, - "queries": [ - { - "description": "Single-bit named bit fields carry no useful information and therefore should not be declared or used.", - "kind": "problem", - "name": "Single-bit named bit fields shall not be of a signed type", - "precision": "very-high", - "severity": "error", - "short_name": "SingleBitNamedBitFieldsOfASignedType", - "tags": [] - } - ], - "title": "Single-bit named bit fields shall not be of a signed type" - }, "RULE-7-4": { "properties": { "obligation": "required" diff --git a/rules.csv b/rules.csv index f9c523c4ba..f5f653c321 100644 --- a/rules.csv +++ b/rules.csv @@ -640,8 +640,8 @@ c,MISRA-C-2012,RULE-5-6,Yes,Required,,,A typedef name shall be a unique identifi c,MISRA-C-2012,RULE-5-7,Yes,Required,,,A tag name shall be a unique identifier,,Declarations3,Easy, c,MISRA-C-2012,RULE-5-8,Yes,Required,,,Identifiers that define objects or functions with external linkage shall be unique,,Declarations6,Easy, c,MISRA-C-2012,RULE-5-9,Yes,Advisory,,,Identifiers that define objects or functions with internal linkage should be unique,,Declarations6,Easy, -c,MISRA-C-2012,RULE-6-1,Yes,Required,,,Bit-fields shall only be declared with an appropriate type,M9-6-4,Types,Medium, -c,MISRA-C-2012,RULE-6-2,Yes,Required,,,Single-bit named bit fields shall not be of a signed type,M9-6-4,Types,Import, +c,MISRA-C-2012,RULE-6-1,Yes,Required,,,Bit-fields shall only be declared with an appropriate type,M9-6-4,BitfieldTypes,Medium, +c,MISRA-C-2012,RULE-6-2,Yes,Required,,,Single-bit named bit fields shall not be of a signed type,M9-6-4,BitfieldTypes,Import, c,MISRA-C-2012,RULE-7-1,Yes,Required,,,Octal constants shall not be used,M2-13-2,Banned,Import, c,MISRA-C-2012,RULE-7-2,Yes,Required,,,A �u� or �U� suffix shall be applied to all integer constants that are represented in an unsigned type,M2-13-3,Syntax,Easy, c,MISRA-C-2012,RULE-7-3,Yes,Required,,,The lowercase character �l� shall not be used in a literal suffix,M2-13-4,Syntax,Easy, From 0e3bd23cf1ed18c28dfec6ee4cbde73a6b69378c Mon Sep 17 00:00:00 2001 From: Jeongsoo Lee Date: Fri, 27 Jan 2023 12:34:51 -0800 Subject: [PATCH 13/23] Remove previous files for rules in Types.json --- ...tectDomainAndRangeErrorsInMathFunctions.md | 18 -------- ...tectDomainAndRangeErrorsInMathFunctions.ql | 18 -------- ...PointConversionsNotWithinRangeOfNewType.md | 16 ------- ...PointConversionsNotWithinRangeOfNewType.ql | 18 -------- ...atingPointOfIntegralValuesLosePrecision.md | 16 ------- ...atingPointOfIntegralValuesLosePrecision.ql | 18 -------- ...ReprUsedForComparingFloatingPointValues.md | 16 ------- ...ReprUsedForComparingFloatingPointValues.ql | 18 -------- ...eThatUnsignedIntegerOperationsDoNotWrap.md | 16 ------- ...eThatUnsignedIntegerOperationsDoNotWrap.ql | 18 -------- ...onversionCausesLostOrMisinterpretedData.md | 16 ------- ...onversionCausesLostOrMisinterpretedData.ql | 18 -------- ...ationsOnSignedIntegersResultsInOverflow.md | 16 ------- ...ationsOnSignedIntegersResultsInOverflow.ql | 18 -------- .../DivAndModOperationResultsInDivByZero.md | 16 ------- .../DivAndModOperationResultsInDivByZero.ql | 18 -------- ...iftedByNegativeBitsOrGreaterThanOperand.md | 16 ------- ...iftedByNegativeBitsOrGreaterThanOperand.ql | 19 -------- .../INT35-C/UseCorrectIntegerPrecisions.md | 16 ------- .../INT35-C/UseCorrectIntegerPrecisions.ql | 18 -------- ...tingAPointerToIntegerOrIntegerToPointer.md | 16 ------- ...tingAPointerToIntegerOrIntegerToPointer.ql | 18 -------- ...defsNotUsedInPlaceOfBasicNumericalTypes.ql | 18 -------- .../OperandsOfAnInappropriateEssentialType.ql | 18 -------- .../RULE-10-2/CharTypeExprsUsedInAddOrSub.ql | 19 -------- .../AssignmentToIncompatibleEssentialType.ql | 19 -------- ...rsionOperandHasDifferentEssTypeCategory.ql | 19 -------- .../ValueCastToInappropriateEssentialType.ql | 18 -------- ...eExprValueAssignedToObjWithWiderEssType.ql | 18 -------- ...CompExprOperandHasWiderEssTypeThanOther.ql | 20 --------- .../CompExprValCastToIncompatEssType.ql | 19 -------- ...onstExprEvalCausesUnsignedIntWraparound.ql | 18 -------- .../ArrayTypeParamAtSizeofOperand.ql | 19 -------- .../LoopCounterHaveEssentiallyFloatingType.ql | 18 -------- ...typeFuncNeitherReprAsUnsignedCharNorEOF.ql | 19 -------- ...emcmpUsedToCompareNullTerminatedStrings.ql | 18 -------- ...MemmoveMemcmpArgNotPointerToCompatTypes.ql | 19 -------- ...otPtsToSignedUnsignedBooleanEnumEssType.ql | 20 --------- ...ralAssignedToObjPtrToConstQualifiedChar.ql | 19 -------- .../cpp/exclusions/c/BitfieldTypes.qll | 44 +++++++++++++++++++ 40 files changed, 44 insertions(+), 695 deletions(-) delete mode 100644 c/cert/src/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.md delete mode 100644 c/cert/src/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.ql delete mode 100644 c/cert/src/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.md delete mode 100644 c/cert/src/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.ql delete mode 100644 c/cert/src/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.md delete mode 100644 c/cert/src/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.ql delete mode 100644 c/cert/src/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.md delete mode 100644 c/cert/src/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.ql delete mode 100644 c/cert/src/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.md delete mode 100644 c/cert/src/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.ql delete mode 100644 c/cert/src/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.md delete mode 100644 c/cert/src/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.ql delete mode 100644 c/cert/src/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.md delete mode 100644 c/cert/src/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.ql delete mode 100644 c/cert/src/rules/INT33-C/DivAndModOperationResultsInDivByZero.md delete mode 100644 c/cert/src/rules/INT33-C/DivAndModOperationResultsInDivByZero.ql delete mode 100644 c/cert/src/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.md delete mode 100644 c/cert/src/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.ql delete mode 100644 c/cert/src/rules/INT35-C/UseCorrectIntegerPrecisions.md delete mode 100644 c/cert/src/rules/INT35-C/UseCorrectIntegerPrecisions.ql delete mode 100644 c/cert/src/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.md delete mode 100644 c/cert/src/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.ql delete mode 100644 c/misra/src/rules/DIR-4-6/NumericTypedefsNotUsedInPlaceOfBasicNumericalTypes.ql delete mode 100644 c/misra/src/rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.ql delete mode 100644 c/misra/src/rules/RULE-10-2/CharTypeExprsUsedInAddOrSub.ql delete mode 100644 c/misra/src/rules/RULE-10-3/AssignmentToIncompatibleEssentialType.ql delete mode 100644 c/misra/src/rules/RULE-10-4/ArithConversionOperandHasDifferentEssTypeCategory.ql delete mode 100644 c/misra/src/rules/RULE-10-5/ValueCastToInappropriateEssentialType.ql delete mode 100644 c/misra/src/rules/RULE-10-6/CompositeExprValueAssignedToObjWithWiderEssType.ql delete mode 100644 c/misra/src/rules/RULE-10-7/ConvertedCompExprOperandHasWiderEssTypeThanOther.ql delete mode 100644 c/misra/src/rules/RULE-10-8/CompExprValCastToIncompatEssType.ql delete mode 100644 c/misra/src/rules/RULE-12-4/ConstExprEvalCausesUnsignedIntWraparound.ql delete mode 100644 c/misra/src/rules/RULE-12-5/ArrayTypeParamAtSizeofOperand.ql delete mode 100644 c/misra/src/rules/RULE-14-1/LoopCounterHaveEssentiallyFloatingType.ql delete mode 100644 c/misra/src/rules/RULE-21-13/CtypeFuncNeitherReprAsUnsignedCharNorEOF.ql delete mode 100644 c/misra/src/rules/RULE-21-14/MemcmpUsedToCompareNullTerminatedStrings.ql delete mode 100644 c/misra/src/rules/RULE-21-15/MemcpyMemmoveMemcmpArgNotPointerToCompatTypes.ql delete mode 100644 c/misra/src/rules/RULE-21-16/MemcmpArgNotPtsToSignedUnsignedBooleanEnumEssType.ql delete mode 100644 c/misra/src/rules/RULE-7-4/StringLiteralAssignedToObjPtrToConstQualifiedChar.ql create mode 100644 cpp/common/src/codingstandards/cpp/exclusions/c/BitfieldTypes.qll diff --git a/c/cert/src/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.md b/c/cert/src/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.md deleted file mode 100644 index 4083d3f36b..0000000000 --- a/c/cert/src/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.md +++ /dev/null @@ -1,18 +0,0 @@ -# FLP32-C: Prevent or detect domain and range errors in math functions - -This query implements the CERT-C rule FLP32-C: - -> Prevent or detect domain and range errors in math functions - - -## CERT - -** REPLACE THIS BY RUNNING THE SCRIPT `scripts/help/cert-help-extraction.py` ** - -## Implementation notes - -None - -## References - -* CERT-C: [FLP32-C: Prevent or detect domain and range errors in math functions](https://wiki.sei.cmu.edu/confluence/display/c) diff --git a/c/cert/src/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.ql b/c/cert/src/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.ql deleted file mode 100644 index 5b86641326..0000000000 --- a/c/cert/src/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.ql +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @id c/cert/prevent-or-detect-domain-and-range-errors-in-math-functions - * @name FLP32-C: Prevent or detect domain and range errors in math functions - * @description TODO. - * @kind problem - * @precision very-high - * @problem.severity error - * @tags external/cert/id/flp32-c - * external/cert/obligation/rule - */ - -import cpp -import codingstandards.c.cert - -from -where - not isExcluded(x, TypesPackage::preventOrDetectDomainAndRangeErrorsInMathFunctionsQuery()) and -select diff --git a/c/cert/src/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.md b/c/cert/src/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.md deleted file mode 100644 index 8b22986f7d..0000000000 --- a/c/cert/src/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.md +++ /dev/null @@ -1,16 +0,0 @@ -# FLP34-C: Ensure that floating-point conversions are within range of the new type - -This query implements the CERT-C rule FLP34-C: - -> Ensure that floating-point conversions are within range of the new type -## CERT - -** REPLACE THIS BY RUNNING THE SCRIPT `scripts/help/cert-help-extraction.py` ** - -## Implementation notes - -None - -## References - -* CERT-C: [FLP34-C: Ensure that floating-point conversions are within range of the new type](https://wiki.sei.cmu.edu/confluence/display/c) diff --git a/c/cert/src/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.ql b/c/cert/src/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.ql deleted file mode 100644 index fe7a1b581a..0000000000 --- a/c/cert/src/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.ql +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @id c/cert/floating-point-conversions-not-within-range-of-new-type - * @name FLP34-C: Ensure that floating-point conversions are within range of the new type - * @description TODO. - * @kind problem - * @precision very-high - * @problem.severity error - * @tags external/cert/id/flp34-c - * external/cert/obligation/rule - */ - -import cpp -import codingstandards.c.cert - -from -where - not isExcluded(x, TypesPackage::floatingPointConversionsNotWithinRangeOfNewTypeQuery()) and -select diff --git a/c/cert/src/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.md b/c/cert/src/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.md deleted file mode 100644 index bac78b4ddd..0000000000 --- a/c/cert/src/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.md +++ /dev/null @@ -1,16 +0,0 @@ -# FLP36-C: Preserve precision when converting integral values to floating-point type - -This query implements the CERT-C rule FLP36-C: - -> Preserve precision when converting integral values to floating-point type -## CERT - -** REPLACE THIS BY RUNNING THE SCRIPT `scripts/help/cert-help-extraction.py` ** - -## Implementation notes - -None - -## References - -* CERT-C: [FLP36-C: Preserve precision when converting integral values to floating-point type](https://wiki.sei.cmu.edu/confluence/display/c) diff --git a/c/cert/src/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.ql b/c/cert/src/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.ql deleted file mode 100644 index 6d61c6aff7..0000000000 --- a/c/cert/src/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.ql +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @id c/cert/floating-point-of-integral-values-lose-precision - * @name FLP36-C: Preserve precision when converting integral values to floating-point type - * @description TODO. - * @kind problem - * @precision very-high - * @problem.severity error - * @tags external/cert/id/flp36-c - * external/cert/obligation/rule - */ - -import cpp -import codingstandards.c.cert - -from -where - not isExcluded(x, TypesPackage::floatingPointOfIntegralValuesLosePrecisionQuery()) and -select diff --git a/c/cert/src/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.md b/c/cert/src/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.md deleted file mode 100644 index 8b738b87cd..0000000000 --- a/c/cert/src/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.md +++ /dev/null @@ -1,16 +0,0 @@ -# FLP37-C: Do not use object representations to compare floating-point values - -This query implements the CERT-C rule FLP37-C: - -> Do not use object representations to compare floating-point values -## CERT - -** REPLACE THIS BY RUNNING THE SCRIPT `scripts/help/cert-help-extraction.py` ** - -## Implementation notes - -None - -## References - -* CERT-C: [FLP37-C: Do not use object representations to compare floating-point values](https://wiki.sei.cmu.edu/confluence/display/c) diff --git a/c/cert/src/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.ql b/c/cert/src/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.ql deleted file mode 100644 index 24fdd70dc4..0000000000 --- a/c/cert/src/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.ql +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @id c/cert/object-repr-used-for-comparing-floating-point-values - * @name FLP37-C: Do not use object representations to compare floating-point values - * @description TODO. - * @kind problem - * @precision very-high - * @problem.severity error - * @tags external/cert/id/flp37-c - * external/cert/obligation/rule - */ - -import cpp -import codingstandards.c.cert - -from -where - not isExcluded(x, TypesPackage::objectReprUsedForComparingFloatingPointValuesQuery()) and -select diff --git a/c/cert/src/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.md b/c/cert/src/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.md deleted file mode 100644 index 402fd7f64a..0000000000 --- a/c/cert/src/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.md +++ /dev/null @@ -1,16 +0,0 @@ -# INT30-C: Ensure that unsigned integer operations do not wrap - -This query implements the CERT-C rule INT30-C: - -> Ensure that unsigned integer operations do not wrap -## CERT - -** REPLACE THIS BY RUNNING THE SCRIPT `scripts/help/cert-help-extraction.py` ** - -## Implementation notes - -None - -## References - -* CERT-C: [INT30-C: Ensure that unsigned integer operations do not wrap](https://wiki.sei.cmu.edu/confluence/display/c) diff --git a/c/cert/src/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.ql b/c/cert/src/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.ql deleted file mode 100644 index c6901a73b1..0000000000 --- a/c/cert/src/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.ql +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @id c/cert/ensure-that-unsigned-integer-operations-do-not-wrap - * @name INT30-C: Ensure that unsigned integer operations do not wrap - * @description TODO. - * @kind problem - * @precision high - * @problem.severity error - * @tags external/cert/id/int30-c - * external/cert/obligation/rule - */ - -import cpp -import codingstandards.c.cert - -from -where - not isExcluded(x, TypesPackage::ensureThatUnsignedIntegerOperationsDoNotWrapQuery()) and -select diff --git a/c/cert/src/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.md b/c/cert/src/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.md deleted file mode 100644 index 3c475e4a77..0000000000 --- a/c/cert/src/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.md +++ /dev/null @@ -1,16 +0,0 @@ -# INT31-C: Ensure that integer conversions do not result in lost or misinterpreted data - -This query implements the CERT-C rule INT31-C: - -> Ensure that integer conversions do not result in lost or misinterpreted data -## CERT - -** REPLACE THIS BY RUNNING THE SCRIPT `scripts/help/cert-help-extraction.py` ** - -## Implementation notes - -None - -## References - -* CERT-C: [INT31-C: Ensure that integer conversions do not result in lost or misinterpreted data](https://wiki.sei.cmu.edu/confluence/display/c) diff --git a/c/cert/src/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.ql b/c/cert/src/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.ql deleted file mode 100644 index 0e994c017f..0000000000 --- a/c/cert/src/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.ql +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @id c/cert/int-conversion-causes-lost-or-misinterpreted-data - * @name INT31-C: Ensure that integer conversions do not result in lost or misinterpreted data - * @description TODO. - * @kind problem - * @precision high - * @problem.severity error - * @tags external/cert/id/int31-c - * external/cert/obligation/rule - */ - -import cpp -import codingstandards.c.cert - -from -where - not isExcluded(x, TypesPackage::intConversionCausesLostOrMisinterpretedDataQuery()) and -select diff --git a/c/cert/src/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.md b/c/cert/src/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.md deleted file mode 100644 index 84dc8fe143..0000000000 --- a/c/cert/src/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.md +++ /dev/null @@ -1,16 +0,0 @@ -# INT32-C: Ensure that operations on signed integers do not result in overflow - -This query implements the CERT-C rule INT32-C: - -> Ensure that operations on signed integers do not result in overflow -## CERT - -** REPLACE THIS BY RUNNING THE SCRIPT `scripts/help/cert-help-extraction.py` ** - -## Implementation notes - -None - -## References - -* CERT-C: [INT32-C: Ensure that operations on signed integers do not result in overflow](https://wiki.sei.cmu.edu/confluence/display/c) diff --git a/c/cert/src/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.ql b/c/cert/src/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.ql deleted file mode 100644 index 2495050987..0000000000 --- a/c/cert/src/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.ql +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @id c/cert/operations-on-signed-integers-results-in-overflow - * @name INT32-C: Ensure that operations on signed integers do not result in overflow - * @description TODO. - * @kind problem - * @precision high - * @problem.severity error - * @tags external/cert/id/int32-c - * external/cert/obligation/rule - */ - -import cpp -import codingstandards.c.cert - -from -where - not isExcluded(x, TypesPackage::operationsOnSignedIntegersResultsInOverflowQuery()) and -select diff --git a/c/cert/src/rules/INT33-C/DivAndModOperationResultsInDivByZero.md b/c/cert/src/rules/INT33-C/DivAndModOperationResultsInDivByZero.md deleted file mode 100644 index 6a86d3e88d..0000000000 --- a/c/cert/src/rules/INT33-C/DivAndModOperationResultsInDivByZero.md +++ /dev/null @@ -1,16 +0,0 @@ -# INT33-C: Ensure that division and remainder operations do not result in divide-by-zero errors - -This query implements the CERT-C rule INT33-C: - -> Ensure that division and remainder operations do not result in divide-by-zero errors -## CERT - -** REPLACE THIS BY RUNNING THE SCRIPT `scripts/help/cert-help-extraction.py` ** - -## Implementation notes - -None - -## References - -* CERT-C: [INT33-C: Ensure that division and remainder operations do not result in divide-by-zero errors](https://wiki.sei.cmu.edu/confluence/display/c) diff --git a/c/cert/src/rules/INT33-C/DivAndModOperationResultsInDivByZero.ql b/c/cert/src/rules/INT33-C/DivAndModOperationResultsInDivByZero.ql deleted file mode 100644 index 4385d79f2e..0000000000 --- a/c/cert/src/rules/INT33-C/DivAndModOperationResultsInDivByZero.ql +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @id c/cert/div-and-mod-operation-results-in-div-by-zero - * @name INT33-C: Ensure that division and remainder operations do not result in divide-by-zero errors - * @description TODO. - * @kind problem - * @precision high - * @problem.severity error - * @tags external/cert/id/int33-c - * external/cert/obligation/rule - */ - -import cpp -import codingstandards.c.cert - -from -where - not isExcluded(x, TypesPackage::divAndModOperationResultsInDivByZeroQuery()) and -select diff --git a/c/cert/src/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.md b/c/cert/src/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.md deleted file mode 100644 index 66c3d5a7a0..0000000000 --- a/c/cert/src/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.md +++ /dev/null @@ -1,16 +0,0 @@ -# INT34-C: Do not shift an expression by a negative number of bits or by greater than or equal to the number of - -This query implements the CERT-C rule INT34-C: - -> Do not shift an expression by a negative number of bits or by greater than or equal to the number of bits that exist in the operand -## CERT - -** REPLACE THIS BY RUNNING THE SCRIPT `scripts/help/cert-help-extraction.py` ** - -## Implementation notes - -None - -## References - -* CERT-C: [INT34-C: Do not shift an expression by a negative number of bits or by greater than or equal to the number of bits that exist in the operand](https://wiki.sei.cmu.edu/confluence/display/c) diff --git a/c/cert/src/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.ql b/c/cert/src/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.ql deleted file mode 100644 index f7a0759b6c..0000000000 --- a/c/cert/src/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.ql +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @id c/cert/expr-shifted-by-negative-bits-or-greater-than-operand - * @name INT34-C: Do not shift an expression by a negative number of bits or by greater than or equal to the number of - * @description Do not shift an expression by a negative number of bits or by greater than or equal - * to the number of bits that exist in the operand. - * @kind problem - * @precision very-high - * @problem.severity error - * @tags external/cert/id/int34-c - * external/cert/obligation/rule - */ - -import cpp -import codingstandards.c.cert - -from -where - not isExcluded(x, TypesPackage::exprShiftedByNegativeBitsOrGreaterThanOperandQuery()) and -select diff --git a/c/cert/src/rules/INT35-C/UseCorrectIntegerPrecisions.md b/c/cert/src/rules/INT35-C/UseCorrectIntegerPrecisions.md deleted file mode 100644 index aaf89abe74..0000000000 --- a/c/cert/src/rules/INT35-C/UseCorrectIntegerPrecisions.md +++ /dev/null @@ -1,16 +0,0 @@ -# INT35-C: Use correct integer precisions - -This query implements the CERT-C rule INT35-C: - -> Use correct integer precisions -## CERT - -** REPLACE THIS BY RUNNING THE SCRIPT `scripts/help/cert-help-extraction.py` ** - -## Implementation notes - -None - -## References - -* CERT-C: [INT35-C: Use correct integer precisions](https://wiki.sei.cmu.edu/confluence/display/c) diff --git a/c/cert/src/rules/INT35-C/UseCorrectIntegerPrecisions.ql b/c/cert/src/rules/INT35-C/UseCorrectIntegerPrecisions.ql deleted file mode 100644 index 41c25374e1..0000000000 --- a/c/cert/src/rules/INT35-C/UseCorrectIntegerPrecisions.ql +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @id c/cert/use-correct-integer-precisions - * @name INT35-C: Use correct integer precisions - * @description TODO. - * @kind problem - * @precision high - * @problem.severity error - * @tags external/cert/id/int35-c - * external/cert/obligation/rule - */ - -import cpp -import codingstandards.c.cert - -from -where - not isExcluded(x, TypesPackage::useCorrectIntegerPrecisionsQuery()) and -select diff --git a/c/cert/src/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.md b/c/cert/src/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.md deleted file mode 100644 index 6df9d2afff..0000000000 --- a/c/cert/src/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.md +++ /dev/null @@ -1,16 +0,0 @@ -# INT36-C: Converting a pointer to integer or integer to pointer - -This query implements the CERT-C rule INT36-C: - -> Converting a pointer to integer or integer to pointer -## CERT - -** REPLACE THIS BY RUNNING THE SCRIPT `scripts/help/cert-help-extraction.py` ** - -## Implementation notes - -None - -## References - -* CERT-C: [INT36-C: Converting a pointer to integer or integer to pointer](https://wiki.sei.cmu.edu/confluence/display/c) diff --git a/c/cert/src/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.ql b/c/cert/src/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.ql deleted file mode 100644 index 8fc0096b6e..0000000000 --- a/c/cert/src/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.ql +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @id c/cert/converting-a-pointer-to-integer-or-integer-to-pointer - * @name INT36-C: Converting a pointer to integer or integer to pointer - * @description TODO. - * @kind problem - * @precision very-high - * @problem.severity error - * @tags external/cert/id/int36-c - * external/cert/obligation/rule - */ - -import cpp -import codingstandards.c.cert - -from -where - not isExcluded(x, TypesPackage::convertingAPointerToIntegerOrIntegerToPointerQuery()) and -select diff --git a/c/misra/src/rules/DIR-4-6/NumericTypedefsNotUsedInPlaceOfBasicNumericalTypes.ql b/c/misra/src/rules/DIR-4-6/NumericTypedefsNotUsedInPlaceOfBasicNumericalTypes.ql deleted file mode 100644 index 0b9a284e56..0000000000 --- a/c/misra/src/rules/DIR-4-6/NumericTypedefsNotUsedInPlaceOfBasicNumericalTypes.ql +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @id c/misra/numeric-typedefs-not-used-in-place-of-basic-numerical-types - * @name DIR-4-6: typedefs that indicate size and signedness should be used in place of the basic numerical types - * @description TODO. - * @kind problem - * @precision high - * @problem.severity error - * @tags external/misra/id/dir-4-6 - * external/misra/obligation/advisory - */ - -import cpp -import codingstandards.c.misra - -from -where - not isExcluded(x, TypesPackage::numericTypedefsNotUsedInPlaceOfBasicNumericalTypesQuery()) and -select diff --git a/c/misra/src/rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.ql b/c/misra/src/rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.ql deleted file mode 100644 index 65e515a87d..0000000000 --- a/c/misra/src/rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.ql +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @id c/misra/operands-of-an-inappropriate-essential-type - * @name RULE-10-1: Operands shall not be of an inappropriate essential type - * @description TODO. - * @kind problem - * @precision high - * @problem.severity error - * @tags external/misra/id/rule-10-1 - * external/misra/obligation/required - */ - -import cpp -import codingstandards.c.misra - -from -where - not isExcluded(x, TypesPackage::operandsOfAnInappropriateEssentialTypeQuery()) and -select diff --git a/c/misra/src/rules/RULE-10-2/CharTypeExprsUsedInAddOrSub.ql b/c/misra/src/rules/RULE-10-2/CharTypeExprsUsedInAddOrSub.ql deleted file mode 100644 index f64bdcc980..0000000000 --- a/c/misra/src/rules/RULE-10-2/CharTypeExprsUsedInAddOrSub.ql +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @id c/misra/char-type-exprs-used-in-add-or-sub - * @name RULE-10-2: Expressions of essentially character type shall not be used inappropriately in addition and - * @description Expressions of essentially character type shall not be used inappropriately in - * addition and subtraction operations. - * @kind problem - * @precision very-high - * @problem.severity error - * @tags external/misra/id/rule-10-2 - * external/misra/obligation/required - */ - -import cpp -import codingstandards.c.misra - -from -where - not isExcluded(x, TypesPackage::charTypeExprsUsedInAddOrSubQuery()) and -select diff --git a/c/misra/src/rules/RULE-10-3/AssignmentToIncompatibleEssentialType.ql b/c/misra/src/rules/RULE-10-3/AssignmentToIncompatibleEssentialType.ql deleted file mode 100644 index 6d0a0c5aba..0000000000 --- a/c/misra/src/rules/RULE-10-3/AssignmentToIncompatibleEssentialType.ql +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @id c/misra/assignment-to-incompatible-essential-type - * @name RULE-10-3: The value of an expression shall not be assigned to an object with a narrower essential type or of a - * @description The value of an expression shall not be assigned to an object with a narrower - * essential type or of a different essential type category. - * @kind problem - * @precision high - * @problem.severity error - * @tags external/misra/id/rule-10-3 - * external/misra/obligation/required - */ - -import cpp -import codingstandards.c.misra - -from -where - not isExcluded(x, TypesPackage::assignmentToIncompatibleEssentialTypeQuery()) and -select diff --git a/c/misra/src/rules/RULE-10-4/ArithConversionOperandHasDifferentEssTypeCategory.ql b/c/misra/src/rules/RULE-10-4/ArithConversionOperandHasDifferentEssTypeCategory.ql deleted file mode 100644 index cc27e5b693..0000000000 --- a/c/misra/src/rules/RULE-10-4/ArithConversionOperandHasDifferentEssTypeCategory.ql +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @id c/misra/arith-conversion-operand-has-different-ess-type-category - * @name RULE-10-4: Both operands of an operator in which the usual arithmetic conversions are performed shall have the - * @description Both operands of an operator in which the usual arithmetic conversions are performed - * shall have the same essential type category. - * @kind problem - * @precision very-high - * @problem.severity error - * @tags external/misra/id/rule-10-4 - * external/misra/obligation/required - */ - -import cpp -import codingstandards.c.misra - -from -where - not isExcluded(x, TypesPackage::arithConversionOperandHasDifferentEssTypeCategoryQuery()) and -select diff --git a/c/misra/src/rules/RULE-10-5/ValueCastToInappropriateEssentialType.ql b/c/misra/src/rules/RULE-10-5/ValueCastToInappropriateEssentialType.ql deleted file mode 100644 index ebdddc2910..0000000000 --- a/c/misra/src/rules/RULE-10-5/ValueCastToInappropriateEssentialType.ql +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @id c/misra/value-cast-to-inappropriate-essential-type - * @name RULE-10-5: The value of an expression should not be cast to an inappropriate essential type - * @description TODO. - * @kind problem - * @precision very-high - * @problem.severity error - * @tags external/misra/id/rule-10-5 - * external/misra/obligation/advisory - */ - -import cpp -import codingstandards.c.misra - -from -where - not isExcluded(x, TypesPackage::valueCastToInappropriateEssentialTypeQuery()) and -select diff --git a/c/misra/src/rules/RULE-10-6/CompositeExprValueAssignedToObjWithWiderEssType.ql b/c/misra/src/rules/RULE-10-6/CompositeExprValueAssignedToObjWithWiderEssType.ql deleted file mode 100644 index 968edd026a..0000000000 --- a/c/misra/src/rules/RULE-10-6/CompositeExprValueAssignedToObjWithWiderEssType.ql +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @id c/misra/composite-expr-value-assigned-to-obj-with-wider-ess-type - * @name RULE-10-6: The value of a composite expression shall not be assigned to an object with wider essential type - * @description TODO. - * @kind problem - * @precision very-high - * @problem.severity error - * @tags external/misra/id/rule-10-6 - * external/misra/obligation/required - */ - -import cpp -import codingstandards.c.misra - -from -where - not isExcluded(x, TypesPackage::compositeExprValueAssignedToObjWithWiderEssTypeQuery()) and -select diff --git a/c/misra/src/rules/RULE-10-7/ConvertedCompExprOperandHasWiderEssTypeThanOther.ql b/c/misra/src/rules/RULE-10-7/ConvertedCompExprOperandHasWiderEssTypeThanOther.ql deleted file mode 100644 index 73d5fd0d30..0000000000 --- a/c/misra/src/rules/RULE-10-7/ConvertedCompExprOperandHasWiderEssTypeThanOther.ql +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @id c/misra/converted-comp-expr-operand-has-wider-ess-type-than-other - * @name RULE-10-7: If a composite expression is used as one operand of an operator in which the usual arithmetic - * @description If a composite expression is used as one operand of an operator in which the usual - * arithmetic conversions are performed then the other operand shall not have wider - * essential type. - * @kind problem - * @precision very-high - * @problem.severity error - * @tags external/misra/id/rule-10-7 - * external/misra/obligation/required - */ - -import cpp -import codingstandards.c.misra - -from -where - not isExcluded(x, TypesPackage::convertedCompExprOperandHasWiderEssTypeThanOtherQuery()) and -select diff --git a/c/misra/src/rules/RULE-10-8/CompExprValCastToIncompatEssType.ql b/c/misra/src/rules/RULE-10-8/CompExprValCastToIncompatEssType.ql deleted file mode 100644 index 5937b33bd4..0000000000 --- a/c/misra/src/rules/RULE-10-8/CompExprValCastToIncompatEssType.ql +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @id c/misra/comp-expr-val-cast-to-incompat-ess-type - * @name RULE-10-8: The value of a composite expression shall not be cast to a different essential type category or a - * @description The value of a composite expression shall not be cast to a different essential type - * category or a wider essential type. - * @kind problem - * @precision very-high - * @problem.severity error - * @tags external/misra/id/rule-10-8 - * external/misra/obligation/required - */ - -import cpp -import codingstandards.c.misra - -from -where - not isExcluded(x, TypesPackage::compExprValCastToIncompatEssTypeQuery()) and -select diff --git a/c/misra/src/rules/RULE-12-4/ConstExprEvalCausesUnsignedIntWraparound.ql b/c/misra/src/rules/RULE-12-4/ConstExprEvalCausesUnsignedIntWraparound.ql deleted file mode 100644 index 86001f7cfb..0000000000 --- a/c/misra/src/rules/RULE-12-4/ConstExprEvalCausesUnsignedIntWraparound.ql +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @id c/misra/const-expr-eval-causes-unsigned-int-wraparound - * @name RULE-12-4: Evaluation of constant expressions should not lead to unsigned integer wrap-around - * @description TODO. - * @kind problem - * @precision very-high - * @problem.severity error - * @tags external/misra/id/rule-12-4 - * external/misra/obligation/advisory - */ - -import cpp -import codingstandards.c.misra - -from -where - not isExcluded(x, TypesPackage::constExprEvalCausesUnsignedIntWraparoundQuery()) and -select diff --git a/c/misra/src/rules/RULE-12-5/ArrayTypeParamAtSizeofOperand.ql b/c/misra/src/rules/RULE-12-5/ArrayTypeParamAtSizeofOperand.ql deleted file mode 100644 index 2c67b24759..0000000000 --- a/c/misra/src/rules/RULE-12-5/ArrayTypeParamAtSizeofOperand.ql +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @id c/misra/array-type-param-at-sizeof-operand - * @name RULE-12-5: The sizeof operator shall not have an operand which is a function parameter declared as 'array of - * @description The sizeof operator shall not have an operand which is a function parameter declared - * as 'array of type'. - * @kind problem - * @precision very-high - * @problem.severity error - * @tags external/misra/id/rule-12-5 - * external/misra/obligation/mandatory - */ - -import cpp -import codingstandards.c.misra - -from -where - not isExcluded(x, TypesPackage::arrayTypeParamAtSizeofOperandQuery()) and -select diff --git a/c/misra/src/rules/RULE-14-1/LoopCounterHaveEssentiallyFloatingType.ql b/c/misra/src/rules/RULE-14-1/LoopCounterHaveEssentiallyFloatingType.ql deleted file mode 100644 index 9b0b57148d..0000000000 --- a/c/misra/src/rules/RULE-14-1/LoopCounterHaveEssentiallyFloatingType.ql +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @id c/misra/loop-counter-have-essentially-floating-type - * @name RULE-14-1: A loop counter shall not have essentially floating type - * @description TODO. - * @kind problem - * @precision high - * @problem.severity error - * @tags external/misra/id/rule-14-1 - * external/misra/obligation/required - */ - -import cpp -import codingstandards.c.misra - -from -where - not isExcluded(x, TypesPackage::loopCounterHaveEssentiallyFloatingTypeQuery()) and -select diff --git a/c/misra/src/rules/RULE-21-13/CtypeFuncNeitherReprAsUnsignedCharNorEOF.ql b/c/misra/src/rules/RULE-21-13/CtypeFuncNeitherReprAsUnsignedCharNorEOF.ql deleted file mode 100644 index ea070a1aa9..0000000000 --- a/c/misra/src/rules/RULE-21-13/CtypeFuncNeitherReprAsUnsignedCharNorEOF.ql +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @id c/misra/ctype-func-neither-repr-as-unsigned-char-nor-eof - * @name RULE-21-13: Any value passed to a function in shall be representable as an unsigned char or be the - * @description Any value passed to a function in shall be representable as an unsigned - * char or be the value EOF. - * @kind problem - * @precision very-high - * @problem.severity error - * @tags external/misra/id/rule-21-13 - * external/misra/obligation/mandatory - */ - -import cpp -import codingstandards.c.misra - -from -where - not isExcluded(x, TypesPackage::ctypeFuncNeitherReprAsUnsignedCharNorEOFQuery()) and -select diff --git a/c/misra/src/rules/RULE-21-14/MemcmpUsedToCompareNullTerminatedStrings.ql b/c/misra/src/rules/RULE-21-14/MemcmpUsedToCompareNullTerminatedStrings.ql deleted file mode 100644 index 362985892f..0000000000 --- a/c/misra/src/rules/RULE-21-14/MemcmpUsedToCompareNullTerminatedStrings.ql +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @id c/misra/memcmp-used-to-compare-null-terminated-strings - * @name RULE-21-14: The Standard Library function memcmp shall not be used to compare null terminated strings - * @description TODO. - * @kind problem - * @precision high - * @problem.severity error - * @tags external/misra/id/rule-21-14 - * external/misra/obligation/required - */ - -import cpp -import codingstandards.c.misra - -from -where - not isExcluded(x, TypesPackage::memcmpUsedToCompareNullTerminatedStringsQuery()) and -select diff --git a/c/misra/src/rules/RULE-21-15/MemcpyMemmoveMemcmpArgNotPointerToCompatTypes.ql b/c/misra/src/rules/RULE-21-15/MemcpyMemmoveMemcmpArgNotPointerToCompatTypes.ql deleted file mode 100644 index 857f066615..0000000000 --- a/c/misra/src/rules/RULE-21-15/MemcpyMemmoveMemcmpArgNotPointerToCompatTypes.ql +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @id c/misra/memcpy-memmove-memcmp-arg-not-pointer-to-compat-types - * @name RULE-21-15: The pointer arguments to the Standard Library functions memcpy, memmove and memcmp shall be pointers - * @description The pointer arguments to the Standard Library functions memcpy, memmove and memcmp - * shall be pointers to qualified or unqualified versions of compatible types. - * @kind problem - * @precision very-high - * @problem.severity error - * @tags external/misra/id/rule-21-15 - * external/misra/obligation/required - */ - -import cpp -import codingstandards.c.misra - -from -where - not isExcluded(x, TypesPackage::memcpyMemmoveMemcmpArgNotPointerToCompatTypesQuery()) and -select diff --git a/c/misra/src/rules/RULE-21-16/MemcmpArgNotPtsToSignedUnsignedBooleanEnumEssType.ql b/c/misra/src/rules/RULE-21-16/MemcmpArgNotPtsToSignedUnsignedBooleanEnumEssType.ql deleted file mode 100644 index b78ac3715f..0000000000 --- a/c/misra/src/rules/RULE-21-16/MemcmpArgNotPtsToSignedUnsignedBooleanEnumEssType.ql +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @id c/misra/memcmp-arg-not-pts-to-signed-unsigned-boolean-enum-ess-type - * @name RULE-21-16: The pointer arguments to the Standard Library function memcmp shall point to either a pointer type, - * @description The pointer arguments to the Standard Library function memcmp shall point to either - * a pointer type, an essentially signed type, an essentially unsigned type, an - * essentially Boolean type or an essentially enum type. - * @kind problem - * @precision very-high - * @problem.severity error - * @tags external/misra/id/rule-21-16 - * external/misra/obligation/required - */ - -import cpp -import codingstandards.c.misra - -from -where - not isExcluded(x, TypesPackage::memcmpArgNotPtsToSignedUnsignedBooleanEnumEssTypeQuery()) and -select diff --git a/c/misra/src/rules/RULE-7-4/StringLiteralAssignedToObjPtrToConstQualifiedChar.ql b/c/misra/src/rules/RULE-7-4/StringLiteralAssignedToObjPtrToConstQualifiedChar.ql deleted file mode 100644 index 54328526d4..0000000000 --- a/c/misra/src/rules/RULE-7-4/StringLiteralAssignedToObjPtrToConstQualifiedChar.ql +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @id c/misra/string-literal-assigned-to-obj-ptr-to-const-qualified-char - * @name RULE-7-4: A string literal shall not be assigned to an object unless the object's type is 'pointer to - * @description A string literal shall not be assigned to an object unless the object's type is - * 'pointer to const-qualified char'. - * @kind problem - * @precision very-high - * @problem.severity error - * @tags external/misra/id/rule-7-4 - * external/misra/obligation/required - */ - -import cpp -import codingstandards.c.misra - -from -where - not isExcluded(x, TypesPackage::stringLiteralAssignedToObjPtrToConstQualifiedCharQuery()) and -select diff --git a/cpp/common/src/codingstandards/cpp/exclusions/c/BitfieldTypes.qll b/cpp/common/src/codingstandards/cpp/exclusions/c/BitfieldTypes.qll new file mode 100644 index 0000000000..ef9e94b27a --- /dev/null +++ b/cpp/common/src/codingstandards/cpp/exclusions/c/BitfieldTypes.qll @@ -0,0 +1,44 @@ +//** THIS FILE IS AUTOGENERATED, DO NOT MODIFY DIRECTLY. **/ +import cpp +import RuleMetadata +import codingstandards.cpp.exclusions.RuleMetadata + +newtype BitfieldTypesQuery = + TBitFieldsShallOnlyBeDeclaredWithAnAppropriateTypeQuery() or + TSingleBitNamedBitFieldsOfASignedTypeQuery() + +predicate isBitfieldTypesQueryMetadata(Query query, string queryId, string ruleId, string category) { + query = + // `Query` instance for the `bitFieldsShallOnlyBeDeclaredWithAnAppropriateType` query + BitfieldTypesPackage::bitFieldsShallOnlyBeDeclaredWithAnAppropriateTypeQuery() and + queryId = + // `@id` for the `bitFieldsShallOnlyBeDeclaredWithAnAppropriateType` query + "c/misra/bit-fields-shall-only-be-declared-with-an-appropriate-type" and + ruleId = "RULE-6-1" and + category = "required" + or + query = + // `Query` instance for the `singleBitNamedBitFieldsOfASignedType` query + BitfieldTypesPackage::singleBitNamedBitFieldsOfASignedTypeQuery() and + queryId = + // `@id` for the `singleBitNamedBitFieldsOfASignedType` query + "c/misra/single-bit-named-bit-fields-of-a-signed-type" and + ruleId = "RULE-6-2" and + category = "required" +} + +module BitfieldTypesPackage { + Query bitFieldsShallOnlyBeDeclaredWithAnAppropriateTypeQuery() { + //autogenerate `Query` type + result = + // `Query` type for `bitFieldsShallOnlyBeDeclaredWithAnAppropriateType` query + TQueryC(TBitfieldTypesPackageQuery(TBitFieldsShallOnlyBeDeclaredWithAnAppropriateTypeQuery())) + } + + Query singleBitNamedBitFieldsOfASignedTypeQuery() { + //autogenerate `Query` type + result = + // `Query` type for `singleBitNamedBitFieldsOfASignedType` query + TQueryC(TBitfieldTypesPackageQuery(TSingleBitNamedBitFieldsOfASignedTypeQuery())) + } +} From 1610215b48e025f3169aae673ccf137eb196fbf8 Mon Sep 17 00:00:00 2001 From: Jeongsoo Lee Date: Fri, 27 Jan 2023 12:40:13 -0800 Subject: [PATCH 14/23] update RuleMetadata.qll --- .../src/codingstandards/cpp/exclusions/c/RuleMetadata.qll | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cpp/common/src/codingstandards/cpp/exclusions/c/RuleMetadata.qll b/cpp/common/src/codingstandards/cpp/exclusions/c/RuleMetadata.qll index 9ee95dd2dd..e1e89326b8 100644 --- a/cpp/common/src/codingstandards/cpp/exclusions/c/RuleMetadata.qll +++ b/cpp/common/src/codingstandards/cpp/exclusions/c/RuleMetadata.qll @@ -3,6 +3,7 @@ import cpp import codingstandards.cpp.exclusions.RuleMetadata //** Import packages for this language **/ import Banned +import BitfieldTypes import Concurrency1 import Concurrency2 import Concurrency3 @@ -47,6 +48,7 @@ import Types /** The TQuery type representing this language * */ newtype TCQuery = TBannedPackageQuery(BannedQuery q) or + TBitfieldTypesPackageQuery(BitfieldTypesQuery q) or TConcurrency1PackageQuery(Concurrency1Query q) or TConcurrency2PackageQuery(Concurrency2Query q) or TConcurrency3PackageQuery(Concurrency3Query q) or @@ -91,6 +93,7 @@ newtype TCQuery = /** The metadata predicate * */ predicate isQueryMetadata(Query query, string queryId, string ruleId, string category) { isBannedQueryMetadata(query, queryId, ruleId, category) or + isBitfieldTypesQueryMetadata(query, queryId, ruleId, category) or isConcurrency1QueryMetadata(query, queryId, ruleId, category) or isConcurrency2QueryMetadata(query, queryId, ruleId, category) or isConcurrency3QueryMetadata(query, queryId, ruleId, category) or From 5f30b7709c7a548d657e932631950b15e4667438 Mon Sep 17 00:00:00 2001 From: Jeongsoo Lee Date: Fri, 27 Jan 2023 14:08:22 -0800 Subject: [PATCH 15/23] remove remaining occurrences/reference to Types --- .../BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql | 2 +- .../rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql | 2 +- .../src/codingstandards/cpp/exclusions/c/RuleMetadata.qll | 7 ++----- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql b/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql index 741e1824eb..94a59e9108 100644 --- a/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql +++ b/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql @@ -32,7 +32,7 @@ predicate isAppropriateTypedef(Type type) { from BitField bitField where -not isExcluded(bitField, TypesPackage::bitFieldsShallOnlyBeDeclaredWithAnAppropriateTypeQuery()) and +not isExcluded(bitField, BitfieldTypesPackage::bitFieldsShallOnlyBeDeclaredWithAnAppropriateTypeQuery()) and /* A violation would neither an appropriate primitive type nor an appropriate typedef. */ not (isAppropriatePrimitive(bitField.getType()) or isAppropriateTypedef(bitField.getType())) select bitField, "Bit-field " + bitField + " is declared on type " + bitField + "." \ No newline at end of file diff --git a/c/misra/src/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql b/c/misra/src/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql index 5950290fb7..bb716692a9 100644 --- a/c/misra/src/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql +++ b/c/misra/src/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql @@ -34,7 +34,7 @@ predicate isSingleBit(BitField bitField) { from BitField bitField where - not isExcluded(bitField, TypesPackage::singleBitNamedBitFieldsOfASignedTypeQuery()) and + not isExcluded(bitField, BitfieldTypesPackage::singleBitNamedBitFieldsOfASignedTypeQuery()) and isSingleBit(bitField) and // Single-bit, not bitField.isAnonymous() and // named, isSigned(bitField.getType()) // but its type is signed. diff --git a/cpp/common/src/codingstandards/cpp/exclusions/c/RuleMetadata.qll b/cpp/common/src/codingstandards/cpp/exclusions/c/RuleMetadata.qll index e1e89326b8..6d0e0445fc 100644 --- a/cpp/common/src/codingstandards/cpp/exclusions/c/RuleMetadata.qll +++ b/cpp/common/src/codingstandards/cpp/exclusions/c/RuleMetadata.qll @@ -43,7 +43,6 @@ import Strings1 import Strings2 import Strings3 import Syntax -import Types /** The TQuery type representing this language * */ newtype TCQuery = @@ -87,8 +86,7 @@ newtype TCQuery = TStrings1PackageQuery(Strings1Query q) or TStrings2PackageQuery(Strings2Query q) or TStrings3PackageQuery(Strings3Query q) or - TSyntaxPackageQuery(SyntaxQuery q) or - TTypesPackageQuery(TypesQuery q) + TSyntaxPackageQuery(SyntaxQuery q) /** The metadata predicate * */ predicate isQueryMetadata(Query query, string queryId, string ruleId, string category) { @@ -132,6 +130,5 @@ predicate isQueryMetadata(Query query, string queryId, string ruleId, string cat isStrings1QueryMetadata(query, queryId, ruleId, category) or isStrings2QueryMetadata(query, queryId, ruleId, category) or isStrings3QueryMetadata(query, queryId, ruleId, category) or - isSyntaxQueryMetadata(query, queryId, ruleId, category) or - isTypesQueryMetadata(query, queryId, ruleId, category) + isSyntaxQueryMetadata(query, queryId, ruleId, category) } From e49bcd6aae346173a4097beea3dee09d1a2716e1 Mon Sep 17 00:00:00 2001 From: Jeongsoo Lee Date: Tue, 31 Jan 2023 08:46:13 -0800 Subject: [PATCH 16/23] update test.c for RULE-6-1 to differ from given examples --- ...nlyBeDeclaredWithAnAppropriateType.expected | 8 ++++---- c/misra/test/rules/RULE-6-1/test.c | 18 ++++++++---------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/c/misra/test/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.expected b/c/misra/test/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.expected index cb80395588..fe371a7972 100644 --- a/c/misra/test/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.expected +++ b/c/misra/test/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.expected @@ -1,4 +1,4 @@ -| test.c:8:7:8:8 | b3 | Bit-field b3 is declared on type b3. | -| test.c:11:15:11:16 | b5 | Bit-field b5 is declared on type b5. | -| test.c:13:15:13:16 | b6 | Bit-field b6 is declared on type b6. | -| test.c:14:14:14:15 | b7 | Bit-field b7 is declared on type b7. | +| test.c:6:7:6:8 | x1 | Bit-field x1 is declared on type x1. | +| test.c:10:15:10:16 | x5 | Bit-field x5 is declared on type x5. | +| test.c:11:15:11:16 | x6 | Bit-field x6 is declared on type x6. | +| test.c:12:14:12:15 | x7 | Bit-field x7 is declared on type x7. | \ No newline at end of file diff --git a/c/misra/test/rules/RULE-6-1/test.c b/c/misra/test/rules/RULE-6-1/test.c index 7fbde78b57..3c1846d956 100644 --- a/c/misra/test/rules/RULE-6-1/test.c +++ b/c/misra/test/rules/RULE-6-1/test.c @@ -1,15 +1,13 @@ -typedef unsigned int UINT_16; +typedef unsigned int UINT16; enum Color { R, G, B }; struct SampleStruct { - unsigned int b1 : 2; // COMPILANT - explicitly unsigned (example in the doc) - signed int b2 : 2; // COMPILANT - explicitly signed - int b3 : 2; // NON_COMPLIANT - plain int not permitted (example in the doc) - UINT_16 b4 : 2; // COMPLIANT - typedef designating unsigned int (example in - // the doc) - signed long b5 : 2; // NON_COMPLIANT - even if long and int are the same size - // (example in the doc) - signed char b6 : 2; // NON_COMPILANT - cannot declare bit field for char - enum Color b7 : 3; // NON_COMPILANT - cannot declare bit field for enum + int x1 : 2; // NON_COMPLIANT - not explicitly signed or unsigned + unsigned int x2 : 2; // COMPILANT - explicitly unsigned (example in the doc) + signed int x3 : 2; // COMPILANT - explicitly signed + UINT16 x4 : 2; // COMPLIANT - type alias resolves to a compliant type + signed long x5 : 2; // NON_COMPLIANT - cannot declare bit field for long, even if it's signed + signed char x6 : 2; // NON_COMPILANT - cannot declare bit field for char, even if it's signed + enum Color x7 : 3; // NON_COMPILANT - cannot declare bit field for enum } sample_struct; \ No newline at end of file From c0ba2620619bce6b36489b03f976da85db79db7d Mon Sep 17 00:00:00 2001 From: Jeongsoo Lee Date: Tue, 31 Jan 2023 11:56:39 -0800 Subject: [PATCH 17/23] delete remaining tests and delete Types.json --- ...mainAndRangeErrorsInMathFunctions.expected | 1 - ...tDomainAndRangeErrorsInMathFunctions.qlref | 1 - ...onversionsNotWithinRangeOfNewType.expected | 1 - ...ntConversionsNotWithinRangeOfNewType.qlref | 1 - ...ointOfIntegralValuesLosePrecision.expected | 1 - ...ngPointOfIntegralValuesLosePrecision.qlref | 1 - ...edForComparingFloatingPointValues.expected | 1 - ...rUsedForComparingFloatingPointValues.qlref | 1 - ...nsignedIntegerOperationsDoNotWrap.expected | 1 - ...atUnsignedIntegerOperationsDoNotWrap.qlref | 1 - ...ionCausesLostOrMisinterpretedData.expected | 1 - ...ersionCausesLostOrMisinterpretedData.qlref | 1 - ...OnSignedIntegersResultsInOverflow.expected | 1 - ...onsOnSignedIntegersResultsInOverflow.qlref | 1 - ...AndModOperationResultsInDivByZero.expected | 1 - ...DivAndModOperationResultsInDivByZero.qlref | 1 - ...yNegativeBitsOrGreaterThanOperand.expected | 1 - ...edByNegativeBitsOrGreaterThanOperand.qlref | 1 - .../UseCorrectIntegerPrecisions.expected | 1 - .../INT35-C/UseCorrectIntegerPrecisions.qlref | 1 - ...ointerToIntegerOrIntegerToPointer.expected | 1 - ...gAPointerToIntegerOrIntegerToPointer.qlref | 1 - ...tUsedInPlaceOfBasicNumericalTypes.expected | 1 - ...sNotUsedInPlaceOfBasicNumericalTypes.qlref | 1 - ...ndsOfAnInappropriateEssentialType.expected | 1 - ...erandsOfAnInappropriateEssentialType.qlref | 1 - .../CharTypeExprsUsedInAddOrSub.expected | 1 - .../CharTypeExprsUsedInAddOrSub.qlref | 1 - ...gnmentToIncompatibleEssentialType.expected | 1 - ...ssignmentToIncompatibleEssentialType.qlref | 1 - ...perandHasDifferentEssTypeCategory.expected | 1 - ...onOperandHasDifferentEssTypeCategory.qlref | 1 - ...eCastToInappropriateEssentialType.expected | 1 - ...alueCastToInappropriateEssentialType.qlref | 1 - ...alueAssignedToObjWithWiderEssType.expected | 1 - ...prValueAssignedToObjWithWiderEssType.qlref | 1 - ...prOperandHasWiderEssTypeThanOther.expected | 1 - ...pExprOperandHasWiderEssTypeThanOther.qlref | 1 - .../CompExprValCastToIncompatEssType.expected | 1 - .../CompExprValCastToIncompatEssType.qlref | 1 - ...prEvalCausesUnsignedIntWraparound.expected | 1 - ...tExprEvalCausesUnsignedIntWraparound.qlref | 1 - .../ArrayTypeParamAtSizeofOperand.expected | 1 - .../ArrayTypeParamAtSizeofOperand.qlref | 1 - ...ounterHaveEssentiallyFloatingType.expected | 1 - ...opCounterHaveEssentiallyFloatingType.qlref | 1 - ...ncNeitherReprAsUnsignedCharNorEOF.expected | 1 - ...eFuncNeitherReprAsUnsignedCharNorEOF.qlref | 1 - ...sedToCompareNullTerminatedStrings.expected | 1 - ...mpUsedToCompareNullTerminatedStrings.qlref | 1 - ...eMemcmpArgNotPointerToCompatTypes.expected | 1 - ...moveMemcmpArgNotPointerToCompatTypes.qlref | 1 - ...oSignedUnsignedBooleanEnumEssType.expected | 1 - ...tsToSignedUnsignedBooleanEnumEssType.qlref | 1 - ...ignedToObjPtrToConstQualifiedChar.expected | 1 - ...AssignedToObjPtrToConstQualifiedChar.qlref | 1 - rule_packages/c/Types.json | 482 ------------------ 57 files changed, 538 deletions(-) delete mode 100644 c/cert/test/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.expected delete mode 100644 c/cert/test/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.qlref delete mode 100644 c/cert/test/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.expected delete mode 100644 c/cert/test/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.qlref delete mode 100644 c/cert/test/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.expected delete mode 100644 c/cert/test/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.qlref delete mode 100644 c/cert/test/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.expected delete mode 100644 c/cert/test/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.qlref delete mode 100644 c/cert/test/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.expected delete mode 100644 c/cert/test/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.qlref delete mode 100644 c/cert/test/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.expected delete mode 100644 c/cert/test/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.qlref delete mode 100644 c/cert/test/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.expected delete mode 100644 c/cert/test/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.qlref delete mode 100644 c/cert/test/rules/INT33-C/DivAndModOperationResultsInDivByZero.expected delete mode 100644 c/cert/test/rules/INT33-C/DivAndModOperationResultsInDivByZero.qlref delete mode 100644 c/cert/test/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.expected delete mode 100644 c/cert/test/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.qlref delete mode 100644 c/cert/test/rules/INT35-C/UseCorrectIntegerPrecisions.expected delete mode 100644 c/cert/test/rules/INT35-C/UseCorrectIntegerPrecisions.qlref delete mode 100644 c/cert/test/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.expected delete mode 100644 c/cert/test/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.qlref delete mode 100644 c/misra/test/rules/DIR-4-6/NumericTypedefsNotUsedInPlaceOfBasicNumericalTypes.expected delete mode 100644 c/misra/test/rules/DIR-4-6/NumericTypedefsNotUsedInPlaceOfBasicNumericalTypes.qlref delete mode 100644 c/misra/test/rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.expected delete mode 100644 c/misra/test/rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.qlref delete mode 100644 c/misra/test/rules/RULE-10-2/CharTypeExprsUsedInAddOrSub.expected delete mode 100644 c/misra/test/rules/RULE-10-2/CharTypeExprsUsedInAddOrSub.qlref delete mode 100644 c/misra/test/rules/RULE-10-3/AssignmentToIncompatibleEssentialType.expected delete mode 100644 c/misra/test/rules/RULE-10-3/AssignmentToIncompatibleEssentialType.qlref delete mode 100644 c/misra/test/rules/RULE-10-4/ArithConversionOperandHasDifferentEssTypeCategory.expected delete mode 100644 c/misra/test/rules/RULE-10-4/ArithConversionOperandHasDifferentEssTypeCategory.qlref delete mode 100644 c/misra/test/rules/RULE-10-5/ValueCastToInappropriateEssentialType.expected delete mode 100644 c/misra/test/rules/RULE-10-5/ValueCastToInappropriateEssentialType.qlref delete mode 100644 c/misra/test/rules/RULE-10-6/CompositeExprValueAssignedToObjWithWiderEssType.expected delete mode 100644 c/misra/test/rules/RULE-10-6/CompositeExprValueAssignedToObjWithWiderEssType.qlref delete mode 100644 c/misra/test/rules/RULE-10-7/ConvertedCompExprOperandHasWiderEssTypeThanOther.expected delete mode 100644 c/misra/test/rules/RULE-10-7/ConvertedCompExprOperandHasWiderEssTypeThanOther.qlref delete mode 100644 c/misra/test/rules/RULE-10-8/CompExprValCastToIncompatEssType.expected delete mode 100644 c/misra/test/rules/RULE-10-8/CompExprValCastToIncompatEssType.qlref delete mode 100644 c/misra/test/rules/RULE-12-4/ConstExprEvalCausesUnsignedIntWraparound.expected delete mode 100644 c/misra/test/rules/RULE-12-4/ConstExprEvalCausesUnsignedIntWraparound.qlref delete mode 100644 c/misra/test/rules/RULE-12-5/ArrayTypeParamAtSizeofOperand.expected delete mode 100644 c/misra/test/rules/RULE-12-5/ArrayTypeParamAtSizeofOperand.qlref delete mode 100644 c/misra/test/rules/RULE-14-1/LoopCounterHaveEssentiallyFloatingType.expected delete mode 100644 c/misra/test/rules/RULE-14-1/LoopCounterHaveEssentiallyFloatingType.qlref delete mode 100644 c/misra/test/rules/RULE-21-13/CtypeFuncNeitherReprAsUnsignedCharNorEOF.expected delete mode 100644 c/misra/test/rules/RULE-21-13/CtypeFuncNeitherReprAsUnsignedCharNorEOF.qlref delete mode 100644 c/misra/test/rules/RULE-21-14/MemcmpUsedToCompareNullTerminatedStrings.expected delete mode 100644 c/misra/test/rules/RULE-21-14/MemcmpUsedToCompareNullTerminatedStrings.qlref delete mode 100644 c/misra/test/rules/RULE-21-15/MemcpyMemmoveMemcmpArgNotPointerToCompatTypes.expected delete mode 100644 c/misra/test/rules/RULE-21-15/MemcpyMemmoveMemcmpArgNotPointerToCompatTypes.qlref delete mode 100644 c/misra/test/rules/RULE-21-16/MemcmpArgNotPtsToSignedUnsignedBooleanEnumEssType.expected delete mode 100644 c/misra/test/rules/RULE-21-16/MemcmpArgNotPtsToSignedUnsignedBooleanEnumEssType.qlref delete mode 100644 c/misra/test/rules/RULE-7-4/StringLiteralAssignedToObjPtrToConstQualifiedChar.expected delete mode 100644 c/misra/test/rules/RULE-7-4/StringLiteralAssignedToObjPtrToConstQualifiedChar.qlref delete mode 100644 rule_packages/c/Types.json diff --git a/c/cert/test/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.expected b/c/cert/test/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.expected deleted file mode 100644 index 2ec1a0ac6c..0000000000 --- a/c/cert/test/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.expected +++ /dev/null @@ -1 +0,0 @@ -No expected results have yet been specified \ No newline at end of file diff --git a/c/cert/test/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.qlref b/c/cert/test/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.qlref deleted file mode 100644 index 7cd938b44b..0000000000 --- a/c/cert/test/rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/FLP32-C/PreventOrDetectDomainAndRangeErrorsInMathFunctions.ql \ No newline at end of file diff --git a/c/cert/test/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.expected b/c/cert/test/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.expected deleted file mode 100644 index 2ec1a0ac6c..0000000000 --- a/c/cert/test/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.expected +++ /dev/null @@ -1 +0,0 @@ -No expected results have yet been specified \ No newline at end of file diff --git a/c/cert/test/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.qlref b/c/cert/test/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.qlref deleted file mode 100644 index fba8b90bf0..0000000000 --- a/c/cert/test/rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/FLP34-C/FloatingPointConversionsNotWithinRangeOfNewType.ql \ No newline at end of file diff --git a/c/cert/test/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.expected b/c/cert/test/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.expected deleted file mode 100644 index 2ec1a0ac6c..0000000000 --- a/c/cert/test/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.expected +++ /dev/null @@ -1 +0,0 @@ -No expected results have yet been specified \ No newline at end of file diff --git a/c/cert/test/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.qlref b/c/cert/test/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.qlref deleted file mode 100644 index 7500c056d2..0000000000 --- a/c/cert/test/rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/FLP36-C/FloatingPointOfIntegralValuesLosePrecision.ql \ No newline at end of file diff --git a/c/cert/test/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.expected b/c/cert/test/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.expected deleted file mode 100644 index 2ec1a0ac6c..0000000000 --- a/c/cert/test/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.expected +++ /dev/null @@ -1 +0,0 @@ -No expected results have yet been specified \ No newline at end of file diff --git a/c/cert/test/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.qlref b/c/cert/test/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.qlref deleted file mode 100644 index 6c9287e855..0000000000 --- a/c/cert/test/rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/FLP37-C/ObjectReprUsedForComparingFloatingPointValues.ql \ No newline at end of file diff --git a/c/cert/test/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.expected b/c/cert/test/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.expected deleted file mode 100644 index 2ec1a0ac6c..0000000000 --- a/c/cert/test/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.expected +++ /dev/null @@ -1 +0,0 @@ -No expected results have yet been specified \ No newline at end of file diff --git a/c/cert/test/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.qlref b/c/cert/test/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.qlref deleted file mode 100644 index c6dde9ace2..0000000000 --- a/c/cert/test/rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/INT30-C/EnsureThatUnsignedIntegerOperationsDoNotWrap.ql \ No newline at end of file diff --git a/c/cert/test/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.expected b/c/cert/test/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.expected deleted file mode 100644 index 2ec1a0ac6c..0000000000 --- a/c/cert/test/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.expected +++ /dev/null @@ -1 +0,0 @@ -No expected results have yet been specified \ No newline at end of file diff --git a/c/cert/test/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.qlref b/c/cert/test/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.qlref deleted file mode 100644 index b95535183b..0000000000 --- a/c/cert/test/rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/INT31-C/IntConversionCausesLostOrMisinterpretedData.ql \ No newline at end of file diff --git a/c/cert/test/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.expected b/c/cert/test/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.expected deleted file mode 100644 index 2ec1a0ac6c..0000000000 --- a/c/cert/test/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.expected +++ /dev/null @@ -1 +0,0 @@ -No expected results have yet been specified \ No newline at end of file diff --git a/c/cert/test/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.qlref b/c/cert/test/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.qlref deleted file mode 100644 index 91ae574c44..0000000000 --- a/c/cert/test/rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/INT32-C/OperationsOnSignedIntegersResultsInOverflow.ql \ No newline at end of file diff --git a/c/cert/test/rules/INT33-C/DivAndModOperationResultsInDivByZero.expected b/c/cert/test/rules/INT33-C/DivAndModOperationResultsInDivByZero.expected deleted file mode 100644 index 2ec1a0ac6c..0000000000 --- a/c/cert/test/rules/INT33-C/DivAndModOperationResultsInDivByZero.expected +++ /dev/null @@ -1 +0,0 @@ -No expected results have yet been specified \ No newline at end of file diff --git a/c/cert/test/rules/INT33-C/DivAndModOperationResultsInDivByZero.qlref b/c/cert/test/rules/INT33-C/DivAndModOperationResultsInDivByZero.qlref deleted file mode 100644 index 529fa9a43a..0000000000 --- a/c/cert/test/rules/INT33-C/DivAndModOperationResultsInDivByZero.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/INT33-C/DivAndModOperationResultsInDivByZero.ql \ No newline at end of file diff --git a/c/cert/test/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.expected b/c/cert/test/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.expected deleted file mode 100644 index 2ec1a0ac6c..0000000000 --- a/c/cert/test/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.expected +++ /dev/null @@ -1 +0,0 @@ -No expected results have yet been specified \ No newline at end of file diff --git a/c/cert/test/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.qlref b/c/cert/test/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.qlref deleted file mode 100644 index b5349c3054..0000000000 --- a/c/cert/test/rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/INT34-C/ExprShiftedByNegativeBitsOrGreaterThanOperand.ql \ No newline at end of file diff --git a/c/cert/test/rules/INT35-C/UseCorrectIntegerPrecisions.expected b/c/cert/test/rules/INT35-C/UseCorrectIntegerPrecisions.expected deleted file mode 100644 index 2ec1a0ac6c..0000000000 --- a/c/cert/test/rules/INT35-C/UseCorrectIntegerPrecisions.expected +++ /dev/null @@ -1 +0,0 @@ -No expected results have yet been specified \ No newline at end of file diff --git a/c/cert/test/rules/INT35-C/UseCorrectIntegerPrecisions.qlref b/c/cert/test/rules/INT35-C/UseCorrectIntegerPrecisions.qlref deleted file mode 100644 index c408baf78d..0000000000 --- a/c/cert/test/rules/INT35-C/UseCorrectIntegerPrecisions.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/INT35-C/UseCorrectIntegerPrecisions.ql \ No newline at end of file diff --git a/c/cert/test/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.expected b/c/cert/test/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.expected deleted file mode 100644 index 2ec1a0ac6c..0000000000 --- a/c/cert/test/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.expected +++ /dev/null @@ -1 +0,0 @@ -No expected results have yet been specified \ No newline at end of file diff --git a/c/cert/test/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.qlref b/c/cert/test/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.qlref deleted file mode 100644 index 70ae157f74..0000000000 --- a/c/cert/test/rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/INT36-C/ConvertingAPointerToIntegerOrIntegerToPointer.ql \ No newline at end of file diff --git a/c/misra/test/rules/DIR-4-6/NumericTypedefsNotUsedInPlaceOfBasicNumericalTypes.expected b/c/misra/test/rules/DIR-4-6/NumericTypedefsNotUsedInPlaceOfBasicNumericalTypes.expected deleted file mode 100644 index 2ec1a0ac6c..0000000000 --- a/c/misra/test/rules/DIR-4-6/NumericTypedefsNotUsedInPlaceOfBasicNumericalTypes.expected +++ /dev/null @@ -1 +0,0 @@ -No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/DIR-4-6/NumericTypedefsNotUsedInPlaceOfBasicNumericalTypes.qlref b/c/misra/test/rules/DIR-4-6/NumericTypedefsNotUsedInPlaceOfBasicNumericalTypes.qlref deleted file mode 100644 index 81fd5998d5..0000000000 --- a/c/misra/test/rules/DIR-4-6/NumericTypedefsNotUsedInPlaceOfBasicNumericalTypes.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/DIR-4-6/NumericTypedefsNotUsedInPlaceOfBasicNumericalTypes.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.expected b/c/misra/test/rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.expected deleted file mode 100644 index 2ec1a0ac6c..0000000000 --- a/c/misra/test/rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.expected +++ /dev/null @@ -1 +0,0 @@ -No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.qlref b/c/misra/test/rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.qlref deleted file mode 100644 index f3120fd81f..0000000000 --- a/c/misra/test/rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-2/CharTypeExprsUsedInAddOrSub.expected b/c/misra/test/rules/RULE-10-2/CharTypeExprsUsedInAddOrSub.expected deleted file mode 100644 index 2ec1a0ac6c..0000000000 --- a/c/misra/test/rules/RULE-10-2/CharTypeExprsUsedInAddOrSub.expected +++ /dev/null @@ -1 +0,0 @@ -No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-2/CharTypeExprsUsedInAddOrSub.qlref b/c/misra/test/rules/RULE-10-2/CharTypeExprsUsedInAddOrSub.qlref deleted file mode 100644 index a0912cc8e9..0000000000 --- a/c/misra/test/rules/RULE-10-2/CharTypeExprsUsedInAddOrSub.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/RULE-10-2/CharTypeExprsUsedInAddOrSub.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-3/AssignmentToIncompatibleEssentialType.expected b/c/misra/test/rules/RULE-10-3/AssignmentToIncompatibleEssentialType.expected deleted file mode 100644 index 2ec1a0ac6c..0000000000 --- a/c/misra/test/rules/RULE-10-3/AssignmentToIncompatibleEssentialType.expected +++ /dev/null @@ -1 +0,0 @@ -No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-3/AssignmentToIncompatibleEssentialType.qlref b/c/misra/test/rules/RULE-10-3/AssignmentToIncompatibleEssentialType.qlref deleted file mode 100644 index d75ee46cd9..0000000000 --- a/c/misra/test/rules/RULE-10-3/AssignmentToIncompatibleEssentialType.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/RULE-10-3/AssignmentToIncompatibleEssentialType.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-4/ArithConversionOperandHasDifferentEssTypeCategory.expected b/c/misra/test/rules/RULE-10-4/ArithConversionOperandHasDifferentEssTypeCategory.expected deleted file mode 100644 index 2ec1a0ac6c..0000000000 --- a/c/misra/test/rules/RULE-10-4/ArithConversionOperandHasDifferentEssTypeCategory.expected +++ /dev/null @@ -1 +0,0 @@ -No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-4/ArithConversionOperandHasDifferentEssTypeCategory.qlref b/c/misra/test/rules/RULE-10-4/ArithConversionOperandHasDifferentEssTypeCategory.qlref deleted file mode 100644 index fdafde4779..0000000000 --- a/c/misra/test/rules/RULE-10-4/ArithConversionOperandHasDifferentEssTypeCategory.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/RULE-10-4/ArithConversionOperandHasDifferentEssTypeCategory.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-5/ValueCastToInappropriateEssentialType.expected b/c/misra/test/rules/RULE-10-5/ValueCastToInappropriateEssentialType.expected deleted file mode 100644 index 2ec1a0ac6c..0000000000 --- a/c/misra/test/rules/RULE-10-5/ValueCastToInappropriateEssentialType.expected +++ /dev/null @@ -1 +0,0 @@ -No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-5/ValueCastToInappropriateEssentialType.qlref b/c/misra/test/rules/RULE-10-5/ValueCastToInappropriateEssentialType.qlref deleted file mode 100644 index 226c29d9c0..0000000000 --- a/c/misra/test/rules/RULE-10-5/ValueCastToInappropriateEssentialType.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/RULE-10-5/ValueCastToInappropriateEssentialType.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-6/CompositeExprValueAssignedToObjWithWiderEssType.expected b/c/misra/test/rules/RULE-10-6/CompositeExprValueAssignedToObjWithWiderEssType.expected deleted file mode 100644 index 2ec1a0ac6c..0000000000 --- a/c/misra/test/rules/RULE-10-6/CompositeExprValueAssignedToObjWithWiderEssType.expected +++ /dev/null @@ -1 +0,0 @@ -No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-6/CompositeExprValueAssignedToObjWithWiderEssType.qlref b/c/misra/test/rules/RULE-10-6/CompositeExprValueAssignedToObjWithWiderEssType.qlref deleted file mode 100644 index 258caa5497..0000000000 --- a/c/misra/test/rules/RULE-10-6/CompositeExprValueAssignedToObjWithWiderEssType.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/RULE-10-6/CompositeExprValueAssignedToObjWithWiderEssType.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-7/ConvertedCompExprOperandHasWiderEssTypeThanOther.expected b/c/misra/test/rules/RULE-10-7/ConvertedCompExprOperandHasWiderEssTypeThanOther.expected deleted file mode 100644 index 2ec1a0ac6c..0000000000 --- a/c/misra/test/rules/RULE-10-7/ConvertedCompExprOperandHasWiderEssTypeThanOther.expected +++ /dev/null @@ -1 +0,0 @@ -No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-7/ConvertedCompExprOperandHasWiderEssTypeThanOther.qlref b/c/misra/test/rules/RULE-10-7/ConvertedCompExprOperandHasWiderEssTypeThanOther.qlref deleted file mode 100644 index ffcbf37d96..0000000000 --- a/c/misra/test/rules/RULE-10-7/ConvertedCompExprOperandHasWiderEssTypeThanOther.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/RULE-10-7/ConvertedCompExprOperandHasWiderEssTypeThanOther.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-8/CompExprValCastToIncompatEssType.expected b/c/misra/test/rules/RULE-10-8/CompExprValCastToIncompatEssType.expected deleted file mode 100644 index 2ec1a0ac6c..0000000000 --- a/c/misra/test/rules/RULE-10-8/CompExprValCastToIncompatEssType.expected +++ /dev/null @@ -1 +0,0 @@ -No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-10-8/CompExprValCastToIncompatEssType.qlref b/c/misra/test/rules/RULE-10-8/CompExprValCastToIncompatEssType.qlref deleted file mode 100644 index 92e74b5640..0000000000 --- a/c/misra/test/rules/RULE-10-8/CompExprValCastToIncompatEssType.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/RULE-10-8/CompExprValCastToIncompatEssType.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-12-4/ConstExprEvalCausesUnsignedIntWraparound.expected b/c/misra/test/rules/RULE-12-4/ConstExprEvalCausesUnsignedIntWraparound.expected deleted file mode 100644 index 2ec1a0ac6c..0000000000 --- a/c/misra/test/rules/RULE-12-4/ConstExprEvalCausesUnsignedIntWraparound.expected +++ /dev/null @@ -1 +0,0 @@ -No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-12-4/ConstExprEvalCausesUnsignedIntWraparound.qlref b/c/misra/test/rules/RULE-12-4/ConstExprEvalCausesUnsignedIntWraparound.qlref deleted file mode 100644 index 8f483e64f3..0000000000 --- a/c/misra/test/rules/RULE-12-4/ConstExprEvalCausesUnsignedIntWraparound.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/RULE-12-4/ConstExprEvalCausesUnsignedIntWraparound.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-12-5/ArrayTypeParamAtSizeofOperand.expected b/c/misra/test/rules/RULE-12-5/ArrayTypeParamAtSizeofOperand.expected deleted file mode 100644 index 2ec1a0ac6c..0000000000 --- a/c/misra/test/rules/RULE-12-5/ArrayTypeParamAtSizeofOperand.expected +++ /dev/null @@ -1 +0,0 @@ -No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-12-5/ArrayTypeParamAtSizeofOperand.qlref b/c/misra/test/rules/RULE-12-5/ArrayTypeParamAtSizeofOperand.qlref deleted file mode 100644 index b083a10d31..0000000000 --- a/c/misra/test/rules/RULE-12-5/ArrayTypeParamAtSizeofOperand.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/RULE-12-5/ArrayTypeParamAtSizeofOperand.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-14-1/LoopCounterHaveEssentiallyFloatingType.expected b/c/misra/test/rules/RULE-14-1/LoopCounterHaveEssentiallyFloatingType.expected deleted file mode 100644 index 2ec1a0ac6c..0000000000 --- a/c/misra/test/rules/RULE-14-1/LoopCounterHaveEssentiallyFloatingType.expected +++ /dev/null @@ -1 +0,0 @@ -No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-14-1/LoopCounterHaveEssentiallyFloatingType.qlref b/c/misra/test/rules/RULE-14-1/LoopCounterHaveEssentiallyFloatingType.qlref deleted file mode 100644 index befc44a33a..0000000000 --- a/c/misra/test/rules/RULE-14-1/LoopCounterHaveEssentiallyFloatingType.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/RULE-14-1/LoopCounterHaveEssentiallyFloatingType.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-21-13/CtypeFuncNeitherReprAsUnsignedCharNorEOF.expected b/c/misra/test/rules/RULE-21-13/CtypeFuncNeitherReprAsUnsignedCharNorEOF.expected deleted file mode 100644 index 2ec1a0ac6c..0000000000 --- a/c/misra/test/rules/RULE-21-13/CtypeFuncNeitherReprAsUnsignedCharNorEOF.expected +++ /dev/null @@ -1 +0,0 @@ -No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-21-13/CtypeFuncNeitherReprAsUnsignedCharNorEOF.qlref b/c/misra/test/rules/RULE-21-13/CtypeFuncNeitherReprAsUnsignedCharNorEOF.qlref deleted file mode 100644 index 60f87891a1..0000000000 --- a/c/misra/test/rules/RULE-21-13/CtypeFuncNeitherReprAsUnsignedCharNorEOF.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/RULE-21-13/CtypeFuncNeitherReprAsUnsignedCharNorEOF.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-21-14/MemcmpUsedToCompareNullTerminatedStrings.expected b/c/misra/test/rules/RULE-21-14/MemcmpUsedToCompareNullTerminatedStrings.expected deleted file mode 100644 index 2ec1a0ac6c..0000000000 --- a/c/misra/test/rules/RULE-21-14/MemcmpUsedToCompareNullTerminatedStrings.expected +++ /dev/null @@ -1 +0,0 @@ -No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-21-14/MemcmpUsedToCompareNullTerminatedStrings.qlref b/c/misra/test/rules/RULE-21-14/MemcmpUsedToCompareNullTerminatedStrings.qlref deleted file mode 100644 index 99017569aa..0000000000 --- a/c/misra/test/rules/RULE-21-14/MemcmpUsedToCompareNullTerminatedStrings.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/RULE-21-14/MemcmpUsedToCompareNullTerminatedStrings.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-21-15/MemcpyMemmoveMemcmpArgNotPointerToCompatTypes.expected b/c/misra/test/rules/RULE-21-15/MemcpyMemmoveMemcmpArgNotPointerToCompatTypes.expected deleted file mode 100644 index 2ec1a0ac6c..0000000000 --- a/c/misra/test/rules/RULE-21-15/MemcpyMemmoveMemcmpArgNotPointerToCompatTypes.expected +++ /dev/null @@ -1 +0,0 @@ -No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-21-15/MemcpyMemmoveMemcmpArgNotPointerToCompatTypes.qlref b/c/misra/test/rules/RULE-21-15/MemcpyMemmoveMemcmpArgNotPointerToCompatTypes.qlref deleted file mode 100644 index e0ff446916..0000000000 --- a/c/misra/test/rules/RULE-21-15/MemcpyMemmoveMemcmpArgNotPointerToCompatTypes.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/RULE-21-15/MemcpyMemmoveMemcmpArgNotPointerToCompatTypes.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-21-16/MemcmpArgNotPtsToSignedUnsignedBooleanEnumEssType.expected b/c/misra/test/rules/RULE-21-16/MemcmpArgNotPtsToSignedUnsignedBooleanEnumEssType.expected deleted file mode 100644 index 2ec1a0ac6c..0000000000 --- a/c/misra/test/rules/RULE-21-16/MemcmpArgNotPtsToSignedUnsignedBooleanEnumEssType.expected +++ /dev/null @@ -1 +0,0 @@ -No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-21-16/MemcmpArgNotPtsToSignedUnsignedBooleanEnumEssType.qlref b/c/misra/test/rules/RULE-21-16/MemcmpArgNotPtsToSignedUnsignedBooleanEnumEssType.qlref deleted file mode 100644 index ade809ada5..0000000000 --- a/c/misra/test/rules/RULE-21-16/MemcmpArgNotPtsToSignedUnsignedBooleanEnumEssType.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/RULE-21-16/MemcmpArgNotPtsToSignedUnsignedBooleanEnumEssType.ql \ No newline at end of file diff --git a/c/misra/test/rules/RULE-7-4/StringLiteralAssignedToObjPtrToConstQualifiedChar.expected b/c/misra/test/rules/RULE-7-4/StringLiteralAssignedToObjPtrToConstQualifiedChar.expected deleted file mode 100644 index 2ec1a0ac6c..0000000000 --- a/c/misra/test/rules/RULE-7-4/StringLiteralAssignedToObjPtrToConstQualifiedChar.expected +++ /dev/null @@ -1 +0,0 @@ -No expected results have yet been specified \ No newline at end of file diff --git a/c/misra/test/rules/RULE-7-4/StringLiteralAssignedToObjPtrToConstQualifiedChar.qlref b/c/misra/test/rules/RULE-7-4/StringLiteralAssignedToObjPtrToConstQualifiedChar.qlref deleted file mode 100644 index d886f5a94a..0000000000 --- a/c/misra/test/rules/RULE-7-4/StringLiteralAssignedToObjPtrToConstQualifiedChar.qlref +++ /dev/null @@ -1 +0,0 @@ -rules/RULE-7-4/StringLiteralAssignedToObjPtrToConstQualifiedChar.ql \ No newline at end of file diff --git a/rule_packages/c/Types.json b/rule_packages/c/Types.json deleted file mode 100644 index 68b873dacd..0000000000 --- a/rule_packages/c/Types.json +++ /dev/null @@ -1,482 +0,0 @@ -{ - "CERT-C": { - "FLP32-C": { - "properties": { - "obligation": "rule" - }, - "queries": [ - { - "description": "TODO.", - "kind": "problem", - "name": "Prevent or detect domain and range errors in math functions", - "precision": "very-high", - "severity": "error", - "short_name": "PreventOrDetectDomainAndRangeErrorsInMathFunctions", - "tags": [] - } - ], - "title": "Prevent or detect domain and range errors in math functions" - }, - "FLP34-C": { - "properties": { - "obligation": "rule" - }, - "queries": [ - { - "description": "TODO.", - "kind": "problem", - "name": "Ensure that floating-point conversions are within range of the new type", - "precision": "very-high", - "severity": "error", - "short_name": "FloatingPointConversionsNotWithinRangeOfNewType", - "tags": [] - } - ], - "title": "Ensure that floating-point conversions are within range of the new type" - }, - "FLP36-C": { - "properties": { - "obligation": "rule" - }, - "queries": [ - { - "description": "TODO.", - "kind": "problem", - "name": "Preserve precision when converting integral values to floating-point type", - "precision": "very-high", - "severity": "error", - "short_name": "FloatingPointOfIntegralValuesLosePrecision", - "tags": [] - } - ], - "title": "Preserve precision when converting integral values to floating-point type" - }, - "FLP37-C": { - "properties": { - "obligation": "rule" - }, - "queries": [ - { - "description": "TODO.", - "kind": "problem", - "name": "Do not use object representations to compare floating-point values", - "precision": "very-high", - "severity": "error", - "short_name": "ObjectReprUsedForComparingFloatingPointValues", - "tags": [] - } - ], - "title": "Do not use object representations to compare floating-point values" - }, - "INT30-C": { - "properties": { - "obligation": "rule" - }, - "queries": [ - { - "description": "TODO.", - "kind": "problem", - "name": "Ensure that unsigned integer operations do not wrap", - "precision": "high", - "severity": "error", - "short_name": "EnsureThatUnsignedIntegerOperationsDoNotWrap", - "tags": [] - } - ], - "title": "Ensure that unsigned integer operations do not wrap" - }, - "INT31-C": { - "properties": { - "obligation": "rule" - }, - "queries": [ - { - "description": "TODO.", - "kind": "problem", - "name": "Ensure that integer conversions do not result in lost or misinterpreted data", - "precision": "high", - "severity": "error", - "short_name": "IntConversionCausesLostOrMisinterpretedData", - "tags": [] - } - ], - "title": "Ensure that integer conversions do not result in lost or misinterpreted data" - }, - "INT32-C": { - "properties": { - "obligation": "rule" - }, - "queries": [ - { - "description": "TODO.", - "kind": "problem", - "name": "Ensure that operations on signed integers do not result in overflow", - "precision": "high", - "severity": "error", - "short_name": "OperationsOnSignedIntegersResultsInOverflow", - "tags": [] - } - ], - "title": "Ensure that operations on signed integers do not result in overflow" - }, - "INT33-C": { - "properties": { - "obligation": "rule" - }, - "queries": [ - { - "description": "TODO.", - "kind": "problem", - "name": "Ensure that division and remainder operations do not result in divide-by-zero errors", - "precision": "high", - "severity": "error", - "short_name": "DivAndModOperationResultsInDivByZero", - "tags": [] - } - ], - "title": "Ensure that division and remainder operations do not result in divide-by-zero errors" - }, - "INT34-C": { - "properties": { - "obligation": "rule" - }, - "queries": [ - { - "description": "Do not shift an expression by a negative number of bits or by greater than or equal to the number of bits that exist in the operand.", - "kind": "problem", - "name": "Do not shift an expression by a negative number of bits or by greater than or equal to the number of", - "precision": "very-high", - "severity": "error", - "short_name": "ExprShiftedByNegativeBitsOrGreaterThanOperand", - "tags": [] - } - ], - "title": "Do not shift an expression by a negative number of bits or by greater than or equal to the number of bits that exist in the operand" - }, - "INT35-C": { - "properties": { - "obligation": "rule" - }, - "queries": [ - { - "description": "TODO.", - "kind": "problem", - "name": "Use correct integer precisions", - "precision": "high", - "severity": "error", - "short_name": "UseCorrectIntegerPrecisions", - "tags": [] - } - ], - "title": "Use correct integer precisions" - }, - "INT36-C": { - "properties": { - "obligation": "rule" - }, - "queries": [ - { - "description": "TODO.", - "kind": "problem", - "name": "Converting a pointer to integer or integer to pointer", - "precision": "very-high", - "severity": "error", - "short_name": "ConvertingAPointerToIntegerOrIntegerToPointer", - "tags": [] - } - ], - "title": "Converting a pointer to integer or integer to pointer" - } - }, - "MISRA-C-2012": { - "DIR-4-6": { - "properties": { - "obligation": "advisory" - }, - "queries": [ - { - "description": "TODO.", - "kind": "problem", - "name": "typedefs that indicate size and signedness should be used in place of the basic numerical types", - "precision": "high", - "severity": "error", - "short_name": "NumericTypedefsNotUsedInPlaceOfBasicNumericalTypes", - "tags": [] - } - ], - "title": "typedefs that indicate size and signedness should be used in place of the basic numerical types" - }, - "RULE-10-1": { - "properties": { - "obligation": "required" - }, - "queries": [ - { - "description": "TODO.", - "kind": "problem", - "name": "Operands shall not be of an inappropriate essential type", - "precision": "high", - "severity": "error", - "short_name": "OperandsOfAnInappropriateEssentialType", - "tags": [] - } - ], - "title": "Operands shall not be of an inappropriate essential type" - }, - "RULE-10-2": { - "properties": { - "obligation": "required" - }, - "queries": [ - { - "description": "Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations.", - "kind": "problem", - "name": "Expressions of essentially character type shall not be used inappropriately in addition and", - "precision": "very-high", - "severity": "error", - "short_name": "CharTypeExprsUsedInAddOrSub", - "tags": [] - } - ], - "title": "Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations" - }, - "RULE-10-3": { - "properties": { - "obligation": "required" - }, - "queries": [ - { - "description": "The value of an expression shall not be assigned to an object with a narrower essential type or of a different essential type category.", - "kind": "problem", - "name": "The value of an expression shall not be assigned to an object with a narrower essential type or of a", - "precision": "high", - "severity": "error", - "short_name": "AssignmentToIncompatibleEssentialType", - "tags": [] - } - ], - "title": "The value of an expression shall not be assigned to an object with a narrower essential type or of a different essential type category" - }, - "RULE-10-4": { - "properties": { - "obligation": "required" - }, - "queries": [ - { - "description": "Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category.", - "kind": "problem", - "name": "Both operands of an operator in which the usual arithmetic conversions are performed shall have the", - "precision": "very-high", - "severity": "error", - "short_name": "ArithConversionOperandHasDifferentEssTypeCategory", - "tags": [] - } - ], - "title": "Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category" - }, - "RULE-10-5": { - "properties": { - "obligation": "advisory" - }, - "queries": [ - { - "description": "TODO.", - "kind": "problem", - "name": "The value of an expression should not be cast to an inappropriate essential type", - "precision": "very-high", - "severity": "error", - "short_name": "ValueCastToInappropriateEssentialType", - "tags": [] - } - ], - "title": "The value of an expression should not be cast to an inappropriate essential type" - }, - "RULE-10-6": { - "properties": { - "obligation": "required" - }, - "queries": [ - { - "description": "TODO.", - "kind": "problem", - "name": "The value of a composite expression shall not be assigned to an object with wider essential type", - "precision": "very-high", - "severity": "error", - "short_name": "CompositeExprValueAssignedToObjWithWiderEssType", - "tags": [] - } - ], - "title": "The value of a composite expression shall not be assigned to an object with wider essential type" - }, - "RULE-10-7": { - "properties": { - "obligation": "required" - }, - "queries": [ - { - "description": "If a composite expression is used as one operand of an operator in which the usual arithmetic conversions are performed then the other operand shall not have wider essential type.", - "kind": "problem", - "name": "If a composite expression is used as one operand of an operator in which the usual arithmetic", - "precision": "very-high", - "severity": "error", - "short_name": "ConvertedCompExprOperandHasWiderEssTypeThanOther", - "tags": [] - } - ], - "title": "If a composite expression is used as one operand of an operator in which the usual arithmetic conversions are performed then the other operand shall not have wider essential type" - }, - "RULE-10-8": { - "properties": { - "obligation": "required" - }, - "queries": [ - { - "description": "The value of a composite expression shall not be cast to a different essential type category or a wider essential type.", - "kind": "problem", - "name": "The value of a composite expression shall not be cast to a different essential type category or a", - "precision": "very-high", - "severity": "error", - "short_name": "CompExprValCastToIncompatEssType", - "tags": [] - } - ], - "title": "The value of a composite expression shall not be cast to a different essential type category or a wider essential type" - }, - "RULE-12-4": { - "properties": { - "obligation": "advisory" - }, - "queries": [ - { - "description": "TODO.", - "kind": "problem", - "name": "Evaluation of constant expressions should not lead to unsigned integer wrap-around", - "precision": "very-high", - "severity": "error", - "short_name": "ConstExprEvalCausesUnsignedIntWraparound", - "tags": [] - } - ], - "title": "Evaluation of constant expressions should not lead to unsigned integer wrap-around" - }, - "RULE-12-5": { - "properties": { - "obligation": "mandatory" - }, - "queries": [ - { - "description": "The sizeof operator shall not have an operand which is a function parameter declared as 'array of type'.", - "kind": "problem", - "name": "The sizeof operator shall not have an operand which is a function parameter declared as 'array of", - "precision": "very-high", - "severity": "error", - "short_name": "ArrayTypeParamAtSizeofOperand", - "tags": [] - } - ], - "title": "The sizeof operator shall not have an operand which is a function parameter declared as 'array of type'" - }, - "RULE-14-1": { - "properties": { - "obligation": "required" - }, - "queries": [ - { - "description": "TODO.", - "kind": "problem", - "name": "A loop counter shall not have essentially floating type", - "precision": "high", - "severity": "error", - "short_name": "LoopCounterHaveEssentiallyFloatingType", - "tags": [] - } - ], - "title": "A loop counter shall not have essentially floating type" - }, - "RULE-21-13": { - "properties": { - "obligation": "mandatory" - }, - "queries": [ - { - "description": "Any value passed to a function in shall be representable as an unsigned char or be the value EOF.", - "kind": "problem", - "name": "Any value passed to a function in shall be representable as an unsigned char or be the", - "precision": "very-high", - "severity": "error", - "short_name": "CtypeFuncNeitherReprAsUnsignedCharNorEOF", - "tags": [] - } - ], - "title": "Any value passed to a function in shall be representable as an unsigned char or be the value EOF" - }, - "RULE-21-14": { - "properties": { - "obligation": "required" - }, - "queries": [ - { - "description": "TODO.", - "kind": "problem", - "name": "The Standard Library function memcmp shall not be used to compare null terminated strings", - "precision": "high", - "severity": "error", - "short_name": "MemcmpUsedToCompareNullTerminatedStrings", - "tags": [] - } - ], - "title": "The Standard Library function memcmp shall not be used to compare null terminated strings" - }, - "RULE-21-15": { - "properties": { - "obligation": "required" - }, - "queries": [ - { - "description": "The pointer arguments to the Standard Library functions memcpy, memmove and memcmp shall be pointers to qualified or unqualified versions of compatible types.", - "kind": "problem", - "name": "The pointer arguments to the Standard Library functions memcpy, memmove and memcmp shall be pointers", - "precision": "very-high", - "severity": "error", - "short_name": "MemcpyMemmoveMemcmpArgNotPointerToCompatTypes", - "tags": [] - } - ], - "title": "The pointer arguments to the Standard Library functions memcpy, memmove and memcmp shall be pointers to qualified or unqualified versions of compatible types" - }, - "RULE-21-16": { - "properties": { - "obligation": "required" - }, - "queries": [ - { - "description": "The pointer arguments to the Standard Library function memcmp shall point to either a pointer type, an essentially signed type, an essentially unsigned type, an essentially Boolean type or an essentially enum type.", - "kind": "problem", - "name": "The pointer arguments to the Standard Library function memcmp shall point to either a pointer type,", - "precision": "very-high", - "severity": "error", - "short_name": "MemcmpArgNotPtsToSignedUnsignedBooleanEnumEssType", - "tags": [] - } - ], - "title": "The pointer arguments to the Standard Library function memcmp shall point to either a pointer type, an essentially signed type, an essentially unsigned type, an essentially Boolean type or an essentially enum type." - }, - "RULE-7-4": { - "properties": { - "obligation": "required" - }, - "queries": [ - { - "description": "A string literal shall not be assigned to an object unless the object's type is 'pointer to const-qualified char'.", - "kind": "problem", - "name": "A string literal shall not be assigned to an object unless the object's type is 'pointer to", - "precision": "very-high", - "severity": "error", - "short_name": "StringLiteralAssignedToObjPtrToConstQualifiedChar", - "tags": [] - } - ], - "title": "A string literal shall not be assigned to an object unless the object's type is 'pointer to const-qualified char'" - } - } -} From 60f282489f4e949cabf7b197bf9c4324ee860d27 Mon Sep 17 00:00:00 2001 From: Jeongsoo Lee Date: Tue, 31 Jan 2023 13:36:14 -0800 Subject: [PATCH 18/23] update test.c for 6-1 and 6-2 1. `compilant` and `non_compliant` to uppercase 2. mark `int x1` of 6-2 to non_compliant 3. `clang-format` all --- c/misra/test/rules/RULE-6-1/test.c | 14 ++++++++------ c/misra/test/rules/RULE-6-2/test.c | 20 +++++++++++--------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/c/misra/test/rules/RULE-6-1/test.c b/c/misra/test/rules/RULE-6-1/test.c index 3c1846d956..0271ed1e32 100644 --- a/c/misra/test/rules/RULE-6-1/test.c +++ b/c/misra/test/rules/RULE-6-1/test.c @@ -3,11 +3,13 @@ typedef unsigned int UINT16; enum Color { R, G, B }; struct SampleStruct { - int x1 : 2; // NON_COMPLIANT - not explicitly signed or unsigned - unsigned int x2 : 2; // COMPILANT - explicitly unsigned (example in the doc) + int x1 : 2; // NON_COMPLIANT - not explicitly signed or unsigned + unsigned int x2 : 2; // COMPILANT - explicitly unsigned signed int x3 : 2; // COMPILANT - explicitly signed - UINT16 x4 : 2; // COMPLIANT - type alias resolves to a compliant type - signed long x5 : 2; // NON_COMPLIANT - cannot declare bit field for long, even if it's signed - signed char x6 : 2; // NON_COMPILANT - cannot declare bit field for char, even if it's signed + UINT16 x4 : 2; // COMPLIANT - type alias resolves to a compliant type + signed long x5 : 2; // NON_COMPLIANT - cannot declare bit field for long, even + // if it's signed + signed char x6 : 2; // NON_COMPILANT - cannot declare bit field for char, even + // if it's signed enum Color x7 : 3; // NON_COMPILANT - cannot declare bit field for enum -} sample_struct; \ No newline at end of file +} sample_struct; diff --git a/c/misra/test/rules/RULE-6-2/test.c b/c/misra/test/rules/RULE-6-2/test.c index 9b18e986b9..e958203b04 100644 --- a/c/misra/test/rules/RULE-6-2/test.c +++ b/c/misra/test/rules/RULE-6-2/test.c @@ -1,17 +1,19 @@ #include struct SampleStruct { - int x1 : 1; // compilant: single-bit named field without signed declaration - signed int x2 : 1; // non_compilant: single-bit named field with a signed type + int x1 : 1; // NON_COMPILANT: very likely be signed, but if it's not, the + // query will automatically handle it since we use signed(), not + // isExplicitlySigned(). + signed int x2 : 1; // NON_COMPILANT: single-bit named field with a signed type signed char - x3 : 1; // non_compilant: single-bit named field with a signed type + x3 : 1; // NON_COMPILANT: single-bit named field with a signed type signed short - x4 : 1; // non_compilant: single-bit named field with a signed type + x4 : 1; // NON_COMPILANT: single-bit named field with a signed type unsigned int - x5 : 1; // compilant: single-bit named field but with an unsigned type - signed int x6 : 2; // compilant: named field with a signed type but declared + x5 : 1; // COMPILANT: single-bit named field but with an unsigned type + signed int x6 : 2; // COMPILANT: named field with a signed type but declared // to carry more than 1 bit - int32_t x7 : 1; // non_compilant: single-bit named field that has single-bit + int32_t x7 : 1; // NON_COMPILANT: single-bit named field that has single-bit // bit-field, even though technically it has 32 bits - signed char : 1; // compilant: single-bit bit-field but unnamed -} sample_struct; \ No newline at end of file + signed char : 1; // COMPILANT: single-bit bit-field but unnamed +} sample_struct; From 294e49e4fde25c0fcc09246a27ab0727b97b89d1 Mon Sep 17 00:00:00 2001 From: Jeongsoo Lee Date: Tue, 31 Jan 2023 14:17:21 -0800 Subject: [PATCH 19/23] update .expected files to reflect clang-format --- ...ieldsShallOnlyBeDeclaredWithAnAppropriateType.expected | 4 ++-- .../SingleBitNamedBitFieldsOfASignedType.expected | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/c/misra/test/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.expected b/c/misra/test/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.expected index fe371a7972..cdcfe74e98 100644 --- a/c/misra/test/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.expected +++ b/c/misra/test/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.expected @@ -1,4 +1,4 @@ | test.c:6:7:6:8 | x1 | Bit-field x1 is declared on type x1. | | test.c:10:15:10:16 | x5 | Bit-field x5 is declared on type x5. | -| test.c:11:15:11:16 | x6 | Bit-field x6 is declared on type x6. | -| test.c:12:14:12:15 | x7 | Bit-field x7 is declared on type x7. | \ No newline at end of file +| test.c:12:15:12:16 | x6 | Bit-field x6 is declared on type x6. | +| test.c:14:14:14:15 | x7 | Bit-field x7 is declared on type x7. | \ No newline at end of file diff --git a/c/misra/test/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.expected b/c/misra/test/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.expected index c54bbafb38..d78e36f0ed 100644 --- a/c/misra/test/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.expected +++ b/c/misra/test/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.expected @@ -1,4 +1,4 @@ -| test.c:5:14:5:15 | x2 | Single-bit bit-field named x2 has a signed type signed int. | -| test.c:7:7:7:8 | x3 | Single-bit bit-field named x3 has a signed type signed char. | -| test.c:9:7:9:8 | x4 | Single-bit bit-field named x4 has a signed type signed short. | -| test.c:14:11:14:12 | x7 | Single-bit bit-field named x7 has a signed type int32_t. | \ No newline at end of file +| test.c:7:14:7:15 | x2 | Single-bit bit-field named x2 has a signed type signed int. | +| test.c:9:7:9:8 | x3 | Single-bit bit-field named x3 has a signed type signed char. | +| test.c:11:7:11:8 | x4 | Single-bit bit-field named x4 has a signed type signed short. | +| test.c:16:11:16:12 | x7 | Single-bit bit-field named x7 has a signed type int32_t. | From a6e86eb7a50ac829bdb5a431fc7dbe4df93fe962 Mon Sep 17 00:00:00 2001 From: Jeongsoo Lee Date: Tue, 31 Jan 2023 16:10:04 -0800 Subject: [PATCH 20/23] incorporate requested changes for query --- ...hallOnlyBeDeclaredWithAnAppropriateType.ql | 54 +++++++++---------- .../SingleBitNamedBitFieldsOfASignedType.ql | 21 ++------ ...lyBeDeclaredWithAnAppropriateType.expected | 8 +-- ...gleBitNamedBitFieldsOfASignedType.expected | 2 +- c/misra/test/rules/RULE-6-2/test.c | 2 - 5 files changed, 36 insertions(+), 51 deletions(-) diff --git a/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql b/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql index 94a59e9108..82f2c9c89a 100644 --- a/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql +++ b/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql @@ -1,38 +1,36 @@ /** - * @id c/misra/bit-fields-shall-only-be-declared-with-an-appropriate-type - * @name RULE-6-1: Bit-fields shall only be declared with an appropriate type - * @description Declaring bit-fields on types other than appropriate ones causes - * implementation-specific or undefined behavior. - * @kind problem - * @precision very-high - * @problem.severity error - * @tags external/misra/id/rule-6-1 - * external/misra/obligation/required - */ +* @id c/misra/bit-fields-shall-only-be-declared-with-an-appropriate-type +* @name RULE-6-1: Bit-fields shall only be declared with an appropriate type +* @description Declaring bit-fields on types other than appropriate ones causes +* implementation-specific or undefined behavior. +* @kind problem +* @precision very-high +* @problem.severity error +* @tags external/misra/id/rule-6-1 +* external/misra/obligation/required +*/ import cpp import codingstandards.c.misra -predicate isSignedOrUnsignedInt(Type type) { - type instanceof IntType and - (type.(IntegralType).isExplicitlySigned() or - type.(IntegralType).isExplicitlyUnsigned()) -} - predicate isAppropriatePrimitive(Type type) { - /* An appropriate primitive types to which a bit-field can be declared. */ - isSignedOrUnsignedInt(type) or type instanceof BoolType -} - -predicate isAppropriateTypedef(Type type) { - type instanceof TypedefType and - /* An appropriate typedef should be an alias to an appropriate primitive type. */ - isAppropriatePrimitive(type.(TypedefType).resolveTypedefs()) + /* An appropriate primitive types to which a bit-field can be declared. */ + type instanceof IntType and + ( + type.(IntegralType).isExplicitlySigned() or + type.(IntegralType).isExplicitlyUnsigned() + ) + or + type instanceof BoolType } from BitField bitField where -not isExcluded(bitField, BitfieldTypesPackage::bitFieldsShallOnlyBeDeclaredWithAnAppropriateTypeQuery()) and -/* A violation would neither an appropriate primitive type nor an appropriate typedef. */ -not (isAppropriatePrimitive(bitField.getType()) or isAppropriateTypedef(bitField.getType())) -select bitField, "Bit-field " + bitField + " is declared on type " + bitField + "." \ No newline at end of file +not isExcluded(bitField, +BitfieldTypesPackage::bitFieldsShallOnlyBeDeclaredWithAnAppropriateTypeQuery()) and + /* A violation would neither an appropriate primitive type nor an appropriate typedef. */ +not ( + isAppropriatePrimitive(bitField.getType()) or + isAppropriatePrimitive(bitField.getType().resolveTypedefs()) + ) +select bitField, "Bit-field " + bitField + " is declared on type " + bitField.getType() + "." diff --git a/c/misra/src/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql b/c/misra/src/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql index bb716692a9..98d2fcc0ef 100644 --- a/c/misra/src/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql +++ b/c/misra/src/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql @@ -13,14 +13,6 @@ import cpp import codingstandards.c.misra -predicate isSigned(Type type) { - /* Check if it's a fixed number type, because declaring fixed number types like int8_t as 1 bit is obviously absurd */ - type instanceof FixedWidthIntegralType or - /* Check if it's EXPLICITLY signed, because according to Rule 6.1, 'int' may be either signed or unsigned depending on the implementation. In the latter case, the query would lead to false positives. */ - type instanceof IntegralType and - type.(IntegralType).isExplicitlySigned() -} - /* Check if the DECLARED bit-fields is a single bit, because Rule 6.2 also intends to catch confusion on the programmers' part. Consider: struct S { @@ -28,14 +20,11 @@ struct S { } In this case, field x is essentially of 32 bits, but is declared as 1 bit and its type int32_t is signed. Therefore, it indicates confusion by the programmer, which is exactly what this rule intends to find. */ -predicate isSingleBit(BitField bitField) { - bitField.getDeclaredNumBits() = 1 -} from BitField bitField where - not isExcluded(bitField, BitfieldTypesPackage::singleBitNamedBitFieldsOfASignedTypeQuery()) and - isSingleBit(bitField) and // Single-bit, - not bitField.isAnonymous() and // named, - isSigned(bitField.getType()) // but its type is signed. -select bitField, "Single-bit bit-field named " + bitField.toString() + " has a signed type " + bitField.getType() + "." \ No newline at end of file +not isExcluded(bitField, BitfieldTypesPackage::singleBitNamedBitFieldsOfASignedTypeQuery()) and +bitField.getDeclaredNumBits() = 1 and // Single-bit, +not bitField.isAnonymous() and // named, +bitField.getType().(IntegralType).isSigned() // but its type is signed. +select bitField, "Single-bit bit-field named " + bitField.toString() + " has a signed type " + bitField.getType() + "." diff --git a/c/misra/test/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.expected b/c/misra/test/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.expected index cdcfe74e98..aaba0ee30c 100644 --- a/c/misra/test/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.expected +++ b/c/misra/test/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.expected @@ -1,4 +1,4 @@ -| test.c:6:7:6:8 | x1 | Bit-field x1 is declared on type x1. | -| test.c:10:15:10:16 | x5 | Bit-field x5 is declared on type x5. | -| test.c:12:15:12:16 | x6 | Bit-field x6 is declared on type x6. | -| test.c:14:14:14:15 | x7 | Bit-field x7 is declared on type x7. | \ No newline at end of file +| test.c:6:7:6:8 | x1 | Bit-field x1 is declared on type int. | +| test.c:10:15:10:16 | x5 | Bit-field x5 is declared on type signed long. | +| test.c:12:15:12:16 | x6 | Bit-field x6 is declared on type signed char. | +| test.c:14:14:14:15 | x7 | Bit-field x7 is declared on type Color. | diff --git a/c/misra/test/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.expected b/c/misra/test/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.expected index d78e36f0ed..df7677961a 100644 --- a/c/misra/test/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.expected +++ b/c/misra/test/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.expected @@ -1,4 +1,4 @@ +| test.c:4:7:4:8 | x1 | Single-bit bit-field named x1 has a signed type int. | | test.c:7:14:7:15 | x2 | Single-bit bit-field named x2 has a signed type signed int. | | test.c:9:7:9:8 | x3 | Single-bit bit-field named x3 has a signed type signed char. | | test.c:11:7:11:8 | x4 | Single-bit bit-field named x4 has a signed type signed short. | -| test.c:16:11:16:12 | x7 | Single-bit bit-field named x7 has a signed type int32_t. | diff --git a/c/misra/test/rules/RULE-6-2/test.c b/c/misra/test/rules/RULE-6-2/test.c index e958203b04..479e0e7ee2 100644 --- a/c/misra/test/rules/RULE-6-2/test.c +++ b/c/misra/test/rules/RULE-6-2/test.c @@ -13,7 +13,5 @@ struct SampleStruct { x5 : 1; // COMPILANT: single-bit named field but with an unsigned type signed int x6 : 2; // COMPILANT: named field with a signed type but declared // to carry more than 1 bit - int32_t x7 : 1; // NON_COMPILANT: single-bit named field that has single-bit - // bit-field, even though technically it has 32 bits signed char : 1; // COMPILANT: single-bit bit-field but unnamed } sample_struct; From 49674de963cf3a6a4d48b5e1deca67492ab35c79 Mon Sep 17 00:00:00 2001 From: Jeongsoo Lee Date: Tue, 31 Jan 2023 16:14:57 -0800 Subject: [PATCH 21/23] minor format --- c/misra/test/rules/RULE-6-2/test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/misra/test/rules/RULE-6-2/test.c b/c/misra/test/rules/RULE-6-2/test.c index 479e0e7ee2..b3eaa0dd0e 100644 --- a/c/misra/test/rules/RULE-6-2/test.c +++ b/c/misra/test/rules/RULE-6-2/test.c @@ -13,5 +13,5 @@ struct SampleStruct { x5 : 1; // COMPILANT: single-bit named field but with an unsigned type signed int x6 : 2; // COMPILANT: named field with a signed type but declared // to carry more than 1 bit - signed char : 1; // COMPILANT: single-bit bit-field but unnamed + signed char : 1; // COMPILANT: single-bit bit-field but unnamed } sample_struct; From 831cf033caeeebb1c67fccb67f4b6b93e7f3fcd4 Mon Sep 17 00:00:00 2001 From: Jeongsoo Lee Date: Tue, 31 Jan 2023 16:21:28 -0800 Subject: [PATCH 22/23] format qldoc comment (indentation) --- ...hallOnlyBeDeclaredWithAnAppropriateType.ql | 38 +++++++++---------- .../SingleBitNamedBitFieldsOfASignedType.ql | 28 ++++++++------ 2 files changed, 35 insertions(+), 31 deletions(-) diff --git a/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql b/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql index 82f2c9c89a..86d12aa263 100644 --- a/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql +++ b/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql @@ -1,14 +1,14 @@ /** -* @id c/misra/bit-fields-shall-only-be-declared-with-an-appropriate-type -* @name RULE-6-1: Bit-fields shall only be declared with an appropriate type -* @description Declaring bit-fields on types other than appropriate ones causes -* implementation-specific or undefined behavior. -* @kind problem -* @precision very-high -* @problem.severity error -* @tags external/misra/id/rule-6-1 -* external/misra/obligation/required -*/ + * @id c/misra/bit-fields-shall-only-be-declared-with-an-appropriate-type + * @name RULE-6-1: Bit-fields shall only be declared with an appropriate type + * @description Declaring bit-fields on types other than appropriate ones causes + * implementation-specific or undefined behavior. + * @kind problem + * @precision very-high + * @problem.severity error + * @tags external/misra/id/rule-6-1 + * external/misra/obligation/required + */ import cpp import codingstandards.c.misra @@ -17,20 +17,20 @@ predicate isAppropriatePrimitive(Type type) { /* An appropriate primitive types to which a bit-field can be declared. */ type instanceof IntType and ( - type.(IntegralType).isExplicitlySigned() or - type.(IntegralType).isExplicitlyUnsigned() - ) + type.(IntegralType).isExplicitlySigned() or + type.(IntegralType).isExplicitlyUnsigned() + ) or type instanceof BoolType } from BitField bitField where -not isExcluded(bitField, -BitfieldTypesPackage::bitFieldsShallOnlyBeDeclaredWithAnAppropriateTypeQuery()) and + not isExcluded(bitField, + BitfieldTypesPackage::bitFieldsShallOnlyBeDeclaredWithAnAppropriateTypeQuery()) and /* A violation would neither an appropriate primitive type nor an appropriate typedef. */ -not ( - isAppropriatePrimitive(bitField.getType()) or - isAppropriatePrimitive(bitField.getType().resolveTypedefs()) - ) + not ( + isAppropriatePrimitive(bitField.getType()) or + isAppropriatePrimitive(bitField.getType().resolveTypedefs()) + ) select bitField, "Bit-field " + bitField + " is declared on type " + bitField.getType() + "." diff --git a/c/misra/src/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql b/c/misra/src/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql index 98d2fcc0ef..d4be3d6dd2 100644 --- a/c/misra/src/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql +++ b/c/misra/src/rules/RULE-6-2/SingleBitNamedBitFieldsOfASignedType.ql @@ -13,18 +13,22 @@ import cpp import codingstandards.c.misra -/* Check if the DECLARED bit-fields is a single bit, because Rule 6.2 also intends to catch confusion on the programmers' part. Consider: - -struct S { - int32_t x: 1; -} - -In this case, field x is essentially of 32 bits, but is declared as 1 bit and its type int32_t is signed. Therefore, it indicates confusion by the programmer, which is exactly what this rule intends to find. */ +/* + * Check if the DECLARED bit-fields is a single bit, because Rule 6.2 also intends to catch confusion on the programmers' part. Consider: + * + * struct S { + * int32_t x: 1; + * } + * + * In this case, field x is essentially of 32 bits, but is declared as 1 bit and its type int32_t is signed. Therefore, it indicates confusion by the programmer, which is exactly what this rule intends to find. + */ from BitField bitField where -not isExcluded(bitField, BitfieldTypesPackage::singleBitNamedBitFieldsOfASignedTypeQuery()) and -bitField.getDeclaredNumBits() = 1 and // Single-bit, -not bitField.isAnonymous() and // named, -bitField.getType().(IntegralType).isSigned() // but its type is signed. -select bitField, "Single-bit bit-field named " + bitField.toString() + " has a signed type " + bitField.getType() + "." + not isExcluded(bitField, BitfieldTypesPackage::singleBitNamedBitFieldsOfASignedTypeQuery()) and + bitField.getDeclaredNumBits() = 1 and // Single-bit, + not bitField.isAnonymous() and // named, + bitField.getType().(IntegralType).isSigned() // but its type is signed. +select bitField, + "Single-bit bit-field named " + bitField.toString() + " has a signed type " + bitField.getType() + + "." From 3e96c5fead7cb5e2eebd435e248aeaa20f96e327 Mon Sep 17 00:00:00 2001 From: Jeongsoo Lee Date: Wed, 1 Feb 2023 10:59:04 -0800 Subject: [PATCH 23/23] refine RULE-6-1 Use the fact that `resolveTypedefs` is an identity operation with types that have no type alias (typedef). --- .../BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql b/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql index 86d12aa263..81c7fb69a3 100644 --- a/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql +++ b/c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql @@ -28,9 +28,6 @@ from BitField bitField where not isExcluded(bitField, BitfieldTypesPackage::bitFieldsShallOnlyBeDeclaredWithAnAppropriateTypeQuery()) and - /* A violation would neither an appropriate primitive type nor an appropriate typedef. */ - not ( - isAppropriatePrimitive(bitField.getType()) or - isAppropriatePrimitive(bitField.getType().resolveTypedefs()) - ) + /* A violation would neither be an appropriate primitive type nor an appropriate typedef. */ + not isAppropriatePrimitive(bitField.getType().resolveTypedefs()) select bitField, "Bit-field " + bitField + " is declared on type " + bitField.getType() + "."