[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.
This commit is contained in:
Andrey Ali Khan Bolshakov
2024-05-24 23:04:18 +03:00
committed by GitHub
parent 2669ee1174
commit 6be1a1535e
2 changed files with 4 additions and 2 deletions

View File

@@ -2271,7 +2271,8 @@ struct CounterCoverageMappingBuilder
}
void VisitOpaqueValueExpr(const OpaqueValueExpr* OVE) {
Visit(OVE->getSourceExpr());
if (OVE->isUnique())
Visit(OVE->getSourceExpr());
}
};

View File

@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name templates.cpp %s | FileCheck %s
// 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) {
@@ -30,5 +30,6 @@ namespace structural_value_crash {
void test() {
tpl_fn<arr>();
tpl_fn<&arr[1]>();
}
}