[Lldb-commits] [lldb] [lldb][Language] Make SourceLanguage::GetDescription for language version (PR #162050)
Michael Buch via lldb-commits
lldb-commits at lists.llvm.org
Wed Oct 8 10:36:27 PDT 2025
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/162050
>From 2aee2b16d171206d953b86aa2a37ae4658c96774 Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Mon, 6 Oct 2025 09:48:28 +0100
Subject: [PATCH 1/2] [lldb][Language] Make SourceLanguage::GetDescription for
language version
This makes sure we also include the version number in the description.
For `C++17`, this would, e.g., now return `"C++17"` instead of `"ISO C++"`.
---
lldb/source/Target/Language.cpp | 2 +-
lldb/unittests/Target/LanguageTest.cpp | 9 +++++++--
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/lldb/source/Target/Language.cpp b/lldb/source/Target/Language.cpp
index 2efd4bc1e2c09..8268d4ae4bb27 100644
--- a/lldb/source/Target/Language.cpp
+++ b/lldb/source/Target/Language.cpp
@@ -582,7 +582,7 @@ lldb::LanguageType SourceLanguage::AsLanguageType() const {
llvm::StringRef SourceLanguage::GetDescription() const {
return llvm::dwarf::LanguageDescription(
- static_cast<llvm::dwarf::SourceLanguageName>(name));
+ static_cast<llvm::dwarf::SourceLanguageName>(name), version);
}
bool SourceLanguage::IsC() const { return name == llvm::dwarf::DW_LNAME_C; }
diff --git a/lldb/unittests/Target/LanguageTest.cpp b/lldb/unittests/Target/LanguageTest.cpp
index a1f9267dd45d0..a882d70b7e120 100644
--- a/lldb/unittests/Target/LanguageTest.cpp
+++ b/lldb/unittests/Target/LanguageTest.cpp
@@ -36,9 +36,14 @@ TEST_F(LanguageTest, SourceLanguage_GetDescription) {
EXPECT_EQ(SourceLanguage(eLanguageTypeC_plus_plus).GetDescription(),
"ISO C++");
EXPECT_EQ(SourceLanguage(eLanguageTypeC_plus_plus_17).GetDescription(),
- "ISO C++");
+ "C++17");
EXPECT_EQ(SourceLanguage(eLanguageTypeC_plus_plus_20).GetDescription(),
- "ISO C++");
+ "C++20");
+
+ EXPECT_EQ(SourceLanguage(eLanguageTypeC).GetDescription(),
+ "C (K&R and ISO)");
+ EXPECT_EQ(SourceLanguage(eLanguageTypeC89).GetDescription(),
+ "C89");
EXPECT_EQ(SourceLanguage(eLanguageTypeObjC).GetDescription(), "Objective C");
EXPECT_EQ(SourceLanguage(eLanguageTypeMipsAssembler).GetDescription(),
>From fb9a075cc92d0c2ec17f61fb29178aa05824638d Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Mon, 6 Oct 2025 10:16:48 +0100
Subject: [PATCH 2/2] fixup! clang-format
---
lldb/unittests/Target/LanguageTest.cpp | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/lldb/unittests/Target/LanguageTest.cpp b/lldb/unittests/Target/LanguageTest.cpp
index a882d70b7e120..720863bda68e4 100644
--- a/lldb/unittests/Target/LanguageTest.cpp
+++ b/lldb/unittests/Target/LanguageTest.cpp
@@ -40,10 +40,8 @@ TEST_F(LanguageTest, SourceLanguage_GetDescription) {
EXPECT_EQ(SourceLanguage(eLanguageTypeC_plus_plus_20).GetDescription(),
"C++20");
- EXPECT_EQ(SourceLanguage(eLanguageTypeC).GetDescription(),
- "C (K&R and ISO)");
- EXPECT_EQ(SourceLanguage(eLanguageTypeC89).GetDescription(),
- "C89");
+ EXPECT_EQ(SourceLanguage(eLanguageTypeC).GetDescription(), "C (K&R and ISO)");
+ EXPECT_EQ(SourceLanguage(eLanguageTypeC89).GetDescription(), "C89");
EXPECT_EQ(SourceLanguage(eLanguageTypeObjC).GetDescription(), "Objective C");
EXPECT_EQ(SourceLanguage(eLanguageTypeMipsAssembler).GetDescription(),
More information about the lldb-commits
mailing list