[llvm-dev] [clang-tidy] How to check this code

zhaoyonggang via llvm-dev llvm-dev at lists.llvm.org
Sun Sep 27 16:10:15 PDT 2020


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.

	

```cpp
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

}


```

> On Sep 27, 2020, at 7:30 PM, zhaoyonggang <yonggang.zhao at icloud.com> wrote:
> 
> I have seen "clang-diagnostic-unreachable-code" when I use clang-tidy 7.0,  is it removed from latest clang-tidy?
> 
>> On Sep 27, 2020, at 6:27 PM, zhaoyonggang via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>> 
>> 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.
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200928/a0a12ab9/attachment.html>


More information about the llvm-dev mailing list