1 Pull in r199571 from upstream clang trunk (by Ted Kremenek):
3 Harden InitListExpr::isStringLiteralInit() against getInit()
6 This led to a crash on invalid code (sorry, no good test case).
8 Fixes <rdar://problem/15831804>.
10 This fixes an assertion when compiling certain incorrect code, as
11 reported upstream in http://llvm.org/PR22684 .
13 Introduced here: http://svnweb.freebsd.org/changeset/base/279289
15 Index: tools/clang/lib/AST/Expr.cpp
16 ===================================================================
17 --- tools/clang/lib/AST/Expr.cpp
18 +++ tools/clang/lib/AST/Expr.cpp
19 @@ -1892,7 +1892,11 @@ bool InitListExpr::isStringLiteralInit() const {
20 const ArrayType *AT = getType()->getAsArrayTypeUnsafe();
21 if (!AT || !AT->getElementType()->isIntegerType())
23 - const Expr *Init = getInit(0)->IgnoreParens();
24 + // It is possible for getInit() to return null.
25 + const Expr *Init = getInit(0);
28 + Init = Init->IgnoreParens();
29 return isa<StringLiteral>(Init) || isa<ObjCEncodeExpr>(Init);