Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix bad joins on function names and unnecessarily large relation on integer constant macros#933

New issue

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

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

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletionsc/cert/src/rules/DCL40-C/IncompatibleFunctionDeclarations.ql
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,28 +24,32 @@ import codingstandards.c.cert
import codingstandards.cpp.types.Compatible
import ExternalIdentifiers

predicate interestedInFunctions(FunctionDeclarationEntry f1, FunctionDeclarationEntry f2) {
predicate interestedInFunctions(
FunctionDeclarationEntry f1, FunctionDeclarationEntry f2, ExternalIdentifiers d
) {
not f1 = f2 and
f1.getDeclaration() = f2.getDeclaration() and
f1.getName() = f2.getName()
d = f1.getDeclaration() and
d = f2.getDeclaration()
}

predicate interestedInFunctions(FunctionDeclarationEntry f1, FunctionDeclarationEntry f2) {
interestedInFunctions(f1, f2, _)
}

module FuncDeclEquiv =
FunctionDeclarationTypeEquivalence<TypesCompatibleConfig, interestedInFunctions/2>;

from ExternalIdentifiers d, FunctionDeclarationEntry f1, FunctionDeclarationEntry f2
where
not isExcluded(f1, Declarations2Package::incompatibleFunctionDeclarationsQuery()) and
not isExcluded(f2, Declarations2Package::incompatibleFunctionDeclarationsQuery()) and
not f1 = f2 and
f1.getDeclaration() = d and
f2.getDeclaration() = d and
f1.getName() = f2.getName() and
interestedInFunctions(f1, f2, d) and
(
//return type check
not FunctionDeclarationTypeEquivalence<TypesCompatibleConfig, interestedInFunctions/2>::equalReturnTypes(f1,
f2)
not FuncDeclEquiv::equalReturnTypes(f1, f2)
or
//parameter type check
not FunctionDeclarationTypeEquivalence<TypesCompatibleConfig, interestedInFunctions/2>::equalParameterTypes(f1,
f2)
not FuncDeclEquiv::equalParameterTypes(f1, f2)
) and
// Apply ordering on start line, trying to avoid the optimiser applying this join too early
// in the pipeline
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,6 +20,7 @@ predicate matchesSign(IntegerConstantMacro macro, PossiblyNegativeLiteral litera
literal.isNegative() implies macro.isSigned()
}

bindingset[literal]
predicate matchesSize(IntegerConstantMacro macro, PossiblyNegativeLiteral literal) {
literal.getRawValue() <= macro.maxValue() and
literal.getRawValue() >= macro.minValue()
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,13 +23,14 @@ predicate interestedInFunctions(FunctionDeclarationEntry f1, FunctionDeclaration
f1.getDeclaration() instanceof ExternalIdentifiers and
f1.isDefinition() and
f1.getDeclaration() = f2.getDeclaration() and
// This condition should always hold, but removing it affects join order performance.
f1.getName() = f2.getName() and
not f2.isDefinition() and
not f1.isFromTemplateInstantiation(_) and
not f2.isFromTemplateInstantiation(_)
}

module FunDeclEquiv =
FunctionDeclarationTypeEquivalence<TypesCompatibleConfig, interestedInFunctions/2>;

from FunctionDeclarationEntry f1
where
not isExcluded(f1, Declarations4Package::compatibleDeclarationFunctionDefinedQuery()) and
Expand All@@ -44,17 +45,13 @@ where
or
//or one exists that is close but incompatible in some way
exists(FunctionDeclarationEntry f2 |
f1.getName() = f2.getName() and
not f2.isDefinition() and
f2.getDeclaration() = f1.getDeclaration() and
interestedInFunctions(f1, f2) and
(
//return types differ
not FunctionDeclarationTypeEquivalence<TypesCompatibleConfig, interestedInFunctions/2>::equalReturnTypes(f1,
f2)
not FunDeclEquiv::equalReturnTypes(f1, f2)
or
//parameter types differ
not FunctionDeclarationTypeEquivalence<TypesCompatibleConfig, interestedInFunctions/2>::equalParameterTypes(f1,
f2)
not FunDeclEquiv::equalParameterTypes(f1, f2)
or
//parameter names differ
parameterNamesUnmatched(f1, f2)
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
- `DCL40-C`, `RULE-8-4`: `IncompatibleFunctionDeclarations.ql`, `CompatibleDeclarationFunctionDefined.ql`.

Choose a reason for hiding this comment

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

The file name format suggests a date of July 15, 2025 (2025-7-15), but the standard format should use two-digit months (2025-07-15).

Copilot uses AI. Check for mistakes.
- Fixed performance issues introduced when upgrading to CodeQL `2.20.7` by removing unnecessary check that matching function declarations have matching names.
- `RULE-7-5`: `IncorrectlySizedIntegerConstantMacroArgument.ql`.
- Added a `bindingset` to improve performance when checking if a literal matches the size of an integer constant macro.

[8]ページ先頭

©2009-2025 Movatter.jp