[Lldb-commits] [lldb] [lldb][DWARF] Add support for case-insensitive identifier lookups using DW_AT_identifier_case (PR #213323)
via lldb-commits
lldb-commits at lists.llvm.org
Fri Jul 31 10:52:47 PDT 2026
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 h,cpp -- lldb/test/API/commands/frame/var-dil/basics/CaseSensitiveLookup/main.cpp lldb/include/lldb/Symbol/CompileUnit.h lldb/include/lldb/lldb-enumerations.h lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/ValueObject/DILEval.cpp lldb/unittests/SymbolFile/DWARF/DWARFDebugNamesIndexTest.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/lldb/include/lldb/Symbol/CompileUnit.h b/lldb/include/lldb/Symbol/CompileUnit.h
index 7d99bd16a..e598a0794 100644
--- a/lldb/include/lldb/Symbol/CompileUnit.h
+++ b/lldb/include/lldb/Symbol/CompileUnit.h
@@ -152,11 +152,9 @@ public:
m_language = language;
}
- lldb::IdentifierCaseType GetCasing() {
- return m_identifier_case;
- }
+ lldb::IdentifierCaseType GetCasing() { return m_identifier_case; }
- void SetCasing(lldb::IdentifierCaseType identifier_case){
+ void SetCasing(lldb::IdentifierCaseType identifier_case) {
m_identifier_case = identifier_case;
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index b31a7c54b..e9476f314 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -892,31 +892,32 @@ llvm::VersionTuple DWARFUnit::GetProducerVersion() {
}
lldb::IdentifierCaseType DWARFUnit::GetIdentifierCase() {
- if(m_identifier_case != eCaseUnknown)
+ if (m_identifier_case != eCaseUnknown)
return m_identifier_case;
const DWARFDebugInfoEntry *die = GetUnitDIEPtrOnly();
- if(!die)
+ if (!die)
m_identifier_case = eCaseSensitive;
-
+
else {
- uint64_t identifier_case = die->GetAttributeValueAsUnsigned(this, DW_AT_identifier_case, llvm::dwarf::DW_ID_case_sensitive);
+ uint64_t identifier_case = die->GetAttributeValueAsUnsigned(
+ this, DW_AT_identifier_case, llvm::dwarf::DW_ID_case_sensitive);
switch (identifier_case) {
- case llvm::dwarf::DW_ID_up_case:
- m_identifier_case = eUpperCase;
- break;
- case llvm::dwarf::DW_ID_down_case:
- m_identifier_case = eLowerCase;
- break;
- case llvm::dwarf::DW_ID_case_insensitive:
- m_identifier_case = eCaseInsensitive;
- break;
- case llvm::dwarf::DW_ID_case_sensitive:
- default:
- m_identifier_case = eCaseSensitive;
- break;
+ case llvm::dwarf::DW_ID_up_case:
+ m_identifier_case = eUpperCase;
+ break;
+ case llvm::dwarf::DW_ID_down_case:
+ m_identifier_case = eLowerCase;
+ break;
+ case llvm::dwarf::DW_ID_case_insensitive:
+ m_identifier_case = eCaseInsensitive;
+ break;
+ case llvm::dwarf::DW_ID_case_sensitive:
+ default:
+ m_identifier_case = eCaseSensitive;
+ break;
}
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 43f53ea34..76506daea 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -160,9 +160,9 @@ void ManualDWARFIndex::IndexUnit(DWARFUnit &unit, SymbolFileDWARFDwo *dwp,
lldb::IdentifierCaseType cu_identifier_case = unit.GetIdentifierCase();
- // If at least one of the Compile Units is case sensitive, then all compile
+ // If at least one of the Compile Units is case sensitive, then all compile
// units will be case sensitive
- if(cu_identifier_case != eCaseSensitive)
+ if (cu_identifier_case != eCaseSensitive)
SetNameCaseInsensitive();
else
SetStrictlyCaseSensitive();
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
index 5e137c0f9..4612e7b97 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
@@ -169,27 +169,27 @@ private:
/// True if this index is a partial index, false otherwise.
bool IsPartial() const;
- void SetNameCaseInsensitive() {
- m_set.function_basenames.SetNameCaseInsensitive();
- m_set.function_fullnames.SetNameCaseInsensitive();
- m_set.function_methods.SetNameCaseInsensitive();
- m_set.function_selectors.SetNameCaseInsensitive();
- m_set.objc_class_selectors.SetNameCaseInsensitive();
- m_set.globals.SetNameCaseInsensitive();
- m_set.types.SetNameCaseInsensitive();
- m_set.namespaces.SetNameCaseInsensitive();
- }
-
- void SetStrictlyCaseSensitive() {
- m_set.function_basenames.SetStrictlyCaseSensitive();
- m_set.function_fullnames.SetStrictlyCaseSensitive();
- m_set.function_methods.SetStrictlyCaseSensitive();
- m_set.function_selectors.SetStrictlyCaseSensitive();
- m_set.objc_class_selectors.SetStrictlyCaseSensitive();
- m_set.globals.SetStrictlyCaseSensitive();
- m_set.types.SetStrictlyCaseSensitive();
- m_set.namespaces.SetStrictlyCaseSensitive();
- }
+ void SetNameCaseInsensitive() {
+ m_set.function_basenames.SetNameCaseInsensitive();
+ m_set.function_fullnames.SetNameCaseInsensitive();
+ m_set.function_methods.SetNameCaseInsensitive();
+ m_set.function_selectors.SetNameCaseInsensitive();
+ m_set.objc_class_selectors.SetNameCaseInsensitive();
+ m_set.globals.SetNameCaseInsensitive();
+ m_set.types.SetNameCaseInsensitive();
+ m_set.namespaces.SetNameCaseInsensitive();
+ }
+
+ void SetStrictlyCaseSensitive() {
+ m_set.function_basenames.SetStrictlyCaseSensitive();
+ m_set.function_fullnames.SetStrictlyCaseSensitive();
+ m_set.function_methods.SetStrictlyCaseSensitive();
+ m_set.function_selectors.SetStrictlyCaseSensitive();
+ m_set.objc_class_selectors.SetStrictlyCaseSensitive();
+ m_set.globals.SetStrictlyCaseSensitive();
+ m_set.types.SetStrictlyCaseSensitive();
+ m_set.namespaces.SetStrictlyCaseSensitive();
+ }
/// The DWARF file which we are indexing.
SymbolFileDWARF *m_dwarf;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp b/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
index c370eaa2a..c2699517b 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
@@ -42,8 +42,9 @@ bool NameToDIE::Find(
if (!NameCaseInsensitive)
return true;
- for (const auto &entry : m_map){
- if(ConstString::Equals(ConstString(entry.cstring.GetCString()), name, false))
+ for (const auto &entry : m_map) {
+ if (ConstString::Equals(ConstString(entry.cstring.GetCString()), name,
+ false))
if (callback(entry.value) == IterationAction::Stop)
return false;
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h b/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h
index a85c6a2cd..01cdffb5b 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h
@@ -86,8 +86,11 @@ public:
void Clear() { m_map.Clear(); }
- void SetNameCaseInsensitive() { if(!StrictlyCaseSensitive) NameCaseInsensitive = true; }
-
+ void SetNameCaseInsensitive() {
+ if (!StrictlyCaseSensitive)
+ NameCaseInsensitive = true;
+ }
+
void SetStrictlyCaseSensitive() {
NameCaseInsensitive = false;
StrictlyCaseSensitive = true;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index ab31c6bba..38a89676f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -807,7 +807,7 @@ lldb::CompUnitSP SymbolFileDWARF::ParseCompileUnit(DWARFCompileUnit &dwarf_cu) {
cu_sp->SetCasing(cu_casing);
dwarf_cu.SetLLDBCompUnit(cu_sp.get());
-
+
SetCompileUnitAtIndex(dwarf_cu.GetID(), cu_sp);
};
@@ -836,7 +836,8 @@ lldb::CompUnitSP SymbolFileDWARF::ParseCompileUnit(DWARFCompileUnit &dwarf_cu) {
if (support_files.GetSize() == 0)
return false;
initialize_cu(support_files.GetSupportFileAtIndex(0),
- eLanguageTypeUnknown, dwarf_cu.GetIdentifierCase(), std::move(support_files));
+ eLanguageTypeUnknown, dwarf_cu.GetIdentifierCase(),
+ std::move(support_files));
return true;
};
diff --git a/lldb/source/ValueObject/DILEval.cpp b/lldb/source/ValueObject/DILEval.cpp
index 0f1967c55..16b6df366 100644
--- a/lldb/source/ValueObject/DILEval.cpp
+++ b/lldb/source/ValueObject/DILEval.cpp
@@ -291,20 +291,19 @@ lldb::ValueObjectSP LookupGlobalIdentifier(llvm::StringRef name_ref,
lldb::VariableListSP variable_list;
lldb::IdentifierCaseType identifier_case = lldb::eCaseSensitive;
- if (symbol_context.comp_unit){
+ if (symbol_context.comp_unit) {
variable_list = symbol_context.comp_unit->GetVariableList(true);
identifier_case = symbol_context.comp_unit->GetCasing();
}
-
name_ref.consume_front("::");
std::string search_string;
- if(identifier_case == lldb::eLowerCase)
+ if (identifier_case == lldb::eLowerCase)
search_string = name_ref.lower();
- else if(identifier_case == lldb::eUpperCase)
+ else if (identifier_case == lldb::eUpperCase)
search_string = name_ref.upper();
- else
+ else
search_string = name_ref.str();
lldb::ValueObjectSP value_sp;
@@ -359,18 +358,19 @@ lldb::ValueObjectSP LookupIdentifier(llvm::StringRef name_ref,
lldb::VariableListSP variable_list(
stack_frame.GetInScopeVariableList(false));
- SymbolContext sc = stack_frame.GetSymbolContext(lldb::eSymbolContextCompUnit);
+ SymbolContext sc =
+ stack_frame.GetSymbolContext(lldb::eSymbolContextCompUnit);
lldb::IdentifierCaseType identifier_case = lldb::eCaseSensitive;
- if(sc.comp_unit)
+ if (sc.comp_unit)
identifier_case = sc.comp_unit->GetCasing();
std::string search_string;
- if(identifier_case == lldb::eLowerCase)
+ if (identifier_case == lldb::eLowerCase)
search_string = name_ref.lower();
- else if(identifier_case == lldb::eUpperCase)
+ else if (identifier_case == lldb::eUpperCase)
search_string = name_ref.upper();
- else
+ else
search_string = name_ref.str();
lldb::ValueObjectSP value_sp;
@@ -386,8 +386,8 @@ lldb::ValueObjectSP LookupIdentifier(llvm::StringRef name_ref,
return value_sp;
// Try looking for an instance variable (class member).
- sc = stack_frame.GetSymbolContext(
- lldb::eSymbolContextFunction | lldb::eSymbolContextBlock);
+ sc = stack_frame.GetSymbolContext(lldb::eSymbolContextFunction |
+ lldb::eSymbolContextBlock);
llvm::StringRef instance_name = sc.GetInstanceName();
value_sp = stack_frame.FindVariable(ConstString(instance_name));
if (value_sp)
diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFDebugNamesIndexTest.cpp b/lldb/unittests/SymbolFile/DWARF/DWARFDebugNamesIndexTest.cpp
index 854e6e1f4..81fa3aca7 100644
--- a/lldb/unittests/SymbolFile/DWARF/DWARFDebugNamesIndexTest.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/DWARFDebugNamesIndexTest.cpp
@@ -26,9 +26,7 @@ using StringRef = llvm::StringRef;
class DWARFDebugNamesIndexTest : public testing::Test {
public:
- void SetUp() override {
- Debugger::Initialize(nullptr);
- }
+ void SetUp() override { Debugger::Initialize(nullptr); }
void TearDown() override { Debugger::Terminate(); }
};
``````````
</details>
https://github.com/llvm/llvm-project/pull/213323
More information about the lldb-commits
mailing list