@@ -17,20 +17,12 @@ import semmle.code.cpp.commons.Exclusions
17
17
* ThisExpr.isCompilerGenerated() is currently not being extracted, so use a heuristic.
18
18
*/
19
19
predicate 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 )
22
22
|
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
32
24
or
33
- zeroDiff = false and sameLocAsCall = true
25
+ exists ( Call c | c . getQualifier ( ) = te | c . getLocation ( ) = te . getLocation ( ) )
34
26
)
35
27
}
36
28
@@ -47,26 +39,16 @@ Expr normalizeExpr(Expr e) {
47
39
else result = e
48
40
}
49
41
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
-
62
42
predicate isParenthesized ( CommaExpr ce ) {
63
- isInLoopHead ( ce )
64
- or
65
- isInDecltypeOrSizeof ( ce )
66
- or
67
43
ce .getParent * ( ) .( Expr ) .isParenthesised ( )
68
44
or
45
+ ce .isUnevaluated ( ) // sizeof(), decltype(), alignof(), noexcept(), typeid()
46
+ or
69
47
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 ( )
70
52
}
71
53
72
54
from CommaExpr ce , Expr left , Expr right , Location leftLoc , Location rightLoc
0 commit comments