summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CoverageMappingGen.cpp
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2015-03-25 04:13:49 +0000
committerJustin Bogner <mail@justinbogner.com>2015-03-25 04:13:49 +0000
commitf14b207882741924deeec9114d94b6a97eb1752b (patch)
tree37323553711f0b63a8b7a3739d8c25c3fc00232f /clang/lib/CodeGen/CoverageMappingGen.cpp
parent506d031dd0ed53da7abce11ab9c258f3fb0fd0e4 (diff)
downloadbcm5719-llvm-f14b207882741924deeec9114d94b6a97eb1752b.tar.gz
bcm5719-llvm-f14b207882741924deeec9114d94b6a97eb1752b.zip
InstrProf: Handle whitespace and comments at the ends of macros
When we try to find the end loc for a token, we have to re-lex the token. This was running into a problem when we'd store the end loc of a macro's coverage region, since we wouldn't actually be at the beginning of a token when we tried to re-lex it, leading us to do silly things (and eventually assert) when whitespace or comments followed. This pushes our use of getPreciseTokenLocEnd earlier, so that we won't call it when it doesn't make sense to. It also removes an unnecessary adjustment by 1 that was working around this problem in some cases. llvm-svn: 233169
Diffstat (limited to 'clang/lib/CodeGen/CoverageMappingGen.cpp')
-rw-r--r--clang/lib/CodeGen/CoverageMappingGen.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 55e7334acc2..07db6c74d11 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -124,7 +124,7 @@ public:
SourceLocation getEndOfFileOrMacro(SourceLocation Loc) {
if (Loc.isMacroID())
return Loc.getLocWithOffset(SM.getFileIDSize(SM.getFileID(Loc)) -
- SM.getFileOffset(Loc) - 1);
+ SM.getFileOffset(Loc));
return SM.getLocForEndOfFile(SM.getFileID(Loc));
}
@@ -147,7 +147,7 @@ public:
SourceLocation Loc = S->getLocEnd();
while (SM.isMacroArgExpansion(Loc))
Loc = SM.getImmediateExpansionRange(Loc).first;
- return Loc;
+ return getPreciseTokenLocEnd(Loc);
}
/// \brief Find the set of files we have regions for and assign IDs
@@ -257,7 +257,7 @@ public:
if (!CovFileID)
continue;
- SourceLocation LocEnd = getPreciseTokenLocEnd(Region.getEndLoc());
+ SourceLocation LocEnd = Region.getEndLoc();
assert(SM.isWrittenInSameFile(LocStart, LocEnd) &&
"region spans multiple files");
@@ -407,7 +407,7 @@ struct CounterCoverageMappingBuilder
SourceRegions.emplace_back(Region.getCounter(), NestedLoc, EndLoc);
- EndLoc = getIncludeOrExpansionLoc(EndLoc);
+ EndLoc = getPreciseTokenLocEnd(getIncludeOrExpansionLoc(EndLoc));
assert(!EndLoc.isInvalid() &&
"File exit was not handled before popRegions");
}
OpenPOWER on IntegriCloud