File tree Expand file tree Collapse file tree 2 files changed +17
-26
lines changed Expand file tree Collapse file tree 2 files changed +17
-26
lines changed Original file line number Diff line number Diff line change 14
14
15
15
import cpp
16
16
import codingstandards.c.cert
17
+ import codingstandards.cpp.Concurrency
17
18
18
19
from MacroInvocation mi , Variable v , Locatable whereFound
19
20
where
@@ -22,13 +23,13 @@ where
22
23
// There isn't a way to safely use this construct in a way that is also
23
24
// possible the reliably detect so advise against using it.
24
25
(
25
- mi . getMacroName ( ) = [ "atomic_store" , "atomic_store_explicit" ]
26
+ mi instanceof AtomicStore
26
27
or
27
28
// This construct is generally safe, but must be used in a loop. To lower
28
29
// the false positive rate we don't look at the conditions of the loop and
29
30
// instead assume if it is found in a looping construct that it is likely
30
31
// related to the safety property.
31
- mi . getMacroName ( ) = [ "atomic_compare_exchange_weak" , "atomic_compare_exchange_weak_explicit" ] and
32
+ mi instanceof AtomicCompareExchange and
32
33
not exists ( Loop l | mi .getAGeneratedElement ( ) .( Expr ) .getParent * ( ) = l )
33
34
) and
34
35
whereFound = mi
Original file line number Diff line number Diff line change 12
12
* external/cert/obligation/rule
13
13
*/
14
14
15
- import cpp
16
- import codingstandards.c.cert
15
+ import cpp
16
+ import codingstandards.c.cert
17
+ import codingstandards.cpp.Concurrency
18
+
17
19
18
- /**
19
- * Models calls to routines in the `stdatomic` library. Note that these
20
- * are typically implemented as macros within Clang and GCC's standard
21
- * libraries.
22
- */
23
- class SpuriouslyFailingFunctionCallType extends MacroInvocation {
24
- SpuriouslyFailingFunctionCallType ( ) {
25
- getMacroName ( ) = [ "atomic_compare_exchange_weak" , "atomic_compare_exchange_weak_explicit" ]
26
- }
27
- }
28
-
29
- from SpuriouslyFailingFunctionCallType fc
30
- where
31
- not isExcluded ( fc , Concurrency3Package:: wrapFunctionsThatCanFailSpuriouslyInLoopQuery ( ) ) and
32
- (
33
- exists ( StmtParent sp | sp = fc .getStmt ( ) and not sp .( Stmt ) .getParentStmt * ( ) instanceof Loop )
34
- or
35
- exists ( StmtParent sp |
36
- sp = fc .getExpr ( ) and not sp .( Expr ) .getEnclosingStmt ( ) .getParentStmt * ( ) instanceof Loop
37
- )
38
- )
39
- select fc , "Function that can spuriously fail not wrapped in a loop."
20
+ from AtomicCompareExchange ace
21
+ where
22
+ not isExcluded ( ace , Concurrency3Package:: wrapFunctionsThatCanFailSpuriouslyInLoopQuery ( ) ) and
23
+ (
24
+ forex ( StmtParent sp | sp = ace .getStmt ( ) | not sp .( Stmt ) .getParentStmt * ( ) instanceof Loop ) or
25
+ forex ( Expr e | e = ace .getExpr ( ) | not e .getEnclosingStmt ( ) .getParentStmt * ( )
26
+ instanceof Loop )
27
+ )
28
+ select ace , "Function that can spuriously fail not wrapped in a loop."
29
+
You can’t perform that action at this time.
0 commit comments