除了控制台上的文本输出外:
clang++ --analyze -Xanalyzer -analyzer-output=text main.cpp
clang++ --analyze -Xanalyzer -analyzer-output=html -o html-dir main.cpp
此外,您可以选择要启用的特定检查器。此页面列出了可用的检查。例如,可以使用标志启用alpha组中的所有C ++检查:
-Xanalyzer -analyzer-checker=alpha.cplusplus
http://coliru.stacked-crooked.com/a/7746c4004704d4a7
main.cpp:5:1: warning: Potential leak of memory pointed to by 'x'
}
^
main.cpp:4:12: note: Memory is allocated
int *x = new int;
^~~~~~~
main.cpp:5:1: note: Potential leak of memory pointed to by 'x'
}
^
显然前端暴露
例如
-analyzer-config -analyzer-checker=alpha.cplusplus
它可能会得到更好的支持,-Xanalyzer
并且可能会扩展到支持单个检查器的选项:http : //lists.cs.uiuc.edu/pipermail/cfe- dev/2014-October/039552.html