forked from OSchip/llvm-project
HTMLDiagnostics: Always display diagnostics *below* the line in question.
llvm-svn: 64959
This commit is contained in:
parent
e3bba6e3d0
commit
ea3a9e270c
|
@ -351,20 +351,14 @@ void HTMLDiagnostics::HandlePiece(Rewriter& R, FileID BugFileID,
|
||||||
const char *TokInstantiationPtr =Pos.getInstantiationLoc().getCharacterData();
|
const char *TokInstantiationPtr =Pos.getInstantiationLoc().getCharacterData();
|
||||||
const char *LineStart = TokInstantiationPtr-ColNo;
|
const char *LineStart = TokInstantiationPtr-ColNo;
|
||||||
|
|
||||||
// Only compute LineEnd if we display below a line.
|
// Compute LineEnd.
|
||||||
const char *LineEnd = TokInstantiationPtr;
|
const char *LineEnd = TokInstantiationPtr;
|
||||||
|
const char* FileEnd = Buf->getBufferEnd();
|
||||||
if (P.getDisplayHint() == PathDiagnosticPiece::Below) {
|
while (*LineEnd != '\n' && LineEnd != FileEnd)
|
||||||
const char* FileEnd = Buf->getBufferEnd();
|
++LineEnd;
|
||||||
|
|
||||||
while (*LineEnd != '\n' && LineEnd != FileEnd)
|
|
||||||
++LineEnd;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compute the margin offset by counting tabs and non-tabs.
|
// Compute the margin offset by counting tabs and non-tabs.
|
||||||
|
unsigned PosNo = 0;
|
||||||
unsigned PosNo = 0;
|
|
||||||
|
|
||||||
for (const char* c = LineStart; c != TokInstantiationPtr; ++c)
|
for (const char* c = LineStart; c != TokInstantiationPtr; ++c)
|
||||||
PosNo += *c == '\t' ? 8 : 1;
|
PosNo += *c == '\t' ? 8 : 1;
|
||||||
|
|
||||||
|
@ -432,19 +426,10 @@ void HTMLDiagnostics::HandlePiece(Rewriter& R, FileID BugFileID,
|
||||||
os << html::EscapeText(Msg) << "</div></td></tr>";
|
os << html::EscapeText(Msg) << "</div></td></tr>";
|
||||||
|
|
||||||
// Insert the new html.
|
// Insert the new html.
|
||||||
unsigned DisplayPos;
|
unsigned DisplayPos = LineEnd - FileStart;
|
||||||
switch (P.getDisplayHint()) {
|
|
||||||
default: assert(0 && "Unhandled hint.");
|
|
||||||
case PathDiagnosticPiece::Above:
|
|
||||||
DisplayPos = LineStart - FileStart;
|
|
||||||
break;
|
|
||||||
case PathDiagnosticPiece::Below:
|
|
||||||
DisplayPos = LineEnd - FileStart;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
SourceLocation Loc =
|
SourceLocation Loc =
|
||||||
SM.getLocForStartOfFile(LPosInfo.first).getFileLocWithOffset(DisplayPos);
|
SM.getLocForStartOfFile(LPosInfo.first).getFileLocWithOffset(DisplayPos);
|
||||||
|
|
||||||
R.InsertStrBefore(Loc, os.str());
|
R.InsertStrBefore(Loc, os.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue