Skip to content

Commit 14a0431

Browse files
authored
Merge pull request #472 from github/lcartey/remove-old-is-excluded
Fix deviations through use of deprecated `isExcluded` predicates
2 parents 033dc61 + 93f6cdc commit 14a0431

15 files changed

+19
-24
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- The following queries have been updated to address issues with applying deviations:
2+
- `A18-5-11`, `A23-0-1`, `A9-3-1`, `M0-1-2`, `M3-1-2`, `M3-2-1`, `M3-2-3`, `M3-9-1`, `M4-5-3`, `M5-0-2`, `M5-2-10`, `A23-0-2`, `CTR51-CPP`, `STR52-CPP`

cpp/autosar/src/rules/A18-5-11/OperatorNewAndOperatorDeleteNotDefinedLocally.ql

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import codingstandards.cpp.autosar
1919

2020
from MemberFunction operator_new, Class c
2121
where
22-
not isExcluded(operator_new) and
22+
not isExcluded(operator_new,
23+
DeclarationsPackage::operatorNewAndOperatorDeleteNotDefinedLocallyQuery()) and
2324
not isExcluded(c, DeclarationsPackage::operatorNewAndOperatorDeleteNotDefinedLocallyQuery()) and
2425
operator_new.hasName("operator new") and
2526
operator_new.getDeclaringType() = c and

cpp/autosar/src/rules/A23-0-1/IteratorImplicitlyConvertedToConstIterator.ql

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ import codingstandards.cpp.Iterators
4040

4141
from ConstIteratorVariable v, STLContainer c, Expr e
4242
where
43-
not isExcluded(v) and
44-
not isExcluded(e) and
43+
not isExcluded(v, IteratorsPackage::iteratorImplicitlyConvertedToConstIteratorQuery()) and
44+
not isExcluded(e, IteratorsPackage::iteratorImplicitlyConvertedToConstIteratorQuery()) and
4545
e = v.getAnAssignedValue() and
4646
e.getAChild*() = /* see note at top of query */ c.getANonConstIteratorFunctionCall()
4747
select e, "Non-const version of container call immediately converted to a `const_iterator`."

