|
|
|
(*
|
|
|
|
* Copyright (c) 2013 - 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.
|
|
|
|
*)
|
|
|
|
|
|
|
|
(** Define the signature of a method consisting of its name, its arguments, *)
|
|
|
|
(** return type, location and whether its an instance method. *)
|
|
|
|
|
|
|
|
type method_signature
|
|
|
|
|
|
|
|
val ms_get_name : method_signature -> Procname.t
|
|
|
|
|
Using clang's method resolution if possible
Summary: public
Using clang's method resolution. This means that, in method calls, clang gives you a pointer to the declaration of the method.
In some cases though, clang doesn't find the right method. For example, when it finds a method in a category, we
need to make it into a method in the corresponding class, because that's how we treat categories in Infer. Moreover,
when it finds a method in a protocol, that is not useful for us, since the implementation will be in some class. Finally,
sometimes the call is on an object of type id, in which case clang doesn't know what is the correct declaration. In
those cases, we fall back to what we were doing before of approximating the method resolution. We also refactor
some of the code.
Reviewed By: akotulski
Differential Revision: D2679766
fb-gh-sync-id: b79bb85
9 years ago
|
|
|
val ms_set_name : method_signature -> Procname.t -> unit
|
|
|
|
|
[clang] [2 of 3] Dealing with custom ast expressions and flow of types in the frontend.
Summary:
This is the second of 3 stack diffs to deal with replacing the parser of types.
This diff is about general changes to the frontend to make it cope with the change. There
are two main challenges:
1. We create pieces of ast in ast_expressions, such as getters and setters. For that we create
custom types.
2. We store types in cMethod_signature for parameters and return type of functions. This was
stored as strings, but that means losing the pointer information which is vital to get the
sil types.
So this diff consists mostly of dealing with these challenges. It change the signature of
cMethod_signature and update modules accordingly.
To deal with the custom types, we build methods in ast_expressions for creating those types,
with a custom type pointer, like "internal_typeint". At the beginning of the translation we save
all these custom types in the map from type pointers to sil types that we build as we compute the
types, so that they are available later.
Another custom type that we build is a type of classes or pointer of classes based on the current
class. I found a simple way to deal with it, giving it a pointer "class_name", and then we know
how to translate those. Something I tried is to save the declaration of the current class and pass
that declaration around, but somehow that lead to pref regression, so I removed it in favor of this
more lightweight version.
9 years ago
|
|
|
val ms_get_args : method_signature ->
|
|
|
|
(string * Clang_ast_t.type_ptr) list
|
|
|
|
|
|
|
|
val ms_get_ret_type : method_signature -> Clang_ast_t.type_ptr
|
|
|
|
|
|
|
|
val ms_get_attributes : method_signature -> Clang_ast_t.attribute list
|
|
|
|
|
|
|
|
val ms_get_loc : method_signature -> Clang_ast_t.source_range
|
|
|
|
|
|
|
|
val ms_is_instance : method_signature -> bool
|
|
|
|
|
|
|
|
val ms_get_lang : method_signature -> CFrontend_config.lang
|
|
|
|
|
Using clang's method resolution if possible
Summary: public
Using clang's method resolution. This means that, in method calls, clang gives you a pointer to the declaration of the method.
In some cases though, clang doesn't find the right method. For example, when it finds a method in a category, we
need to make it into a method in the corresponding class, because that's how we treat categories in Infer. Moreover,
when it finds a method in a protocol, that is not useful for us, since the implementation will be in some class. Finally,
sometimes the call is on an object of type id, in which case clang doesn't know what is the correct declaration. In
those cases, we fall back to what we were doing before of approximating the method resolution. We also refactor
some of the code.
Reviewed By: akotulski
Differential Revision: D2679766
fb-gh-sync-id: b79bb85
9 years ago
|
|
|
val ms_get_pointer_to_parent : method_signature -> Clang_ast_t.pointer option
|
|
|
|
|
|
|
|
val ms_get_pointer_to_property_opt : method_signature -> Clang_ast_t.pointer option
|
|
|
|
|
|
|
|
val ms_has_return_param : method_signature -> bool
|
|
|
|
|
|
|
|
val ms_is_getter : method_signature -> bool
|
|
|
|
|
|
|
|
val ms_is_setter : method_signature -> bool
|
|
|
|
|
|
|
|
val make_ms : Procname.t -> (string * Clang_ast_t.type_ptr) list -> Clang_ast_t.type_ptr
|
|
|
|
-> Clang_ast_t.attribute list -> Clang_ast_t.source_range -> bool -> CFrontend_config.lang
|
|
|
|
-> Clang_ast_t.pointer option -> Clang_ast_t.pointer option -> has_return_param : bool
|
|
|
|
-> method_signature
|
|
|
|
|
|
|
|
val replace_name_ms : method_signature -> Procname.t -> method_signature
|
|
|
|
|
|
|
|
val ms_to_string : method_signature -> string
|