@@ -17,20 +17,12 @@ import semmle.code.cpp.commons.Exclusions
1717 * ThisExpr.isCompilerGenerated() is currently not being extracted, so use a heuristic.
1818 */
1919predicate isCompilerGenerated ( ThisExpr te ) {
20- exists (
21- string filepath , int line , int colStart , int colEnd , boolean zeroDiff , boolean sameLocAsCall
20+ exists ( int line , int colStart , int colEnd |
21+ te . getLocation ( ) . hasLocationInfo ( _ , line , colStart , line , colEnd )
2222 |
23- te .getLocation ( ) .hasLocationInfo ( filepath , line , colStart , line , colEnd ) and
24- ( if colStart = colEnd then zeroDiff = true else zeroDiff = false ) and
25- (
26- if exists ( Call c | c .getQualifier ( ) = te | c .getLocation ( ) = te .getLocation ( ) )
27- then sameLocAsCall = true
28- else sameLocAsCall = false
29- )
30- |
31- zeroDiff = true
23+ colStart = colEnd
3224 or
33- zeroDiff = false and sameLocAsCall = true
25+ exists ( Call c | c . getQualifier ( ) = te | c . getLocation ( ) = te . getLocation ( ) )
3426 )
3527}
3628
@@ -47,26 +39,16 @@ Expr normalizeExpr(Expr e) {
4739 else result = e
4840}
4941
50- predicate isInLoopHead ( CommaExpr ce ) {
51- ce .getParent * ( ) = [ any ( Loop l ) .getCondition ( ) , any ( ForStmt f ) .getUpdate ( ) ]
52- or
53- ce .getEnclosingStmt ( ) = any ( ForStmt f ) .getInitialization ( )
54- }
55-
56- predicate isInDecltypeOrSizeof ( CommaExpr ce ) {
57- ce .getParent * ( ) instanceof SizeofExprOperator
58- or
59- ce .getParent * ( ) = any ( Decltype d ) .getExpr ( )
60- }
61-
6242predicate isParenthesized ( CommaExpr ce ) {
63- isInLoopHead ( ce )
64- or
65- isInDecltypeOrSizeof ( ce )
66- or
6743 ce .getParent * ( ) .( Expr ) .isParenthesised ( )
6844 or
45+ ce .isUnevaluated ( ) // sizeof(), decltype(), alignof(), noexcept(), typeid()
46+ or
6947 ce .getParent * ( ) = any ( IfStmt i ) .getCondition ( )
48+ or
49+ ce .getParent * ( ) = [ any ( Loop l ) .getCondition ( ) , any ( ForStmt f ) .getUpdate ( ) ]
50+ or
51+ ce .getEnclosingStmt ( ) = any ( ForStmt f ) .getInitialization ( )
7052}
7153
7254from CommaExpr ce , Expr left , Expr right , Location leftLoc , Location rightLoc
0 commit comments