Skip to content

reporting bad coverage for code in unevaluated context #75751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hanickadot opened this issue Dec 17, 2023 · 4 comments
Closed

reporting bad coverage for code in unevaluated context #75751

hanickadot opened this issue Dec 17, 2023 · 4 comments
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" coverage

Comments

@hanickadot
Copy link
Contributor

Dear LLVM developers! I noticed bad code-coverage for code in unevaluated context. Like when constexpr function is called in decltype(...) or even in concepts:

Screenshot 2023-12-17 at 22 16 51

Such code shouldn't be marked uncovered.

@asl asl added the incomplete Issue not complete (e.g. missing a reproducer, build arguments, etc.) label Dec 18, 2023
@hanickadot
Copy link
Contributor Author

hanickadot commented Dec 18, 2023

Sorry for not proper bug report. I should be better. There is all you need:

template <typename T, template <typename...> typename Wrapper> 
concept is_base_of = requires(const T & obj) {
  []<typename... Y>(const Wrapper<Y...> &){ }(obj);
};

template <typename...> struct variant { };

struct foo: variant<int, bool> { };

static_assert(is_base_of<foo, variant>);

int main() { }

These commands needs to be run:

clang++ -fprofile-instr-generate -fcoverage-mapping test.cpp -std=c++20 -o test

./test

llvm-profdata merge default.profraw -o coverage.profdata

llvm-cov show test -instr-profile=coverage.profdata

And the resulting coverage is:
Screenshot 2023-12-18 at 08 52 44

(notice the uncovered branch in lambda inside concepts)

@hanickadot
Copy link
Contributor Author

And I'm using clang 17.0.6. Don't know about other versions as this is not possible (AFAIK) on CE.

@cor3ntin cor3ntin added clang:frontend Language frontend issues, e.g. anything involving "Sema" and removed incomplete Issue not complete (e.g. missing a reproducer, build arguments, etc.) labels Jan 7, 2024
@llvmbot
Copy link
Member

llvmbot commented Jan 7, 2024

@llvm/issue-subscribers-clang-frontend

Author: Hana Dusíková (hanickadot)

Dear LLVM developers! I noticed bad code-coverage for code in unevaluated context. Like when constexpr function is called in `decltype(...)` or even in concepts:

<img width="1081" alt="Screenshot 2023-12-17 at 22 16 51" src="https://github.com/llvm/llvm-project/assets/6557263/10b6884a-b7fd-4e52-9973-82e5e51efbb0">

Such code shouldn't be marked uncovered.

@hanickadot
Copy link
Contributor Author

Fixed in #78033

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" coverage
Projects
None yet
Development

No branches or pull requests

5 participants