Andrey Ali Khan Bolshakov 6be1a1535e
[clang][c++20] Fix code coverage mapping crash with generalized NTTPs (#85837)
Introduced in #78041, originally reported as #79957 and fixed partially
in #80050.

`OpaqueValueExpr` used with `TemplateArgument::StructuralValue` has no
corresponding source expression.

A test case with subobject-referring NTTP added.
2024-05-24 13:04:18 -07:00

36 lines
639 B
C++

// RUN: %clang_cc1 -std=c++20 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name templates.cpp %s | FileCheck %s
template<typename T>
void unused(T x) {
return;
}
template<typename T>
int func(T x) { // CHECK: func
if(x) // CHECK: func
return 0;
else
return 1;
int j = 1;
}
int main() {
func<int>(0);
func<bool>(true);
return 0;
}
namespace structural_value_crash {
template <int* p>
void tpl_fn() {
(void)p;
}
int arr[] = {1, 2, 3};
void test() {
tpl_fn<arr>();
tpl_fn<&arr[1]>();
}
}