[lldb][NFC] Fix all formatting errors in .cpp file headers
Summary:
A *.cpp file header in LLDB (and in LLDB) should like this:
```
//===-- TestUtilities.cpp -------------------------------------------------===//
```
However in LLDB most of our source files have arbitrary changes to this format and
these changes are spreading through LLDB as folks usually just use the existing
source files as templates for their new files (most notably the unnecessary
editor language indicator `-*- C++ -*-` is spreading and in every review
someone is pointing out that this is wrong, resulting in people pointing out that this
is done in the same way in other files).
This patch removes most of these inconsistencies including the editor language indicators,
all the different missing/additional '-' characters, files that center the file name, missing
trailing `===//` (mostly caused by clang-format breaking the line).
Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D73258
2020-01-24 15:23:27 +08:00
|
|
|
//===-- FormatClasses.cpp -------------------------------------------------===//
|
2013-01-29 07:47:25 +08:00
|
|
|
//
|
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;
|
|
|
|
}
|