File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 2424 not lambdaExpression = otherLambdaExpression and
2525 not lambdaExpression .isFromTemplateInstantiation ( _) and
2626 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+ )
2836select lambdaExpression , "Lambda expression is identical to $@ lambda expression." ,
2937 otherLambdaExpression , "this"
Original file line number Diff line number Diff line change @@ -104,4 +104,10 @@ class Test_issue468 {
104104 LogError (" Error" );
105105 LogFatal (" Fatal" );
106106 }
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