[IR] Add a boolean field in DILocation to know if a line must covered or not
Summary:
Some lines have a hit counter where they should not have one.
For example, in C++, some cleanup is adding at the end of a scope represented by a '}'.
So such a line has a hit counter where a user expects to not have one.
The goal of the patch is to add this information in DILocation which is used to get the covered lines in GCOVProfiling.cpp.
A following patch in clang will add this information when generating IR (https://reviews.llvm.org/D49916).
Reviewers: marco-c, davidxl, vsk, javed.absar, rnk
Reviewed By: rnk
Subscribers: eraman, xur, danielcdh, aprantl, rnk, dblaikie, #debug-info, vsk, llvm-commits, sylvestre.ledru
Tags: #debug-info
Differential Revision: https://reviews.llvm.org/D49915
llvm-svn: 342631
diff --git a/llvm/lib/IR/DebugLoc.cpp b/llvm/lib/IR/DebugLoc.cpp
index 36f3e17..10ec98a 100644
--- a/llvm/lib/IR/DebugLoc.cpp
+++ b/llvm/lib/IR/DebugLoc.cpp
@@ -56,15 +56,28 @@
return DebugLoc();
}
+bool DebugLoc::isImplicitCode() const {
+ if (DILocation *Loc = get()) {
+ return Loc->isImplicitCode();
+ }
+ return true;
+}
+
+void DebugLoc::setImplicitCode(bool ImplicitCode) {
+ if (DILocation *Loc = get()) {
+ Loc->setImplicitCode(ImplicitCode);
+ }
+}
+
DebugLoc DebugLoc::get(unsigned Line, unsigned Col, const MDNode *Scope,
- const MDNode *InlinedAt) {
+ const MDNode *InlinedAt, bool ImplicitCode) {
// If no scope is available, this is an unknown location.
if (!Scope)
return DebugLoc();
return DILocation::get(Scope->getContext(), Line, Col,
const_cast<MDNode *>(Scope),
- const_cast<MDNode *>(InlinedAt));
+ const_cast<MDNode *>(InlinedAt), ImplicitCode);
}
DebugLoc DebugLoc::appendInlinedAt(DebugLoc DL, DILocation *InlinedAt,