clang-format: Cache results of formatting nested blocks.

This somewhat improves the performance problem reported in
llvm.org/PR18761. No other behavior changes intended.