summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExprCXX.cpp
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2017-08-31 06:17:08 +0000
committerNico Weber <nicolasweber@gmx.de>2017-08-31 06:17:08 +0000
commitbf2260ca6276a5f7a18e3bc7d7a55d46fed163bf (patch)
tree5901dd38ab869bae0b2f92117b41b8d7f559c8c6 /clang/lib/Sema/SemaExprCXX.cpp
parenta22742be5a2703c0773f9613c3e385ae3861ce15 (diff)
downloadbcm5719-llvm-bf2260ca6276a5f7a18e3bc7d7a55d46fed163bf.tar.gz
bcm5719-llvm-bf2260ca6276a5f7a18e3bc7d7a55d46fed163bf.zip
Suppress -Wdelete-non-virtual-dtor warnings about classes defined in system headers.
r312167 made it so that we emit Wdelete-non-virtual-dtor from delete statements that are in system headers (e.g. std::unique_ptr). That works great on Linux and macOS, but on Windows there are non-final classes that are defined in system headers that have virtual methods but non-virtual destructors and yet get deleted through a base class pointer (e.g. ATL::CAccessToken::CRevert). So paddle back a bit and don't emit the warning if it's about a class defined in a system header. https://reviews.llvm.org/D37324 llvm-svn: 312216
Diffstat (limited to 'clang/lib/Sema/SemaExprCXX.cpp')
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 8de3d33d085..08c4f50091f 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -3299,6 +3299,12 @@ void Sema::CheckVirtualDtorCall(CXXDestructorDecl *dtor, SourceLocation Loc,
if (!PointeeRD->isPolymorphic() || PointeeRD->hasAttr<FinalAttr>())
return;
+ // If the superclass is in a system header, there's nothing that can be done.
+ // The `delete` (where we emit the warning) can be in a system header,
+ // what matters for this warning is where the deleted type is defined.
+ if (getSourceManager().isInSystemHeader(PointeeRD->getLocation()))
+ return;
+
QualType ClassType = dtor->getThisType(Context)->getPointeeType();
if (PointeeRD->isAbstract()) {
// If the class is abstract, we warn by default, because we're
OpenPOWER on IntegriCloud