From d92e82b379b3c4cfbbcdbdb424b3eb5e7889afbe Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Mon, 30 Apr 2018 09:05:49 -0700 Subject: [PATCH] [clang] fix translation of `UserDefinedLiteral` Summary: User-defined literals are really just function calls. Reviewed By: sblackshear Differential Revision: D7813464 fbshipit-source-id: c9302b9 --- infer/src/clang/cTrans.ml | 6 ++---- .../cpp/frontend/literals/user_defined.cpp.dot | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/infer/src/clang/cTrans.ml b/infer/src/clang/cTrans.ml index 079ce30cc..4c73a8451 100644 --- a/infer/src/clang/cTrans.ml +++ b/infer/src/clang/cTrans.ml @@ -3103,7 +3103,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s arraySubscriptExpr_trans trans_state expr_info stmt_list | BinaryOperator (stmt_info, stmt_list, expr_info, binop_info) -> binaryOperator_trans_with_cond trans_state stmt_info stmt_list expr_info binop_info - | CallExpr (stmt_info, stmt_list, ei) -> + | CallExpr (stmt_info, stmt_list, ei) | UserDefinedLiteral (stmt_info, stmt_list, ei) -> callExpr_trans trans_state stmt_info stmt_list ei | CXXMemberCallExpr (stmt_info, stmt_list, ei) -> cxxMemberCallExpr_trans trans_state stmt_info stmt_list ei @@ -3306,9 +3306,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s sub-expressions *) | ObjCAvailabilityCheckExpr (_, _, expr_info, _) -> trans_into_undefined_expr trans_state expr_info - | ExtVectorElementExpr (_, stmts, _) - | ShuffleVectorExpr (_, stmts, _) - | UserDefinedLiteral (_, stmts, _) -> + | ExtVectorElementExpr (_, stmts, _) | ShuffleVectorExpr (_, stmts, _) -> skip_unimplemented trans_state stmts (* Infer somehow ended up in templated non instantiated code - right now it's not supported and failure in those cases is expected. *) diff --git a/infer/tests/codetoanalyze/cpp/frontend/literals/user_defined.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/literals/user_defined.cpp.dot index 11ef83587..af84a7b23 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/literals/user_defined.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/literals/user_defined.cpp.dot @@ -7,7 +7,7 @@ digraph cfg { "foo#972162870672026475.86d7db357d6a36081d09067fb38ce85e_2" [label="2: Exit foo \n " color=yellow style=filled] -"foo#972162870672026475.86d7db357d6a36081d09067fb38ce85e_3" [label="3: Return Stmt \n *&return:int=-1 [line 12, column 13]\n " shape="box"] +"foo#972162870672026475.86d7db357d6a36081d09067fb38ce85e_3" [label="3: Return Stmt \n n$0=_fun_operator\"\"_literal(0:unsigned long long) [line 12, column 20]\n *&return:int=n$0 [line 12, column 13]\n " shape="box"] "foo#972162870672026475.86d7db357d6a36081d09067fb38ce85e_3" -> "foo#972162870672026475.86d7db357d6a36081d09067fb38ce85e_2" ;