File tree 2 files changed +16
-2
lines changed
2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 24
24
not lambdaExpression = otherLambdaExpression and
25
25
not lambdaExpression .isFromTemplateInstantiation ( _) and
26
26
not otherLambdaExpression .isFromTemplateInstantiation ( _) and
27
- getLambdaHashCons ( lambdaExpression ) = getLambdaHashCons ( otherLambdaExpression )
27
+ getLambdaHashCons ( lambdaExpression ) = getLambdaHashCons ( otherLambdaExpression ) and
28
+ // Do not report lambdas produced by the same macro in different invocations
29
+ not exists ( Macro m , MacroInvocation m1 , MacroInvocation m2 |
30
+ m1 = m .getAnInvocation ( ) and
31
+ m2 = m .getAnInvocation ( ) and
32
+ not m1 = m2 and // Lambdas in the same macro can be reported
33
+ m1 .getAnExpandedElement ( ) = lambdaExpression and
34
+ m2 .getAnExpandedElement ( ) = otherLambdaExpression
35
+ )
28
36
select lambdaExpression , "Lambda expression is identical to $@ lambda expression." ,
29
37
otherLambdaExpression , "this"
Original file line number Diff line number Diff line change @@ -104,4 +104,10 @@ class Test_issue468 {
104
104
LogError (" Error" );
105
105
LogFatal (" Fatal" );
106
106
}
107
- };
107
+ };
108
+
109
+ #define MACRO () [](int i) -> int { return i + 3 ; }
110
+ void test_macros () {
111
+ MACRO (); // COMPLIANT
112
+ MACRO (); // COMPLIANT - no duplication
113
+ }
You can’t perform that action at this time.
0 commit comments