File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2758,12 +2758,8 @@ bool Converter::VisitInitListExpr(clang::InitListExpr *expr) {
27582758 StrCat (token::kComma );
27592759 }
27602760 } else {
2761- if (expr->getNumInits () == 1 && qual_type->isArrayType () &&
2762- qual_type->getArrayElementTypeNoTypeQual ()->isCharType () &&
2763- clang::isa<clang::StringLiteral>(
2764- expr->getInit (0 )->IgnoreParenImpCasts ())) {
2765- auto *init = expr->getInit (0 );
2766- ConvertVarInit (init->getType (), init);
2761+ if (IsInitExprOfStringLiteral (expr)) {
2762+ Convert (expr->getInit (0 )->IgnoreParenImpCasts ());
27672763 return false ;
27682764 }
27692765 PushBracket bracket (*this );
Original file line number Diff line number Diff line change @@ -255,6 +255,14 @@ bool IsAsciiStringLiteral(const clang::StringLiteral *str) {
255255 return true ;
256256}
257257
258+ bool IsInitExprOfStringLiteral (const clang::InitListExpr *expr) {
259+ auto type = expr->getType ();
260+ return expr->getNumInits () == 1 && type->isArrayType () &&
261+ type->getArrayElementTypeNoTypeQual ()->isCharType () &&
262+ clang::isa<clang::StringLiteral>(
263+ expr->getInit (0 )->IgnoreParenImpCasts ());
264+ }
265+
258266std::vector<clang::CXXConstructorDecl *>
259267GetTemplateInstantiatedCtors (clang::CXXRecordDecl *decl) {
260268 std::vector<clang::CXXConstructorDecl *> out;
Original file line number Diff line number Diff line change @@ -67,6 +67,8 @@ bool IsCallToOstream(clang::CallExpr *expr);
6767
6868bool IsAsciiStringLiteral (const clang::StringLiteral *str);
6969
70+ bool IsInitExprOfStringLiteral (const clang::InitListExpr *expr);
71+
7072std::vector<clang::CXXConstructorDecl *>
7173GetTemplateInstantiatedCtors (clang::CXXRecordDecl *decl);
7274
Original file line number Diff line number Diff line change @@ -1397,6 +1397,12 @@ bool ConverterRefCount::VisitInitListExpr(clang::InitListExpr *expr) {
13971397 return false ;
13981398 }
13991399
1400+ if (IsInitExprOfStringLiteral (expr)) {
1401+ Convert (expr->getInit (0 )->IgnoreParenImpCasts ());
1402+ computed_expr_type_ = ComputedExprType::FreshValue;
1403+ return false ;
1404+ }
1405+
14001406 auto conv = getConversionKind ();
14011407 // 2D arrays are FullRefCount'ed on the second level as well.
14021408 PushConversionKind push (
You can’t perform that action at this time.
0 commit comments