The root of the problem was that findMainViewFileID(File, Function) could return some ID for any given file,
even though that file was not the main for that function.
This patch ensures that the result of this function is conformed with the result of findMainViewFileID(Function).
Details
Details
- Reviewers
davidxl bogner vsk - Commits
- rG1c14dc4c5a3b: Reapply "[Coverage] Prevent detection of false instantiations in case of macro…
rG061d496c511b: [Coverage] Prevent detection of false instantiations in case of macro expansion.
rL266620: Reapply "[Coverage] Prevent detection of false instantiations in case of…
rL266436: [Coverage] Prevent detection of false instantiations in case of macro expansion.
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
Comment Actions
Use the following commands to reproduce the issue:
$ cat > sample.cpp << EOF #include "sample.h" void func1() { DO_SOMETHING(); } void func2() { DO_SOMETHING(); } int main() { for (int I = 0; I < 10; ++I) if (I < 7) func1(); else func2(); return 0; } EOF $ cat > sample.h << EOF #define DO_SOMETHING() \ do { \ } while(0) /* * We need some lines here to show the issue. * * * */ EOF $ clang++ -fprofile-instr-generate -fcoverage-mapping sample.cpp $ ./a.out $ llvm-profdata merge -o default.profdata default.profraw $ llvm-cov show a.out -instr-profile default.profdata -filename-equivalence sample.h | 1|#define DO_SOMETHING() \ 10| 2| do { \ 10| 3| } while(0) | 4| | 5|/* ------------------ | _Z5func1v: | 7| 3| } while(0) | 7| 4| | 7| 5|/* ------------------ | 6| * We need some lines here to show the issue. | 7| * | 8| * | 9| * ------------------ | _Z5func2v: | 3| 7| * | 3| 8| * | 3| 9| * ------------------ | 10| */
Comment Actions
Can you also add the motivation case as one of the test case under tests/tools/llvm-cov ?
Otherwise looks good.
llvm/trunk/lib/ProfileData/CoverageMapping.cpp | ||
---|---|---|
379 | while you are at it, please add a brief comment for this method. | |
384 | Another fix is to check && FilenameEquivalence[CR.ExpandedFileID]) ... but I think your refactored code looks better. | |
390 | Add a comment for the function. |
Comment Actions
- Added the motivation case to the tests for llvm-cov.
- Added comments.
- Updated findMainViewFileID(File, Function) according to Justin's comment.
while you are at it, please add a brief comment for this method.