https://github.com/arichardson updated https://github.com/llvm/llvm-project/pull/233309
>From 76bfd83295008d00e23bc867d520943fd5bf9a57 Mon Sep 17 00:00:00 2001 From: Alex Richardson <[email protected]> Date: Sun, 18 Oct 2026 15:09:11 -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 ff9c21b76f3a0..3fbfb851266f0 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 6bbd12e720c80..16954bed53515 100644 --- a/llvm/unittests/Support/SourceMgrDiagnosticVerifierTest.cpp +++ b/llvm/unittests/Support/SourceMgrDiagnosticVerifierTest.cpp @@ -262,3 +262,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
