[llvm] [llvm][dsymutil] Use the DW_AT_name of the uniqued DIE for insertion into .debug_names (PR #168513)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 18 03:12:37 PST 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- llvm/include/llvm/DWARFLinker/Classic/DWARFLinker.h llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerDeclContext.h llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp llvm/lib/DWARFLinker/Classic/DWARFLinkerDeclContext.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/include/llvm/DWARFLinker/Classic/DWARFLinker.h b/llvm/include/llvm/DWARFLinker/Classic/DWARFLinker.h
index 65935ad84..32a8c0cdd 100644
--- a/llvm/include/llvm/DWARFLinker/Classic/DWARFLinker.h
+++ b/llvm/include/llvm/DWARFLinker/Classic/DWARFLinker.h
@@ -708,9 +708,8 @@ private:
/// already there.
/// \returns is a name was found.
bool getDIENames(const DWARFDie &Die, AttributesInfo &Info,
- OffsetsStringPool &StringPool,
- const DWARFFile &File, CompileUnit &Unit,
- bool StripTemplate = false);
+ OffsetsStringPool &StringPool, const DWARFFile &File,
+ CompileUnit &Unit, bool StripTemplate = false);
uint32_t hashFullyQualifiedName(DWARFDie DIE, CompileUnit &U,
const DWARFFile &File,
@@ -728,7 +727,8 @@ private:
/// Relocate address ranges.
void generateLineTableForUnit(CompileUnit &Unit);
- llvm::StringRef getCanonicalDIEName(DWARFDie Die, const DWARFFile &File, CompileUnit *Unit);
+ llvm::StringRef getCanonicalDIEName(DWARFDie Die, const DWARFFile &File,
+ CompileUnit *Unit);
};
/// Assign an abbreviation number to \p Abbrev
diff --git a/llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerDeclContext.h b/llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerDeclContext.h
index feccd89b7..5ced6d05c 100644
--- a/llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerDeclContext.h
+++ b/llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerDeclContext.h
@@ -84,11 +84,13 @@ public:
DeclContext() : DefinedInClangModule(0), Parent(*this) {}
DeclContext(unsigned Hash, uint32_t Line, uint32_t ByteSize, uint16_t Tag,
- StringRef Name, StringRef NameForUniquing, StringRef File, const DeclContext &Parent,
- DWARFDie LastSeenDIE = DWARFDie(), unsigned CUId = 0)
+ StringRef Name, StringRef NameForUniquing, StringRef File,
+ const DeclContext &Parent, DWARFDie LastSeenDIE = DWARFDie(),
+ unsigned CUId = 0)
: QualifiedNameHash(Hash), Line(Line), ByteSize(ByteSize), Tag(Tag),
- DefinedInClangModule(0), Name(Name), NameForUniquing(NameForUniquing), File(File), Parent(Parent),
- LastSeenDIE(LastSeenDIE), LastSeenCompileUnitID(CUId) {}
+ DefinedInClangModule(0), Name(Name), NameForUniquing(NameForUniquing),
+ File(File), Parent(Parent), LastSeenDIE(LastSeenDIE),
+ LastSeenCompileUnitID(CUId) {}
uint32_t getQualifiedNameHash() const { return QualifiedNameHash; }
diff --git a/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp b/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
index 0d0cf0268..8eafcf78c 100644
--- a/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
+++ b/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
@@ -153,7 +153,9 @@ static bool isTypeTag(uint16_t Tag) {
/// Recurse through the input DIE's canonical references until we find a
/// DW_AT_name.
-llvm::StringRef DWARFLinker::DIECloner::getCanonicalDIEName(DWARFDie Die, const DWARFFile &File, CompileUnit *Unit) {
+llvm::StringRef
+DWARFLinker::DIECloner::getCanonicalDIEName(DWARFDie Die, const DWARFFile &File,
+ CompileUnit *Unit) {
std::optional<DWARFFormValue> Ref;
auto GetDieName = [](const DWARFDie &D) -> llvm::StringRef {
@@ -175,12 +177,12 @@ llvm::StringRef DWARFLinker::DIECloner::getCanonicalDIEName(DWARFDie Die, const
return Name;
while (true) {
- if (!(Ref = Die.find(llvm::dwarf::DW_AT_specification))
- && !(Ref = Die.find(llvm::dwarf::DW_AT_abstract_origin)))
+ if (!(Ref = Die.find(llvm::dwarf::DW_AT_specification)) &&
+ !(Ref = Die.find(llvm::dwarf::DW_AT_abstract_origin)))
break;
Die = Linker.resolveDIEReference(File, CompileUnits, *Ref, Die, Unit);
- assert (Unit);
+ assert(Unit);
unsigned SpecIdx = Unit->getOrigUnit().getDIEIndex(Die);
CompileUnit::DIEInfo &SpecInfo = Unit->getInfo(SpecIdx);
@@ -199,11 +201,9 @@ llvm::StringRef DWARFLinker::DIECloner::getCanonicalDIEName(DWARFDie Die, const
return Name;
}
-bool DWARFLinker::DIECloner::getDIENames(const DWARFDie &Die,
- AttributesInfo &Info,
- OffsetsStringPool &StringPool,
- const DWARFFile &File, CompileUnit &Unit,
- bool StripTemplate) {
+bool DWARFLinker::DIECloner::getDIENames(
+ const DWARFDie &Die, AttributesInfo &Info, OffsetsStringPool &StringPool,
+ const DWARFFile &File, CompileUnit &Unit, bool StripTemplate) {
// This function will be called on DIEs having low_pcs and
// ranges. As getting the name might be more expansive, filter out
// blocks directly.
diff --git a/llvm/lib/DWARFLinker/Classic/DWARFLinkerDeclContext.cpp b/llvm/lib/DWARFLinker/Classic/DWARFLinkerDeclContext.cpp
index d9356bd71..e22683f8a 100644
--- a/llvm/lib/DWARFLinker/Classic/DWARFLinkerDeclContext.cpp
+++ b/llvm/lib/DWARFLinker/Classic/DWARFLinkerDeclContext.cpp
@@ -96,7 +96,8 @@ DeclContextTree::getChildDeclContext(DeclContext &Context, const DWARFDie &DIE,
else if (!Name.empty())
NameForUniquing = Name;
- bool IsAnonymousNamespace = NameForUniquing.empty() && Tag == dwarf::DW_TAG_namespace;
+ bool IsAnonymousNamespace =
+ NameForUniquing.empty() && Tag == dwarf::DW_TAG_namespace;
if (IsAnonymousNamespace) {
// FIXME: For dsymutil-classic compatibility. I think uniquing within
// anonymous namespaces is wrong. There is no ODR guarantee there.
@@ -157,7 +158,8 @@ DeclContextTree::getChildDeclContext(DeclContext &Context, const DWARFDie &DIE,
// FIXME: dsymutil-classic won't unique the same type presented
// once as a struct and once as a class. Using the Tag in the fully
// qualified name hash to get the same effect.
- unsigned Hash = hash_combine(Context.getQualifiedNameHash(), Tag, NameForUniquing);
+ unsigned Hash =
+ hash_combine(Context.getQualifiedNameHash(), Tag, NameForUniquing);
// FIXME: dsymutil-classic compatibility: when we don't have a name,
// use the filename.
@@ -165,15 +167,16 @@ DeclContextTree::getChildDeclContext(DeclContext &Context, const DWARFDie &DIE,
Hash = hash_combine(Hash, FileRef);
// Now look if this context already exists.
- DeclContext Key(Hash, Line, ByteSize, Tag, Name, NameForUniquing, FileRef, Context);
+ DeclContext Key(Hash, Line, ByteSize, Tag, Name, NameForUniquing, FileRef,
+ Context);
auto ContextIter = Contexts.find(&Key);
if (ContextIter == Contexts.end()) {
// The context wasn't found.
bool Inserted;
- DeclContext *NewContext =
- new (Allocator) DeclContext(Hash, Line, ByteSize, Tag, Name, NameForUniquing, FileRef,
- Context, DIE, U.getUniqueID());
+ DeclContext *NewContext = new (Allocator)
+ DeclContext(Hash, Line, ByteSize, Tag, Name, NameForUniquing, FileRef,
+ Context, DIE, U.getUniqueID());
std::tie(ContextIter, Inserted) = Contexts.insert(NewContext);
assert(Inserted && "Failed to insert DeclContext");
(void)Inserted;
``````````
</details>
https://github.com/llvm/llvm-project/pull/168513
More information about the llvm-commits
mailing list