[frontend] Do not die when selector is unknown in objc boxed expr

Summary:
Sometimes clang9 does not return a boxing method (a name of function to apply), e.g., [@("str")].
To solve the issue, this diff uses "unknownSelector:" instead of giving up the translation.

Reviewed By: dulmarod

Differential Revision: D18831844

fbshipit-source-id: b9324ba39
master
Sungkeun Cho 5 years ago committed by Facebook Github Bot
parent 07cef38d1f
commit 668969a3c2

@ -3483,12 +3483,14 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
floatingLiteral_trans trans_state expr_info float_string floatingLiteral_trans trans_state expr_info float_string
| CXXScalarValueInitExpr (_, _, expr_info) -> | CXXScalarValueInitExpr (_, _, expr_info) ->
cxxScalarValueInitExpr_trans trans_state expr_info cxxScalarValueInitExpr_trans trans_state expr_info
| ObjCBoxedExpr (stmt_info, stmts, info, boxed_expr_info) -> ( | ObjCBoxedExpr (stmt_info, stmts, info, boxed_expr_info) ->
match boxed_expr_info.Clang_ast_t.obei_boxing_method with (* Sometimes clang does not return a boxing method (a name of function to apply), e.g.,
| Some sel -> [@("str")]. In that case, it uses "unknownSelector:" instead of giving up the
objCBoxedExpr_trans trans_state info sel stmt_info stmts translation. *)
| None -> let sel =
assert false ) Option.value boxed_expr_info.Clang_ast_t.obei_boxing_method ~default:"unknownSelector:"
in
objCBoxedExpr_trans trans_state info sel stmt_info stmts
| ObjCArrayLiteral (stmt_info, stmts, expr_info, array_literal_info) -> | ObjCArrayLiteral (stmt_info, stmts, expr_info, array_literal_info) ->
objCArrayLiteral_trans trans_state expr_info stmt_info stmts array_literal_info objCArrayLiteral_trans trans_state expr_info stmt_info stmts array_literal_info
| ObjCDictionaryLiteral (stmt_info, stmts, expr_info, dict_literal_info) -> | ObjCDictionaryLiteral (stmt_info, stmts, expr_info, dict_literal_info) ->

@ -42,4 +42,10 @@
; ;
} }
- (NSString*)getString {
NSString* s = @("hello world");
return s;
;
}
@end @end

@ -98,4 +98,19 @@ digraph cfg {
"getS#Boxing#instance.97ccd331527b54376eb9b2b822cb25a3_4" -> "getS#Boxing#instance.97ccd331527b54376eb9b2b822cb25a3_3" ; "getS#Boxing#instance.97ccd331527b54376eb9b2b822cb25a3_4" -> "getS#Boxing#instance.97ccd331527b54376eb9b2b822cb25a3_3" ;
"getString#Boxing#instance.0cdd84065923a1c621289a9de4707559_1" [label="1: Start Boxing::getString\nFormals: self:Boxing*\nLocals: s:NSString* \n " color=yellow style=filled]
"getString#Boxing#instance.0cdd84065923a1c621289a9de4707559_1" -> "getString#Boxing#instance.0cdd84065923a1c621289a9de4707559_4" ;
"getString#Boxing#instance.0cdd84065923a1c621289a9de4707559_2" [label="2: Exit Boxing::getString \n " color=yellow style=filled]
"getString#Boxing#instance.0cdd84065923a1c621289a9de4707559_3" [label="3: Return Stmt \n n$19=*&s:NSString* [line 47, column 10]\n *&return:NSString*=n$19 [line 47, column 3]\n " shape="box"]
"getString#Boxing#instance.0cdd84065923a1c621289a9de4707559_3" -> "getString#Boxing#instance.0cdd84065923a1c621289a9de4707559_2" ;
"getString#Boxing#instance.0cdd84065923a1c621289a9de4707559_4" [label="4: DeclStmt \n VARIABLE_DECLARED(s:NSString*); [line 46, column 3]\n n$20=_fun_NSString::unknownSelector:(\"hello world\":char*) [line 46, column 17]\n *&s:NSString*=n$20 [line 46, column 3]\n " shape="box"]
"getString#Boxing#instance.0cdd84065923a1c621289a9de4707559_4" -> "getString#Boxing#instance.0cdd84065923a1c621289a9de4707559_3" ;
} }

Loading…
Cancel
Save