Conversation

charles-zablit

#140762 introduces some compilation warnings in lldb/unittests/Core/MangledTest.cpp. This adds explicit default initialization to DemangledNameInfo to suppress those warnings.

We only had the default initialization values to PrefixRange and SuffixRange because they are the only optional fields of the structure.

@llvmbot

@llvm/pr-subscribers-lldb

Author: Charles Zablit (charles-zablit)

Changes

#140762 introduces some compilation warnings in lldb/unittests/Core/MangledTest.cpp. This adds explicit default initialization to DemangledNameInfo to suppress those warnings.

We only had the default initialization values to PrefixRange and SuffixRange because they are the only optional fields of the structure.


Full diff: https://.com/llvm/llvm-project/pull/141790.diff

1 Files Affected:

  • (modified) lldb/include/lldb/Core/DemangledNameInfo.h (+2-2)
diff --git a/lldb/include/lldb/Core/DemangledNameInfo.h b/lldb/include/lldb/Core/DemangledNameInfo.h
index ab9bb3e211b66..e26adc7035a56 100644
--- a/lldb/include/lldb/Core/DemangledNameInfo.h
+++ b/lldb/include/lldb/Core/DemangledNameInfo.h
@@ -62,12 +62,12 @@ struct DemangledNameInfo {
   /// Indicates the [start, end) of the function's prefix. This is a
   /// catch-all range for anything that is not tracked by the rest of
   /// the pairs.
-  std::pair<size_t, size_t> PrefixRange;
+  std::pair<size_t, size_t> PrefixRange{};
 
   /// Indicates the [start, end) of the function's suffix. This is a
   /// catch-all range for anything that is not tracked by the rest of
   /// the pairs.
-  std::pair<size_t, size_t> SuffixRange;
+  std::pair<size_t, size_t> SuffixRange{};
 
   /// Returns \c true if this object holds a valid basename range.
   bool hasBasename() const {

@JDevlieghere

The warning in question is -Wmissing-field-initializers, which is warning that in the unit test not all fields of this struct are explicitly initialized. Even if these fields are optional, I think this is the wrong way to address this: we should either update the unit tests to initialize those fields by adding {}, {}, or add a constructor with default arguments.

@charles-zablit

The warning in question is -Wmissing-field-initializers, which is warning that in the unit test not all fields of this struct are explicitly initialized. Even if these fields are optional, I think this is the wrong way to address this: we should either update the unit tests to initialize those fields by adding {}, {}, or add a constructor with default arguments.

I agree, this is more explicit.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! LGTM.

@kazutakahirata

@charles-zablit I've verified that this PR fixes check-lldb-unit in my local build. Thank you for fixing this!

@charles-zablit

Please feel free to merge when possible, as I do not have commit access yet.

@Michael137Michael137 merged commit 711a177 into llvm:main May 28, 2025
10 checks passed
google-yfyang pushed a commit to google-yfyang/llvm-project that referenced this pull request May 29, 2025
…rning (llvm#141790)

llvm#140762 introduces some
compilation warnings in `lldb/unittests/Core/MangledTest.cpp`. This
 adds explicit default initialization to `DemangledNameInfo` to
suppress those warnings.

We only had the default initialization values to `PrefixRange` and
`SuffixRange` because they are the only _optional_ fields of the
structure.
charles-zablit added a commit to swiftlang/llvm-project that referenced this pull request May 30, 2025
…rning (llvm#141790)

llvm#140762 introduces some
compilation warnings in `lldb/unittests/Core/MangledTest.cpp`. This
 adds explicit default initialization to `DemangledNameInfo` to
suppress those warnings.

We only had the default initialization values to `PrefixRange` and
`SuffixRange` because they are the only _optional_ fields of the
structure.
adrian-prantl pushed a commit to swiftlang/llvm-project that referenced this pull request Jun 3, 2025
* [Demangling] Refactor Demangler range tracking (llvm#140762)

This PR is a subset of the commits made in
#10710.

The most notable change is the addition of `PrefixRange` and
`SuffixRange` which are a catch-all to track anything after or before a
function's demangled name. In the case of Swift, this allows to add
support for name highlighting without having to track the range of the
scope and specifiers of a function (this will come in another PR).

* add explicit default initialization to DemangledNameInfo to remove warning (llvm#141790)

llvm#140762 introduces some
compilation warnings in `lldb/unittests/Core/MangledTest.cpp`. This
 adds explicit default initialization to `DemangledNameInfo` to
suppress those warnings.

We only had the default initialization values to `PrefixRange` and
`SuffixRange` because they are the only _optional_ fields of the
structure.
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Jun 3, 2025
…rning (llvm#141790)

llvm#140762 introduces some
compilation warnings in `lldb/unittests/Core/MangledTest.cpp`. This
 adds explicit default initialization to `DemangledNameInfo` to
suppress those warnings.

We only had the default initialization values to `PrefixRange` and
`SuffixRange` because they are the only _optional_ fields of the
structure.
Sign up for free to join this conversation on . Already have an account? Sign in to comment
None yet

Successfully merging this pull request may close these issues.