[Lldb-commits] [lldb] 673f910 - [lldb][NFCI] Remove unneeded use of ConstString in ASTResultSynthesizer
Alex Langford via lldb-commits
lldb-commits at lists.llvm.org
Mon Jul 3 09:31:56 PDT 2023
Author: Alex Langford
Date: 2023-07-03T09:31:10-07:00
New Revision: 673f91055a41b2273e159eafe86d0d7d87fa474f
URL: https://github.com/llvm/llvm-project/commit/673f91055a41b2273e159eafe86d0d7d87fa474f
DIFF: https://github.com/llvm/llvm-project/commit/673f91055a41b2273e159eafe86d0d7d87fa474f.diff
LOG: [lldb][NFCI] Remove unneeded use of ConstString in ASTResultSynthesizer
2/3 of the ConstStrings in this class were just to be able to log
something. Putting something in the StringPool just to log it doesn't
make a lot of sense, so let's remove them.
The remaining use is for `RegisterPersistentDecl` which is fine for now.
Differential Revision: https://reviews.llvm.org/D153905
Added:
Modified:
lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
index 07cb4c9f027c15..3e2c208bd2018e 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
@@ -429,15 +429,10 @@ void ASTResultSynthesizer::MaybeRecordPersistentType(TypeDecl *D) {
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 @@ void ASTResultSynthesizer::RecordPersistentDecl(NamedDecl *D) {
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 @@ void ASTResultSynthesizer::CommitPersistentDecls() {
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 @@ void ASTResultSynthesizer::CommitPersistentDecls() {
}
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);
}
}
More information about the lldb-commits
mailing list