2013-01-29 07:47:25 +08:00
|
|
|
//===-- FormatClasses.cpp ----------------------------------------*- C++
|
|
|
|
//-*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2013-01-29 07:47:25 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
<rdar://problem/15530080>
Rework data formatters matching algorithm
What happens now is that, for each category, the FormatNavigator generates all possible matches, and checks them one by one
Since the possible matches do not actually depend on the category (whether a match is accepted or not does, but that check can be shifted at a more convenient time),
it is actually feasible to generate every possible match upfront and then let individual categories just scan through those
This commit changes things by introducing a notion of formatters match candidate, and shifting responsibility for generating all of them given a (ValueObject,DynamicValueType) pair
from the FormatNavigator back to the FormatManager
A list of these candidates is then passed down to each category for matching
Candidates also need to remember whether they were generated by stripping pointers, references, typedefs, since this is something that individual formatters can choose to reject
This check, however, is conveniently only done once a "textual" match has been found, so that the list of candidates is truly category-independent
While the performance benefit is small (mostly, due to caching), this is much cleaner from a design perspective
llvm-svn: 195395
2013-11-22 08:02:13 +08:00
|
|
|
#include "lldb/DataFormatters/FormatClasses.h"
|
2013-01-29 07:47:25 +08:00
|
|
|
|
2015-10-06 09:02:47 +08:00
|
|
|
#include "lldb/DataFormatters/FormatManager.h"
|
|
|
|
|
2013-01-29 07:47:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2015-10-06 09:02:47 +08:00
|
|
|
FormattersMatchData::FormattersMatchData(ValueObject &valobj,
|
|
|
|
lldb::DynamicValueType use_dynamic)
|
|
|
|
: m_valobj(valobj), m_dynamic_value_type(use_dynamic),
|
|
|
|
m_formatters_match_vector({}, false), m_type_for_cache(),
|
|
|
|
m_candidate_languages() {
|
|
|
|
m_type_for_cache = FormatManager::GetTypeForCache(valobj, use_dynamic);
|
2019-12-10 09:04:46 +08:00
|
|
|
m_candidate_languages =
|
|
|
|
FormatManager::GetCandidateLanguages(valobj.GetObjectRuntimeLanguage());
|
2015-10-06 09:02:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
FormattersMatchVector FormattersMatchData::GetMatchesVector() {
|
|
|
|
if (!m_formatters_match_vector.second) {
|
|
|
|
m_formatters_match_vector.second = true;
|
|
|
|
m_formatters_match_vector.first =
|
|
|
|
FormatManager::GetPossibleMatches(m_valobj, m_dynamic_value_type);
|
|
|
|
}
|
|
|
|
return m_formatters_match_vector.first;
|
|
|
|
}
|
|
|
|
|
|
|
|
ConstString FormattersMatchData::GetTypeForCache() { return m_type_for_cache; }
|
|
|
|
|
|
|
|
CandidateLanguagesVector FormattersMatchData::GetCandidateLanguages() {
|
|
|
|
return m_candidate_languages;
|
|
|
|
}
|
|
|
|
|
|
|
|
ValueObject &FormattersMatchData::GetValueObject() { return m_valobj; }
|
|
|
|
|
|
|
|
lldb::DynamicValueType FormattersMatchData::GetDynamicValueType() {
|
|
|
|
return m_dynamic_value_type;
|
|
|
|
}
|