llvm-project/lldb/test/Shell/Expr/TestClangModuleLoadError_InvalidSearchPath.test
Michael Buch 74e34eff3f
[lldb][ClangModulesDeclVendor] Don't stop loading Clang modules if an individual import failed (#166940)
Depends on:
* https://github.com/llvm/llvm-project/pull/166917

When loading all Clang modules for a CU, we stop on first error. This
means benign module loading errors may stop us from importing actually
useful modules. There's no good reason to bail on the first one. The
pathological case would be if we try to load a large number of Clang
modules
but all fail to load for the same reason. That could happen, but in
practice I've always seen only a handful of modules failing to load out
of a large number. Particularly system modules are useful and usually
don't fail to load. Whereas project-specific Clang modules are more
likely to fail because the build system moves the modulemap/sources
around.

This patch accumulates all module loading errors and doesn't stop when
an error is encountered.
2025-11-07 23:11:48 +00:00

47 lines
1.1 KiB
Plaintext

## Tests the case where the DW_AT_LLVM_include_path of the module is invalid.
## We forces this by just removing that directory (which in our case is 'sources').
#
# REQUIRES: system-darwin
#
# RUN: split-file %s %t/sources
# RUN: %clang_host -g %t/sources/main.m -fmodules -fcxx-modules \
# RUN: -fmodule-map-file=%t/sources/module.modulemap \
# RUN: -fmodules-cache-path=%t/ModuleCache -o %t.out
#
# RUN: cp %t/sources/commands.input %t/commands.input
# RUN: rm -r %t/sources
#
# RUN: %lldb -x -o "settings set interpreter.stop-command-source-on-error false" \
# RUN: -s %t/commands.input %t.out -o exit 2>&1 | FileCheck %s
#--- main.m
@import foo;
@import bar;
int main() { __builtin_debugtrap(); }
#--- foo.h
struct foo {};
#--- bar.h
struct bar {};
#--- module.modulemap
module foo {
header "foo.h"
export *
}
module bar {
header "bar.h"
export *
}
#--- commands.input
run
## Make sure expression fails so the 'note' diagnostics get printed.
expr blah
# CHECK: note: couldn't find module search path directory {{.*}}sources
# CHECK: note: couldn't find module search path directory {{.*}}sources