Skip to content

Commit 57dd748

Browse files
committed
Rule 5.4: Address review comments
1 parent 892cb96 commit 57dd748

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

c/misra/src/rules/RULE-5-4/MacroIdentifiersNotDistinct.ql

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ where
9999
// when m2 is defined
100100
isIncludedUnconditionallyFromCommonFile(m, m2) and
101101
// Macros can't be mutually exclusive
102-
not mutuallyExclusiveMacros(m, m2) and
103-
not mutuallyExclusiveMacros(m2, m) and
102+
not mutuallyExclusiveBranchDirectiveMacros(m, m2) and
103+
not mutuallyExclusiveBranchDirectiveMacros(m2, m) and
104104
// If at least one invocation exists for at least one of the macros, then they must share a link
105105
// target - i.e. must both be expanded in the same context
106106
(

cpp/common/src/codingstandards/cpp/PreprocessorDirective.qll

+3-6
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,9 @@ predicate isMacroDefinedWithinBranch(PreprocessorBranchDirective bd, Macro m) {
9898
* Holds if the pair of macros are "conditional" i.e. only one of the macros is followed in any
9999
* particular compilation of the containing file.
100100
*/
101-
predicate mutuallyExclusiveMacros(Macro firstMacro, Macro secondMacro) {
102-
exists(
103-
PreprocessorBranchDirective b1, PreprocessorBranchDirective b2, string filepath,
104-
int b1StartLocation, int b2StartLocation
105-
|
106-
isBranchDirectivePair(b1, b2, filepath, b1StartLocation, b2StartLocation) and
101+
predicate mutuallyExclusiveBranchDirectiveMacros(Macro firstMacro, Macro secondMacro) {
102+
exists(PreprocessorBranchDirective b1, PreprocessorBranchDirective b2 |
103+
isBranchDirectivePair(b1, b2, _, _, _) and
107104
isMacroDefinedWithinBranch(b1, firstMacro) and
108105
isMacroDefinedWithinBranch(b2, secondMacro)
109106
)

0 commit comments

Comments
 (0)