[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
|
|
|
//===-- FormattersHelpers.cpp ---------------------------------------------===//
|
2015-09-02 09:21:31 +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
|
2015-09-02 09:21:31 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "lldb/DataFormatters/FormattersHelpers.h"
|
|
|
|
|
2015-09-04 08:33:51 +08:00
|
|
|
#include "lldb/Target/StackFrame.h"
|
2015-10-20 12:50:09 +08:00
|
|
|
#include "lldb/Target/Target.h"
|
2015-09-04 08:33:51 +08:00
|
|
|
#include "lldb/Target/Thread.h"
|
2017-02-03 05:39:50 +08:00
|
|
|
#include "lldb/Utility/ConstString.h"
|
|
|
|
#include "lldb/Utility/RegularExpression.h"
|
2015-09-02 09:21:31 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
using namespace lldb_private::formatters;
|
|
|
|
|
|
|
|
void lldb_private::formatters::AddFormat(
|
|
|
|
TypeCategoryImpl::SharedPointer category_sp, lldb::Format format,
|
|
|
|
ConstString type_name, TypeFormatImpl::Flags flags, bool regex) {
|
|
|
|
lldb::TypeFormatImplSP format_sp(new TypeFormatImpl_Format(format, flags));
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-09-02 09:21:31 +08:00
|
|
|
if (regex)
|
|
|
|
category_sp->GetRegexTypeFormatsContainer()->Add(
|
2019-09-04 17:47:18 +08:00
|
|
|
RegularExpression(type_name.GetStringRef()), format_sp);
|
2015-09-02 09:21:31 +08:00
|
|
|
else
|
2019-09-04 17:47:18 +08:00
|
|
|
category_sp->GetTypeFormatsContainer()->Add(std::move(type_name),
|
|
|
|
format_sp);
|
2015-09-02 09:21:31 +08:00
|
|
|
}
|
|
|
|
|
2015-09-17 08:14:50 +08:00
|
|
|
void lldb_private::formatters::AddSummary(
|
|
|
|
TypeCategoryImpl::SharedPointer category_sp, TypeSummaryImplSP summary_sp,
|
|
|
|
ConstString type_name, bool regex) {
|
|
|
|
if (regex)
|
|
|
|
category_sp->GetRegexTypeSummariesContainer()->Add(
|
2019-09-04 17:47:18 +08:00
|
|
|
RegularExpression(type_name.GetStringRef()), summary_sp);
|
2015-09-17 08:14:50 +08:00
|
|
|
else
|
2019-09-04 17:47:18 +08:00
|
|
|
category_sp->GetTypeSummariesContainer()->Add(std::move(type_name),
|
|
|
|
summary_sp);
|
2015-09-17 08:14:50 +08:00
|
|
|
}
|
2015-09-02 09:21:31 +08:00
|
|
|
|
|
|
|
void lldb_private::formatters::AddStringSummary(
|
|
|
|
TypeCategoryImpl::SharedPointer category_sp, const char *string,
|
|
|
|
ConstString type_name, TypeSummaryImpl::Flags flags, bool regex) {
|
|
|
|
lldb::TypeSummaryImplSP summary_sp(new StringSummaryFormat(flags, string));
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-09-02 09:21:31 +08:00
|
|
|
if (regex)
|
|
|
|
category_sp->GetRegexTypeSummariesContainer()->Add(
|
2019-09-04 17:47:18 +08:00
|
|
|
RegularExpression(type_name.GetStringRef()), summary_sp);
|
2015-09-02 09:21:31 +08:00
|
|
|
else
|
2019-09-04 17:47:18 +08:00
|
|
|
category_sp->GetTypeSummariesContainer()->Add(std::move(type_name),
|
|
|
|
summary_sp);
|
2015-09-02 09:21:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void lldb_private::formatters::AddOneLineSummary(
|
|
|
|
TypeCategoryImpl::SharedPointer category_sp, ConstString type_name,
|
|
|
|
TypeSummaryImpl::Flags flags, bool regex) {
|
|
|
|
flags.SetShowMembersOneLiner(true);
|
|
|
|
lldb::TypeSummaryImplSP summary_sp(new StringSummaryFormat(flags, ""));
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-09-02 09:21:31 +08:00
|
|
|
if (regex)
|
|
|
|
category_sp->GetRegexTypeSummariesContainer()->Add(
|
2019-09-04 17:47:18 +08:00
|
|
|
RegularExpression(type_name.GetStringRef()), summary_sp);
|
2015-09-02 09:21:31 +08:00
|
|
|
else
|
2019-09-04 17:47:18 +08:00
|
|
|
category_sp->GetTypeSummariesContainer()->Add(std::move(type_name),
|
|
|
|
summary_sp);
|
2015-09-02 09:21:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void lldb_private::formatters::AddCXXSummary(
|
|
|
|
TypeCategoryImpl::SharedPointer category_sp,
|
|
|
|
CXXFunctionSummaryFormat::Callback funct, const char *description,
|
|
|
|
ConstString type_name, TypeSummaryImpl::Flags flags, bool regex) {
|
|
|
|
lldb::TypeSummaryImplSP summary_sp(
|
|
|
|
new CXXFunctionSummaryFormat(flags, funct, description));
|
|
|
|
if (regex)
|
|
|
|
category_sp->GetRegexTypeSummariesContainer()->Add(
|
2019-09-04 17:47:18 +08:00
|
|
|
RegularExpression(type_name.GetStringRef()), summary_sp);
|
2015-09-02 09:21:31 +08:00
|
|
|
else
|
2019-09-04 17:47:18 +08:00
|
|
|
category_sp->GetTypeSummariesContainer()->Add(std::move(type_name),
|
|
|
|
summary_sp);
|
2015-09-02 09:21:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void lldb_private::formatters::AddCXXSynthetic(
|
|
|
|
TypeCategoryImpl::SharedPointer category_sp,
|
|
|
|
CXXSyntheticChildren::CreateFrontEndCallback generator,
|
|
|
|
const char *description, ConstString type_name,
|
|
|
|
ScriptedSyntheticChildren::Flags flags, bool regex) {
|
|
|
|
lldb::SyntheticChildrenSP synth_sp(
|
|
|
|
new CXXSyntheticChildren(flags, description, generator));
|
|
|
|
if (regex)
|
|
|
|
category_sp->GetRegexTypeSyntheticsContainer()->Add(
|
2019-09-04 17:47:18 +08:00
|
|
|
RegularExpression(type_name.GetStringRef()), synth_sp);
|
2015-09-02 09:21:31 +08:00
|
|
|
else
|
2019-09-04 17:47:18 +08:00
|
|
|
category_sp->GetTypeSyntheticsContainer()->Add(std::move(type_name),
|
|
|
|
synth_sp);
|
2015-09-02 09:21:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void lldb_private::formatters::AddFilter(
|
|
|
|
TypeCategoryImpl::SharedPointer category_sp,
|
|
|
|
std::vector<std::string> children, const char *description,
|
|
|
|
ConstString type_name, ScriptedSyntheticChildren::Flags flags, bool regex) {
|
|
|
|
TypeFilterImplSP filter_sp(new TypeFilterImpl(flags));
|
|
|
|
for (auto child : children)
|
|
|
|
filter_sp->AddExpressionPath(child);
|
|
|
|
if (regex)
|
|
|
|
category_sp->GetRegexTypeFiltersContainer()->Add(
|
2019-09-04 17:47:18 +08:00
|
|
|
RegularExpression(type_name.GetStringRef()), filter_sp);
|
2015-09-02 09:21:31 +08:00
|
|
|
else
|
2019-09-04 17:47:18 +08:00
|
|
|
category_sp->GetTypeFiltersContainer()->Add(std::move(type_name),
|
|
|
|
filter_sp);
|
2015-09-02 09:21:31 +08:00
|
|
|
}
|
2015-09-04 08:33:51 +08:00
|
|
|
|
|
|
|
size_t lldb_private::formatters::ExtractIndexFromString(const char *item_name) {
|
|
|
|
if (!item_name || !*item_name)
|
|
|
|
return UINT32_MAX;
|
|
|
|
if (*item_name != '[')
|
|
|
|
return UINT32_MAX;
|
|
|
|
item_name++;
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
char *endptr = nullptr;
|
2015-09-04 08:33:51 +08:00
|
|
|
unsigned long int idx = ::strtoul(item_name, &endptr, 0);
|
|
|
|
if (idx == 0 && endptr == item_name)
|
|
|
|
return UINT32_MAX;
|
|
|
|
if (idx == ULONG_MAX)
|
|
|
|
return UINT32_MAX;
|
|
|
|
return idx;
|
|
|
|
}
|
2015-09-25 10:16:52 +08:00
|
|
|
|
|
|
|
lldb::addr_t
|
|
|
|
lldb_private::formatters::GetArrayAddressOrPointerValue(ValueObject &valobj) {
|
|
|
|
lldb::addr_t data_addr = LLDB_INVALID_ADDRESS;
|
|
|
|
|
|
|
|
if (valobj.IsPointerType())
|
|
|
|
data_addr = valobj.GetValueAsUnsigned(0);
|
|
|
|
else if (valobj.IsArrayType())
|
|
|
|
data_addr = valobj.GetAddressOf();
|
|
|
|
|
|
|
|
return data_addr;
|
|
|
|
}
|