mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Merge pull request #16557 from MathiasVP/fix-unique-pointer-query-fp
C++: Fix `cpp/use-of-unique-pointer-after-lifetime-ends` FP
This commit is contained in:
@@ -30,6 +30,8 @@ where
|
||||
outlivesFullExpr(c) and
|
||||
not c.isFromUninstantiatedTemplate(_) and
|
||||
isUniquePointerDerefFunction(c.getTarget()) and
|
||||
// Exclude cases where the pointer is implicitly converted to a non-pointer type
|
||||
not c.getActualType() instanceof IntegralType and
|
||||
isTemporary(c.getQualifier().getFullyConverted())
|
||||
select c,
|
||||
"The underlying unique pointer object is destroyed after the call to '" + c.getTarget() +
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
---
|
||||
category: minorAnalysis
|
||||
---
|
||||
* The "Use of unique pointer after lifetime ends" query (`cpp/use-of-unique-pointer-after-lifetime-ends`) no longer reports an alert when the pointer is converted to a boolean
|
||||
@@ -203,4 +203,12 @@ void test2(bool b1, bool b2) {
|
||||
auto s11 = b2 ? nullptr : sRefRef.get(); // GOOD
|
||||
const S* s12;
|
||||
s12 = sRefRef.get(); // GOOD
|
||||
}
|
||||
|
||||
void test_convert_to_bool() {
|
||||
bool b = get_unique_ptr().get(); // GOOD
|
||||
|
||||
if(get_unique_ptr().get()) { // GOOD
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user