cppcheck

Static analysis tool for detecting bugs in C and C++ code

brewmacoslinux
Try with needOr install directly
Source

About

Static analysis of C and C++ code

Commands

cppcheck

Examples

Analyze all C++ files in current directory$ cppcheck .
Check specific file with verbose output$ cppcheck --verbose myfile.cpp
Generate XML report with specific error checking$ cppcheck --xml --enable=all src/ > report.xml