summaryrefslogtreecommitdiff
path: root/lldb/source/Target
diff options
context:
space:
mode:
authorMichael Buch <michaelbuch12@gmail.com>2025-10-03 23:23:08 +0100
committerGitHub <noreply@github.com>2025-10-03 22:23:08 +0000
commit2c3724419c04c3b6d918eb4c2eec00a4372d2937 (patch)
tree4392e0f0450ddeb083c59e90a8175b31db08a68b /lldb/source/Target
parent7f51a2a47d2e706d04855b0e41690ebafa2b3238 (diff)
[lldb][Language] Add Language::GetDisplayNameForLanguageType API (#161803)
The intention for this API is to be used when presenting language names to the user, e.g., in expression evaluation diagnostics or LLDB errors. Most uses of `GetNameForLanguageType` can be probably replaced with `GetDisplayNameForLanguageType`, but that's out of scope of this PR. This uses `llvm::dwarf::LanguageDescription` under the hood, so we would lose the version numbers in the names. If we deem those to be important, we could switch to an implementation that hardcodes a list of user-friendly names with version numbers included. The intention is to use it from https://github.com/llvm/llvm-project/pull/161688 Depends on https://github.com/llvm/llvm-project/pull/161804
Diffstat (limited to 'lldb/source/Target')
-rw-r--r--lldb/source/Target/Language.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/lldb/source/Target/Language.cpp b/lldb/source/Target/Language.cpp
index c8cb0ca31e91..395718ecbe29 100644
--- a/lldb/source/Target/Language.cpp
+++ b/lldb/source/Target/Language.cpp
@@ -271,6 +271,10 @@ const char *Language::GetNameForLanguageType(LanguageType language) {
return language_names[eLanguageTypeUnknown].name;
}
+llvm::StringRef Language::GetDisplayNameForLanguageType(LanguageType language) {
+ return SourceLanguage(language).GetDescription();
+}
+
void Language::PrintSupportedLanguagesForExpressions(Stream &s,
llvm::StringRef prefix,
llvm::StringRef suffix) {