check-cpp: Make it more robust

Authored by bgamari on Oct 20 2016, 3:13 PM.