Skip to content

Commit 516ef74

Browse files
committed
Rule 23.11.1: Address review comments
- Simplify query - Improve documentation
1 parent a2de810 commit 516ef74

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

cpp/misra/src/rules/RULE-23-11-1/UseSmartPtrFactoryFunctions.ql

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ where
2424
smartPtrClass.hasQualifiedName("std", "shared_ptr") or
2525
smartPtrClass.hasQualifiedName("std", "unique_ptr")
2626
) and
27-
call.getNumberOfArguments() >= 1 and
28-
exists(Type argType |
29-
argType = call.getArgument(0).getType().getUnspecifiedType() and
30-
argType instanceof PointerType
31-
)
27+
// The rule only applies to constructors that take a raw pointer as the first argument
28+
// This includes the (*p, deleter) and (*p, deleter, alloc) constructors
29+
// and excludes e.g. the move or aliasing constructors.
30+
call.getArgument(0).getType().getUnspecifiedType() instanceof PointerType
3231
select call, "Use of raw pointer constructor for 'std::" + smartPtrClass.getSimpleName() + "'."

0 commit comments

Comments
 (0)