From 996c1b63e05c62ff50909255a39e42eec16ef8e3 Mon Sep 17 00:00:00 2001 From: Daiva Naudziuniene Date: Thu, 17 Sep 2020 07:19:46 -0700 Subject: [PATCH] [frontend] Check if a method is a cpp lambda call operator Summary: Added a function to check if a method is a cpp lambda call operator that will be used in later diffs #skipdeadcode Reviewed By: jvillard Differential Revision: D23564089 fbshipit-source-id: 144c3d735 --- infer/src/clang/CMethodProperties.ml | 13 +++++++++++++ infer/src/clang/CMethodProperties.mli | 2 ++ 2 files changed, 15 insertions(+) diff --git a/infer/src/clang/CMethodProperties.ml b/infer/src/clang/CMethodProperties.ml index 161cb58a9..e6222cd75 100644 --- a/infer/src/clang/CMethodProperties.ml +++ b/infer/src/clang/CMethodProperties.ml @@ -92,6 +92,19 @@ let get_method_body method_decl = raise CFrontend_errors.Invalid_declaration +let is_cpp_lambda_call_operator meth_decl = + let open Clang_ast_t in + match meth_decl with + | CXXMethodDecl (di, _, _, _, _) -> ( + match CAst_utils.get_decl_opt di.di_parent_pointer with + | Some (Clang_ast_t.CXXRecordDecl (_, _, _, _, _, _, _, cxx_rdi)) -> + Option.is_some cxx_rdi.xrdi_lambda_call_operator + | _ -> + false ) + | _ -> + false + + let is_cpp_virtual method_decl = let open Clang_ast_t in match method_decl with diff --git a/infer/src/clang/CMethodProperties.mli b/infer/src/clang/CMethodProperties.mli index 05f1add2c..cac774f27 100644 --- a/infer/src/clang/CMethodProperties.mli +++ b/infer/src/clang/CMethodProperties.mli @@ -19,6 +19,8 @@ val get_param_decls : Clang_ast_t.decl -> Clang_ast_t.decl list val get_method_body : Clang_ast_t.decl -> Clang_ast_t.stmt option +val is_cpp_lambda_call_operator : Clang_ast_t.decl -> bool + val is_cpp_virtual : Clang_ast_t.decl -> bool val get_init_list_instrs :