https://github.com/arichardson updated https://github.com/llvm/llvm-project/pull/233309
>From 05d8d701dfadeaa089b7abfb3fc60ac5516554eb Mon Sep 17 00:00:00 2001 From: Alex Richardson <[email protected]> Date: Tue, 20 Oct 2026 14:56:19 -0700 Subject: [PATCH] [nspr] initial commit --- llvm/lib/Support/SourceMgrDiagnosticVerifier.cpp | 4 ++-- .../Support/SourceMgrDiagnosticVerifierTest.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Support/SourceMgrDiagnosticVerifier.cpp b/llvm/lib/Support/SourceMgrDiagnosticVerifier.cpp index 1946ff4e6c11f..c4d210aca2f08 100644 --- a/llvm/lib/Support/SourceMgrDiagnosticVerifier.cpp +++ b/llvm/lib/Support/SourceMgrDiagnosticVerifier.cpp @@ -67,9 +67,9 @@ bool SourceMgrDiagnosticVerifier::emitError(const ExpectedDiag &diag, SMRange range; ArrayRef<SMRange> ranges; if (diag.fileLoc.isValid()) { + // Highlight the whole directive, up to and including the closing '}}'. range = - SMRange(diag.fileLoc, SMLoc::getFromPointer(diag.fileLoc.getPointer() + - diag.substring.size())); + SMRange(diag.fileLoc, SMLoc::getFromPointer(diag.substring.end() + 2)); ranges = range; } printDiag(mgr.GetMessage(diag.fileLoc, SourceMgr::DK_Error, msg, ranges)); diff --git a/llvm/unittests/Support/SourceMgrDiagnosticVerifierTest.cpp b/llvm/unittests/Support/SourceMgrDiagnosticVerifierTest.cpp index c262ff8162084..18685b55f7195 100644 --- a/llvm/unittests/Support/SourceMgrDiagnosticVerifierTest.cpp +++ b/llvm/unittests/Support/SourceMgrDiagnosticVerifierTest.cpp @@ -291,3 +291,14 @@ TEST_F(SourceMgrDiagnosticVerifierTest, AlreadyMatchedIsNotNearMiss) { EXPECT_EQ(StringRef(Output).find("diagnostic emitted when expecting"), StringRef::npos); } + +TEST_F(SourceMgrDiagnosticVerifierTest, ErrorHighlightsWholeDirective) { + addBuffer("op\n# expected-error@-1 {{missing}}\n"); + SourceMgrDiagnosticVerifier Verifier(SM, OS); + + EXPECT_FALSE(Verifier.verify()); + EXPECT_NE(StringRef(Output).find("# expected-error@-1 {{missing}}\n" + " ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"), + StringRef::npos) + << Output; +} _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
