Tag | clang

  1. Find Undefined Behavior with Clang UBSan

    Two weeks ago, I came across an interesting bug. The convert() function below returns 0x80000001 when p points to 0x01, 0x00, 0x00, 0x80, but the expected return value is 0x00000001 instead.

    int32_t convert(const uint8_t *restrict p) {
      uint32_t x = (                  p[0] +
                    256 *             p[1] +
                    256 * 256 *       p …

    More

  2. Check Code Coverage with Clang and LCOV

    Code coverage is a metric to show the code being untested. It can be considered as a hint to add more test cases. When we are writing C/C++, the most notable code coverage testing tool is gcov, which is a GCC built-in coverage testing tool. Besides, we can collect …

    More

  3. LLVM Bugpoint

    In this post, I would like to introduce the bugpoint command line tool. This is a automatic test case reduction tool which can help us generate minimal test case.

    As a compiler developer, the first step to debug is to create a minimal test case which can still reproduce the …

    More