[Lldb-commits] [PATCH] D153905: [lldb][NFCI] Remove unneeded use of ConstString in ASTResultSynthesizer

Alex Langford via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Jul 3 09:31:56 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG673f91055a41: [lldb][NFCI] Remove unneeded use of ConstString in ASTResultSynthesizer (authored by bulbazord).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153905

Files:
  lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp


Index: lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
===================================================================
--- lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
@@ -429,15 +429,10 @@
     return;
 
   StringRef name = D->getName();
-
-  if (name.size() == 0 || name[0] != '$')
+  if (name.empty() || name.front() != '$')
     return;
 
-  Log *log = GetLog(LLDBLog::Expressions);
-
-  ConstString name_cs(name.str().c_str());
-
-  LLDB_LOGF(log, "Recording persistent type %s\n", name_cs.GetCString());
+  LLDB_LOG(GetLog(LLDBLog::Expressions), "Recording persistent type {0}", name);
 
   m_decls.push_back(D);
 }
@@ -449,15 +444,10 @@
     return;
 
   StringRef name = D->getName();
-
-  if (name.size() == 0)
+  if (name.empty())
     return;
 
-  Log *log = GetLog(LLDBLog::Expressions);
-
-  ConstString name_cs(name.str().c_str());
-
-  LLDB_LOGF(log, "Recording persistent decl %s\n", name_cs.GetCString());
+  LLDB_LOG(GetLog(LLDBLog::Expressions), "Recording persistent decl {0}", name);
 
   m_decls.push_back(D);
 }
@@ -475,7 +465,6 @@
 
   for (clang::NamedDecl *decl : m_decls) {
     StringRef name = decl->getName();
-    ConstString name_cs(name.str().c_str());
 
     Decl *D_scratch = persistent_vars->GetClangASTImporter()->DeportDecl(
         &scratch_ts_sp->getASTContext(), decl);
@@ -496,8 +485,8 @@
     }
 
     if (NamedDecl *NamedDecl_scratch = dyn_cast<NamedDecl>(D_scratch))
-      persistent_vars->RegisterPersistentDecl(name_cs, NamedDecl_scratch,
-                                              scratch_ts_sp);
+      persistent_vars->RegisterPersistentDecl(ConstString(name),
+                                              NamedDecl_scratch, scratch_ts_sp);
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153905.536800.patch
Type: text/x-patch
Size: 1828 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230703/0c82fa15/attachment.bin>


More information about the lldb-commits mailing list