[Lldb-commits] [PATCH] D71289: [FormatManager] Move Language lookup into the obviously non-cached part (NFC)
Adrian Prantl via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Dec 10 11:05:00 PST 2019
aprantl created this revision.
aprantl added reviewers: jingham, davide.
aprantl added a parent revision: D71233: Do not cache hardcoded formats in FormatManager.
This refactoring makes the lookup caching easier to reason about. This has no observable effect although it does slightly change what is being cached.
Before this patch a negative lookup in the LanguageCategory would be cached, but a positive wouldn't.
After this patch LanguageCategory lookups aren't cached, period.
https://reviews.llvm.org/D71289
Files:
lldb/source/DataFormatters/FormatManager.cpp
Index: lldb/source/DataFormatters/FormatManager.cpp
===================================================================
--- lldb/source/DataFormatters/FormatManager.cpp
+++ lldb/source/DataFormatters/FormatManager.cpp
@@ -630,7 +630,22 @@
return retval_sp;
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS));
- LLDB_LOGF(log, "[%s] Search failed. Giving hardcoded a chance.", __FUNCTION__);
+
+ LLDB_LOGF(log, "[%s] Search failed. Giving language a chance.", __FUNCTION__);
+ for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) {
+ if (LanguageCategory *lang_category = GetCategoryForLanguage(lang_type)) {
+ ImplSP retval_sp;
+ if (lang_category->Get(match_data, retval_sp))
+ if (retval_sp) {
+ LLDB_LOGF(log, "[%s] Language search success. Returning.",
+ __FUNCTION__);
+ return retval_sp;
+ }
+ }
+ }
+
+ LLDB_LOGF(log, "[%s] Search failed. Giving hardcoded a chance.",
+ __FUNCTION__);
return GetHardcoded<ImplSP>(match_data);
}
@@ -655,21 +670,6 @@
}
m_categories_map.Get(match_data, retval_sp);
- if (!retval_sp) {
- LLDB_LOGF(log, "[%s] Search failed. Giving language a chance.",
- __FUNCTION__);
- for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) {
- if (LanguageCategory *lang_category = GetCategoryForLanguage(lang_type)) {
- if (lang_category->Get(match_data, retval_sp))
- break;
- }
- }
- if (retval_sp) {
- LLDB_LOGF(log, "[%s] Language search success. Returning.", __FUNCTION__);
- return retval_sp;
- }
- }
-
if (match_data.GetTypeForCache() && (!retval_sp || !retval_sp->NonCacheable())) {
LLDB_LOGF(log, "[%s] Caching %p for type %s", __FUNCTION__,
static_cast<void *>(retval_sp.get()),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71289.233148.patch
Type: text/x-patch
Size: 1871 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20191210/5afed21f/attachment.bin>
More information about the lldb-commits
mailing list