Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions clang/lib/Verify/Driver/Verifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "DumpIR.h"
#include "clang/AST/ASTContext.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Frontend/TextDiagnostic.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
Expand Down Expand Up @@ -1075,6 +1076,9 @@ struct VerifyDiagnostic {
/// interrupted function, which its Interrupted line replaces, or a vacuity
/// finding that rests on a fact that is not established.
bool Hidden = false;
/// For an error about source the verifier cannot represent: that source,
/// shown with its line as a compiler error is.
SourceRange Span;
};

static std::string backendSuffix(const VerifyResult &Result) {
Expand Down Expand Up @@ -1730,8 +1734,12 @@ class Verifier {
Converter.getUnverifiedCallers();
for (const auto &[Loc, Message] : Converter.getWarnings())
Diags.push_back({VerifyDiagnostic::Warning, Message, Loc});
for (const std::string &Err : Converter.getErrors())
Diags.push_back({VerifyDiagnostic::Error, Err});
for (const ConversionError &Err : Converter.getErrors()) {
VerifyDiagnostic D{VerifyDiagnostic::Error, Err.Message,
Err.Range.getBegin()};
D.Span = Err.Range;
Diags.push_back(std::move(D));
}
if (!Converter.getErrors().empty())
return false;
if (Functions.empty()) {
Expand Down Expand Up @@ -3834,6 +3842,13 @@ class Verifier {
Source.Column = Location.getColumn();
Source.EndLine = Source.Line;
Source.EndColumn = Source.Column;
if (D.Span.isValid())
if (PresumedLoc End =
Ctx.getSourceManager().getPresumedLoc(D.Span.getEnd());
End.isValid()) {
Source.EndLine = End.getLine();
Source.EndColumn = End.getColumn();
}
}
}
if (Source.isValid())
Expand Down Expand Up @@ -4006,6 +4021,16 @@ class Verifier {
printJSONDiagnostic(D, OS);
continue;
}
if (D.K == VerifyDiagnostic::Error && D.Span.isValid()) {
DiagnosticOptions DiagOpts;
DiagOpts.ShowPresumedLoc = true;
TextDiagnostic Text(OS, Ctx.getLangOpts(), DiagOpts);
Text.emitDiagnostic(
FullSourceLoc(D.Span.getBegin(), Ctx.getSourceManager()),
DiagnosticsEngine::Error, D.Message,
CharSourceRange::getTokenRange(D.Span), {});
continue;
}
if (D.Loc.isValid()) {
PresumedLoc PLoc = Ctx.getSourceManager().getPresumedLoc(D.Loc);
if (PLoc.isValid())
Expand Down
Loading
Loading