1 #include "ns.h"
2
func()3 static int func()
4 {
5 std::printf("static m2.cpp func()\n");
6 return 2;
7 }
test_lookup_at_file_scope()8 void test_lookup_at_file_scope()
9 {
10 // BP_file_scope
11 std::printf("at file scope: func() = %d\n", func()); // eval func(), exp: 2
12 std::printf("at file scope: func(10) = %d\n", func(10)); // eval func(10), exp: 11
13 }
14 namespace A {
15 namespace B {
func()16 int func()
17 {
18 std::printf("A::B::func()\n");
19 return 4;
20 }
test_lookup_at_nested_ns_scope()21 void test_lookup_at_nested_ns_scope()
22 {
23 // BP_nested_ns_scope
24 std::printf("at nested ns scope: func() = %d\n", func()); // eval func(), exp: 4
25
26 //printf("func(10) = %d\n", func(10)); // eval func(10), exp: 13
27 // NOTE: Under the rules of C++, this test would normally get an error
28 // because A::B::func() hides A::func(), but lldb intentionally
29 // disobeys these rules so that the intended overload can be found
30 // by only removing duplicates if they have the same type.
31 }
test_lookup_at_nested_ns_scope_after_using()32 void test_lookup_at_nested_ns_scope_after_using()
33 {
34 // BP_nested_ns_scope_after_using
35 using A::func;
36 std::printf("at nested ns scope after using: func() = %d\n", func()); // eval func(), exp: 3
37 }
38 }
39 }
foo()40 int A::foo()
41 {
42 std::printf("A::foo()\n");
43 return 42;
44 }
func(int a)45 int A::func(int a)
46 {
47 std::printf("A::func(int)\n");
48 return a + 3;
49 }
test_lookup_at_ns_scope()50 void A::test_lookup_at_ns_scope()
51 {
52 // BP_ns_scope
53 std::printf("at nested ns scope: func() = %d\n", func()); // eval func(), exp: 3
54 std::printf("at nested ns scope: func(10) = %d\n", func(10)); // eval func(10), exp: 13
55 std::printf("at nested ns scope: foo() = %d\n", foo()); // eval foo(), exp: 42
56 }
57