Skip to content

Commit 8dc1ea5

Browse files
authored
Merge pull request #241 from github/lcartey/20-12-improve-perf
Rule 20.12: Improve performance
2 parents 200c125 + d9188c7 commit 8dc1ea5

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

c/misra/src/rules/RULE-20-12/MacroParameterUsedAsHashOperand.ql

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import codingstandards.cpp.Macro
1919

2020
from FunctionLikeMacro m, MacroInvocation mi, int i, string expanded, string param
2121
where
22-
not isExcluded(m, Preprocessor2Package::macroParameterUsedAsHashOperandQuery()) and
22+
not isExcluded(mi, Preprocessor2Package::macroParameterUsedAsHashOperandQuery()) and
2323
mi = m.getAnInvocation() and
2424
param = m.getParameter(i) and
2525
(
@@ -31,9 +31,6 @@ where
3131
// This check ensure there is an expansion that is used.
3232
expanded = mi.getExpandedArgument(i) and
3333
not expanded = "" and
34-
exists(Macro furtherExpandedMacro |
35-
mi.getUnexpandedArgument(i).matches(furtherExpandedMacro.getName() + "%")
36-
)
34+
not mi.getUnexpandedArgument(i) = mi.getExpandedArgument(i)
3735
select m,
38-
"Macro " + m.getName() + " contains use of parameter " + m.getParameter(i) +
39-
" used in multiple contexts."
36+
"Macro " + m.getName() + " contains use of parameter " + param + " used in multiple contexts."

change_notes/2023-03-07-20-12-perf.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* `Rule 20.12` - the performance of this rule has been improved.

0 commit comments

Comments
 (0)