[clang] [llvm] [coverage] skipping code coverage for 'if constexpr' and 'if consteval' (PR #78033)
Jessica Paquette via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 22 00:10:29 PST 2024
Hana =?utf-8?q?Dusíková?= <hanicka at hanicka.net>,
Hana =?utf-8?q?Dusíková?= <hanicka at hanicka.net>,
Hana =?utf-8?q?Dusíková?= <hanicka at hanicka.net>,
Hana =?utf-8?q?Dusíková?= <hanicka at hanicka.net>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/78033 at github.com>
================
@@ -1251,6 +1264,69 @@ struct CounterCoverageMappingBuilder
popRegions(Index);
}
+ /// Find a valid range starting with \p StartingLoc and ending before \p
+ /// BeforeLoc.
+ std::optional<SourceRange> findAreaStartingFromTo(SourceLocation StartingLoc,
+ SourceLocation BeforeLoc) {
+ // If StartingLoc is in function-like macro, use its start location.
+ if (StartingLoc.isMacroID()) {
+ FileID FID = SM.getFileID(StartingLoc);
+ const SrcMgr::ExpansionInfo *EI = &SM.getSLocEntry(FID).getExpansion();
+ if (EI->isFunctionMacroExpansion())
+ StartingLoc = EI->getExpansionLocStart();
+ }
+
+ size_t StartDepth = locationDepth(StartingLoc);
+ size_t EndDepth = locationDepth(BeforeLoc);
+ while (!SM.isWrittenInSameFile(StartingLoc, BeforeLoc)) {
+ bool UnnestStart = StartDepth >= EndDepth;
+ bool UnnestEnd = EndDepth >= StartDepth;
+ if (UnnestEnd) {
----------------
ornata wrote:
Could you add a comment explaining `UnnestStart` and `UnnestEnd`?
https://github.com/llvm/llvm-project/pull/78033
More information about the cfe-commits
mailing list