How do I tell gcov to ignore un-hittable lines of C++ code?

后端 未结 4 1900
悲哀的现实
悲哀的现实 2020-12-28 11:45

I\'m using gcov to measure coverage in my C++ code. I\'d like to get to 100% coverage, but am hampered by the fact that there are some lines of code that are theoretically

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-28 12:37

    I do not believe this is possible. Gcov depends on gcc to generate extra code to produce the coverage output. GCov itself just parses the data. This means that Gcov cannot analyze the code any better than gcc (and I assume you use -Wall and have removed code reported as unreachable).

    Remember that relocatable functions can be called from anywhere, potentially even external dlls or executables so there is no way the compiler can know what relocatable functions will not be called or what input these functions may have.

    You probably will need to use some facy static analysis tool to get the info that you want.

提交回复
热议问题