cpp/autosar/src/rules/A9-3-1/ReturnsNonConstRawPointersOrReferencesToPrivateOrProtectedData.ql

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ class AccessAwareMemberFunction extends MemberFunction {
5757

5858
from Class c, AccessAwareMemberFunction mf, FieldAccess a, ReturnStmt rs
5959
where
60-
not isExcluded(c) and
60+
not isExcluded(c,
61+
ClassesPackage::returnsNonConstRawPointersOrReferencesToPrivateOrProtectedDataQuery()) and
6162
not isExcluded(mf,
6263
ClassesPackage::returnsNonConstRawPointersOrReferencesToPrivateOrProtectedDataQuery()) and
6364
// Find all of the methods within this class

cpp/autosar/src/rules/M0-1-2/InfeasiblePath.ql

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,6 @@ predicate hasInfeasiblePath(
158158

159159
from ConditionalControlFlowNode cond, boolean infeasiblePath, string explanation
160160
where
161-
not isExcluded(cond) and
161+
not isExcluded(cond, DeadCodePackage::infeasiblePathQuery()) and
162162
hasInfeasiblePath(cond, infeasiblePath, explanation)
163163
select cond, "The " + infeasiblePath + " path is infeasible because " + explanation + "."

cpp/autosar/src/rules/M3-1-2/FunctionsDeclaredAtBlockScope.ql

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import codingstandards.cpp.autosar
2020

2121
from DeclStmt decl, Function f
2222
where
23-
not isExcluded(decl) and
23+
not isExcluded(decl, DeclarationsPackage::functionsDeclaredAtBlockScopeQuery()) and
2424
not isExcluded(f, DeclarationsPackage::functionsDeclaredAtBlockScopeQuery()) and
2525
decl.getADeclaration() = f
2626
select f, "Function " + f.getName() + " is declared at block scope."

cpp/autosar/src/rules/M3-2-1/DeclarationsOfAFunctionShallHaveCompatibleTypes.ql

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import codingstandards.cpp.Typehelpers
2222

2323
from FunctionDeclarationEntry f1, FunctionDeclarationEntry f2
2424
where
25-
not isExcluded(f1) and
25+
not isExcluded(f1, DeclarationsPackage::declarationsOfAFunctionShallHaveCompatibleTypesQuery()) and
2626
not isExcluded(f2, DeclarationsPackage::declarationsOfAFunctionShallHaveCompatibleTypesQuery()) and
2727
not f1 = f2 and
2828
f1.getDeclaration() = f2.getDeclaration() and

cpp/autosar/src/rules/M3-2-3/MultipleDeclarationViolation.ql

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import codingstandards.cpp.Scope
2020

2121
from DeclarationEntry de, DeclarationEntry otherDeclaration, string kind
2222
where
23-
not isExcluded(de) and
23+
not isExcluded(de, ScopePackage::multipleDeclarationViolationQuery()) and
2424
exists(Declaration d |
2525
de.getDeclaration() = d and
2626
otherDeclaration.getDeclaration() = d and

cpp/autosar/src/rules/M3-9-1/TypesNotIdenticalInObjectDeclarations.ql

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import codingstandards.cpp.autosar
1818

1919
from VariableDeclarationEntry decl1, VariableDeclarationEntry decl2
2020
where
21-
not isExcluded(decl1) and
21+
not isExcluded(decl1, DeclarationsPackage::typesNotIdenticalInObjectDeclarationsQuery()) and
2222
not isExcluded(decl2, DeclarationsPackage::typesNotIdenticalInObjectDeclarationsQuery()) and
2323
decl1.getDeclaration() = decl2.getDeclaration() and
2424
not decl1.getType() = decl2.getType()

cpp/autosar/src/rules/M3-9-1/TypesNotIdenticalInReturnDeclarations.ql

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import codingstandards.cpp.autosar
1818

1919
from FunctionDeclarationEntry f1, FunctionDeclarationEntry f2
2020
where
21-
not isExcluded(f1) and
21+
not isExcluded(f1, DeclarationsPackage::typesNotIdenticalInReturnDeclarationsQuery()) and
2222
not isExcluded(f2, DeclarationsPackage::typesNotIdenticalInReturnDeclarationsQuery()) and
2323
f1.getDeclaration() = f2.getDeclaration() and
2424
not f1.getType() = f2.getType()

cpp/autosar/src/rules/M4-5-3/CharUsedAsOperandsToDisallowedBuiltInOperators.ql

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import codingstandards.cpp.autosar
2222

2323
from Operation o
2424
where
25-
not isExcluded(o) and
25+
not isExcluded(o, ExpressionsPackage::charUsedAsOperandsToDisallowedBuiltInOperatorsQuery()) and
2626
not (
2727
o instanceof EqualityOperation or
2828
o instanceof BitwiseAndExpr or

cpp/autosar/src/rules/M5-0-2/GratuitousUseOfParentheses.ql

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ predicate isGratuitousUseOfParentheses(ParenthesisExpr pe) {
8484

8585
from ParenthesisExpr p
8686
where
87-
not isExcluded(p) and
87+
not isExcluded(p, OrderOfEvaluationPackage::gratuitousUseOfParenthesesQuery()) and
8888
isGratuitousUseOfParentheses(p) and
8989
not p.isInMacroExpansion()
9090
select p, "Gratuitous use of parentheses around $@.", p.getExpr(), p.getExpr().toString()

cpp/autosar/src/rules/M5-2-10/IncrementAndDecrementOperatorsMixedWithOtherOperatorsInExpression.ql

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import codingstandards.cpp.Expr
2020

2121
from CrementOperation cop, ArithmeticOperation op, string name
2222
where
23-
not isExcluded(cop) and
23+
not isExcluded(cop,
24+
OrderOfEvaluationPackage::incrementAndDecrementOperatorsMixedWithOtherOperatorsInExpressionQuery()) and
2425
not isExcluded(op,
2526
OrderOfEvaluationPackage::incrementAndDecrementOperatorsMixedWithOtherOperatorsInExpressionQuery()) and
2627
op.getAnOperand() = cop and

cpp/common/src/codingstandards/cpp/Exclusions.qll

-10
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,6 @@ private class ExcludeOutsideSourceLocation extends ExcludedFile {
1414
ExcludeOutsideSourceLocation() { not exists(getRelativePath()) }
1515
}
1616

17-
/** Holds if the element should be excluded. */
18-
predicate isExcluded(Element e) {
19-
e instanceof ExcludedElement
20-
or
21-
e.getFile() instanceof ExcludedFile
22-
or
23-
// Compiler generated
24-
not exists(e.getFile())
25-
}
26-
2717
bindingset[e, query]
2818
predicate isExcluded(Element e, Query query) { isExcluded(e, query, _) }
2919

cpp/common/src/codingstandards/cpp/rules/validcontainerelementaccess/ValidContainerElementAccess.qll

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ query predicate problems(
3636
ContainerInvalidationOperation cio, string actionType
3737
) {
3838
not isExcluded(cio, getQuery()) and
39-
not isExcluded(ca) and
39+
not isExcluded(ca, getQuery()) and
4040
// The definition of an invalidation is slightly different
4141
// for references vs iterators -- this check ensures that the conditions
4242
// under which a call should be an invalidator are considered correctly.

0 commit comments

Comments
 (0)