evgeny777 updated this revision to Diff 39893.
evgeny777 added a comment.

Added test case


http://reviews.llvm.org/D14542

Files:
  packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespace.py
  packages/Python/lldbsuite/test/lang/cpp/namespace/main.cpp
  source/Symbol/ClangASTContext.cpp

Index: source/Symbol/ClangASTContext.cpp
===================================================================
--- source/Symbol/ClangASTContext.cpp
+++ source/Symbol/ClangASTContext.cpp
@@ -9186,6 +9186,8 @@
 
             for (auto it = search_queue.find(decl_context); it != search_queue.end(); it++)
             {
+                if (searched.find(it->second) != searched.end())
+                    continue;
                 searched.insert(it->second);
                 symbol_file->ParseDeclsForContext(CompilerDeclContext(this, it->second));
 
Index: packages/Python/lldbsuite/test/lang/cpp/namespace/main.cpp
===================================================================
--- packages/Python/lldbsuite/test/lang/cpp/namespace/main.cpp
+++ packages/Python/lldbsuite/test/lang/cpp/namespace/main.cpp
@@ -72,9 +72,31 @@
     }
 }
 
+namespace ns1 {
+    int value = 100;
+}
+
+namespace ns2 {
+    int value = 200;
+}
+
 #include <stdio.h>
+void test_namespace_scopes() {
+    do {
+        using namespace ns1;
+        printf("ns1::value = %d\n", value); // Evaluate ns1::value
+    } while(0);
+    
+    do {
+        using namespace ns2;
+        printf("ns2::value = %d\n", value); // Evaluate ns2::value
+    } while(0);
+}
+
 int Foo::myfunc(int a)
 {
+    test_namespace_scopes();    
+
     ::my_uint_t anon_uint = 0;
     A::uint_t a_uint = 1;
     B::uint_t b_uint = 2;
Index: packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespace.py
===================================================================
--- packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespace.py
+++ packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespace.py
@@ -26,23 +26,37 @@
         # And the line number to break at.
         self.line_break = line_number('main.cpp',
                 '// Set break point at this line.')
+        # Break inside do {} while and evaluate value
+        self.line_break_ns1 = line_number('main.cpp', '// Evaluate ns1::value')
+        self.line_break_ns2 = line_number('main.cpp', '// Evaluate ns2::value')
+
+    def runToBkpt(self, command):
+        self.runCmd(command, RUN_SUCCEEDED)
+        # The stop reason of the thread should be breakpoint.
+        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+            substrs = ['stopped',
+                       'stop reason = breakpoint'])
 
     # rdar://problem/8668674
     @expectedFailureWindows("llvm.org/pr24764")
     def test_with_run_command(self):
         """Test that anonymous and named namespace variables display correctly."""
         self.build()
         self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
 
+        lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line_break_ns1, num_expected_locations=1, loc_exact=True)
+        lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line_break_ns2, num_expected_locations=1, loc_exact=True)
         lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line_break, num_expected_locations=1, loc_exact=True)
 
-        self.runCmd("run", RUN_SUCCEEDED)
-
-        # The stop reason of the thread should be breakpoint.
-        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
-            substrs = ['stopped',
-                       'stop reason = breakpoint'])
-
+        self.runToBkpt("run")
+        # Evaluate ns1::value
+        self.expect("expression -- value", startstr = "(int) $0 = 100")
+
+        self.runToBkpt("continue")
+        # Evaluate ns2::value
+        self.expect("expression -- value", startstr = "(int) $1 = 200")
+        
+        self.runToBkpt("continue")
         # On Mac OS X, gcc 4.2 emits the wrong debug info with respect to types.
         slist = ['(int) a = 12', 'anon_uint', 'a_uint', 'b_uint', 'y_uint']
         if self.platformIsDarwin() and self.getCompiler() in ['clang', 'llvm-gcc']:
@@ -83,8 +97,8 @@
         # test/namespace: 'expression -- i+j' not working
         # This has been fixed.
         self.expect("expression -- i + j",
-            startstr = "(int) $0 = 7")
-        # (int) $0 = 7
+            startstr = "(int) $2 = 7")
+        # (int) $2 = 7
 
         self.runCmd("expression -- i")
         self.runCmd("expression -- j")
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to