lldb simplified template names rebuild without clang ast by dwblaikie · Pull Request #90008 · llvm/llvm-project (original) (raw)
⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️
You can test this locally with the following command:
git-clang-format --diff 396cdabe47f3596464b289d0937c0066f50a0ac6 9a654b056d9c05c0aa4856db161c1f1b08b9dfe9 -- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp llvm/include/llvm-c/Error.h llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h llvm/lib/DebugInfo/DWARF/DWARFDie.cpp llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp
View the diff from clang-format here.
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 962844af28..1232f29e36 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -6,9 +6,9 @@ // //===----------------------------------------------------------------------===//
+#include #include #include -#include
#include "DWARFASTParser.h" #include "DWARFASTParserClang.h" @@ -1569,7 +1569,8 @@ DWARFASTParserClang::GetCPlusPlusQualifiedName(const DWARFDIE &die) { if (!name) return ""; static int indent = 0;
- std::cerr << std::string(indent, ' ') << "starting qualified name for: " << name << '\n';
std::cerr << std::string(indent, ' ')
<< "starting qualified name for: " << name << '\n';
auto &FS = die.GetCU()->GetSymbolFileDWARF().GetObjectFile()->GetFileSpec(); std::string Directory = FS.GetDirectory().AsCString(""); std::cerr << std::string(indent, ' ') @@ -1623,7 +1624,8 @@ DWARFASTParserClang::GetCPlusPlusQualifiedName(const DWARFDIE &die) { qualified_name.append(GetDIEClassTemplateParams(die).AsCString(""));
--indent;
- std::cerr << std::string(indent, ' ') << "computed qualified name: " << qualified_name << '\n';
- std::cerr << std::string(indent, ' ')
return qualified_name;<< "computed qualified name: " << qualified_name << '\n';
} diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h index 6a5ef1f83a..10c946a292 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h @@ -87,9 +87,7 @@ public:
// Accessing information about a DIE dw_tag_t Tag() const;
- dw_tag_t getTag() const {
- return Tag();
- }
dw_tag_t getTag() const { return Tag(); } using DWARFFormValue = dwarf::DWARFFormValue;
const char *GetTagAsCString() const;
@@ -103,9 +101,7 @@ public: lldb::user_id_t GetID() const;
const char *GetName() const;
- const char *getShortName() const {
- return GetName();
- }
const char *getShortName() const { return GetName(); }
lldb::ModuleSP GetModule() const;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp index 064c510eea..eb8147e01c 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp @@ -532,9 +532,7 @@ llvm::iterator_rangeDWARFDIE::child_iterator DWARFDIE::children() const { DWARFDIE::child_iterator DWARFDIE::begin() const { return child_iterator(*this); } -DWARFDIE::child_iterator DWARFDIE::end() const {
- return child_iterator(); -} +DWARFDIE::child_iterator DWARFDIE::end() const { return child_iterator(); } std::optional DWARFDIE::find(const dw_attr_t attr) const { DWARFFormValue form_value; if (m_die->GetAttributeValue(m_cu, attr, form_value, nullptr, false)) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h index 42a9b9e8e7..c4e2db2407 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h @@ -118,15 +118,16 @@ protected: ValueType m_value; // Contains all data for the form };
-inline const char* toString(DWARFFormValue Value, const char* Default) {
- if (const char* R = Value.AsCString()) +inline const char *toString(DWARFFormValue Value, const char *Default) {
- if (const char R = Value.AsCString()) return R; return Default; } -inline const char toString(std::optional Value, const char* Default) { +inline const char *toString(std::optional Value,
if (!Value) return Default;const char *Default) {
- if (const char* R = Value->AsCString())
- if (const char *R = Value->AsCString()) return R; return Default; } diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h index abc0ab8e27..cadc47caf1 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h @@ -82,11 +82,14 @@ void DWARFTypePrinter::appendArrayType(const DieType &D) { std::optional Count; std::optional UB; std::optional DefaultLB;
- if (std::optional L = C.find(dwarf::DW_AT_lower_bound))
- if (std::optional L =
C.find(dwarf::DW_AT_lower_bound)) LB = L->getAsUnsignedConstant();
- if (std::optional CountV = C.find(dwarf::DW_AT_count))
- if (std::optional CountV =
C.find(dwarf::DW_AT_count)) Count = CountV->getAsUnsignedConstant();
- if (std::optional UpperV = C.find(dwarf::DW_AT_upper_bound))
- if (std::optional UpperV =
/* if (std::optional LV = @@ -124,10 +127,11 @@ void DWARFTypePrinter::appendArrayType(const DieType &D) { }C.find(dwarf::DW_AT_upper_bound)) UB = UpperV->getAsUnsignedConstant();
namespace detail { -template +template DieType resolveReferencedType(DieType D,
dwarf::Attribute Attr = dwarf::DW_AT_type) {
- return D.getAttributeValueAsReferencedDie(Attr); // .resolveTypeUnitReference();
dwarf::Attribute Attr = dwarf::DW_AT_type) {
- return D.getAttributeValueAsReferencedDie(
Attr); // .resolveTypeUnitReference();
} template DieType resolveReferencedType(DieType D, typename DieType::DWARFFormValue F) { @@ -204,7 +208,8 @@ DieType DWARFTypePrinter::appendUnqualifiedNameBefore( OS << '('; else if (Word) OS << ' ';
- if (DieType Cont = detail::resolveReferencedType(D, dwarf::DW_AT_containing_type)) {
- if (DieType Cont =
detail::resolveReferencedType(D, dwarf::DW_AT_containing_type)) { appendQualifiedName(Cont); EndedWithTemplate = false; OS << "::";
@@ -275,7 +280,8 @@ DieType DWARFTypePrinter::appendUnqualifiedNameBefore( }
template -void DWARFTypePrinter::appendAndTerminateTemplateParameters(DieType D) { +void DWARFTypePrinter::appendAndTerminateTemplateParameters(
- DieType D) {
if (!appendTemplateParameters(D)) return;
@@ -354,8 +360,11 @@ void DWARFTypePrinter::appendUnqualifiedNameAfter( llvm::raw_string_ostream PtrauthStream(PtrauthString); PtrauthStream << "__ptrauth(" << getValOrNull(dwarf::DW_AT_LLVM_ptrauth_key) << ", "
<< getValOrNull(dwarf::DW_AT_LLVM_ptrauth_address_discriminated) << ", 0x0"
<< utohexstr(getValOrNull(dwarf::DW_AT_LLVM_ptrauth_extra_discriminator), true)
<< getValOrNull(dwarf::DW_AT_LLVM_ptrauth_address_discriminated)
<< ", 0x0"
<< utohexstr(
getValOrNull(dwarf::DW_AT_LLVM_ptrauth_extra_discriminator),
OS << PtrauthStream.str(); break; @@ -470,8 +479,8 @@ bool DWARFTypePrinter::appendTemplateParameters(DieType D, } else if (Name == "char" || (IsQualifiedChar = (Name == "unsigned char" || Name == "signed char"))) {true) << options << ")";
// FIXME: check T's dwarf::DW_AT_type to see if it's signed or not (since
// char signedness is implementation defined).
// FIXME: check T's dwarf::DW_AT_type to see if it's signed or not
// (since char signedness is implementation defined). auto Val = *V->getAsSignedConstant(); // Copied/hacked up from Clang's CharacterLiteral::print - incomplete // (doesn't actually support different character types/widths, sign
@@ -573,8 +582,8 @@ void DWARFTypePrinter::appendConstVolatileQualifierAfter(DieType N) { DieType T; decomposeConstVolatile(N, T, C, V); if (T && T.getTag() == dwarf::DW_TAG_subroutine_type)
- appendSubroutineNameAfter(T, detail::resolveReferencedType(T), false, C.isValid(),
V.isValid());
- appendSubroutineNameAfter(T, detail::resolveReferencedType(T), false,
else appendUnqualifiedNameAfter(T, detail::resolveReferencedType(T)); } @@ -632,7 +641,8 @@ void DWARFTypePrinter::appendSubroutineNameAfter( P.getTag() != dwarf::DW_TAG_unspecified_parameters) return; DieType T = detail::resolveReferencedType(P);C.isValid(), V.isValid());
- if (SkipFirstParamIfArtificial && RealFirst && P.find(dwarf::DW_AT_artificial)) {
- if (SkipFirstParamIfArtificial && RealFirst &&
P.find(dwarf::DW_AT_artificial)) { FirstParamIfArtificial = T; RealFirst = false; continue;
@@ -752,7 +762,7 @@ void DWARFTypePrinter::appendScopes(DieType D) { return; if (D.getTag() == dwarf::DW_TAG_lexical_block) return;
- //D = D.resolveTypeUnitReference();
- // D = D.resolveTypeUnitReference(); if (DieType P = D.getParent()) appendScopes(P); appendUnqualifiedName(D);