[Lldb-commits] [PATCH] D114627: [lldb] add new overload for SymbolFile::FindTypes that accepts a scope

Andy Yankovsky via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Nov 26 04:28:24 PST 2021


werat added inline comments.


================
Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:2464
 
+    const char *qn = die.GetQualifiedName(s);
+    if (strncmp(sc, qn, strlen(sc)))
----------------
Can `GetQualifiedName` return `NULL` string?


================
Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:2464-2465
 
+    const char *qn = die.GetQualifiedName(s);
+    if (strncmp(sc, qn, strlen(sc)))
+      return true;
----------------
werat wrote:
> Can `GetQualifiedName` return `NULL` string?
We can skip this check altogether if the `scope` is empty.


================
Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:2465
+    const char *qn = die.GetQualifiedName(s);
+    if (strncmp(sc, qn, strlen(sc)))
+      return true;
----------------
There's no need to calculate length on every iteration.

Also you can make `sc` an `llvm::StringRef` and do something like `StringRef(s).startswith(sc)`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114627



More information about the lldb-commits mailing list