[PATCH] D65498: Fix completion for functions in anonymous namespaces

Jonas Devlieghere via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 31 11:01:18 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL367455: Fix completion for functions in anonymous namespaces (authored by JDevlieghere, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D65498?vs=212505&id=212627#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65498/new/

https://reviews.llvm.org/D65498

Files:
  lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
  lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/main.cpp
  lldb/trunk/source/Commands/CommandCompletions.cpp


Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/main.cpp
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/main.cpp
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/main.cpp
@@ -7,6 +7,8 @@
     }
 };
 
+namespace { int Quux (void) { return 0; } }
+
 struct Container { int MemberVar; };
 
 int main()
@@ -17,5 +19,6 @@
 
     Container container;
     Container *ptr_container = &container;
+    int q = Quux();
     return container.MemberVar = 3; // Break here
 }
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
@@ -297,3 +297,6 @@
         self.complete_from_to('breakpoint set -n Fo',
                               'breakpoint set -n Foo::Bar(int,\\ int)',
                               turn_off_re_match=True)
+        # No completion for Qu because the candidate is
+        # (anonymous namespace)::Quux().
+        self.complete_from_to('breakpoint set -n Qu', '')
Index: lldb/trunk/source/Commands/CommandCompletions.cpp
===================================================================
--- lldb/trunk/source/Commands/CommandCompletions.cpp
+++ lldb/trunk/source/Commands/CommandCompletions.cpp
@@ -471,7 +471,11 @@
     for (uint32_t i = 0; i < sc_list.GetSize(); i++) {
       if (sc_list.GetContextAtIndex(i, sc)) {
         ConstString func_name = sc.GetFunctionName(Mangled::ePreferDemangled);
-        if (!func_name.IsEmpty())
+        // Ensure that the function name matches the regex. This is more than a
+        // sanity check. It is possible that the demangled function name does
+        // not start with the prefix, for example when it's in an anonymous
+        // namespace.
+        if (!func_name.IsEmpty() && m_regex.Execute(func_name.GetStringRef()))
           m_match_set.insert(func_name);
       }
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65498.212627.patch
Type: text/x-patch
Size: 2185 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190731/c515044b/attachment.bin>


More information about the llvm-commits mailing list