xref: /llvm-project/lldb/test/Shell/SymbolFile/DWARF/split-dwarf-expression-eval-bug.cpp (revision d875838e8b45cb0da5070298d0c1a2d1ee78ce7e)
12cf69684SPavel Labath // This tests a crash which occured under very specific circumstances. The
22cf69684SPavel Labath // interesting aspects of this test are:
32cf69684SPavel Labath // - we print a global variable from one compile unit
42cf69684SPavel Labath // - we are stopped in a member function of a class in a namespace
52cf69684SPavel Labath // - that namespace is also present in a third file, which also has a global
62cf69684SPavel Labath //   variable
72cf69684SPavel Labath 
82cf69684SPavel Labath // UNSUPPORTED: system-darwin, system-windows
92cf69684SPavel Labath 
1068830425SHaojian Wu // RUN: %clang_host -c -gsplit-dwarf -g %s -o %t1.o -DONE
1168830425SHaojian Wu // RUN: %clang_host -c -gsplit-dwarf -g %s -o %t2.o -DTWO
1268830425SHaojian Wu // RUN: %clang_host -c -gsplit-dwarf -g %s -o %t3.o -DTHREE
132cf69684SPavel Labath // RUN: %clang_host %t1.o %t2.o %t3.o -o %t
14*d875838eSDave Lee // RUN: %lldb %t -o "br set -n foo" -o run -o "expression bool_in_first_cu" -o exit \
152cf69684SPavel Labath // RUN:   | FileCheck %s
162cf69684SPavel Labath 
17*d875838eSDave Lee // CHECK: (lldb) expression bool_in_first_cu
182cf69684SPavel Labath // CHECK: (bool) $0 = true
192cf69684SPavel Labath 
202cf69684SPavel Labath 
212cf69684SPavel Labath #if defined(ONE)
222cf69684SPavel Labath bool bool_in_first_cu = true;
232cf69684SPavel Labath #elif defined(TWO)
242cf69684SPavel Labath bool bool_in_second_cu = true;
252cf69684SPavel Labath 
262cf69684SPavel Labath namespace NS {
f()272cf69684SPavel Labath void f() {}
282cf69684SPavel Labath }
292cf69684SPavel Labath #elif defined(THREE)
302cf69684SPavel Labath namespace NS {
312cf69684SPavel Labath struct S {
fooNS::S322cf69684SPavel Labath   void foo() {}
332cf69684SPavel Labath };
342cf69684SPavel Labath }
352cf69684SPavel Labath 
main()362cf69684SPavel Labath int main() { NS::S().foo(); }
372cf69684SPavel Labath #endif
38