[Lldb-commits] [lldb] 8cf8ec4 - [lldb][NFC] Modernize string handling in ClangExpressionDeclMap::FindExternalVisibleDecl

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Thu Nov 21 06:00:19 PST 2019


Author: Raphael Isemann
Date: 2019-11-21T14:59:47+01:00
New Revision: 8cf8ec40a1fee9706237d30385e78e1de214d8f7

URL: https://github.com/llvm/llvm-project/commit/8cf8ec40a1fee9706237d30385e78e1de214d8f7
DIFF: https://github.com/llvm/llvm-project/commit/8cf8ec40a1fee9706237d30385e78e1de214d8f7.diff

LOG: [lldb][NFC] Modernize string handling in ClangExpressionDeclMap::FindExternalVisibleDecl

Added: 
    

Modified: 
    lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index c6cb63407f70..418a90614cd1 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -1453,20 +1453,17 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
   if (!namespace_decl)
     SearchPersistenDecls(context, name, current_id);
 
-  if (name.GetCString()[0] == '$' && !namespace_decl) {
-    static ConstString g_lldb_class_name("$__lldb_class");
-
-    if (name == g_lldb_class_name) {
+  if (name.GetStringRef().startswith("$") && !namespace_decl) {
+    if (name == "$__lldb_class") {
       LookUpLldbClass(context, current_id);
       return;
     }
 
-    static ConstString g_lldb_objc_class_name("$__lldb_objc_class");
-    if (name == g_lldb_objc_class_name) {
+    if (name == "$__lldb_objc_class") {
       LookUpLldbObjCClass(context, current_id);
       return;
     }
-    if (name == ConstString(g_lldb_local_vars_namespace_cstr)) {
+    if (name == g_lldb_local_vars_namespace_cstr) {
       LookupLocalVarNamespace(sym_ctx, context);
       return;
     }
@@ -1483,7 +1480,8 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
       return;
     }
 
-    const char *reg_name(&name.GetCString()[1]);
+    assert(name.GetStringRef().startswith("$"));
+    llvm::StringRef reg_name = name.GetStringRef().substr(1);
 
     if (m_parser_vars->m_exe_ctx.GetRegisterContext()) {
       const RegisterInfo *reg_info(
@@ -1500,9 +1498,8 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
     return;
   }
 
-  bool local_var_lookup =
-      !namespace_decl || (namespace_decl.GetName() ==
-                          ConstString(g_lldb_local_vars_namespace_cstr));
+  bool local_var_lookup = !namespace_decl || (namespace_decl.GetName() ==
+                                              g_lldb_local_vars_namespace_cstr);
   if (frame && local_var_lookup)
     if (LookupLocalVariable(context, name, current_id, sym_ctx, namespace_decl))
       return;


        


More information about the lldb-commits mailing list