[Lldb-commits] [lldb] 70e3d0e - [FormatManager] Move Language lookup into the obviously non-cached part (NFC)
Adrian Prantl via lldb-commits
lldb-commits at lists.llvm.org
Tue Dec 10 15:58:45 PST 2019
Author: Adrian Prantl
Date: 2019-12-10T15:57:53-08:00
New Revision: 70e3d0ea55e8b9385168d389fcba16a283f20214
URL: https://github.com/llvm/llvm-project/commit/70e3d0ea55e8b9385168d389fcba16a283f20214
DIFF: https://github.com/llvm/llvm-project/commit/70e3d0ea55e8b9385168d389fcba16a283f20214.diff
LOG: [FormatManager] Move Language lookup into the obviously non-cached part (NFC)
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 by
FormatManager, period. (LanguageCategory has its own FormatCache for this!)
Differential Revision: https://reviews.llvm.org/D71289
Added:
Modified:
lldb/source/DataFormatters/FormatManager.cpp
Removed:
################################################################################
diff --git a/lldb/source/DataFormatters/FormatManager.cpp b/lldb/source/DataFormatters/FormatManager.cpp
index db15a7f7a4cc..8c7967aaf1e1 100644
--- a/lldb/source/DataFormatters/FormatManager.cpp
+++ b/lldb/source/DataFormatters/FormatManager.cpp
@@ -630,7 +630,22 @@ ImplSP FormatManager::Get(ValueObject &valobj,
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 @@ ImplSP FormatManager::GetCached(FormattersMatchData &match_data) {
}
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()),
More information about the lldb-commits
mailing list