Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3eecfa0

Browse files
Update StdFunctionOrMacro with feedback
1 parent1b2199f commit3eecfa0

File tree

2 files changed

+15
-22
lines changed

2 files changed

+15
-22
lines changed

‎c/misra/src/rules/RULE-9-7/UninitializedAtomicObject.ql‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,8 @@ class ThreadSpawningFunction extends Function {
3030
}
3131
}
3232

33-
privatestringatomicInit(){result="atomic_init"}
34-
3533
classAtomicInitAddressOfExprextendsAddressOfExpr{
36-
AtomicInitAddressOfExpr(){
37-
exists(StdFunctionOrMacro<C11FunctionWrapperMacro,atomicInit/0>::Callc|
38-
this=c.getArgument(0)
39-
)
40-
}
34+
AtomicInitAddressOfExpr(){exists(AtomicInitCallc|this=c.getArgument(0))}
4135
}
4236

4337
ControlFlowNodegetARequiredInitializationPoint(LocalScopeVariablev){

‎cpp/common/src/codingstandards/cpp/StdFunctionOrMacro.qll‎

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,28 @@
3131

3232
import cppas cpp
3333

34+
privatestringatomicInit(){result="atomic_init"}
35+
36+
classAtomicInitCall= StdFunctionOrMacro<C11FunctionWrapperMacro,atomicInit/0>::Call;
37+
3438
/** Specify the name of your function as a predicate */
35-
signaturestringgetName();
39+
privatesignaturestringgetName();
3640

3741
/** Signature module to implement custom argument resolution behavior in expanded macros */
38-
signaturemodule InferMacroExpansionArguments{
42+
privatesignaturemodule InferMacroExpansionArguments{
3943
bindingset[mi, argumentIdx]
4044
cpp::ExprinferArgument(cpp::MacroInvocationmi,intargumentIdx);
4145
}
4246

43-
/** Assume all subexpressions of an expanded macro may be the result of any ith argument */
44-
module NoMacroExpansionInferenceimplementsInferMacroExpansionArguments{
45-
bindingset[mi, argumentIdx]
46-
cpp::ExprinferArgument(cpp::MacroInvocationmi,intargumentIdx){
47-
result.getParent*()=mi.getExpr()
48-
}
49-
}
50-
5147
/** Assume macro `f(x, y, ...)` expands to `__c11_f(x, y, ...)`. */
52-
module C11FunctionWrapperMacroimplementsInferMacroExpansionArguments{
48+
privatemodule C11FunctionWrapperMacroimplementsInferMacroExpansionArguments{
5349
bindingset[mi, argumentIdx]
5450
cpp::ExprinferArgument(cpp::MacroInvocationmi,intargumentIdx){
55-
ifmi.getExpr().(cpp::FunctionCall).getTarget().hasName("__c11_"+mi.getMacroName())
56-
thenresult=mi.getExpr().(cpp::FunctionCall).getArgument(argumentIdx)
57-
elseresult= NoMacroExpansionInference::inferArgument(mi,argumentIdx)
51+
exists(cpp::FunctionCallfc|
52+
fc=mi.getExpr()and
53+
fc.getTarget().hasName("__c11_"+mi.getMacroName())and
54+
result=mi.getExpr().(cpp::FunctionCall).getArgument(argumentIdx)
55+
)
5856
}
5957
}
6058

@@ -72,7 +70,8 @@ module C11FunctionWrapperMacro implements InferMacroExpansionArguments {
7270
* select c.getArgument(0)
7371
* ```
7472
*/
75-
module StdFunctionOrMacro<InferMacroExpansionArguments InferExpansion,getName/0 getStdName>{
73+
privatemodule StdFunctionOrMacro<InferMacroExpansionArguments InferExpansion,getName/0 getStdName>
74+
{
7675
finalprivateclassExpr= cpp::Expr;
7776

7877
finalprivateclassFunctionCall= cpp::FunctionCall;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp