#include "polly/Support/ScopLocation.h"
#include "llvm/Analysis/RegionInfo.h"
#include "llvm/IR/DebugInfoMetadata.h"
using namespace llvm;
namespace polly {
void getDebugLocation(const Region *R, unsigned &LineBegin, unsigned &LineEnd,
std::string &FileName) {
LineBegin = -1;
LineEnd = 0;
for (const BasicBlock *BB : R->blocks())
for (const Instruction &Inst : *BB) {
DebugLoc DL = Inst.getStableDebugLoc();
if (!DL)
continue;
auto *Scope = cast<DIScope>(DL.getScope());
if (FileName.empty())
FileName = Scope->getFilename().str();
unsigned NewLine = DL.getLine();
LineBegin = std::min(LineBegin, NewLine);
LineEnd = std::max(LineEnd, NewLine);
}
}
}