Files
clang-p2996/lldb/test/API/lang/objc/modules-compile-error/TestModulesCompileError.py
Adrian Prantl 84fdfb9ca6 [lldb] Store expression evaluator diagnostics in an llvm::Error (NFC) (#106442)
…NFC]

This patch is the first patch in a series reworking of Pete Lawrence's
(@PortalPete) amazing proposal for better expression evaluator error
messages (https://github.com/llvm/llvm-project/pull/80938)

This patch is preparatory patch for improving the rendering of
expression evaluator diagnostics. Currently diagnostics are rendered
into a string and the command interpreter layer then textually parses
words like "error:" to (sometimes) color the output accordingly. In
order to enable user interfaces to do better with diagnostics, we need
to store them in a machine-readable fromat. This patch does this by
adding a new llvm::Error kind wrapping a DiagnosticDetail struct that
is used when the error type is eErrorTypeExpression. Multiple
diagnostics are modeled using llvm::ErrorList.

Right now the extra information is not used by the CommandInterpreter,
this will be added in a follow-up patch!
2024-09-27 16:09:52 -07:00

29 lines
1.1 KiB
Python

import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class TestCase(TestBase):
@skipIf(compiler="clang", compiler_version=["<", "11.0"])
def test(self):
self.build()
lldbutil.run_to_source_breakpoint(
self, "// break here", lldb.SBFileSpec("main.m")
)
# Try importing our custom module. This will fail as LLDB won't define
# the CLANG_ONLY define when it compiles the module for the expression
# evaluator.
# Check that the error message shows file/line/column, prints the relevant
# line from the source code and mentions the module that failed to build.
self.expect(
"expr @import LLDBTestModule",
error=True,
substrs=[
"module.h:4:1: error: use of undeclared identifier 'syntax_error_for_lldb_to_find'",
"syntax_error_for_lldb_to_find // comment that tests source printing",
"could not build module 'LLDBTestModule'",
],
)