Index: llvm/trunk/test/tools/sancov/Inputs/blacklist.txt =================================================================== --- llvm/trunk/test/tools/sancov/Inputs/blacklist.txt +++ llvm/trunk/test/tools/sancov/Inputs/blacklist.txt @@ -1 +0,0 @@ -fun:bar* Index: llvm/trunk/test/tools/sancov/Inputs/fun_blacklist.txt =================================================================== --- llvm/trunk/test/tools/sancov/Inputs/fun_blacklist.txt +++ llvm/trunk/test/tools/sancov/Inputs/fun_blacklist.txt @@ -0,0 +1 @@ +fun:bar* Index: llvm/trunk/test/tools/sancov/Inputs/src_blacklist.txt =================================================================== --- llvm/trunk/test/tools/sancov/Inputs/src_blacklist.txt +++ llvm/trunk/test/tools/sancov/Inputs/src_blacklist.txt @@ -0,0 +1,3 @@ +# this path looks like sancov/Inputs/../Inputs/ in the binary. +# Make sure it is filtered out correctly. +src:*/sancov/Inputs/foo.cpp Index: llvm/trunk/test/tools/sancov/Inputs/test.cpp =================================================================== --- llvm/trunk/test/tools/sancov/Inputs/test.cpp +++ llvm/trunk/test/tools/sancov/Inputs/test.cpp @@ -1,7 +1,7 @@ // compile & generate coverage data using: -// clang++ -g -o test-linux_x86_64 -fsanitize=address -fsanitize-coverage=bb test.cpp foo.cpp -// ASAN_OPTIONS="coverage=1" ./test-linux_x86_64 && mv test-linux_x86_64.*.sancov test-linux_x86_64.sancov -// ASAN_OPTIONS="coverage=1" ./test-linux_x86_64 1 && mv test-linux_x86_64.*.sancov test-linux_x86_64-1.sancov +// clang++ -g -o test-linux_x86_64 -fsanitize=address -fsanitize-coverage=bb test.cpp ../Inputs/foo.cpp +// ASAN_OPTIONS="coverage=1" ./test-linux_x86_64 && mv test-linux_x86_64.??*.sancov test-linux_x86_64.0.sancov +// ASAN_OPTIONS="coverage=1" ./test-linux_x86_64 1 && mv test-linux_x86_64.??*.sancov test-linux_x86_64.1.sancov #include #include Index: llvm/trunk/test/tools/sancov/blacklist.test =================================================================== --- llvm/trunk/test/tools/sancov/blacklist.test +++ llvm/trunk/test/tools/sancov/blacklist.test @@ -1,5 +1,10 @@ REQUIRES: x86_64-linux -RUN: sancov -covered-functions -blacklist %p/Inputs/blacklist.txt %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s +RUN: sancov -covered-functions -blacklist %p/Inputs/fun_blacklist.txt %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s +RUN: sancov -covered-functions -blacklist %p/Inputs/src_blacklist.txt %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.1.sancov | FileCheck --check-prefix=CHECK1 %s CHECK-NOT: Inputs{{[/\\]}}test.cpp:12 bar(std::string) CHECK: Inputs{{[/\\]}}test.cpp:14 main + +CHECK1-NOT: foo +CHECK1: Inputs{{[/\\]}}test.cpp:12 bar(std::string) +CHECK1: Inputs{{[/\\]}}test.cpp:14 main Index: llvm/trunk/test/tools/sancov/print.test =================================================================== --- llvm/trunk/test/tools/sancov/print.test +++ llvm/trunk/test/tools/sancov/print.test @@ -1,11 +1,9 @@ REQUIRES: x86_64-linux RUN: sancov -print %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s -CHECK: 0x4dbe2b -CHECK: 0x4dbf72 -CHECK: 0x4dbfec -CHECK: 0x4dc033 -CHECK: 0x4dc06a -CHECK: 0x4dc09d -CHECK: 0x4dc0d0 +CHECK: 0x4e132b +CHECK: 0x4e1472 +CHECK: 0x4e1520 +CHECK: 0x4e1553 +CHECK: 0x4e1586 Index: llvm/trunk/test/tools/sancov/print_coverage_pcs.test =================================================================== --- llvm/trunk/test/tools/sancov/print_coverage_pcs.test +++ llvm/trunk/test/tools/sancov/print_coverage_pcs.test @@ -1,20 +1,13 @@ REQUIRES: x86_64-linux RUN: sancov -print-coverage-pcs %p/Inputs/test-linux_x86_64 | FileCheck %s -CHECK: 0x4cced1 -CHECK: 0x4ccf01 -CHECK: 0x4dbe2b -CHECK: 0x4dbf72 -CHECK: 0x4dbfc2 -CHECK: 0x4dbfec -CHECK: 0x4dc033 -CHECK: 0x4dc06a -CHECK: 0x4dc09d -CHECK: 0x4dc0d0 -CHECK: 0x4dc17f -CHECK: 0x4dc1c6 -CHECK: 0x4dc20d -CHECK: 0x4dc237 -CHECK: 0x4dc265 -CHECK: 0x4dc34c +CHECK: 0x4e132b +CHECK: 0x4e1472 +CHECK: 0x4e14c2 +CHECK: 0x4e1520 +CHECK: 0x4e1553 +CHECK: 0x4e1586 +CHECK: 0x4e1635 +CHECK: 0x4e1690 +CHECK: 0x4e178c Index: llvm/trunk/test/tools/sancov/stats.test =================================================================== --- llvm/trunk/test/tools/sancov/stats.test +++ llvm/trunk/test/tools/sancov/stats.test @@ -1,8 +1,8 @@ REQUIRES: x86_64-linux RUN: sancov -print-coverage-stats %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s -CHECK: all-edges: 16 -CHECK: cov-edges: 7 +CHECK: all-edges: 9 +CHECK: cov-edges: 5 CHECK: all-functions: 3 CHECK: cov-functions: 2 Index: llvm/trunk/tools/sancov/sancov.cc =================================================================== --- llvm/trunk/tools/sancov/sancov.cc +++ llvm/trunk/tools/sancov/sancov.cc @@ -241,14 +241,16 @@ : DefaultBlacklist(createDefaultBlacklist()), UserBlacklist(createUserBlacklist()) {} - bool isBlacklisted(const DILineInfo &DI) { - if (DefaultBlacklist && DefaultBlacklist->inSection("fun", DI.FunctionName)) + // AddrInfo contains normalized filename. It is important to check it rather + // than DILineInfo. + bool isBlacklisted(const AddrInfo &AI) { + if (DefaultBlacklist && DefaultBlacklist->inSection("fun", AI.FunctionName)) return true; - if (DefaultBlacklist && DefaultBlacklist->inSection("src", DI.FileName)) + if (DefaultBlacklist && DefaultBlacklist->inSection("src", AI.FileName)) return true; - if (UserBlacklist && UserBlacklist->inSection("fun", DI.FunctionName)) + if (UserBlacklist && UserBlacklist->inSection("fun", AI.FunctionName)) return true; - if (UserBlacklist && UserBlacklist->inSection("src", DI.FileName)) + if (UserBlacklist && UserBlacklist->inSection("src", AI.FileName)) return true; return false; } @@ -286,17 +288,19 @@ for (auto Addr : Addrs) { auto LineInfo = Symbolizer->symbolizeCode(ObjectFile, Addr); FailIfError(LineInfo); - if (B.isBlacklisted(*LineInfo)) + auto LineAddrInfo = AddrInfo(*LineInfo, Addr); + if (B.isBlacklisted(LineAddrInfo)) continue; - Result.push_back(AddrInfo(*LineInfo, Addr)); + Result.push_back(LineAddrInfo); if (InlinedCode) { auto InliningInfo = Symbolizer->symbolizeInlinedCode(ObjectFile, Addr); FailIfError(InliningInfo); for (uint32_t I = 0; I < InliningInfo->getNumberOfFrames(); ++I) { auto FrameInfo = InliningInfo->getFrame(I); - if (B.isBlacklisted(FrameInfo)) + auto FrameAddrInfo = AddrInfo(FrameInfo, Addr); + if (B.isBlacklisted(FrameAddrInfo)) continue; - Result.push_back(AddrInfo(FrameInfo, Addr)); + Result.push_back(FrameAddrInfo); } } }