[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
|
|
|
//===-- FormatCache.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
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "lldb/DataFormatters/FormatCache.h"
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
FormatCache::Entry::Entry()
|
|
|
|
: m_format_cached(false), m_summary_cached(false),
|
2019-12-11 07:32:57 +08:00
|
|
|
m_synthetic_cached(false) {}
|
2013-10-18 06:27:19 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool FormatCache::Entry::IsFormatCached() { return m_format_cached; }
|
2013-01-29 07:47:25 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool FormatCache::Entry::IsSummaryCached() { return m_summary_cached; }
|
2013-01-29 07:47:25 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool FormatCache::Entry::IsSyntheticCached() { return m_synthetic_cached; }
|
2014-09-06 04:45:07 +08:00
|
|
|
|
2019-12-10 08:22:26 +08:00
|
|
|
void FormatCache::Entry::Get(lldb::TypeFormatImplSP &retval) {
|
|
|
|
retval = m_format_sp;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2019-12-10 08:22:26 +08:00
|
|
|
void FormatCache::Entry::Get(lldb::TypeSummaryImplSP &retval) {
|
|
|
|
retval = m_summary_sp;
|
2013-01-29 07:47:25 +08:00
|
|
|
}
|
|
|
|
|
2019-12-10 08:22:26 +08:00
|
|
|
void FormatCache::Entry::Get(lldb::SyntheticChildrenSP &retval) {
|
|
|
|
retval = m_synthetic_sp;
|
2013-01-29 07:47:25 +08:00
|
|
|
}
|
|
|
|
|
2019-12-10 08:22:26 +08:00
|
|
|
void FormatCache::Entry::Set(lldb::TypeFormatImplSP format_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
m_format_cached = true;
|
|
|
|
m_format_sp = format_sp;
|
2013-10-18 06:27:19 +08:00
|
|
|
}
|
|
|
|
|
2019-12-10 08:22:26 +08:00
|
|
|
void FormatCache::Entry::Set(lldb::TypeSummaryImplSP summary_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
m_summary_cached = true;
|
|
|
|
m_summary_sp = summary_sp;
|
2013-01-29 07:47:25 +08:00
|
|
|
}
|
|
|
|
|
2019-12-10 08:22:26 +08:00
|
|
|
void FormatCache::Entry::Set(lldb::SyntheticChildrenSP synthetic_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
m_synthetic_cached = true;
|
|
|
|
m_synthetic_sp = synthetic_sp;
|
2013-01-29 07:47:25 +08:00
|
|
|
}
|
|
|
|
|
2019-03-07 05:22:25 +08:00
|
|
|
FormatCache::Entry &FormatCache::GetEntry(ConstString type) {
|
2016-09-07 04:57:50 +08:00
|
|
|
auto i = m_map.find(type), e = m_map.end();
|
|
|
|
if (i != e)
|
|
|
|
return i->second;
|
|
|
|
m_map[type] = FormatCache::Entry();
|
|
|
|
return m_map[type];
|
2013-01-29 07:47:25 +08:00
|
|
|
}
|
|
|
|
|
2020-02-06 04:29:59 +08:00
|
|
|
namespace lldb_private {
|
|
|
|
|
2019-12-10 08:22:26 +08:00
|
|
|
template<> bool FormatCache::Entry::IsCached<lldb::TypeFormatImplSP>() {
|
|
|
|
return IsFormatCached();
|
2013-10-18 06:27:19 +08:00
|
|
|
}
|
2019-12-10 08:22:26 +08:00
|
|
|
template<> bool FormatCache::Entry::IsCached<lldb::TypeSummaryImplSP> () {
|
|
|
|
return IsSummaryCached();
|
2013-01-29 07:47:25 +08:00
|
|
|
}
|
2019-12-10 08:22:26 +08:00
|
|
|
template<> bool FormatCache::Entry::IsCached<lldb::SyntheticChildrenSP>() {
|
|
|
|
return IsSyntheticCached();
|
|
|
|
}
|
2013-01-29 07:47:25 +08:00
|
|
|
|
2020-02-06 04:29:59 +08:00
|
|
|
} // namespace lldb_private
|
|
|
|
|
2019-12-10 08:22:26 +08:00
|
|
|
template <typename ImplSP>
|
|
|
|
bool FormatCache::Get(ConstString type, ImplSP &format_impl_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
|
|
|
auto entry = GetEntry(type);
|
2019-12-10 08:22:26 +08:00
|
|
|
if (entry.IsCached<ImplSP>()) {
|
2016-09-07 04:57:50 +08:00
|
|
|
m_cache_hits++;
|
2019-12-10 08:22:26 +08:00
|
|
|
entry.Get(format_impl_sp);
|
2016-09-07 04:57:50 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
m_cache_misses++;
|
2019-12-10 08:22:26 +08:00
|
|
|
format_impl_sp.reset();
|
2016-09-07 04:57:50 +08:00
|
|
|
return false;
|
2014-09-06 04:45:07 +08:00
|
|
|
}
|
|
|
|
|
2019-12-11 07:32:57 +08:00
|
|
|
/// Explicit instantiations for the three types.
|
2019-12-10 08:22:26 +08:00
|
|
|
/// \{
|
|
|
|
template bool
|
|
|
|
FormatCache::Get<lldb::TypeFormatImplSP>(ConstString, lldb::TypeFormatImplSP &);
|
|
|
|
template bool
|
|
|
|
FormatCache::Get<lldb::TypeSummaryImplSP>(ConstString,
|
|
|
|
lldb::TypeSummaryImplSP &);
|
|
|
|
template bool
|
|
|
|
FormatCache::Get<lldb::SyntheticChildrenSP>(ConstString,
|
|
|
|
lldb::SyntheticChildrenSP &);
|
|
|
|
/// \}
|
|
|
|
|
|
|
|
void FormatCache::Set(ConstString type, lldb::TypeFormatImplSP &format_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2019-12-10 08:22:26 +08:00
|
|
|
GetEntry(type).Set(format_sp);
|
2013-10-18 06:27:19 +08:00
|
|
|
}
|
|
|
|
|
2019-12-10 08:22:26 +08:00
|
|
|
void FormatCache::Set(ConstString type, lldb::TypeSummaryImplSP &summary_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2019-12-10 08:22:26 +08:00
|
|
|
GetEntry(type).Set(summary_sp);
|
2013-01-29 07:47:25 +08:00
|
|
|
}
|
|
|
|
|
2019-12-10 08:22:26 +08:00
|
|
|
void FormatCache::Set(ConstString type,
|
|
|
|
lldb::SyntheticChildrenSP &synthetic_sp) {
|
2016-09-07 04:57:50 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
2019-12-10 08:22:26 +08:00
|
|
|
GetEntry(type).Set(synthetic_sp);
|
2013-01-29 07:47:25 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void FormatCache::Clear() {
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
|
|
|
m_map.clear();
|
2013-01-29 07:47:25 +08:00
|
|
|
}
|