This avoids creating a DILocation just to represent a line number,
since creating Metadata is expensive. Creating a DiagnosticLocation
directly is much cheaper.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295531
91177308-0d34-0410-b5e6-
96231b3b80d8
public:
DiagnosticLocation() {}
DiagnosticLocation(const DebugLoc &DL);
+ DiagnosticLocation(const DISubprogram *SP);
bool isValid() const { return !Filename.empty(); }
StringRef getFilename() const { return Filename; }
Column = DL->getColumn();
}
+DiagnosticLocation::DiagnosticLocation(const DISubprogram *SP) {
+ if (!SP)
+ return;
+ Filename = SP->getFilename();
+ Line = SP->getScopeLine();
+ Column = 0;
+}
+
void DiagnosticInfoWithLocationBase::getLocation(StringRef *Filename,
unsigned *Line,
unsigned *Column) const {
: Key(Key) {
if (auto *F = dyn_cast<Function>(V)) {
if (DISubprogram *SP = F->getSubprogram())
- Loc = DebugLoc::get(SP->getScopeLine(), 0, SP);
+ Loc = SP;
}
else if (auto *I = dyn_cast<Instruction>(V))
Loc = I->getDebugLoc();
for (const auto &DT : DevirtTargets) {
Function *F = DT.second;
DISubprogram *SP = F->getSubprogram();
- DebugLoc DL = SP ? DebugLoc::get(SP->getScopeLine(), 0, SP) : DebugLoc();
- emitOptimizationRemark(F->getContext(), DEBUG_TYPE, *F, DL,
+ emitOptimizationRemark(F->getContext(), DEBUG_TYPE, *F, SP,
Twine("devirtualized ") + F->getName());
}
}