Modify BaseFormatter to help static analysers
authorPhil Willoughby <philwill@fb.com>
Tue, 7 Feb 2017 08:45:01 +0000 (00:45 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 7 Feb 2017 08:50:20 +0000 (00:50 -0800)
commit115059030653fe6f73e351073097ba1e06507f21
tree29302df5eae4da70e5912dc1402460d26a3d9a30
parent9773e441c61fd246829aeb8f371968fc7866aa8c
Modify BaseFormatter to help static analysers

Summary:
This decouples the format-string-parser from the storage of the arguments to be
formatted: a static analyser can now define a class which derives from
`BaseFormatter` with no storage and use `BaseFormatter::operator()` to verify
the syntax of the format string and determine which arguments will be
referenced.

This method of allowing overrides is resolved at compile time; the benchmarks
confirm that there is no run-time difference.

Reviewed By: yfeldblum

Differential Revision: D4507689

fbshipit-source-id: f109d81ae54dc074ac363720ef6e565520435d26
folly/Format-inl.h
folly/Format.h