Model other functions from glog library

Reviewed By: akotulski

Differential Revision: D3293184

fbshipit-source-id: 033f435
master
Dulma Churchill 9 years ago committed by Facebook Github Bot 0
parent 944176bf67
commit 6c7c18e920

@ -113,6 +113,16 @@ let fbAssertWithSignalAndLogFunctionHelper = "FBAssertWithSignalAndLogFunctionHe
let google_LogMessageFatal = "google::LogMessageFatal_LogMessageFatal"
let google_MakeCheckOpString = "google::MakeCheckOpString"
let google_whitelisting_functions = [
"CheckNotNull";
"GetReferenceableValue";
"Check_NEImpl";
"Check_LEImpl";
"Check_GTImpl";
"Check_EQImpl"]
let pseudo_object_type = "<pseudo-object type>"
let count = "count"

@ -115,6 +115,10 @@ val handleFailureInFunction : string
val google_LogMessageFatal : string
val google_MakeCheckOpString : string
val google_whitelisting_functions : string list
val pseudo_object_type : string
val count : string

@ -147,14 +147,18 @@ struct
let source_range = info.Clang_ast_t.di_source_range in
let translate_location = CLocation.should_translate_lib source_range decl_trans_context in
let always_translate_decl = match dec with
| Clang_ast_t.FunctionDecl (_, name_info, _, _) ->
| Clang_ast_t.FunctionDecl (_, name_info, _, _)
| Clang_ast_t.CXXMethodDecl (_, name_info, _, _, _) ->
(* named_decl_info.ni_name has name without template parameters.*)
(* It makes it possible to capture whole family of function instantiations*)
(* to be named the same *)
let fun_name = name_info.Clang_ast_t.ni_name in
let top_qual = IList.hd (IList.rev name_info.Clang_ast_t.ni_qual_name) in
let qual_name = name_info.Clang_ast_t.ni_qual_name in
let top_qual = IList.hd (IList.rev qual_name) in
(* Always translate std::move so that it can be analyzed *)
top_qual="std" && fun_name = "move"
top_qual = "std" && fun_name = "move" ||
top_qual = "google" &&
IList.mem (=) fun_name CFrontend_config.google_whitelisting_functions
| _ -> false in
translate_location || always_translate_decl

@ -76,7 +76,8 @@ let is_modeled_builtin funct =
let is_assert_log_s funct =
funct = CFrontend_config.assert_rtn ||
funct = CFrontend_config.assert_fail ||
funct = CFrontend_config.fbAssertWithSignalAndLogFunctionHelper
funct = CFrontend_config.fbAssertWithSignalAndLogFunctionHelper ||
Utils.string_contains CFrontend_config.google_MakeCheckOpString funct
let is_assert_log_method m =
m = CFrontend_config.google_LogMessageFatal

@ -26,6 +26,11 @@ int check_example(int* a) {
return *a; // no null deref flagged by Infer
}
int check_not_null_example(int* p) {
CHECK_NOTNULL(p);
return *p;
}
int log_non_fatal_example() {
int* a = nullptr;
LOG_IF(INFO, a) << "well\n";
@ -40,8 +45,6 @@ int log_if_fatal_example() {
return *a; // no null deref
}
// Still not modelled
int check_ne_example(int x) {
CHECK_NE(x, 5);
return x;
@ -52,7 +55,12 @@ int check_eq_example(int x, int y) {
return x;
}
int check_not_null_example(int* p) {
CHECK_NOTNULL(p);
return *p;
int check_le_example(int x) {
CHECK_LE(x, 5);
return x;
}
int check_gt_example(int x) {
CHECK_GT(x, 5);
return x;
}

Loading…
Cancel
Save