Hi, all,
I build clang-tidy by "ninja clang-tidy", but when I run below command, I get no checks. Where is the clang-diagnostic* checkers? Thanks in advance.
$ /Users/zyg/Documents/workspace/llvm-project/llvm/cmake-build-debug/bin/clang-tidy --checks="-*,clang-diagnostic-*" --list-checks
No checks enabled.
I have seen "clang-diagnostic-unreachable-code" when I use clang-tidy 7.0, is it removed from latest clang-tidy?
Hi, Everyone
My problem is how to check below code. How to add custom check for below code ? Stmt(after(returnStmt))? Any clue is welcome, thanks
FYI , I have noted such issue can be checked by “clang-diagnostic-unreachable-code” when I use clang-tidy 7(not so sure). But currently I want to develop custom checker, and I clone latest llvm repo and build clang-tidy. Clang-tidy I build can’t find any issue.
int16_t with_unreach( int16_t para) {
int16_t local = 0;
int* pt = nullptr;
int a = *pt;
switch (para) {
local = para;
// unreachable code
case 1:{
break;
}
default: {
break;
}
}
return para;
para++;
// unreachable code
}
Hi,
clang-diagnostic* doesn't refer to a group of checkers, they refer to
diagnostics emitted by clang during parsing and sema.
If you want a full list of checks available you can run
`clang-tidy --checks=* --list-checks`
~Nathan
Hi, Nathan
Thanks a lot.
When I modify below code, and clang-diagnostic-unreachable-code warning will be reported when I run `/Users/zyg/Documents/workspace/llvm-project/llvm/cmake-build-debug/bin/clang-tidy --checks=* ../library.cpp`. I still need to find how to enable "unreachable code" warning by command option not by modifying code
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -612,7 +612,7 @@ def warn_suggest_noreturn_block : Warning<
// Unreachable code.
def warn_unreachable : Warning<
"code will never be executed">,
- InGroup<UnreachableCode>, DefaultIgnore;
+ InGroup<UnreachableCode>;
def warn_unreachable_break : Warning<
"'break' will never be executed">,
InGroup<UnreachableCodeBreak>, DefaultIgnore;