Skip to content

Commit

Permalink
[Issue mgehre#70] Initial version detecting release on std::unique_ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
lklein53 committed Nov 11, 2019
1 parent 58d57e2 commit 9ad7d12
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions clang/lib/Analysis/LifetimePsetBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,16 @@ class PSetsBuilder : public ConstStmtVisitor<PSetsBuilder, void> {
if (!Callee)
return;

if (auto MCE = dyn_cast<CXXMemberCallExpr>(CallE)) {
const CXXRecordDecl *RD = MCE->getRecordDecl();
StringRef ClassName = RD->getName();
if (RD->isInStdNamespace() && ClassName.endswith("unique_ptr") &&
Callee->getName() == "release") {
// TODO: Print warning/note to suggest to not use release on std::unique_ptr
return;
}
}

/// Special case for assignment of Pointer into Pointer: copy pset
if (auto *OC = dyn_cast<CXXOperatorCallExpr>(CallE)) {
if (OC->getOperator() == OO_Equal && OC->getNumArgs() == 2 &&
Expand Down

0 comments on commit 9ad7d12

Please sign in to comment.