brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 78c9a7c Raw
57 lines · cpp
1#include "ns.h"2 3static int func()4{5  std::printf("static m2.cpp func()\n");6  return 2;7}8void test_lookup_at_file_scope()9{10  // BP_file_scope11  std::printf("at file scope: func() = %d\n", func()); // eval func(), exp: 212  std::printf("at file scope: func(10) = %d\n", func(10)); // eval func(10), exp: 1113}14namespace A {15    namespace B {16        int func()17        {18          std::printf("A::B::func()\n");19          return 4;20        }21        void test_lookup_at_nested_ns_scope()22        {23            // BP_nested_ns_scope24            std::printf("at nested ns scope: func() = %d\n", func()); // eval func(), exp: 425 26            //printf("func(10) = %d\n", func(10)); // eval func(10), exp: 1327            // NOTE: Under the rules of C++, this test would normally get an error28            // because A::B::func() hides A::func(), but lldb intentionally29            // disobeys these rules so that the intended overload can be found30            // by only removing duplicates if they have the same type.31        }32        void test_lookup_at_nested_ns_scope_after_using()33        {34            // BP_nested_ns_scope_after_using35            using A::func;36            std::printf("at nested ns scope after using: func() = %d\n", func()); // eval func(), exp: 337        }38    }39}40int A::foo()41{42  std::printf("A::foo()\n");43  return 42;44}45int A::func(int a)46{47  std::printf("A::func(int)\n");48  return a + 3;49}50void A::test_lookup_at_ns_scope()51{52  // BP_ns_scope53  std::printf("at nested ns scope: func() = %d\n", func()); // eval func(), exp: 354  std::printf("at nested ns scope: func(10) = %d\n", func(10)); // eval func(10), exp: 1355  std::printf("at nested ns scope: foo() = %d\n", foo()); // eval foo(), exp: 4256}57