Skip to content

Commit 8e79261

Browse files
committed
Add missing checks for nullptr.
rdar://106151539
1 parent d8093c5 commit 8e79261

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lldb/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,15 @@ class LLDBExprNameLookup : public LLDBNameLookup {
245245
unsigned count = counter++;
246246

247247
StringRef NameStr = Name.getIdentifier().str();
248+
if (NameStr.empty())
249+
return false;
248250

251+
ConstString name_const_str(NameStr);
249252
if (m_log) {
250253
m_log->Printf("[LLDBExprNameLookup::lookupAdditions (%u)] Searching for %s",
251-
count, Name.getIdentifier().str().str().c_str());
254+
count, name_const_str.AsCString("<anonymous>"));
252255
}
253256

254-
ConstString name_const_str(NameStr);
255257
std::vector<swift::ValueDecl *> results;
256258

257259
for (auto *alias : m_type_aliases) {
@@ -396,11 +398,13 @@ class LLDBREPLNameLookup : public LLDBNameLookup {
396398
unsigned count = counter++;
397399

398400
StringRef NameStr = Name.getIdentifier().str();
399-
ConstString name_const_str(NameStr);
401+
if (NameStr.empty())
402+
return false;
400403

404+
ConstString name_const_str(NameStr);
401405
if (m_log) {
402406
m_log->Printf("[LLDBREPLNameLookup::lookupAdditions (%u)] Searching for %s",
403-
count, Name.getIdentifier().str().str().c_str());
407+
count, name_const_str.AsCString("<anonymous>"));
404408
}
405409

406410
// Find decls that come from the current compilation.

0 commit comments

Comments
 (0)