summaryrefslogtreecommitdiff
path: root/compilerplugins/clang
diff options
context:
space:
mode:
Diffstat (limited to 'compilerplugins/clang')
-rw-r--r--compilerplugins/clang/makeshared.cxx13
1 files changed, 13 insertions, 0 deletions
diff --git a/compilerplugins/clang/makeshared.cxx b/compilerplugins/clang/makeshared.cxx
index 9f12b6c3bd6b..9b512371d635 100644
--- a/compilerplugins/clang/makeshared.cxx
+++ b/compilerplugins/clang/makeshared.cxx
@@ -132,6 +132,19 @@ bool MakeShared::VisitCXXConstructExpr(CXXConstructExpr const* constructExpr)
return true;
else if (isa<CXXNullPtrLiteralExpr>(arg0))
return true;
+ else if (auto const call = dyn_cast<CallExpr>(arg0))
+ {
+ if (auto const decl = call->getDirectCallee())
+ {
+ // Don't warn about cases where e.g. the Bitmap* result of calling Windows'
+ // Bitmap::FromBITMAPINFO is wrapped in a shared_ptr:
+ if (decl->getReturnType()->isPointerType()
+ && compiler.getSourceManager().isInSystemHeader(decl->getLocation()))
+ {
+ return true;
+ }
+ }
+ }
StringRef fn = getFilenameOfLocation(
compiler.getSourceManager().getSpellingLoc(compat::getBeginLoc(constructExpr)));