You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Mitya Lyubarskiy
59e17f59b8
[logging] Introduce a function to call arbitrary function with subsequent logs written in an indended way.
Summary:
The problem: you want to log "as much as possible" so you rarely need to
debug your stuff. But you are worried that logs will become not readable
because it will be hard to follow the logic of the program.
Solution: Indentation!
If everything what is happening inside the function is indended, it
won't hurt readability: the overall flow of the whole program will be
easy to comprehend.
Intended usage of this new helper: if the function is complex enough
that does something nontrivial inside (e.g. calls other complex
functions), wrap it in `d_with_indent` at top level.
This diff also uses this function in several top-level places of
Nullsafe. Follow up diffs will include more logging in nullsafe.
Example of log:
```
before:
&bad -> [Field codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic (object: OptimisticFallback)] Nullable java.lang.Object*
&codetoanalyze.java.nullsafe_default.NullFieldAccess_codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic -> [Field codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic (object: OptimisticFallback)] Nullable java.lang.Object*
&this -> [this] StrictNonnull codetoanalyze.java.nullsafe_default.NullFieldAccess*
-----------------------------
Typecking instr: n$1=*&bad:java.lang.Object* [line 45]
Executing typecheck_expr:
Expr: &bad
Result of typecheck_expr:
Typ: java.lang.Object*; Nullability: Nullable
Executing convert_complex_exp_to_pvar:
Result of convert_complex_exp_to_pvar:
Exp: &bad;
Typestate:
&bad -> [Field codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic (object: OptimisticFallback)] Nullable java.lang.Object*
&codetoanalyze.java.nullsafe_default.NullFieldAccess_codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic -> [Field codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic (object: OptimisticFallback)] Nullable java.lang.Object*
&this -> [this] StrictNonnull codetoanalyze.java.nullsafe_default.NullFieldAccess*
Executing typecheck_expr:
Expr: &bad
Result of typecheck_expr:
Typ: java.lang.Object*; Nullability: Nullable
Setting Nullable to Id n$1: Sil.Load
New state:
n$1 -> [Field codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic (object: OptimisticFallback)] Nullable java.lang.Object*
&bad -> [Field codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic (object: OptimisticFallback)] Nullable java.lang.Object*
&codetoanalyze.java.nullsafe_default.NullFieldAccess_codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic -> [Field codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic (object: OptimisticFallback)] Nullable java.lang.Object*
&this -> [this] StrictNonnull codetoanalyze.java.nullsafe_default.NullFieldAccess*
-----------------------------
Typecking instr: _=*n$1:java.lang.Object*(root java.lang.Object) [line 45]
Executing typecheck_expr:
Expr: n$1
Result of typecheck_expr:
Typ: java.lang.Object*; Nullability: Nullable
Executing convert_complex_exp_to_pvar:
Result of convert_complex_exp_to_pvar:
Exp: &bad;
Typestate:
n$1 -> [Field codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic (object: OptimisticFallback)] Nullable java.lang.Object*
&bad -> [Field codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic (object: OptimisticFallback)] Nullable java.lang.Object*
&codetoanalyze.java.nullsafe_default.NullFieldAccess_codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic -> [Field codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic (object: OptimisticFallback)] Nullable java.lang.Object*
&this -> [this] StrictNonnull codetoanalyze.java.nullsafe_default.NullFieldAccess*
Executing typecheck_expr:
Expr: &bad
Result of typecheck_expr:
Typ: java.lang.Object*; Nullability: Nullable
Setting Nullable to Id _: Sil.Load
New state:
n$1 -> [Field codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic (object: OptimisticFallback)] Nullable java.lang.Object*
_ -> [Field codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic (object: OptimisticFallback)] Nullable java.lang.Object*
&bad -> [Field codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic (object: OptimisticFallback)] Nullable java.lang.Object*
&codetoanalyze.java.nullsafe_default.NullFieldAccess_codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic -> [Field codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic (object: OptimisticFallback)] Nullable java.lang.Object*
&this -> [this] StrictNonnull codetoanalyze.java.nullsafe_default.NullFieldAccess*
-----------------------------
Typecking instr: n$3=_fun_String Object.toString()(n$1:java.lang.Object*) virtual [line 45]
Executing typecheck_expr:
Expr: n$1
Result of typecheck_expr:
Typ: java.lang.Object*; Nullability: Nullable
Executing convert_complex_exp_to_pvar:
Result of convert_complex_exp_to_pvar:
Exp: &bad;
Typestate:
n$1 -> [Field codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic (object: OptimisticFallback)] Nullable java.lang.Object*
_ -> [Field codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic (object: OptimisticFallback)] Nullable java.lang.Object*
&bad -> [Field codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic (object: OptimisticFallback)] Nullable java.lang.Object*
&codetoanalyze.java.nullsafe_default.NullFieldAccess_codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic -> [Field codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic (object: OptimisticFallback)] Nullable java.lang.Object*
&this -> [this] StrictNonnull codetoanalyze.java.nullsafe_default.NullFieldAccess*
Executing typecheck_expr:
Expr: &bad
Result of typecheck_expr:
Typ: java.lang.Object*; Nullability: Nullable
exp_rv_dexp: normal var n$1
find_normal_variable_load defining &bad
exp_lv_dexp: program var &bad
WARNING: ERADICATE_NULLABLE_DEREFERENCE `bad` is nullable and is not locally checked for null when calling `toString()`: field nullableStatic at line 44.
Setting ThirdPartyNonnull to Id n$3: typecheck_sil_call_function
New state:
n$3 -> [Fun toString()] ThirdPartyNonnull java.lang.String*
n$1 -> [Field codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic (object: OptimisticFallback)] Nullable java.lang.Object*
_ -> [Field codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic (object: OptimisticFallback)] Nullable java.lang.Object*
&bad -> [Field codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic (object: OptimisticFallback)] Nullable java.lang.Object*
&codetoanalyze.java.nullsafe_default.NullFieldAccess_codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic -> [Field codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic (object: OptimisticFallback)] Nullable java.lang.Object*
&this -> [this] StrictNonnull codetoanalyze.java.nullsafe_default.NullFieldAccess*
-----------------------------
Typecking instr: *&$irvar0:java.lang.String*=n$3 [line 45]
Executing typecheck_expr:
Expr: &$irvar0
Result of typecheck_expr:
Typ: void; Nullability: StrictNonnull
Executing convert_complex_exp_to_pvar:
exp_rv_dexp: program var &$irvar0
exp_lv_dexp: program var &$irvar0
exp_rv_dexp: constant _fun_String Object.toString()
exp_rv_dexp: normal var n$1
find_normal_variable_load defining &bad
exp_lv_dexp: program var &bad
Result of convert_complex_exp_to_pvar:
Exp: &java.lang.Object.toString():java.lang.String(bad)V;
Typestate:
n$3 -> [Fun toString()] ThirdPartyNonnull java.lang.String*
n$1 -> [Field codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic (object: OptimisticFallback)] Nullable java.lang.Object*
_ -> [Field codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic (object: OptimisticFallback)] Nullable java.lang.Object*
&bad -> [Field codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic (object: OptimisticFallback)] Nullable java.lang.Object*
&codetoanalyze.java.nullsafe_default.NullFieldAccess_codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic -> [Field codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic (object: OptimisticFallback)] Nullable java.lang.Object*
&this -> [this] StrictNonnull codetoanalyze.java.nullsafe_default.NullFieldAccess*
Executing typecheck_expr:
Expr: n$3
Result of typecheck_expr:
Typ: java.lang.String*; Nullability: ThirdPartyNonnull
Setting ThirdPartyNonnull to Pvar java.lang.Object.toString():java.lang.String(bad)V: Sil.Store: Exp.Lvar case
New state:
n$3 -> [Fun toString()] ThirdPartyNonnull java.lang.String*
n$1 -> [Field codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic (object: OptimisticFallback)] Nullable java.lang.Object*
_ -> [Field codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic (object: OptimisticFallback)] Nullable java.lang.Object*
&java.lang.Object.toString():java.lang.String(bad)V -> [Fun toString()] ThirdPartyNonnull java.lang.String*
&bad -> [Field codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic (object: OptimisticFallback)] Nullable java.lang.Object*
&codetoanalyze.java.nullsafe_default.NullFieldAccess_codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic -> [Field codetoanalyze.java.nullsafe_default.NullFieldAccess.nullableStatic (object: OptimisticFallback)] Nullable java.lang.Object*
&this -> [this] StrictNonnull codetoanalyze.java.nullsafe_default.NullFieldAccess*
-----------------------------
Typecking instr: NULLIFY(&bad); [line 45]
```
Reviewed By: artempyanykh
Differential Revision: D20304424
fbshipit-source-id: 7fa3f459e
|
5 years ago |
.github/workflows
|
[infer][PR] Update deploy.yml
|
5 years ago |
dependencies
|
[copyright] Remove years
|
6 years ago |
docker
|
[infer] Update docker build script
|
5 years ago |
examples
|
[copyright] Remove years
|
6 years ago |
facebook-clang-plugins@bab3919746
|
@update-submodule: facebook-clang-plugins Fix handling of non-literal `offsetof` expressions
|
5 years ago |
infer
|
[logging] Introduce a function to call arbitrary function with subsequent logs written in an indended way.
|
5 years ago |
m4
|
[copyright] Remove years
|
6 years ago |
scripts
|
[scripts] delete check_hash_collisions.py
|
5 years ago |
sledge
|
[sledge] Enforce variable context conditions in solver goals
|
5 years ago |
website
|
[debt] kill --procs-csv
|
5 years ago |
.buckconfig
|
[infer][genrule] Add example of Buck DEFS macro to generate Infer analysis targets
|
8 years ago |
.clang-format
|
fix sync mishaps
|
9 years ago |
.gitattributes
|
[website] exclude from repo language stats
|
5 years ago |
.gitignore
|
[tests] remove genrule test
|
5 years ago |
.gitmodules
|
[infer] Add facebook clang plugins submodule
|
10 years ago |
.inferconfig
|
[java] Add command-line option to specify external Java packages
|
7 years ago |
.ocamlformat
|
[ocamlformat] Move .ocamlformat config file to the project root
|
6 years ago |
.travis.yml
|
[infer][PR] Fix CI
|
5 years ago |
CODE_OF_CONDUCT.md
|
[infer][PR] Update CODE_OF_CONDUCT.md
|
7 years ago |
CONTRIBUTING.md
|
[infer][PR] Fix the ppx_deriving issue URL
|
5 years ago |
CONTRIBUTORS
|
Inferbo
|
8 years ago |
FILES.md
|
[trace] infer subcommand for inferTraceBugs
|
8 years ago |
INSTALL.md
|
[install] mpfr was missing from dependencies
|
5 years ago |
ISSUE_TEMPLATE.md
|
[github] add issue and PR templates
|
6 years ago |
LICENSE
|
[copyright] Remove years
|
6 years ago |
Makefile
|
[tech debt] Remove experimental nullability checkers
|
5 years ago |
Makefile.autoconf.in
|
[inferbo] Revert external relational domains (apron, elina)
|
5 years ago |
Makefile.config
|
[buck] kill python code for the dead Java integration
|
5 years ago |
PULL_REQUEST_TEMPLATE.md
|
[github] add issue and PR templates
|
6 years ago |
README.md
|
Change license to MIT
|
7 years ago |
autogen.sh
|
[copyright] Remove years
|
6 years ago |
build-infer.sh
|
[ocaml] 4.08.1
|
5 years ago |
configure.ac
|
[inferbo] Revert external relational domains (apron, elina)
|
5 years ago |
dotbuckversion
|
[buck] fix version hashes
|
5 years ago |
install-sh
|
[utils] Add CTypes binding of fts and implement remove_directory_tree
|
8 years ago |
opam
|
[infer] Use let* instead of let%bind
|
5 years ago |
opam.locked
|
@allow-large-files [opam] Update dune to 2.3.1
|
5 years ago |
Infer
Infer is a static analysis tool for Java,
C++, Objective-C, and C. Infer is written in OCaml.
Installation
Read our Getting
Started page for
details on how to install packaged versions of Infer. To build Infer
from source, see INSTALL.md.
Contributing
See CONTRIBUTING.md.
License
Infer is MIT-licensed.
Note: Enabling Java support may require you to download and install
components licensed under the GPL.