Summary: update-submodule: facebook-clang-plugins Don't replace `clang_ast_types.ml` from fcp. Instead, one can now extend `Clang_ast_t.type_ptr` type! Reviewed By: jberdine Differential Revision: D4922249 fbshipit-source-id: 53b22b0master
parent
a42302bd38
commit
a81f4e7bf9
@ -1 +1 @@
|
|||||||
Subproject commit c61920129b7b519a420e8dc648d1319391aaaf73
|
Subproject commit ee26293dd046acc5c2dd862d3201aa9f7dace96a
|
@ -0,0 +1,63 @@
|
|||||||
|
(*
|
||||||
|
* Copyright (c) 2015 - present Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*)
|
||||||
|
|
||||||
|
open! IStd
|
||||||
|
|
||||||
|
(* This module adds more variants to some types in AST *)
|
||||||
|
(* The implementation extends default one from *)
|
||||||
|
(* facebook-clang-plugins repository *)
|
||||||
|
|
||||||
|
|
||||||
|
(* Type pointers *)
|
||||||
|
type Clang_ast_types.TypePtr.t +=
|
||||||
|
| Prebuilt of int
|
||||||
|
| PointerOf of Clang_ast_types.TypePtr.t
|
||||||
|
| ReferenceOf of Clang_ast_types.TypePtr.t
|
||||||
|
| ClassType of Typ.Name.t
|
||||||
|
| DeclPtr of int
|
||||||
|
| ErrorType
|
||||||
|
|
||||||
|
module TypePointerOrd = struct
|
||||||
|
type t = Clang_ast_types.TypePtr.t
|
||||||
|
let rec compare a1 a2 = match a1, a2 with
|
||||||
|
| _ when phys_equal a1 a2 -> 0
|
||||||
|
| Clang_ast_types.TypePtr.Ptr a, Clang_ast_types.TypePtr.Ptr b -> Int.compare a b
|
||||||
|
| Clang_ast_types.TypePtr.Ptr _, _ -> 1
|
||||||
|
| _, Clang_ast_types.TypePtr.Ptr _ -> -1
|
||||||
|
| Prebuilt a, Prebuilt b -> Int.compare a b
|
||||||
|
| Prebuilt _, _ -> 1
|
||||||
|
| _, Prebuilt _ -> -1
|
||||||
|
| PointerOf a, PointerOf b -> compare a b
|
||||||
|
| PointerOf _, _ -> 1
|
||||||
|
| _, PointerOf _ -> -1
|
||||||
|
| ReferenceOf a, ReferenceOf b -> compare a b
|
||||||
|
| ReferenceOf _, _ -> 1
|
||||||
|
| _, ReferenceOf _ -> -1
|
||||||
|
| ClassType a, ClassType b -> Typ.Name.compare a b
|
||||||
|
| ClassType _, _ -> 1
|
||||||
|
| _, ClassType _ -> -1
|
||||||
|
| DeclPtr a, DeclPtr b -> Int.compare a b
|
||||||
|
| DeclPtr _, _ -> 1
|
||||||
|
| _, DeclPtr _ -> -1
|
||||||
|
| ErrorType, ErrorType -> 0
|
||||||
|
| _ -> raise (invalid_arg ("unexpected type_ptr variants: "))
|
||||||
|
end
|
||||||
|
|
||||||
|
module TypePointerMap = Caml.Map.Make(TypePointerOrd)
|
||||||
|
|
||||||
|
|
||||||
|
let rec type_ptr_to_string = function
|
||||||
|
| Clang_ast_types.TypePtr.Ptr raw -> "clang_ptr_" ^ (string_of_int raw)
|
||||||
|
| Prebuilt raw -> "prebuilt_" ^ (string_of_int raw)
|
||||||
|
| PointerOf typ -> "pointer_of_" ^ type_ptr_to_string typ
|
||||||
|
| ReferenceOf typ -> "reference_of_" ^ type_ptr_to_string typ
|
||||||
|
| ClassType name -> "class_name_" ^ Typ.Name.name name
|
||||||
|
| DeclPtr raw -> "decl_ptr_" ^ (string_of_int raw)
|
||||||
|
| ErrorType -> "error_type"
|
||||||
|
| _ -> "unknown"
|
@ -1,65 +0,0 @@
|
|||||||
(*
|
|
||||||
* Copyright (c) 2015 - present Facebook, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the BSD style license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
|
||||||
*)
|
|
||||||
|
|
||||||
open! IStd
|
|
||||||
|
|
||||||
(* This module adds more structure to some fields in AST *)
|
|
||||||
(* The implementation is replacement of default one from *)
|
|
||||||
(* facebook-clang-plugins repository *)
|
|
||||||
|
|
||||||
|
|
||||||
(* Type pointers *)
|
|
||||||
|
|
||||||
exception Not_Clang_Pointer
|
|
||||||
|
|
||||||
type t_ptr = [
|
|
||||||
| `TPtr of int
|
|
||||||
| `Prebuilt of int
|
|
||||||
| `PointerOf of t_ptr
|
|
||||||
| `ReferenceOf of t_ptr
|
|
||||||
| `ClassType of Typ.Name.t
|
|
||||||
| `StructType of Typ.Name.t
|
|
||||||
| `DeclPtr of int
|
|
||||||
| `ErrorType
|
|
||||||
] [@@deriving compare]
|
|
||||||
|
|
||||||
module TypePointerOrd = struct
|
|
||||||
type t = t_ptr [@@deriving compare]
|
|
||||||
end
|
|
||||||
|
|
||||||
module TypePointerMap = Caml.Map.Make(TypePointerOrd)
|
|
||||||
|
|
||||||
let rec type_ptr_to_string type_ptr = match type_ptr with
|
|
||||||
| `TPtr raw -> "clang_ptr_" ^ (string_of_int raw)
|
|
||||||
| `Prebuilt raw -> "prebuilt_" ^ (string_of_int raw)
|
|
||||||
| `PointerOf typ -> "pointer_of_" ^ type_ptr_to_string typ
|
|
||||||
| `ReferenceOf typ -> "reference_of_" ^ type_ptr_to_string typ
|
|
||||||
| `ClassType name -> "class_name_" ^ Typ.Name.name name
|
|
||||||
| `StructType name -> "struct_name_" ^ Typ.Name.name name
|
|
||||||
| `DeclPtr raw -> "decl_ptr_" ^ (string_of_int raw)
|
|
||||||
| `ErrorType -> "error_type"
|
|
||||||
|
|
||||||
let type_ptr_to_clang_pointer type_ptr = match type_ptr with
|
|
||||||
| `TPtr raw -> raw
|
|
||||||
| _ -> raise Not_Clang_Pointer
|
|
||||||
|
|
||||||
let pointer_to_type_ptr raw = `TPtr raw
|
|
||||||
|
|
||||||
let type_ptr_to_pointer type_ptr = match type_ptr with
|
|
||||||
| `TPtr raw -> raw
|
|
||||||
| _ -> 0 (* invalid pointer *)
|
|
||||||
|
|
||||||
|
|
||||||
(* Source files *)
|
|
||||||
|
|
||||||
type src_file = SourceFile.t
|
|
||||||
|
|
||||||
let source_file_of_string = SourceFile.from_abs_path
|
|
||||||
|
|
||||||
let string_of_source_file = SourceFile.to_abs_path
|
|
Loading…
Reference in new issue