|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
(*
|
|
|
|
|
* Copyright (c) 2014-present, Facebook, Inc.
|
|
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
|
|
|
*
|
|
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
|
|
|
@ -33,11 +33,10 @@ let name_info name = {ni_name= name; ni_qual_name= [name]}
|
|
|
|
|
let append_name_info info suffix =
|
|
|
|
|
{ni_name= info.ni_name ^ suffix; ni_qual_name= List.map (fun x -> x ^ suffix) info.ni_qual_name}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let qual_type ptr =
|
|
|
|
|
{ qt_type_ptr= ptr
|
|
|
|
|
; qt_is_const= false
|
|
|
|
|
; qt_is_restrict= false
|
|
|
|
|
; qt_is_volatile= false }
|
|
|
|
|
{qt_type_ptr= ptr; qt_is_const= false; qt_is_restrict= false; qt_is_volatile= false}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let var_decl_info ~is_global =
|
|
|
|
|
{ vdi_is_global= is_global
|
|
|
|
@ -49,16 +48,16 @@ let var_decl_info ~is_global =
|
|
|
|
|
; vdi_is_init_expr_cxx11_constant= false
|
|
|
|
|
; vdi_init_expr= None
|
|
|
|
|
; vdi_parm_index_in_function= None
|
|
|
|
|
; vdi_is_static = false}
|
|
|
|
|
; vdi_is_static= false }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let stmt_info pointer =
|
|
|
|
|
{ si_pointer= pointer
|
|
|
|
|
; si_source_range= (empty_source_location, empty_source_location) }
|
|
|
|
|
{si_pointer= pointer; si_source_range= (empty_source_location, empty_source_location)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let expr_info qual_type =
|
|
|
|
|
{ ei_qual_type= qual_type
|
|
|
|
|
; ei_value_kind= `RValue
|
|
|
|
|
; ei_object_kind= `Ordinary }
|
|
|
|
|
{ei_qual_type= qual_type; ei_value_kind= `RValue; ei_object_kind= `Ordinary}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let cxx_construct_expr_info decl_ref is_copy_constructor =
|
|
|
|
|
{ xcei_decl_ref= decl_ref
|
|
|
|
@ -84,39 +83,41 @@ let () =
|
|
|
|
|
let di2 = decl_info (source_location ~file:"bla" ()) (source_location ~file:"bleh" ()) in
|
|
|
|
|
let decl3 = update_decl_tuple (fun _ -> di2) decl in
|
|
|
|
|
assert_equal "update_decl_tuple" (get_decl_tuple decl3) di2 ;
|
|
|
|
|
|
|
|
|
|
assert_equal "get_var_decl_tuple_none" (get_var_decl_tuple decl) None ;
|
|
|
|
|
let vdi = var_decl_info ~is_global:true in
|
|
|
|
|
let qt = qual_type (Clang_ast_types.TypePtr.wrap 0) in
|
|
|
|
|
let var_decl = ParmVarDecl(di, name_info "fooey", qt, vdi) in
|
|
|
|
|
let var_decl = ParmVarDecl (di, name_info "fooey", qt, vdi) in
|
|
|
|
|
assert_equal "get_var_decl_tuple" (get_var_decl_tuple var_decl)
|
|
|
|
|
(Some (di, name_info "fooey", qt, vdi)) ;
|
|
|
|
|
let updated_var_decl = update_var_decl_tuple
|
|
|
|
|
(fun (di, ni, qt, vdi) ->
|
|
|
|
|
(di, append_name_info ni "-mod", qt, var_decl_info ~is_global:false))
|
|
|
|
|
var_decl in
|
|
|
|
|
assert_equal "update_var_decl_tuple" (get_var_decl_tuple updated_var_decl)
|
|
|
|
|
let updated_var_decl =
|
|
|
|
|
update_var_decl_tuple
|
|
|
|
|
(fun (di, ni, qt, vdi) -> (di, append_name_info ni "-mod", qt, var_decl_info ~is_global:false))
|
|
|
|
|
var_decl
|
|
|
|
|
in
|
|
|
|
|
assert_equal "update_var_decl_tuple"
|
|
|
|
|
(get_var_decl_tuple updated_var_decl)
|
|
|
|
|
(Some (di, name_info "fooey-mod", qt, var_decl_info ~is_global:false)) ;
|
|
|
|
|
|
|
|
|
|
let stmt = DoStmt(stmt_info 0, []) in
|
|
|
|
|
assert_equal "get_cxx_construct_expr_tuple_from_stmt"
|
|
|
|
|
(get_cxx_construct_expr_tuple stmt) None ;
|
|
|
|
|
let stmt = DoStmt (stmt_info 0, []) in
|
|
|
|
|
assert_equal "get_cxx_construct_expr_tuple_from_stmt" (get_cxx_construct_expr_tuple stmt) None ;
|
|
|
|
|
let ei = expr_info qt in
|
|
|
|
|
let dr = { dr_kind= `CXXConstructor
|
|
|
|
|
; dr_decl_pointer= 0
|
|
|
|
|
; dr_name= None
|
|
|
|
|
; dr_is_hidden= false
|
|
|
|
|
; dr_qual_type= None } in
|
|
|
|
|
let dr =
|
|
|
|
|
{ dr_kind= `CXXConstructor
|
|
|
|
|
; dr_decl_pointer= 0
|
|
|
|
|
; dr_name= None
|
|
|
|
|
; dr_is_hidden= false
|
|
|
|
|
; dr_qual_type= None }
|
|
|
|
|
in
|
|
|
|
|
let xcei = cxx_construct_expr_info dr true in
|
|
|
|
|
let xcei2 = cxx_construct_expr_info dr false in
|
|
|
|
|
let cxx_ctor_expr = CXXConstructExpr(stmt_info 1, [], ei, xcei) in
|
|
|
|
|
let cxx_ctor_expr = CXXConstructExpr (stmt_info 1, [], ei, xcei) in
|
|
|
|
|
assert_equal "get_cxx_construct_expr_tuple"
|
|
|
|
|
(get_cxx_construct_expr_tuple cxx_ctor_expr)
|
|
|
|
|
(Some (stmt_info 1, [], ei, xcei)) ;
|
|
|
|
|
let updated_cxx_ctor_expr = update_cxx_construct_expr_tuple
|
|
|
|
|
(fun (si, sl, ei, xcei) ->
|
|
|
|
|
(stmt_info (si.si_pointer + 1)), sl, ei, xcei2)
|
|
|
|
|
cxx_ctor_expr in
|
|
|
|
|
let updated_cxx_ctor_expr =
|
|
|
|
|
update_cxx_construct_expr_tuple
|
|
|
|
|
(fun (si, sl, ei, xcei) -> (stmt_info (si.si_pointer + 1), sl, ei, xcei2))
|
|
|
|
|
cxx_ctor_expr
|
|
|
|
|
in
|
|
|
|
|
assert_equal "update_cxx_construct_expr_tuple"
|
|
|
|
|
(get_cxx_construct_expr_tuple updated_cxx_ctor_expr)
|
|
|
|
|
(Some (stmt_info 2, [], ei, xcei2)) ;
|
|
|
|
|
(Some (stmt_info 2, [], ei, xcei2))
|
|
|
|
|