提交 5ddc4136 编写于 作者: J Jacques Pienaar 提交者: TensorFlower Gardener

Avoid passing in line/col for files not registered with SourceMgr.

This can result in index expression overflow in "Loc.getPointer() - ColumnNo"
in SourgeMgr.

loc could also be prefixed to the message additionally in this case.

PiperOrigin-RevId: 262935408
上级 d1225113
......@@ -415,12 +415,10 @@ void SourceMgrDiagnosticHandler::emitDiagnostic(Location loc, Twine message,
if (smloc.isValid())
return mgr.PrintMessage(os, smloc, getDiagKind(kind), message);
// If the conversion was unsuccessful, create a diagnostic with the source
// location information directly.
llvm::SMDiagnostic diag(mgr, llvm::SMLoc(), fileLoc->getFilename(),
fileLoc->getLine(), fileLoc->getColumn(),
getDiagKind(kind), message.str(), /*LineStr=*/"",
/*Ranges=*/llvm::None);
// If the conversion was unsuccessful, create a diagnostic with the file
// information.
llvm::SMDiagnostic diag(fileLoc->getFilename(), getDiagKind(kind),
message.str());
diag.print(nullptr, os);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册