summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/tools/clang/lib/AST
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2018-01-16 08:00:07 +0000
committerLuiz Souza <luiz@netgate.com>2018-02-21 15:20:01 -0300
commitee49d4c5a19918b9960cffdf0460a5cab9989625 (patch)
tree30c3a9f45afd743757b3646d14c2b899faac78ef /contrib/llvm/tools/clang/lib/AST
parentb042831d7b39460b5b04220cf450867d9dabe394 (diff)
downloadFreeBSD-src-ee49d4c5a19918b9960cffdf0460a5cab9989625.zip
FreeBSD-src-ee49d4c5a19918b9960cffdf0460a5cab9989625.tar.gz
MFC r327930:
Pull in r314499 from upstream clang trunk (by Daniel Marjamäki): [Sema] Suppress warnings for C's zero initializer Patch by S. Gilles! Differential Revision: https://reviews.llvm.org/D28148 Pull in r314838 from upstream clang trunk (by Richard Smith): Suppress -Wmissing-braces warning when aggregate-initializing a struct with a single field that is itself an aggregate. In C++, such initialization of std::array<T, N> types is guaranteed to work by the standard, is completely idiomatic, and the "suggested" alternative from Clang was technically invalid. Together, these suppress unneeded "suggest braces around initialization of subobject" warnings for C++11 initializer lists. (cherry picked from commit af874530b0f44fb960658f50bf0b3f9b8cf3dd33)
Diffstat (limited to 'contrib/llvm/tools/clang/lib/AST')
-rw-r--r--contrib/llvm/tools/clang/lib/AST/Expr.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/contrib/llvm/tools/clang/lib/AST/Expr.cpp b/contrib/llvm/tools/clang/lib/AST/Expr.cpp
index afc7fa8..1052834 100644
--- a/contrib/llvm/tools/clang/lib/AST/Expr.cpp
+++ b/contrib/llvm/tools/clang/lib/AST/Expr.cpp
@@ -1899,6 +1899,17 @@ bool InitListExpr::isTransparent() const {
getInit(0)->getType().getCanonicalType();
}
+bool InitListExpr::isIdiomaticZeroInitializer(const LangOptions &LangOpts) const {
+ assert(isSyntacticForm() && "only test syntactic form as zero initializer");
+
+ if (LangOpts.CPlusPlus || getNumInits() != 1) {
+ return false;
+ }
+
+ const IntegerLiteral *Lit = dyn_cast<IntegerLiteral>(getInit(0));
+ return Lit && Lit->getValue() == 0;
+}
+
SourceLocation InitListExpr::getLocStart() const {
if (InitListExpr *SyntacticForm = getSyntacticForm())
return SyntacticForm->getLocStart();
OpenPOWER on IntegriCloud