|
@@ -396,13 +396,13 @@ void BackendConsumer::OptimizationRemarkHandler(
|
|
unsigned Line, Column;
|
|
unsigned Line, Column;
|
|
D.getLocation(&Filename, &Line, &Column);
|
|
D.getLocation(&Filename, &Line, &Column);
|
|
SourceLocation Loc;
|
|
SourceLocation Loc;
|
|
- if (Line > 0) {
|
|
|
|
|
|
+ const FileEntry *FE = FileMgr.getFile(Filename);
|
|
|
|
+ if (FE && Line > 0) {
|
|
// If -gcolumn-info was not used, Column will be 0. This upsets the
|
|
// If -gcolumn-info was not used, Column will be 0. This upsets the
|
|
// source manager, so if Column is not set, set it to 1.
|
|
// source manager, so if Column is not set, set it to 1.
|
|
if (Column == 0)
|
|
if (Column == 0)
|
|
Column = 1;
|
|
Column = 1;
|
|
- Loc = SourceMgr.translateFileLineCol(FileMgr.getFile(Filename), Line,
|
|
|
|
- Column);
|
|
|
|
|
|
+ Loc = SourceMgr.translateFileLineCol(FE, Line, Column);
|
|
}
|
|
}
|
|
Diags.Report(Loc, diag::remark_fe_backend_optimization_remark)
|
|
Diags.Report(Loc, diag::remark_fe_backend_optimization_remark)
|
|
<< AddFlagValue(D.getPassName()) << D.getMsg().str();
|
|
<< AddFlagValue(D.getPassName()) << D.getMsg().str();
|
|
@@ -415,6 +415,13 @@ void BackendConsumer::OptimizationRemarkHandler(
|
|
// -Rpass is used. !srcloc annotations need to be emitted in
|
|
// -Rpass is used. !srcloc annotations need to be emitted in
|
|
// approximately the same spots as !dbg nodes.
|
|
// approximately the same spots as !dbg nodes.
|
|
Diags.Report(diag::note_fe_backend_optimization_remark_missing_loc);
|
|
Diags.Report(diag::note_fe_backend_optimization_remark_missing_loc);
|
|
|
|
+ else if (Loc.isInvalid())
|
|
|
|
+ // If we were not able to translate the file:line:col information
|
|
|
|
+ // back to a SourceLocation, at least emit a note stating that
|
|
|
|
+ // we could not translate this location. This can happen in the
|
|
|
|
+ // case of #line directives.
|
|
|
|
+ Diags.Report(diag::note_fe_backend_optimization_remark_invalid_loc)
|
|
|
|
+ << Filename << Line << Column;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|