Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lldb/include/lldb/Target/Language.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class Language : public PluginInterface {
llvm::StringRef file_path);

// return false from callback to stop iterating
static void ForEach(std::function<bool(Language *)> callback);
static void ForEach(llvm::function_ref<IterationAction(Language *)> callback);

virtual lldb::LanguageType GetLanguageType() const = 0;

Expand Down Expand Up @@ -420,7 +420,8 @@ class Language : public PluginInterface {
llvm::StringRef suffix);

// return false from callback to stop iterating
static void ForAllLanguages(std::function<bool(lldb::LanguageType)> callback);
static void ForAllLanguages(
llvm::function_ref<IterationAction(lldb::LanguageType)> callback);

static bool LanguageIsCPlusPlus(lldb::LanguageType language);

Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Breakpoint/BreakpointResolverName.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ void BreakpointResolverName::AddNameLookup(ConstString name,
m_lookups.emplace_back(variant_lookup);
}
}
return true;
return IterationAction::Continue;
};

if (Language *lang = Language::FindPlugin(m_language)) {
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Commands/CommandObjectType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2610,7 +2610,7 @@ class CommandObjectTypeLookup : public CommandObjectRaw {
Language::ForEach([&](Language *lang) {
if (const char *help = lang->GetLanguageSpecificTypeLookupHelp())
stream.Printf("%s\n", help);
return true;
return IterationAction::Continue;
});

m_cmd_help_long = std::string(stream.GetString());
Expand Down Expand Up @@ -2649,7 +2649,7 @@ class CommandObjectTypeLookup : public CommandObjectRaw {
(m_command_options.m_language == eLanguageTypeUnknown))) {
Language::ForEach([&](Language *lang) {
languages.push_back(lang);
return true;
return IterationAction::Continue;
});
} else {
languages.push_back(Language::FindPlugin(m_command_options.m_language));
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Core/Mangled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,9 @@ lldb::LanguageType Mangled::GuessLanguage() const {
Language::ForEach([this, &result](Language *l) {
if (l->SymbolNameFitsToLanguage(*this)) {
result = l->GetLanguageType();
return false;
return IterationAction::Stop;
}
return true;
return IterationAction::Continue;
});
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Symbol/Symtab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ void Symtab::InitNameIndexes() {
std::vector<Language *> languages;
Language::ForEach([&languages](Language *l) {
languages.push_back(l);
return true;
return IterationAction::Continue;
});

auto &name_to_index = GetNameToSymbolIndexMap(lldb::eFunctionNameTypeNone);
Expand Down
15 changes: 8 additions & 7 deletions lldb/source/Target/Language.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ Language *Language::FindPlugin(llvm::StringRef file_path) {
ForEach([&result, file_path](Language *language) {
if (language->IsSourceFile(file_path)) {
result = language;
return false;
return IterationAction::Stop;
}
return true;
return IterationAction::Continue;
});
return result;
}
Expand All @@ -128,7 +128,8 @@ Language *Language::FindPlugin(LanguageType language,
return result;
}

void Language::ForEach(std::function<bool(Language *)> callback) {
void Language::ForEach(
llvm::function_ref<IterationAction(Language *)> callback) {
// If we want to iterate over all languages, we first have to complete the
// LanguagesMap.
static llvm::once_flag g_initialize;
Expand All @@ -153,7 +154,7 @@ void Language::ForEach(std::function<bool(Language *)> callback) {
}

for (auto *lang : loaded_plugins) {
if (!callback(lang))
if (callback(lang) == IterationAction::Stop)
break;
}
}
Expand Down Expand Up @@ -289,9 +290,9 @@ void Language::PrintAllLanguages(Stream &s, const char *prefix,
}

void Language::ForAllLanguages(
std::function<bool(lldb::LanguageType)> callback) {
llvm::function_ref<IterationAction(lldb::LanguageType)> callback) {
for (uint32_t i = 1; i < num_languages; i++) {
if (!callback(language_names[i].type))
if (callback(language_names[i].type) == IterationAction::Stop)
break;
}
}
Expand Down Expand Up @@ -416,7 +417,7 @@ std::set<lldb::LanguageType> Language::GetSupportedLanguages() {
std::set<lldb::LanguageType> supported_languages;
ForEach([&](Language *lang) {
supported_languages.emplace(lang->GetLanguageType());
return true;
return IterationAction::Continue;
});
return supported_languages;
}
Expand Down
Loading