summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorErich Keane <erich.keane@intel.com>2019-12-12 11:27:10 -0800
committerErich Keane <erich.keane@intel.com>2019-12-12 11:34:17 -0800
commit654c0daef75a41eede06b413a5ecdd8ad2640240 (patch)
tree05ffcdd2ce918fd567451ff12310b6eecb045394 /clang/lib
parent61368c8e98c567fa76d45e8f928306db9d00dde2 (diff)
downloadbcm5719-llvm-654c0daef75a41eede06b413a5ecdd8ad2640240.tar.gz
bcm5719-llvm-654c0daef75a41eede06b413a5ecdd8ad2640240.zip
Suppress -Wwarn-unused-variables when we don't know the constructor
This warning is supposed to be suppressed when the constructor/destructor are non-trivial, since it might be a RAII type. However, if the type has a trivial destructor and the constructor hasn't been resolved (since it is called with dependent arguments), we were still warning. This patch suppresses the warning if the type could possibly have a be a non-trivial constructor call. Note that this does not take the arity of the constructors into consideration, so it might suppress the warning in cases where it isn't possible to call a non-trivial constructor.
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 1cf87e45a29..c2571245201 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -1805,6 +1805,13 @@ static bool ShouldDiagnoseUnusedDecl(const NamedDecl *D) {
(VD->getInit()->isValueDependent() || !VD->evaluateValue()))
return false;
}
+
+ // Suppress the warning if we don't know how this is constructed, and
+ // it could possibly be non-trivial constructor.
+ if (Init->isTypeDependent())
+ for (const CXXConstructorDecl *Ctor : RD->ctors())
+ if (!Ctor->isTrivial())
+ return false;
}
}
}
OpenPOWER on IntegriCloud