[clang] [Coverage][Expansion] handle nested macros in scratch space (PR #89869)
NAKAMURA Takumi via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 24 15:31:33 PDT 2024
================
@@ -339,8 +365,17 @@ class CoverageMappingBuilder {
llvm::SmallSet<FileID, 8> Visited;
SmallVector<std::pair<SourceLocation, unsigned>, 8> FileLocs;
- for (const auto &Region : SourceRegions) {
+ for (auto &Region : SourceRegions) {
SourceLocation Loc = Region.getBeginLoc();
+
+ // Replace Region with its definition if it is in <scratch space>.
+ auto NonScratchExpansionLoc = getNonScratchExpansionLoc(Loc);
+ Loc = NonScratchExpansionLoc.first;
+ auto EndLoc = NonScratchExpansionLoc.second;
+ Region.setStartLoc(Loc);
+ Region.setEndLoc(EndLoc.has_value() ? EndLoc.value()
+ : Region.getEndLoc());
----------------
chapuni wrote:
Could you make updates optional?
```
if (has_value) {
Loc = ...;
Region.set(...);
}
```
https://github.com/llvm/llvm-project/pull/89869
More information about the cfe-commits
mailing list