Skip to content

Commit 3074878

Browse files
Fix query formats
1 parent 61b2852 commit 3074878

9 files changed

+30
-29
lines changed

c/common/src/codingstandards/c/Generic.qll

+3-8
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ string deparenthesize(string input) {
1010
result = input.substring(1, input.length() - 1)
1111
}
1212

13-
1413
class GenericMacro extends Macro {
1514
string ctrlExpr;
1615

@@ -61,9 +60,7 @@ class ParsedGenericMacro extends Macro {
6160
)
6261
}
6362

64-
string getAParameter() {
65-
result = this.(FunctionLikeMacro).getAParameter()
66-
}
63+
string getAParameter() { result = this.(FunctionLikeMacro).getAParameter() }
6764

6865
int getAParsedGenericCommaSeparatorOffset() {
6966
exists(ParsedText text |
@@ -118,9 +115,7 @@ class ParsedGenericMacro extends Macro {
118115
)
119116
}
120117

121-
string getControllingExprString() {
122-
result = getSelectionString(1)
123-
}
118+
string getControllingExprString() { result = getSelectionString(1) }
124119

125120
bindingset[str, word]
126121
private int countWordInString(string word, string str) {
@@ -152,4 +147,4 @@ class ParsedGenericMacro extends Macro {
152147
not idx = 0 and
153148
result = expansionsInsideSelection(parameter, idx + 1)
154149
}
155-
}
150+
}

c/misra/src/rules/RULE-23-1/GenericSelectionNotExpandedFromAMacro.ql

+2-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ from C11GenericExpr generic, Expr ctrlExpr
1818
where
1919
not isExcluded(generic, GenericsPackage::genericSelectionNotExpandedFromAMacroQuery()) and
2020
ctrlExpr = generic.getControllingExpr() and
21-
not exists(MacroInvocation mi |
22-
mi.getAGeneratedElement() = generic.getExpr()
23-
)
21+
not exists(MacroInvocation mi | mi.getAGeneratedElement() = generic.getExpr())
2422
select generic, "Generic expression with controlling expression $@ is not expanded froma macro",
25-
ctrlExpr, ctrlExpr.toString()
23+
ctrlExpr, ctrlExpr.toString()

c/misra/src/rules/RULE-23-2/GenericSelectionNotFromMacroWithSideEffects.ql

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,4 @@ where
8484
not isExcluded(res.getPrimaryElement(),
8585
GenericsPackage::genericSelectionNotFromMacroWithSideEffectsQuery())
8686
select res.getPrimaryElement(), res.getMessage(), res.getOptionalPlaceholderLocatable(),
87-
res.getOptionalPlaceholderMessage()
87+
res.getOptionalPlaceholderMessage()

c/misra/src/rules/RULE-23-3/GenericWithoutNonDefaultAssociation.ql

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ where
3131
not exists(Type t |
3232
t = generic.getAnAssociationType() and
3333
not t instanceof VoidType
34-
) and primaryElement = MacroUnwrapper<InvalidGeneric>::unwrapElement(generic)
34+
) and
35+
primaryElement = MacroUnwrapper<InvalidGeneric>::unwrapElement(generic)
3536
select primaryElement, "Generic selection contains no non-default association."

c/misra/src/rules/RULE-23-4/GenericAssociationWithUnselectableType.ql

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import codingstandards.cpp.alertreporting.DeduplicateMacroResults
2020

2121
/**
2222
* Check if a type contains an unmatchable anonymous struct or union.
23-
*
23+
*
2424
* Anonymous structs and unions are only equal to themselves. So any anonymous struct, or compound
2525
* type containing an anonymous struct, is unmatchable.
26-
*
26+
*
2727
* However, there is an exception if the anonymous struct is behind a typedef. All uses of that
2828
* typedef will resolve to the same anonymous struct, and so the typedef is matchable.
2929
*/

c/misra/src/rules/RULE-23-6/GenericExpressionWithIncorrectEssentialType.ql

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@ where
5757
)
5858
)
5959
select generic,
60-
"Controlling expression in generic " + extraMessage +
61-
"has standard type " + ctrlType.toString() + ", which doesn't match its essential type " +
62-
ctrlEssentialType.toString() + ".", extraElement, extraString
60+
"Controlling expression in generic " + extraMessage + "has standard type " + ctrlType.toString() +
61+
", which doesn't match its essential type " + ctrlEssentialType.toString() + ".", extraElement,
62+
extraString

c/misra/src/rules/RULE-23-8/DefaultGenericSelectionNotFirstOrLast.ql

+6-3
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,15 @@ module GenericMisplacedDefaultReportConfig implements
5353
bindingset[description]
5454
string getMessageSameResultInAllExpansions(Macro m, string description) {
5555
result =
56-
"Generic macro " + m.getName() + " has default as " + description + " association, which is not first or last."
56+
"Generic macro " + m.getName() + " has default as " + description +
57+
" association, which is not first or last."
5758
}
5859

5960
/* Create a message to describe this macro, using '$@' to describe an example `ResultElement`. */
6061
string getMessageVariedResultInAllExpansions(Macro m) {
6162
result =
62-
"Generic macro " + m.getName() + " has a default association which is not first or last, for example $@."
63+
"Generic macro " + m.getName() +
64+
" has a default association which is not first or last, for example $@."
6365
}
6466

6567
/**
@@ -68,7 +70,8 @@ module GenericMisplacedDefaultReportConfig implements
6870
*/
6971
string getMessageResultInIsolatedExpansion(GenericWithMisplacedDefault element) {
7072
result =
71-
"Generic macro $@, in this expansion, has default as " + describe(element) + " association, which is not first or last."
73+
"Generic macro $@, in this expansion, has default as " + describe(element) +
74+
" association, which is not first or last."
7275
}
7376

7477
/**

c/misra/src/rules/RULE-8-3/DeclarationsOfAFunctionSameNameAndType.ql

+9-5
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,19 @@ where
2525
//return type check
2626
(
2727
not FunctionDeclarationTypeEquivalence<TypeNamesMatchConfig>::equalReturnTypes(f1, f2) and
28-
case = "return type" and pluralDo = "does"
28+
case = "return type" and
29+
pluralDo = "does"
2930
or
3031
//parameter type check
3132
not FunctionDeclarationTypeEquivalence<TypeNamesMatchConfig>::equalParameterTypes(f1, f2) and
32-
case = "parameter types" and pluralDo = "do"
33+
case = "parameter types" and
34+
pluralDo = "do"
3335
or
3436
//parameter name check
3537
parameterNamesUnmatched(f1, f2) and
36-
case = "parameter names" and pluralDo = "do"
38+
case = "parameter names" and
39+
pluralDo = "do"
3740
)
38-
select f1, "The " + case + " of re-declaration of $@ " + pluralDo + " not use the same type names as declaration $@", f1,
39-
f1.getName(), f2, f2.getName()
41+
select f1,
42+
"The " + case + " of re-declaration of $@ " + pluralDo +
43+
" not use the same type names as declaration $@", f1, f1.getName(), f2, f2.getName()

c/misra/src/rules/RULE-8-3/DeclarationsOfAnObjectSameNameAndType.ql

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@ where
5252
decl2.getType())
5353
select decl1,
5454
"The object $@ of type " + decl1.getType().toString() +
55-
" does not use the same type names as re-declaration $@ of type " + decl2.getType().toString(), decl1,
56-
decl1.getName(), decl2, decl2.getName()
55+
" does not use the same type names as re-declaration $@ of type " + decl2.getType().toString(),
56+
decl1, decl1.getName(), decl2, decl2.getName()

0 commit comments

Comments
 (0)