+void DwarfUnit::addRange(RangeSpan Range) {
+ // Only add a range for this unit if we're emitting full debug.
+ if (getCUNode().getEmissionKind() == DIBuilder::FullDebug) {
+ // If we have no current ranges just add the range and return, otherwise,
+ // check the current section and CU against the previous section and CU we
+ // emitted into and the subprogram was contained within. If these are the
+ // same then extend our current range, otherwise add this as a new range.
+ if (CURanges.size() == 0 ||
+ this != DD->getPrevCU() ||
+ Asm->getCurrentSection() != DD->getPrevSection()) {
+ CURanges.push_back(Range);
+ return;
+ }
+
+ assert(&(CURanges.back().getEnd()->getSection()) ==
+ &(Range.getEnd()->getSection()) &&
+ "We can only append to a range in the same section!");
+ CURanges.back().setEnd(Range.getEnd());
+ }
+}
+