[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-05-01 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

https://github.com/llvm/llvm-project/pull/90753

https://github.com/llvm/llvm-project/pull/89981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-30 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

> Thanks for the explanation! What kind of tool reads this file?

One such tool is SWIG, which happens to support macro expansion, but we have 
other tools downstream that don't. 

> It's still weird to use tblgen to process non-td files imho. We have a bunch 
> of places that run python scripts as part of the build 
> (clang/utils/bundle_resources.py, 
> clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py, 
> compiler-rt/lib/sanitizer_common/scripts/gen_dynamic_list.py, 
> clang-tools-extra/clangd/quality/CompletionModelCodegen.py) – maybe that 
> could work here?

Yeah I agree and that's my fault for suggesting it in the first place to 
Adrian. We considered Python but weren't sure it was a hard build dependency 
(even though LLDB relies on it extensively, you can actually turn it off with a 
CMake flag). If that's the case then that's certainly a viable option. 

https://github.com/llvm/llvm-project/pull/89981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-30 Thread Alex Langford via lldb-commits

bulbazord wrote:

This doesn't actually copy `SBLanguages.h` into the framework, so this breaks 
the framework.
These tests now fail:
```


Unresolved Tests (5):
  lldb-api :: api/check_public_api_headers/TestPublicAPIHeaders.py
  lldb-api :: api/multiple-debuggers/TestMultipleDebuggers.py
  lldb-api :: api/multiple-targets/TestMultipleTargets.py
  lldb-api :: api/multithreaded/TestMultithreaded.py
  lldb-api :: functionalities/plugins/command_plugin/TestPluginCommands.py
  ```
 

https://github.com/llvm/llvm-project/pull/89981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-30 Thread Nico Weber via lldb-commits

nico wrote:

Thanks for the explanation! What kind of tool reads this file?

It's still weird to use tblgen to process non-td files imho. We have a bunch of 
places that run python scripts as part of the build 
(clang/utils/bundle_resources.py, 
clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py, 
compiler-rt/lib/sanitizer_common/scripts/gen_dynamic_list.py, 
clang-tools-extra/clangd/quality/CompletionModelCodegen.py) – maybe that could 
work here?

https://github.com/llvm/llvm-project/pull/89981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-30 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

Btw. github doesn't let you see older revisions, but the code snippet you 
posted that includes a .def file was exactly my first version of this patch. 
You can still find @JDevlieghere's comment asking me to change it though :-)

Another thing worth noting is that the public LLDB API can't expect an LLVM 
header to be present either.

https://github.com/llvm/llvm-project/pull/89981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-30 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

That's also why it's a `.h` file and not a `.inc`.

https://github.com/llvm/llvm-project/pull/89981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-30 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

> Why does this use tablegen to parse a .def file?
> 
> Can't you get the same behavior without tablegen, using normal xmacro 
> techniques, something like
> 
> ```c++
> enum SBSourceLanguageName : uint16_t {
> 
> #define HANDLE_DW_LNAME(ID, NAME, DESC, LOWER_BOUND) \
>   eLanguageName ## NAME = ID,
> 
> #include "llvm/include/llvm/BinaryFormat/Dwarf.def"
> 
> #undef HANDLE_DW_LNAME
> 
> };
> ```
> 
> ? Why bring tablegen into this?
> 
> (Sorry if I'm missing something obvious.)

That's a very valid question to ask!
The reason is that the header files produced here are part of the LLDB 
scripting API and are going to be processed by tools that are not full 
compilers and fully expanding this at compile-time avoids any compatibility 
issues with not fully compliant interface generators. The reason why this is 
implemented in C++ is because I don't want to assume that there is `sed` or 
something equivalent available on the build system especially on platforms like 
Windows.

https://github.com/llvm/llvm-project/pull/89981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-30 Thread Nico Weber via lldb-commits

nico wrote:

I left another comment on the commit that doesn't show up here 
(https://github.com/llvm/llvm-project/commit/975eca0e6a3459e59e96b0df33ea0cfbd157c597).

If you do want to keep the generated file: All other tablegen invocations use 
".inc" for tablegen output. Maybe this could match that convention?

(But not needing a generated file seems even nicer.)

https://github.com/llvm/llvm-project/pull/89981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-30 Thread Nico Weber via lldb-commits

nico wrote:

Why does this use tablegen to parse a .def file?

Can't you get the same behavior without tablegen, using normal xmacro 
techniques, something like

```c++

enum SBSourceLanguageName : uint16_t {

#define HANDLE_DW_LNAME(ID, NAME, DESC, LOWER_BOUND) \
  eLanguageName ## NAME = ID,

#include "llvm/include/llvm/BinaryFormat/Dwarf.def"

#undef HANDLE_DW_LNAME

};

```

? Why bring tablegen into this?

(Sorry if I'm missing something obvious.)

https://github.com/llvm/llvm-project/pull/89981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-29 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl closed 
https://github.com/llvm/llvm-project/pull/89981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-29 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/89981

>From 34eda7b484e3fa9eaaf97c66af3e81bf337e6edd Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Wed, 24 Apr 2024 12:50:43 -0700
Subject: [PATCH] Add a new SBExpressionOptions::SetLanguage() API (NFCI)

that separates out language and version. To avoid reinventing the
wheel and introducing subtle incompatibilities, this API uses the
table of languages and versiond defined by the upcoming DWARF 6
standard (https://dwarfstd.org/languages-v6.html). While the DWARF 6
spec is not finialized, the list of languages is broadly considered
stable.

The primary motivation for this is to allow the Swift language plugin
to switch between language dialects between, e.g., Swift 5.9 and 6.0
with out introducing a ton of new language codes. On the main branch
this change is considered NFC.
---
 lldb/include/lldb/API/SBExpressionOptions.h   |  5 ++
 lldb/include/lldb/Expression/Expression.h |  7 +-
 .../lldb/Expression/LLVMUserExpression.h  |  2 +-
 lldb/include/lldb/Expression/UserExpression.h | 33 -
 lldb/include/lldb/Symbol/TypeSystem.h | 10 ++-
 lldb/include/lldb/Target/StackFrame.h | 12 ++--
 lldb/include/lldb/Target/Target.h | 19 --
 lldb/include/lldb/lldb-private-types.h| 19 ++
 .../Python/lldbsuite/test/configuration.py|  1 +
 lldb/packages/Python/lldbsuite/test/dotest.py |  3 +
 .../Python/lldbsuite/test/dotest_args.py  |  8 ++-
 .../Python/lldbsuite/test/lldbtest.py | 25 +--
 lldb/source/API/CMakeLists.txt|  7 ++
 lldb/source/API/SBExpressionOptions.cpp   |  7 ++
 lldb/source/API/SBFrame.cpp   | 30 +
 lldb/source/Breakpoint/Watchpoint.cpp |  5 +-
 .../Commands/CommandObjectDWIMPrint.cpp   |  2 +-
 lldb/source/Commands/CommandObjectType.cpp|  2 +-
 lldb/source/Expression/LLVMUserExpression.cpp |  2 +-
 lldb/source/Expression/UserExpression.cpp | 14 ++--
 lldb/source/Expression/UtilityFunction.cpp|  4 +-
 .../Clang/ClangExpressionParser.cpp   | 12 ++--
 .../Clang/ClangUserExpression.cpp | 19 +++---
 .../Clang/ClangUserExpression.h   |  6 +-
 .../TypeSystem/Clang/TypeSystemClang.cpp  |  2 +-
 .../TypeSystem/Clang/TypeSystemClang.h| 12 ++--
 lldb/source/Target/Language.cpp   | 34 ++
 lldb/source/Target/StackFrame.cpp | 23 +++
 lldb/source/Target/Target.cpp | 21 +++---
 lldb/test/API/lit.cfg.py  |  3 +
 lldb/test/API/lit.site.cfg.py.in  |  2 +-
 lldb/utils/TableGen/CMakeLists.txt|  1 +
 lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp| 67 +++
 lldb/utils/TableGen/LLDBTableGen.cpp  |  9 ++-
 lldb/utils/TableGen/LLDBTableGenBackends.h|  1 +
 35 files changed, 306 insertions(+), 123 deletions(-)
 create mode 100644 lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp

diff --git a/lldb/include/lldb/API/SBExpressionOptions.h 
b/lldb/include/lldb/API/SBExpressionOptions.h
index e0ddfda5ba37a2..19c416d0f3bcbc 100644
--- a/lldb/include/lldb/API/SBExpressionOptions.h
+++ b/lldb/include/lldb/API/SBExpressionOptions.h
@@ -10,6 +10,7 @@
 #define LLDB_API_SBEXPRESSIONOPTIONS_H
 
 #include "lldb/API/SBDefines.h"
+#include "lldb/API/SBLanguages.h"
 
 #include 
 
@@ -67,6 +68,10 @@ class LLDB_API SBExpressionOptions {
   void SetTrapExceptions(bool trap_exceptions = true);
 
   void SetLanguage(lldb::LanguageType language);
+  /// Set the language using a pair of language code and version as
+  /// defined by the DWARF 6 specification.
+  /// WARNING: These codes may change until DWARF 6 is finalized.
+  void SetLanguage(SBSourceLanguageName name, uint32_t version);
 
 #ifndef SWIG
   void SetCancelCallback(lldb::ExpressionCancelCallback callback, void *baton);
diff --git a/lldb/include/lldb/Expression/Expression.h 
b/lldb/include/lldb/Expression/Expression.h
index 3e61d78828bbbf..356fe4b82ae43a 100644
--- a/lldb/include/lldb/Expression/Expression.h
+++ b/lldb/include/lldb/Expression/Expression.h
@@ -47,11 +47,8 @@ class Expression {
   /// expression.  Text() should contain the definition of this function.
   virtual const char *FunctionName() = 0;
 
-  /// Return the language that should be used when parsing.  To use the
-  /// default, return eLanguageTypeUnknown.
-  virtual lldb::LanguageType Language() const {
-return lldb::eLanguageTypeUnknown;
-  }
+  /// Return the language that should be used when parsing.
+  virtual SourceLanguage Language() const { return {}; }
 
   /// Return the Materializer that the parser should use when registering
   /// external values.
diff --git a/lldb/include/lldb/Expression/LLVMUserExpression.h 
b/lldb/include/lldb/Expression/LLVMUserExpression.h
index 7d32d17dbf544c..40b463933c07e8 100644
--- a/lldb/include/lldb/Expression/LLVMUserExpression.h
+++ b/lldb/include/lldb/Expression/LLVMUserExpression.h
@

[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-29 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/89981

>From c4b1ff6c92126ebf721b6044088b05112ec98477 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Wed, 24 Apr 2024 12:50:43 -0700
Subject: [PATCH] Add a new SBExpressionOptions::SetLanguage() API (NFCI)

that separates out language and version. To avoid reinventing the
wheel and introducing subtle incompatibilities, this API uses the
table of languages and versiond defined by the upcoming DWARF 6
standard (https://dwarfstd.org/languages-v6.html). While the DWARF 6
spec is not finialized, the list of languages is broadly considered
stable.

The primary motivation for this is to allow the Swift language plugin
to switch between language dialects between, e.g., Swift 5.9 and 6.0
with out introducing a ton of new language codes. On the main branch
this change is considered NFC.
---
 lldb/include/lldb/API/SBExpressionOptions.h   |  5 ++
 lldb/include/lldb/Expression/Expression.h |  7 +-
 .../lldb/Expression/LLVMUserExpression.h  |  2 +-
 lldb/include/lldb/Expression/UserExpression.h | 33 -
 lldb/include/lldb/Symbol/TypeSystem.h | 10 ++-
 lldb/include/lldb/Target/StackFrame.h | 12 ++--
 lldb/include/lldb/Target/Target.h | 19 --
 lldb/include/lldb/lldb-private-types.h| 19 ++
 .../Python/lldbsuite/test/configuration.py|  1 +
 lldb/packages/Python/lldbsuite/test/dotest.py |  3 +
 .../Python/lldbsuite/test/dotest_args.py  |  8 ++-
 .../Python/lldbsuite/test/lldbtest.py | 19 --
 lldb/source/API/CMakeLists.txt|  7 ++
 lldb/source/API/SBExpressionOptions.cpp   |  7 ++
 lldb/source/API/SBFrame.cpp   | 30 +
 lldb/source/Breakpoint/Watchpoint.cpp |  5 +-
 .../Commands/CommandObjectDWIMPrint.cpp   |  2 +-
 lldb/source/Commands/CommandObjectType.cpp|  2 +-
 lldb/source/Expression/LLVMUserExpression.cpp |  2 +-
 lldb/source/Expression/UserExpression.cpp | 14 ++--
 lldb/source/Expression/UtilityFunction.cpp|  4 +-
 .../Clang/ClangExpressionParser.cpp   | 12 ++--
 .../Clang/ClangUserExpression.cpp | 19 +++---
 .../Clang/ClangUserExpression.h   |  6 +-
 .../TypeSystem/Clang/TypeSystemClang.cpp  |  2 +-
 .../TypeSystem/Clang/TypeSystemClang.h| 12 ++--
 lldb/source/Target/Language.cpp   | 34 ++
 lldb/source/Target/StackFrame.cpp | 23 +++
 lldb/source/Target/Target.cpp | 21 +++---
 lldb/test/API/lit.cfg.py  |  3 +
 lldb/test/API/lit.site.cfg.py.in  |  2 +-
 lldb/utils/TableGen/CMakeLists.txt|  1 +
 lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp| 67 +++
 lldb/utils/TableGen/LLDBTableGen.cpp  |  9 ++-
 lldb/utils/TableGen/LLDBTableGenBackends.h|  1 +
 35 files changed, 300 insertions(+), 123 deletions(-)
 create mode 100644 lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp

diff --git a/lldb/include/lldb/API/SBExpressionOptions.h 
b/lldb/include/lldb/API/SBExpressionOptions.h
index e0ddfda5ba37a2..19c416d0f3bcbc 100644
--- a/lldb/include/lldb/API/SBExpressionOptions.h
+++ b/lldb/include/lldb/API/SBExpressionOptions.h
@@ -10,6 +10,7 @@
 #define LLDB_API_SBEXPRESSIONOPTIONS_H
 
 #include "lldb/API/SBDefines.h"
+#include "lldb/API/SBLanguages.h"
 
 #include 
 
@@ -67,6 +68,10 @@ class LLDB_API SBExpressionOptions {
   void SetTrapExceptions(bool trap_exceptions = true);
 
   void SetLanguage(lldb::LanguageType language);
+  /// Set the language using a pair of language code and version as
+  /// defined by the DWARF 6 specification.
+  /// WARNING: These codes may change until DWARF 6 is finalized.
+  void SetLanguage(SBSourceLanguageName name, uint32_t version);
 
 #ifndef SWIG
   void SetCancelCallback(lldb::ExpressionCancelCallback callback, void *baton);
diff --git a/lldb/include/lldb/Expression/Expression.h 
b/lldb/include/lldb/Expression/Expression.h
index 3e61d78828bbbf..356fe4b82ae43a 100644
--- a/lldb/include/lldb/Expression/Expression.h
+++ b/lldb/include/lldb/Expression/Expression.h
@@ -47,11 +47,8 @@ class Expression {
   /// expression.  Text() should contain the definition of this function.
   virtual const char *FunctionName() = 0;
 
-  /// Return the language that should be used when parsing.  To use the
-  /// default, return eLanguageTypeUnknown.
-  virtual lldb::LanguageType Language() const {
-return lldb::eLanguageTypeUnknown;
-  }
+  /// Return the language that should be used when parsing.
+  virtual SourceLanguage Language() const { return {}; }
 
   /// Return the Materializer that the parser should use when registering
   /// external values.
diff --git a/lldb/include/lldb/Expression/LLVMUserExpression.h 
b/lldb/include/lldb/Expression/LLVMUserExpression.h
index 7d32d17dbf544c..40b463933c07e8 100644
--- a/lldb/include/lldb/Expression/LLVMUserExpression.h
+++ b/lldb/include/lldb/Expression/LLVMUserExpression.h
@@

[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-29 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/89981

>From 00fdda9a57660533c5a97223bd52619b36f8999c Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Wed, 24 Apr 2024 12:50:43 -0700
Subject: [PATCH] Add a new SBExpressionOptions::SetLanguage() API (NFCI)

that separates out language and version. To avoid reinventing the
wheel and introducing subtle incompatibilities, this API uses the
table of languages and versiond defined by the upcoming DWARF 6
standard (https://dwarfstd.org/languages-v6.html). While the DWARF 6
spec is not finialized, the list of languages is broadly considered
stable.

The primary motivation for this is to allow the Swift language plugin
to switch between language dialects between, e.g., Swift 5.9 and 6.0
with out introducing a ton of new language codes. On the main branch
this change is considered NFC.
---
 lldb/include/lldb/API/SBExpressionOptions.h   |  5 ++
 lldb/include/lldb/Expression/Expression.h |  7 +-
 .../lldb/Expression/LLVMUserExpression.h  |  2 +-
 lldb/include/lldb/Expression/UserExpression.h | 33 -
 lldb/include/lldb/Symbol/TypeSystem.h | 10 ++-
 lldb/include/lldb/Target/StackFrame.h | 12 ++--
 lldb/include/lldb/Target/Target.h | 19 --
 lldb/include/lldb/lldb-private-types.h| 19 ++
 .../Python/lldbsuite/test/configuration.py|  1 +
 lldb/packages/Python/lldbsuite/test/dotest.py |  3 +
 .../Python/lldbsuite/test/dotest_args.py  |  8 ++-
 .../Python/lldbsuite/test/lldbtest.py | 19 --
 lldb/source/API/CMakeLists.txt|  7 ++
 lldb/source/API/SBExpressionOptions.cpp   |  7 ++
 lldb/source/API/SBFrame.cpp   | 30 +
 lldb/source/Breakpoint/Watchpoint.cpp |  5 +-
 .../Commands/CommandObjectDWIMPrint.cpp   |  2 +-
 lldb/source/Commands/CommandObjectType.cpp|  2 +-
 lldb/source/Expression/LLVMUserExpression.cpp |  2 +-
 lldb/source/Expression/UserExpression.cpp | 14 ++--
 lldb/source/Expression/UtilityFunction.cpp|  4 +-
 .../Clang/ClangExpressionParser.cpp   | 12 ++--
 .../Clang/ClangUserExpression.cpp | 19 +++---
 .../Clang/ClangUserExpression.h   |  6 +-
 .../TypeSystem/Clang/TypeSystemClang.cpp  |  2 +-
 .../TypeSystem/Clang/TypeSystemClang.h| 12 ++--
 lldb/source/Target/Language.cpp   | 34 ++
 lldb/source/Target/StackFrame.cpp | 23 +++
 lldb/source/Target/Target.cpp | 21 +++---
 lldb/test/API/lit.cfg.py  |  3 +
 lldb/test/API/lit.site.cfg.py.in  |  2 +-
 lldb/utils/TableGen/CMakeLists.txt|  1 +
 lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp| 67 +++
 lldb/utils/TableGen/LLDBTableGen.cpp  |  9 ++-
 lldb/utils/TableGen/LLDBTableGenBackends.h|  1 +
 35 files changed, 300 insertions(+), 123 deletions(-)
 create mode 100644 lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp

diff --git a/lldb/include/lldb/API/SBExpressionOptions.h 
b/lldb/include/lldb/API/SBExpressionOptions.h
index e0ddfda5ba37a2..19c416d0f3bcbc 100644
--- a/lldb/include/lldb/API/SBExpressionOptions.h
+++ b/lldb/include/lldb/API/SBExpressionOptions.h
@@ -10,6 +10,7 @@
 #define LLDB_API_SBEXPRESSIONOPTIONS_H
 
 #include "lldb/API/SBDefines.h"
+#include "lldb/API/SBLanguages.h"
 
 #include 
 
@@ -67,6 +68,10 @@ class LLDB_API SBExpressionOptions {
   void SetTrapExceptions(bool trap_exceptions = true);
 
   void SetLanguage(lldb::LanguageType language);
+  /// Set the language using a pair of language code and version as
+  /// defined by the DWARF 6 specification.
+  /// WARNING: These codes may change until DWARF 6 is finalized.
+  void SetLanguage(SBSourceLanguageName name, uint32_t version);
 
 #ifndef SWIG
   void SetCancelCallback(lldb::ExpressionCancelCallback callback, void *baton);
diff --git a/lldb/include/lldb/Expression/Expression.h 
b/lldb/include/lldb/Expression/Expression.h
index 3e61d78828bbbf..356fe4b82ae43a 100644
--- a/lldb/include/lldb/Expression/Expression.h
+++ b/lldb/include/lldb/Expression/Expression.h
@@ -47,11 +47,8 @@ class Expression {
   /// expression.  Text() should contain the definition of this function.
   virtual const char *FunctionName() = 0;
 
-  /// Return the language that should be used when parsing.  To use the
-  /// default, return eLanguageTypeUnknown.
-  virtual lldb::LanguageType Language() const {
-return lldb::eLanguageTypeUnknown;
-  }
+  /// Return the language that should be used when parsing.
+  virtual SourceLanguage Language() const { return {}; }
 
   /// Return the Materializer that the parser should use when registering
   /// external values.
diff --git a/lldb/include/lldb/Expression/LLVMUserExpression.h 
b/lldb/include/lldb/Expression/LLVMUserExpression.h
index 7d32d17dbf544c..40b463933c07e8 100644
--- a/lldb/include/lldb/Expression/LLVMUserExpression.h
+++ b/lldb/include/lldb/Expression/LLVMUserExpression.h
@@

[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-29 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/89981

>From ea06aa4664b9b47b3cb11ec27774b9a0d109f92f Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Wed, 24 Apr 2024 12:50:43 -0700
Subject: [PATCH] Add a new SBExpressionOptions::SetLanguage() API (NFCI)

that separates out language and version. To avoid reinventing the
wheel and introducing subtle incompatibilities, this API uses the
table of languages and versiond defined by the upcoming DWARF 6
standard (https://dwarfstd.org/languages-v6.html). While the DWARF 6
spec is not finialized, the list of languages is broadly considered
stable.

The primary motivation for this is to allow the Swift language plugin
to switch between language dialects between, e.g., Swift 5.9 and 6.0
with out introducing a ton of new language codes. On the main branch
this change is considered NFC.
---
 lldb/include/lldb/API/SBExpressionOptions.h   |  5 ++
 lldb/include/lldb/Expression/Expression.h |  7 +-
 .../lldb/Expression/LLVMUserExpression.h  |  2 +-
 lldb/include/lldb/Expression/UserExpression.h | 33 -
 lldb/include/lldb/Symbol/TypeSystem.h | 10 ++-
 lldb/include/lldb/Target/StackFrame.h | 11 ++-
 lldb/include/lldb/Target/Target.h | 19 --
 lldb/include/lldb/lldb-private-types.h| 19 ++
 .../Python/lldbsuite/test/configuration.py|  1 +
 lldb/packages/Python/lldbsuite/test/dotest.py |  3 +
 .../Python/lldbsuite/test/dotest_args.py  |  8 ++-
 .../Python/lldbsuite/test/lldbtest.py | 19 --
 lldb/source/API/CMakeLists.txt|  7 ++
 lldb/source/API/SBExpressionOptions.cpp   |  7 ++
 lldb/source/API/SBFrame.cpp   | 30 +
 lldb/source/Breakpoint/Watchpoint.cpp |  5 +-
 .../Commands/CommandObjectDWIMPrint.cpp   |  2 +-
 lldb/source/Commands/CommandObjectType.cpp|  2 +-
 lldb/source/Expression/LLVMUserExpression.cpp |  2 +-
 lldb/source/Expression/UserExpression.cpp | 14 ++--
 lldb/source/Expression/UtilityFunction.cpp|  4 +-
 .../Clang/ClangExpressionParser.cpp   | 12 ++--
 .../Clang/ClangUserExpression.cpp | 19 +++---
 .../Clang/ClangUserExpression.h   |  6 +-
 .../TypeSystem/Clang/TypeSystemClang.cpp  |  2 +-
 .../TypeSystem/Clang/TypeSystemClang.h| 12 ++--
 lldb/source/Target/Language.cpp   | 34 ++
 lldb/source/Target/StackFrame.cpp | 23 +++
 lldb/source/Target/Target.cpp | 21 +++---
 lldb/test/API/lit.cfg.py  |  3 +
 lldb/test/API/lit.site.cfg.py.in  |  2 +-
 lldb/utils/TableGen/CMakeLists.txt|  1 +
 lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp| 67 +++
 lldb/utils/TableGen/LLDBTableGen.cpp  |  9 ++-
 lldb/utils/TableGen/LLDBTableGenBackends.h|  1 +
 35 files changed, 299 insertions(+), 123 deletions(-)
 create mode 100644 lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp

diff --git a/lldb/include/lldb/API/SBExpressionOptions.h 
b/lldb/include/lldb/API/SBExpressionOptions.h
index e0ddfda5ba37a2..19c416d0f3bcbc 100644
--- a/lldb/include/lldb/API/SBExpressionOptions.h
+++ b/lldb/include/lldb/API/SBExpressionOptions.h
@@ -10,6 +10,7 @@
 #define LLDB_API_SBEXPRESSIONOPTIONS_H
 
 #include "lldb/API/SBDefines.h"
+#include "lldb/API/SBLanguages.h"
 
 #include 
 
@@ -67,6 +68,10 @@ class LLDB_API SBExpressionOptions {
   void SetTrapExceptions(bool trap_exceptions = true);
 
   void SetLanguage(lldb::LanguageType language);
+  /// Set the language using a pair of language code and version as
+  /// defined by the DWARF 6 specification.
+  /// WARNING: These codes may change until DWARF 6 is finalized.
+  void SetLanguage(SBSourceLanguageName name, uint32_t version);
 
 #ifndef SWIG
   void SetCancelCallback(lldb::ExpressionCancelCallback callback, void *baton);
diff --git a/lldb/include/lldb/Expression/Expression.h 
b/lldb/include/lldb/Expression/Expression.h
index 3e61d78828bbbf..356fe4b82ae43a 100644
--- a/lldb/include/lldb/Expression/Expression.h
+++ b/lldb/include/lldb/Expression/Expression.h
@@ -47,11 +47,8 @@ class Expression {
   /// expression.  Text() should contain the definition of this function.
   virtual const char *FunctionName() = 0;
 
-  /// Return the language that should be used when parsing.  To use the
-  /// default, return eLanguageTypeUnknown.
-  virtual lldb::LanguageType Language() const {
-return lldb::eLanguageTypeUnknown;
-  }
+  /// Return the language that should be used when parsing.
+  virtual SourceLanguage Language() const { return {}; }
 
   /// Return the Materializer that the parser should use when registering
   /// external values.
diff --git a/lldb/include/lldb/Expression/LLVMUserExpression.h 
b/lldb/include/lldb/Expression/LLVMUserExpression.h
index 7d32d17dbf544c..40b463933c07e8 100644
--- a/lldb/include/lldb/Expression/LLVMUserExpression.h
+++ b/lldb/include/lldb/Expression/LLVMUserExpression.h
@@ 

[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-29 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere approved this pull request.

Thanks for bearing with me! LGTM.

https://github.com/llvm/llvm-project/pull/89981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-29 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/89981

>From 6d91ad848b73183268617fecf14255b0ba0b9dd8 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Wed, 24 Apr 2024 12:50:43 -0700
Subject: [PATCH] Add a new SBExpressionOptions::SetLanguage() API (NFCI)

that separates out language and version. To avoid reinventing the
wheel and introducing subtle incompatibilities, this API uses the
table of languages and versiond defined by the upcoming DWARF 6
standard (https://dwarfstd.org/languages-v6.html). While the DWARF 6
spec is not finialized, the list of languages is broadly considered
stable.

The primary motivation for this is to allow the Swift language plugin
to switch between language dialects between, e.g., Swift 5.9 and 6.0
with out introducing a ton of new language codes. On the main branch
this change is considered NFC.
---
 lldb/include/lldb/API/SBExpressionOptions.h   |  5 ++
 lldb/include/lldb/Expression/Expression.h |  7 +-
 .../lldb/Expression/LLVMUserExpression.h  |  2 +-
 lldb/include/lldb/Expression/UserExpression.h | 33 -
 lldb/include/lldb/Symbol/TypeSystem.h | 10 ++-
 lldb/include/lldb/Target/StackFrame.h | 11 ++-
 lldb/include/lldb/Target/Target.h | 19 --
 lldb/include/lldb/lldb-private-types.h| 19 ++
 .../Python/lldbsuite/test/configuration.py|  1 +
 lldb/packages/Python/lldbsuite/test/dotest.py |  3 +
 .../Python/lldbsuite/test/dotest_args.py  |  8 ++-
 .../Python/lldbsuite/test/lldbtest.py | 19 --
 lldb/source/API/CMakeLists.txt|  7 ++
 lldb/source/API/SBExpressionOptions.cpp   |  7 ++
 lldb/source/API/SBFrame.cpp   | 30 +
 lldb/source/Breakpoint/Watchpoint.cpp |  5 +-
 .../Commands/CommandObjectDWIMPrint.cpp   |  2 +-
 lldb/source/Commands/CommandObjectType.cpp|  2 +-
 lldb/source/Expression/LLVMUserExpression.cpp |  2 +-
 lldb/source/Expression/UserExpression.cpp | 14 ++--
 lldb/source/Expression/UtilityFunction.cpp|  4 +-
 .../Clang/ClangExpressionParser.cpp   | 12 ++--
 .../Clang/ClangUserExpression.cpp | 19 +++---
 .../Clang/ClangUserExpression.h   |  6 +-
 .../TypeSystem/Clang/TypeSystemClang.cpp  |  2 +-
 .../TypeSystem/Clang/TypeSystemClang.h| 12 ++--
 lldb/source/Target/Language.cpp   | 34 ++
 lldb/source/Target/StackFrame.cpp | 23 +++
 lldb/source/Target/Target.cpp | 21 +++---
 lldb/test/API/lit.cfg.py  |  3 +
 lldb/test/API/lit.site.cfg.py.in  |  2 +-
 lldb/utils/TableGen/CMakeLists.txt|  1 +
 lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp| 67 +++
 lldb/utils/TableGen/LLDBTableGen.cpp  |  9 ++-
 lldb/utils/TableGen/LLDBTableGenBackends.h|  1 +
 35 files changed, 299 insertions(+), 123 deletions(-)
 create mode 100644 lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp

diff --git a/lldb/include/lldb/API/SBExpressionOptions.h 
b/lldb/include/lldb/API/SBExpressionOptions.h
index e0ddfda5ba37a2..19c416d0f3bcbc 100644
--- a/lldb/include/lldb/API/SBExpressionOptions.h
+++ b/lldb/include/lldb/API/SBExpressionOptions.h
@@ -10,6 +10,7 @@
 #define LLDB_API_SBEXPRESSIONOPTIONS_H
 
 #include "lldb/API/SBDefines.h"
+#include "lldb/API/SBLanguages.h"
 
 #include 
 
@@ -67,6 +68,10 @@ class LLDB_API SBExpressionOptions {
   void SetTrapExceptions(bool trap_exceptions = true);
 
   void SetLanguage(lldb::LanguageType language);
+  /// Set the language using a pair of language code and version as
+  /// defined by the DWARF 6 specification.
+  /// WARNING: These codes may change until DWARF 6 is finalized.
+  void SetLanguage(SBSourceLanguageName name, uint32_t version);
 
 #ifndef SWIG
   void SetCancelCallback(lldb::ExpressionCancelCallback callback, void *baton);
diff --git a/lldb/include/lldb/Expression/Expression.h 
b/lldb/include/lldb/Expression/Expression.h
index 3e61d78828bbbf..356fe4b82ae43a 100644
--- a/lldb/include/lldb/Expression/Expression.h
+++ b/lldb/include/lldb/Expression/Expression.h
@@ -47,11 +47,8 @@ class Expression {
   /// expression.  Text() should contain the definition of this function.
   virtual const char *FunctionName() = 0;
 
-  /// Return the language that should be used when parsing.  To use the
-  /// default, return eLanguageTypeUnknown.
-  virtual lldb::LanguageType Language() const {
-return lldb::eLanguageTypeUnknown;
-  }
+  /// Return the language that should be used when parsing.
+  virtual SourceLanguage Language() const { return {}; }
 
   /// Return the Materializer that the parser should use when registering
   /// external values.
diff --git a/lldb/include/lldb/Expression/LLVMUserExpression.h 
b/lldb/include/lldb/Expression/LLVMUserExpression.h
index 7d32d17dbf544c..40b463933c07e8 100644
--- a/lldb/include/lldb/Expression/LLVMUserExpression.h
+++ b/lldb/include/lldb/Expression/LLVMUserExpression.h
@@ 

[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-29 Thread Adrian Prantl via lldb-commits


@@ -10,6 +10,7 @@ config.llvm_build_mode = 
lit_config.substitute("@LLVM_BUILD_MODE@")
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.lldb_obj_root = "@LLDB_BINARY_DIR@"
 config.lldb_src_root = "@LLDB_SOURCE_DIR@"
+config.lldb_built_include_dir = 
lit_config.substitute("@LLDB_BINARY_DIR@/include")

adrian-prantl wrote:

@JDevlieghere  I made the change — I'm not sure it does what you were hoping 
for though, since we still need to thread through `lldb_obj_root`.

https://github.com/llvm/llvm-project/pull/89981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-29 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/89981

>From 19cfcf3230d02a93a907fe93ca95dbecd48bcaf9 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Wed, 24 Apr 2024 12:50:43 -0700
Subject: [PATCH] Add a new SBExpressionOptions::SetLanguage() API (NFCI)

that separates out language and version. To avoid reinventing the
wheel and introducing subtle incompatibilities, this API uses the
table of languages and versiond defined by the upcoming DWARF 6
standard (https://dwarfstd.org/languages-v6.html). While the DWARF 6
spec is not finialized, the list of languages is broadly considered
stable.

The primary motivation for this is to allow the Swift language plugin
to switch between language dialects between, e.g., Swift 5.9 and 6.0
with out introducing a ton of new language codes. On the main branch
this change is considered NFC.
---
 lldb/include/lldb/API/SBExpressionOptions.h   |  5 ++
 lldb/include/lldb/Expression/Expression.h |  7 +-
 .../lldb/Expression/LLVMUserExpression.h  |  2 +-
 lldb/include/lldb/Expression/UserExpression.h | 33 -
 lldb/include/lldb/Symbol/TypeSystem.h | 10 ++-
 lldb/include/lldb/Target/StackFrame.h | 11 ++-
 lldb/include/lldb/Target/Target.h | 19 --
 lldb/include/lldb/lldb-private-types.h| 19 ++
 .../Python/lldbsuite/test/configuration.py|  1 +
 lldb/packages/Python/lldbsuite/test/dotest.py |  3 +
 .../Python/lldbsuite/test/dotest_args.py  |  8 ++-
 .../Python/lldbsuite/test/lldbtest.py | 19 --
 lldb/source/API/CMakeLists.txt|  7 ++
 lldb/source/API/SBExpressionOptions.cpp   |  7 ++
 lldb/source/API/SBFrame.cpp   | 30 +
 lldb/source/Breakpoint/Watchpoint.cpp |  5 +-
 .../Commands/CommandObjectDWIMPrint.cpp   |  2 +-
 lldb/source/Commands/CommandObjectType.cpp|  2 +-
 lldb/source/Expression/LLVMUserExpression.cpp |  2 +-
 lldb/source/Expression/UserExpression.cpp | 14 ++--
 lldb/source/Expression/UtilityFunction.cpp|  4 +-
 .../Clang/ClangExpressionParser.cpp   | 12 ++--
 .../Clang/ClangUserExpression.cpp | 19 +++---
 .../Clang/ClangUserExpression.h   |  6 +-
 .../TypeSystem/Clang/TypeSystemClang.cpp  |  2 +-
 .../TypeSystem/Clang/TypeSystemClang.h| 12 ++--
 lldb/source/Target/Language.cpp   | 34 ++
 lldb/source/Target/StackFrame.cpp | 23 +++
 lldb/source/Target/Target.cpp | 21 +++---
 lldb/test/API/lit.cfg.py  |  3 +
 lldb/utils/TableGen/CMakeLists.txt|  1 +
 lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp| 67 +++
 lldb/utils/TableGen/LLDBTableGen.cpp  |  9 ++-
 lldb/utils/TableGen/LLDBTableGenBackends.h|  1 +
 34 files changed, 298 insertions(+), 122 deletions(-)
 create mode 100644 lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp

diff --git a/lldb/include/lldb/API/SBExpressionOptions.h 
b/lldb/include/lldb/API/SBExpressionOptions.h
index e0ddfda5ba37a2..19c416d0f3bcbc 100644
--- a/lldb/include/lldb/API/SBExpressionOptions.h
+++ b/lldb/include/lldb/API/SBExpressionOptions.h
@@ -10,6 +10,7 @@
 #define LLDB_API_SBEXPRESSIONOPTIONS_H
 
 #include "lldb/API/SBDefines.h"
+#include "lldb/API/SBLanguages.h"
 
 #include 
 
@@ -67,6 +68,10 @@ class LLDB_API SBExpressionOptions {
   void SetTrapExceptions(bool trap_exceptions = true);
 
   void SetLanguage(lldb::LanguageType language);
+  /// Set the language using a pair of language code and version as
+  /// defined by the DWARF 6 specification.
+  /// WARNING: These codes may change until DWARF 6 is finalized.
+  void SetLanguage(SBSourceLanguageName name, uint32_t version);
 
 #ifndef SWIG
   void SetCancelCallback(lldb::ExpressionCancelCallback callback, void *baton);
diff --git a/lldb/include/lldb/Expression/Expression.h 
b/lldb/include/lldb/Expression/Expression.h
index 3e61d78828bbbf..356fe4b82ae43a 100644
--- a/lldb/include/lldb/Expression/Expression.h
+++ b/lldb/include/lldb/Expression/Expression.h
@@ -47,11 +47,8 @@ class Expression {
   /// expression.  Text() should contain the definition of this function.
   virtual const char *FunctionName() = 0;
 
-  /// Return the language that should be used when parsing.  To use the
-  /// default, return eLanguageTypeUnknown.
-  virtual lldb::LanguageType Language() const {
-return lldb::eLanguageTypeUnknown;
-  }
+  /// Return the language that should be used when parsing.
+  virtual SourceLanguage Language() const { return {}; }
 
   /// Return the Materializer that the parser should use when registering
   /// external values.
diff --git a/lldb/include/lldb/Expression/LLVMUserExpression.h 
b/lldb/include/lldb/Expression/LLVMUserExpression.h
index 7d32d17dbf544c..40b463933c07e8 100644
--- a/lldb/include/lldb/Expression/LLVMUserExpression.h
+++ b/lldb/include/lldb/Expression/LLVMUserExpression.h
@@ -52,7 +52,7 @@ class LLVMUserExpression : public UserEx

[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-26 Thread Jonas Devlieghere via lldb-commits


@@ -239,6 +239,9 @@ def delete_module_cache(path):
 if is_configured("server"):
 dotest_cmd += ["--server", config.server]
 
+if is_configured("lldb_built_include_dir"):
+dotest_cmd += ["--lldb-built-include-dir", config.lldb_built_include_dir]

JDevlieghere wrote:

If you do:
```
 is_configured("config.lldb_obj_root"):
  dotest_cmd += ["--lldb-built-include-dir", os.path.join(config.lldb_obj_root, 
'include')] 
```

you can get rid of `config.lldb_built_include_dir`. 

https://github.com/llvm/llvm-project/pull/89981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-26 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/89981

>From e9b2e98cfe0383b53d2d875f070a63c2ccffe3d3 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Wed, 24 Apr 2024 12:50:43 -0700
Subject: [PATCH] Add a new SBExpressionOptions::SetLanguage() API (NFCI)

that separates out language and version. To avoid reinventing the
wheel and introducing subtle incompatibilities, this API uses the
table of languages and versiond defined by the upcoming DWARF 6
standard (https://dwarfstd.org/languages-v6.html). While the DWARF 6
spec is not finialized, the list of languages is broadly considered
stable.

The primary motivation for this is to allow the Swift language plugin
to switch between language dialects between, e.g., Swift 5.9 and 6.0
with out introducing a ton of new language codes. On the main branch
this change is considered NFC.
---
 lldb/include/lldb/API/SBExpressionOptions.h   |  5 ++
 lldb/include/lldb/Expression/Expression.h |  7 +-
 .../lldb/Expression/LLVMUserExpression.h  |  2 +-
 lldb/include/lldb/Expression/UserExpression.h | 33 -
 lldb/include/lldb/Symbol/TypeSystem.h | 10 ++-
 lldb/include/lldb/Target/StackFrame.h | 11 ++-
 lldb/include/lldb/Target/Target.h | 19 --
 lldb/include/lldb/lldb-private-types.h| 19 ++
 .../Python/lldbsuite/test/configuration.py|  1 +
 lldb/packages/Python/lldbsuite/test/dotest.py |  3 +
 .../Python/lldbsuite/test/dotest_args.py  |  6 ++
 .../Python/lldbsuite/test/lldbtest.py | 19 --
 lldb/source/API/CMakeLists.txt|  7 ++
 lldb/source/API/SBExpressionOptions.cpp   |  7 ++
 lldb/source/API/SBFrame.cpp   | 30 +
 lldb/source/Breakpoint/Watchpoint.cpp |  5 +-
 .../Commands/CommandObjectDWIMPrint.cpp   |  2 +-
 lldb/source/Commands/CommandObjectType.cpp|  2 +-
 lldb/source/Expression/LLVMUserExpression.cpp |  2 +-
 lldb/source/Expression/UserExpression.cpp | 14 ++--
 lldb/source/Expression/UtilityFunction.cpp|  4 +-
 .../Clang/ClangExpressionParser.cpp   | 12 ++--
 .../Clang/ClangUserExpression.cpp | 19 +++---
 .../Clang/ClangUserExpression.h   |  6 +-
 .../TypeSystem/Clang/TypeSystemClang.cpp  |  2 +-
 .../TypeSystem/Clang/TypeSystemClang.h| 12 ++--
 lldb/source/Target/Language.cpp   | 34 ++
 lldb/source/Target/StackFrame.cpp | 23 +++
 lldb/source/Target/Target.cpp | 21 +++---
 lldb/test/API/lit.cfg.py  |  3 +
 lldb/test/API/lit.site.cfg.py.in  |  1 +
 lldb/utils/TableGen/CMakeLists.txt|  1 +
 lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp| 67 +++
 lldb/utils/TableGen/LLDBTableGen.cpp  |  9 ++-
 lldb/utils/TableGen/LLDBTableGenBackends.h|  1 +
 35 files changed, 298 insertions(+), 121 deletions(-)
 create mode 100644 lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp

diff --git a/lldb/include/lldb/API/SBExpressionOptions.h 
b/lldb/include/lldb/API/SBExpressionOptions.h
index e0ddfda5ba37a2..19c416d0f3bcbc 100644
--- a/lldb/include/lldb/API/SBExpressionOptions.h
+++ b/lldb/include/lldb/API/SBExpressionOptions.h
@@ -10,6 +10,7 @@
 #define LLDB_API_SBEXPRESSIONOPTIONS_H
 
 #include "lldb/API/SBDefines.h"
+#include "lldb/API/SBLanguages.h"
 
 #include 
 
@@ -67,6 +68,10 @@ class LLDB_API SBExpressionOptions {
   void SetTrapExceptions(bool trap_exceptions = true);
 
   void SetLanguage(lldb::LanguageType language);
+  /// Set the language using a pair of language code and version as
+  /// defined by the DWARF 6 specification.
+  /// WARNING: These codes may change until DWARF 6 is finalized.
+  void SetLanguage(SBSourceLanguageName name, uint32_t version);
 
 #ifndef SWIG
   void SetCancelCallback(lldb::ExpressionCancelCallback callback, void *baton);
diff --git a/lldb/include/lldb/Expression/Expression.h 
b/lldb/include/lldb/Expression/Expression.h
index 3e61d78828bbbf..356fe4b82ae43a 100644
--- a/lldb/include/lldb/Expression/Expression.h
+++ b/lldb/include/lldb/Expression/Expression.h
@@ -47,11 +47,8 @@ class Expression {
   /// expression.  Text() should contain the definition of this function.
   virtual const char *FunctionName() = 0;
 
-  /// Return the language that should be used when parsing.  To use the
-  /// default, return eLanguageTypeUnknown.
-  virtual lldb::LanguageType Language() const {
-return lldb::eLanguageTypeUnknown;
-  }
+  /// Return the language that should be used when parsing.
+  virtual SourceLanguage Language() const { return {}; }
 
   /// Return the Materializer that the parser should use when registering
   /// external values.
diff --git a/lldb/include/lldb/Expression/LLVMUserExpression.h 
b/lldb/include/lldb/Expression/LLVMUserExpression.h
index 7d32d17dbf544c..40b463933c07e8 100644
--- a/lldb/include/lldb/Expression/LLVMUserExpression.h
+++ b/lldb/include/lldb/Expression/LLVMUserExpression.h
@@ -5

[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-26 Thread Adrian Prantl via lldb-commits


@@ -0,0 +1,45 @@
+//===- LLDBPropertyDefEmitter.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Produce the list of source languages header file fragment for the SBAPI. 
+//
+//===--===//
+
+#include 
+#include 
+namespace lldb_private {
+int EmitSBAPIDWARFEnum(int argc, char **argv) {
+  std::string InputFilename;
+  std::string OutputFilename;
+  std::string DepFilename;
+  // This command line option parser is as robust as the worst shell script.
+  for (int i = 0; i < argc; ++i) {
+if (llvm::StringRef(argv[i]).ends_with("Dwarf.def"))
+  InputFilename = std::string(argv[i]);
+if (llvm::StringRef(argv[i]) == "-o" && i + 1 < argc)
+  OutputFilename = std::string(argv[i + 1]);
+if (llvm::StringRef(argv[i]) == "-d" && i + 1 < argc)
+  DepFilename = std::string(argv[i + 1]);
+  }
+  std::ifstream input(InputFilename);
+  std::ofstream output(OutputFilename);
+  output << "// Do not include this file directly.\n";
+  output << "#ifndef HANDLE_DW_LNAME\n";
+  output << "#error \"Missing macro definition\"\n";
+  output << "#endif\n";
+  std::string line;
+  while (std::getline(input, line)) {
+if (llvm::StringRef(line).starts_with("HANDLE_DW_LNAME"))
+  output << line << '\n';
+  }
+  output << "#undef HANDLE_DW_LNAME\n";

adrian-prantl wrote:

@JDevlieghere Can you take another look? Now we're even generating Doxygen 
comments!

https://github.com/llvm/llvm-project/pull/89981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-26 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/89981

>From e561968f8290b0fbe679950e5743f1f60144d716 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Wed, 24 Apr 2024 12:50:43 -0700
Subject: [PATCH] Add a new SBExpressionOptions::SetLanguage() API (NFCI)

that separates out language and version. To avoid reinventing the
wheel and introducing subtle incompatibilities, this API uses the
table of languages and versiond defined by the upcoming DWARF 6
standard (https://dwarfstd.org/languages-v6.html). While the DWARF 6
spec is not finialized, the list of languages is broadly considered
stable.

The primary motivation for this is to allow the Swift language plugin
to switch between language dialects between, e.g., Swift 5.9 and 6.0
with out introducing a ton of new language codes. On the main branch
this change is considered NFC.
---
 lldb/include/lldb/API/SBExpressionOptions.h   |  5 ++
 lldb/include/lldb/Expression/Expression.h |  7 +-
 .../lldb/Expression/LLVMUserExpression.h  |  2 +-
 lldb/include/lldb/Expression/UserExpression.h | 33 -
 lldb/include/lldb/Symbol/TypeSystem.h | 10 ++-
 lldb/include/lldb/Target/StackFrame.h | 11 ++-
 lldb/include/lldb/Target/Target.h | 19 --
 lldb/include/lldb/lldb-private-types.h| 19 ++
 .../Python/lldbsuite/test/configuration.py|  1 +
 lldb/packages/Python/lldbsuite/test/dotest.py |  3 +
 .../Python/lldbsuite/test/dotest_args.py  |  6 ++
 .../Python/lldbsuite/test/lldbtest.py | 19 --
 lldb/source/API/CMakeLists.txt|  7 ++
 lldb/source/API/SBExpressionOptions.cpp   |  7 ++
 lldb/source/API/SBFrame.cpp   | 30 +
 lldb/source/Breakpoint/Watchpoint.cpp |  5 +-
 .../Commands/CommandObjectDWIMPrint.cpp   |  2 +-
 lldb/source/Commands/CommandObjectType.cpp|  2 +-
 lldb/source/Expression/LLVMUserExpression.cpp |  2 +-
 lldb/source/Expression/UserExpression.cpp | 14 ++--
 lldb/source/Expression/UtilityFunction.cpp|  4 +-
 .../Clang/ClangExpressionParser.cpp   | 12 ++--
 .../Clang/ClangUserExpression.cpp | 19 +++---
 .../Clang/ClangUserExpression.h   |  6 +-
 .../TypeSystem/Clang/TypeSystemClang.cpp  |  2 +-
 .../TypeSystem/Clang/TypeSystemClang.h| 12 ++--
 lldb/source/Target/Language.cpp   | 34 ++
 lldb/source/Target/StackFrame.cpp | 23 +++
 lldb/source/Target/Target.cpp | 21 +++---
 lldb/test/API/lit.cfg.py  |  3 +
 lldb/test/API/lit.site.cfg.py.in  |  1 +
 lldb/utils/TableGen/CMakeLists.txt|  1 +
 lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp| 67 +++
 lldb/utils/TableGen/LLDBTableGen.cpp  |  9 ++-
 lldb/utils/TableGen/LLDBTableGenBackends.h|  1 +
 35 files changed, 298 insertions(+), 121 deletions(-)
 create mode 100644 lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp

diff --git a/lldb/include/lldb/API/SBExpressionOptions.h 
b/lldb/include/lldb/API/SBExpressionOptions.h
index e0ddfda5ba37a2..19c416d0f3bcbc 100644
--- a/lldb/include/lldb/API/SBExpressionOptions.h
+++ b/lldb/include/lldb/API/SBExpressionOptions.h
@@ -10,6 +10,7 @@
 #define LLDB_API_SBEXPRESSIONOPTIONS_H
 
 #include "lldb/API/SBDefines.h"
+#include "lldb/API/SBLanguages.h"
 
 #include 
 
@@ -67,6 +68,10 @@ class LLDB_API SBExpressionOptions {
   void SetTrapExceptions(bool trap_exceptions = true);
 
   void SetLanguage(lldb::LanguageType language);
+  /// Set the language using a pair of language code and version as
+  /// defined by the DWARF 6 specification.
+  /// WARNING: These codes may change until DWARF 6 is finalized.
+  void SetLanguage(SBSourceLanguageName name, uint32_t version);
 
 #ifndef SWIG
   void SetCancelCallback(lldb::ExpressionCancelCallback callback, void *baton);
diff --git a/lldb/include/lldb/Expression/Expression.h 
b/lldb/include/lldb/Expression/Expression.h
index 3e61d78828bbbf..356fe4b82ae43a 100644
--- a/lldb/include/lldb/Expression/Expression.h
+++ b/lldb/include/lldb/Expression/Expression.h
@@ -47,11 +47,8 @@ class Expression {
   /// expression.  Text() should contain the definition of this function.
   virtual const char *FunctionName() = 0;
 
-  /// Return the language that should be used when parsing.  To use the
-  /// default, return eLanguageTypeUnknown.
-  virtual lldb::LanguageType Language() const {
-return lldb::eLanguageTypeUnknown;
-  }
+  /// Return the language that should be used when parsing.
+  virtual SourceLanguage Language() const { return {}; }
 
   /// Return the Materializer that the parser should use when registering
   /// external values.
diff --git a/lldb/include/lldb/Expression/LLVMUserExpression.h 
b/lldb/include/lldb/Expression/LLVMUserExpression.h
index 7d32d17dbf544c..40b463933c07e8 100644
--- a/lldb/include/lldb/Expression/LLVMUserExpression.h
+++ b/lldb/include/lldb/Expression/LLVMUserExpression.h
@@ -5

[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-26 Thread Jonas Devlieghere via lldb-commits


@@ -0,0 +1,45 @@
+//===- LLDBPropertyDefEmitter.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Produce the list of source languages header file fragment for the SBAPI. 
+//
+//===--===//
+
+#include 
+#include 
+namespace lldb_private {
+int EmitSBAPIDWARFEnum(int argc, char **argv) {
+  std::string InputFilename;
+  std::string OutputFilename;
+  std::string DepFilename;
+  // This command line option parser is as robust as the worst shell script.
+  for (int i = 0; i < argc; ++i) {
+if (llvm::StringRef(argv[i]).ends_with("Dwarf.def"))
+  InputFilename = std::string(argv[i]);
+if (llvm::StringRef(argv[i]) == "-o" && i + 1 < argc)
+  OutputFilename = std::string(argv[i + 1]);
+if (llvm::StringRef(argv[i]) == "-d" && i + 1 < argc)
+  DepFilename = std::string(argv[i + 1]);
+  }
+  std::ifstream input(InputFilename);
+  std::ofstream output(OutputFilename);
+  output << "// Do not include this file directly.\n";
+  output << "#ifndef HANDLE_DW_LNAME\n";
+  output << "#error \"Missing macro definition\"\n";
+  output << "#endif\n";
+  std::string line;
+  while (std::getline(input, line)) {
+if (llvm::StringRef(line).starts_with("HANDLE_DW_LNAME"))
+  output << line << '\n';
+  }
+  output << "#undef HANDLE_DW_LNAME\n";

JDevlieghere wrote:

Why not generate `SBSourceLanguageName` directly? It seems tedious that you 
would have to run the preprocessor on the LLDB headers. Does that even work for 
SWIG?

https://github.com/llvm/llvm-project/pull/89981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-26 Thread Jonas Devlieghere via lldb-commits


@@ -10,6 +10,7 @@ config.llvm_build_mode = 
lit_config.substitute("@LLVM_BUILD_MODE@")
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.lldb_obj_root = "@LLDB_BINARY_DIR@"
 config.lldb_src_root = "@LLDB_SOURCE_DIR@"
+config.lldb_built_include_dir = 
lit_config.substitute("@LLDB_BINARY_DIR@/include")

JDevlieghere wrote:

If this is always `@LLDB_BINARY_DIR@/include`, why not use 

```
config.lldb_built_include_dir = os.path.join(config.lldb_obj_root. 'include')
```

or even better: don't create a new variable at all and have dotest derive it 
from `config.lldb_obj_root`? 

https://github.com/llvm/llvm-project/pull/89981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-26 Thread Jonas Devlieghere via lldb-commits


@@ -0,0 +1,45 @@
+//===- LLDBPropertyDefEmitter.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Produce the list of source languages header file fragment for the SBAPI. 
+//
+//===--===//
+
+#include 
+#include 
+namespace lldb_private {
+int EmitSBAPIDWARFEnum(int argc, char **argv) {
+  std::string InputFilename;
+  std::string OutputFilename;
+  std::string DepFilename;
+  // This command line option parser is as robust as the worst shell script.

JDevlieghere wrote:

😂

https://github.com/llvm/llvm-project/pull/89981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-26 Thread Adrian Prantl via lldb-commits


@@ -67,6 +67,10 @@ class LLDB_API SBExpressionOptions {
   void SetTrapExceptions(bool trap_exceptions = true);
 
   void SetLanguage(lldb::LanguageType language);
+  /// Set the language using a pair of language code and version as
+  /// defined by the DWARF 6 specification.
+  /// WARNING: These codes may change until DWARF 6 is finalized.
+  void SetLanguage(uint16_t dwarf_lname_code, uint32_t dwarf_lversion);

adrian-prantl wrote:

@JDevlieghere Can you take another look? This version generates a header file 
in the API directory from LLVM's Dwarf.def and (at least locally) passes the 
testsuite and installs into the include/API directory.

https://github.com/llvm/llvm-project/pull/89981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-26 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/89981

>From 280caa3e26227338071409213646625d05f6eba5 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Wed, 24 Apr 2024 12:50:43 -0700
Subject: [PATCH] Add a new SBExpressionOptions::SetLanguage() API (NFCI)

that separates out language and version. To avoid reinventing the
wheel and introducing subtle incompatibilities, this API uses the
table of languages and versiond defined by the upcoming DWARF 6
standard (https://dwarfstd.org/languages-v6.html). While the DWARF 6
spec is not finialized, the list of languages is broadly considered
stable.

The primary motivation for this is to allow the Swift language plugin
to switch between language dialects between, e.g., Swift 5.9 and 6.0
with out introducing a ton of new language codes. On the main branch
this change is considered NFC.
---
 lldb/include/lldb/API/SBExpressionOptions.h   | 13 ++
 lldb/include/lldb/Expression/Expression.h |  7 +--
 .../lldb/Expression/LLVMUserExpression.h  |  2 +-
 lldb/include/lldb/Expression/UserExpression.h | 33 +++---
 lldb/include/lldb/Symbol/TypeSystem.h | 10 ++---
 lldb/include/lldb/Target/StackFrame.h | 11 +++--
 lldb/include/lldb/Target/Target.h | 19 +---
 lldb/include/lldb/lldb-private-types.h| 25 +++
 .../Python/lldbsuite/test/configuration.py|  1 +
 lldb/packages/Python/lldbsuite/test/dotest.py |  3 ++
 .../Python/lldbsuite/test/dotest_args.py  |  6 +++
 .../Python/lldbsuite/test/lldbtest.py | 19 +---
 lldb/source/API/CMakeLists.txt|  7 +++
 lldb/source/API/SBExpressionOptions.cpp   |  7 +++
 lldb/source/API/SBFrame.cpp   | 30 +++--
 lldb/source/Breakpoint/Watchpoint.cpp |  5 +--
 .../Commands/CommandObjectDWIMPrint.cpp   |  2 +-
 lldb/source/Commands/CommandObjectType.cpp|  2 +-
 lldb/source/Expression/LLVMUserExpression.cpp |  2 +-
 lldb/source/Expression/UserExpression.cpp | 14 +++---
 lldb/source/Expression/UtilityFunction.cpp|  4 +-
 .../Clang/ClangExpressionParser.cpp   | 12 ++---
 .../Clang/ClangUserExpression.cpp | 19 
 .../Clang/ClangUserExpression.h   |  6 +--
 .../TypeSystem/Clang/TypeSystemClang.cpp  |  2 +-
 .../TypeSystem/Clang/TypeSystemClang.h| 12 ++---
 lldb/source/Target/Language.cpp   | 34 ++
 lldb/source/Target/StackFrame.cpp | 23 +-
 lldb/source/Target/Target.cpp | 21 -
 lldb/test/API/lit.cfg.py  |  3 ++
 lldb/test/API/lit.site.cfg.py.in  |  1 +
 lldb/utils/TableGen/CMakeLists.txt|  1 +
 lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp| 45 +++
 lldb/utils/TableGen/LLDBTableGen.cpp  |  9 +++-
 lldb/utils/TableGen/LLDBTableGenBackends.h|  1 +
 35 files changed, 290 insertions(+), 121 deletions(-)
 create mode 100644 lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp

diff --git a/lldb/include/lldb/API/SBExpressionOptions.h 
b/lldb/include/lldb/API/SBExpressionOptions.h
index e0ddfda5ba37a2..10acbdb9683a67 100644
--- a/lldb/include/lldb/API/SBExpressionOptions.h
+++ b/lldb/include/lldb/API/SBExpressionOptions.h
@@ -15,6 +15,15 @@
 
 namespace lldb {
 
+/// Programming language type.
+///
+/// These enumerations use the same language enumerations as the DWARF
+/// specification for ease of use and consistency.
+enum SBSourceLanguageName : uint16_t {
+#define HANDLE_DW_LNAME(ID, NAME, DESC, LOWER_BOUND) eLanguageName##NAME = ID,
+#include "lldb/API/Languages.h"
+};
+
 class LLDB_API SBExpressionOptions {
 public:
   SBExpressionOptions();
@@ -67,6 +76,10 @@ class LLDB_API SBExpressionOptions {
   void SetTrapExceptions(bool trap_exceptions = true);
 
   void SetLanguage(lldb::LanguageType language);
+  /// Set the language using a pair of language code and version as
+  /// defined by the DWARF 6 specification.
+  /// WARNING: These codes may change until DWARF 6 is finalized.
+  void SetLanguage(SBSourceLanguageName name, uint32_t version);
 
 #ifndef SWIG
   void SetCancelCallback(lldb::ExpressionCancelCallback callback, void *baton);
diff --git a/lldb/include/lldb/Expression/Expression.h 
b/lldb/include/lldb/Expression/Expression.h
index 3e61d78828bbbf..356fe4b82ae43a 100644
--- a/lldb/include/lldb/Expression/Expression.h
+++ b/lldb/include/lldb/Expression/Expression.h
@@ -47,11 +47,8 @@ class Expression {
   /// expression.  Text() should contain the definition of this function.
   virtual const char *FunctionName() = 0;
 
-  /// Return the language that should be used when parsing.  To use the
-  /// default, return eLanguageTypeUnknown.
-  virtual lldb::LanguageType Language() const {
-return lldb::eLanguageTypeUnknown;
-  }
+  /// Return the language that should be used when parsing.
+  virtual SourceLanguage Language() const { return {}; }
 
   /// Return the Materializer tha

[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-26 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/89981

>From 762029753f7c21352f653e1719cb6c75107f6a50 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Wed, 24 Apr 2024 12:50:43 -0700
Subject: [PATCH] Add a new SBExpressionOptions::SetLanguage() API (NFCI)

that separates out language and version. To avoid reinventing the
wheel and introducing subtle incompatibilities, this API uses the
table of languages and versiond defined by the upcoming DWARF 6
standard (https://dwarfstd.org/languages-v6.html). While the DWARF 6
spec is not finialized, the list of languages is broadly considered
stable.

The primary motivation for this is to allow the Swift language plugin
to switch between language dialects between, e.g., Swift 5.9 and 6.0
with out introducing a ton of new language codes. On the main branch
this change is considered NFC.
---
 lldb/include/lldb/API/SBExpressionOptions.h   | 13 ++
 lldb/include/lldb/Expression/Expression.h |  7 +--
 .../lldb/Expression/LLVMUserExpression.h  |  2 +-
 lldb/include/lldb/Expression/UserExpression.h | 33 +++---
 lldb/include/lldb/Symbol/TypeSystem.h | 10 ++---
 lldb/include/lldb/Target/StackFrame.h | 11 +++--
 lldb/include/lldb/Target/Target.h | 19 +---
 lldb/include/lldb/lldb-private-types.h| 25 +++
 .../Python/lldbsuite/test/configuration.py|  1 +
 lldb/packages/Python/lldbsuite/test/dotest.py |  3 ++
 .../Python/lldbsuite/test/dotest_args.py  |  6 +++
 .../Python/lldbsuite/test/lldbtest.py |  6 ++-
 lldb/source/API/CMakeLists.txt|  7 +++
 lldb/source/API/SBExpressionOptions.cpp   |  7 +++
 lldb/source/API/SBFrame.cpp   | 30 +++--
 lldb/source/Breakpoint/Watchpoint.cpp |  5 +--
 .../Commands/CommandObjectDWIMPrint.cpp   |  2 +-
 lldb/source/Commands/CommandObjectType.cpp|  2 +-
 lldb/source/Expression/LLVMUserExpression.cpp |  2 +-
 lldb/source/Expression/UserExpression.cpp | 14 +++---
 lldb/source/Expression/UtilityFunction.cpp|  4 +-
 .../Clang/ClangExpressionParser.cpp   | 12 ++---
 .../Clang/ClangUserExpression.cpp | 19 
 .../Clang/ClangUserExpression.h   |  6 +--
 .../TypeSystem/Clang/TypeSystemClang.cpp  |  2 +-
 .../TypeSystem/Clang/TypeSystemClang.h| 12 ++---
 lldb/source/Target/Language.cpp   | 34 ++
 lldb/source/Target/StackFrame.cpp | 23 +-
 lldb/source/Target/Target.cpp | 21 -
 .../api/multithreaded/TestMultithreaded.py|  1 +
 lldb/test/API/lit.cfg.py  |  3 ++
 lldb/test/API/lit.site.cfg.py.in  |  1 +
 lldb/utils/TableGen/CMakeLists.txt|  1 +
 lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp| 45 +++
 lldb/utils/TableGen/LLDBTableGen.cpp  |  9 +++-
 lldb/utils/TableGen/LLDBTableGenBackends.h|  1 +
 36 files changed, 283 insertions(+), 116 deletions(-)
 create mode 100644 lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp

diff --git a/lldb/include/lldb/API/SBExpressionOptions.h 
b/lldb/include/lldb/API/SBExpressionOptions.h
index e0ddfda5ba37a2..10acbdb9683a67 100644
--- a/lldb/include/lldb/API/SBExpressionOptions.h
+++ b/lldb/include/lldb/API/SBExpressionOptions.h
@@ -15,6 +15,15 @@
 
 namespace lldb {
 
+/// Programming language type.
+///
+/// These enumerations use the same language enumerations as the DWARF
+/// specification for ease of use and consistency.
+enum SBSourceLanguageName : uint16_t {
+#define HANDLE_DW_LNAME(ID, NAME, DESC, LOWER_BOUND) eLanguageName##NAME = ID,
+#include "lldb/API/Languages.h"
+};
+
 class LLDB_API SBExpressionOptions {
 public:
   SBExpressionOptions();
@@ -67,6 +76,10 @@ class LLDB_API SBExpressionOptions {
   void SetTrapExceptions(bool trap_exceptions = true);
 
   void SetLanguage(lldb::LanguageType language);
+  /// Set the language using a pair of language code and version as
+  /// defined by the DWARF 6 specification.
+  /// WARNING: These codes may change until DWARF 6 is finalized.
+  void SetLanguage(SBSourceLanguageName name, uint32_t version);
 
 #ifndef SWIG
   void SetCancelCallback(lldb::ExpressionCancelCallback callback, void *baton);
diff --git a/lldb/include/lldb/Expression/Expression.h 
b/lldb/include/lldb/Expression/Expression.h
index 3e61d78828bbbf..356fe4b82ae43a 100644
--- a/lldb/include/lldb/Expression/Expression.h
+++ b/lldb/include/lldb/Expression/Expression.h
@@ -47,11 +47,8 @@ class Expression {
   /// expression.  Text() should contain the definition of this function.
   virtual const char *FunctionName() = 0;
 
-  /// Return the language that should be used when parsing.  To use the
-  /// default, return eLanguageTypeUnknown.
-  virtual lldb::LanguageType Language() const {
-return lldb::eLanguageTypeUnknown;
-  }
+  /// Return the language that should be used when parsing.
+  virtual SourceLanguage Language() const { 

[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-26 Thread via lldb-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r 
300340f656d762afa8bde5fc398757d2951560bf...aba61b23b402f350161139adfffc3799a3135c8a
 lldb/packages/Python/lldbsuite/test/configuration.py 
lldb/packages/Python/lldbsuite/test/dotest.py 
lldb/packages/Python/lldbsuite/test/dotest_args.py 
lldb/packages/Python/lldbsuite/test/lldbtest.py 
lldb/test/API/api/multithreaded/TestMultithreaded.py lldb/test/API/lit.cfg.py
``





View the diff from darker here.


``diff
--- test/API/api/multithreaded/TestMultithreaded.py 2024-04-26 
19:25:57.00 +
+++ test/API/api/multithreaded/TestMultithreaded.py 2024-04-26 
19:28:58.154176 +
@@ -105,11 +105,13 @@
 
 self.inferior = "inferior_program"
 self.buildProgram("inferior.cpp", self.inferior)
 self.addTearDownHook(lambda: 
os.remove(self.getBuildArtifact(self.inferior)))
 
-import pdb;pdb.set_trace()
+import pdb
+
+pdb.set_trace()
 self.buildDriver(sources, test_name)
 self.addTearDownHook(lambda: 
os.remove(self.getBuildArtifact(test_name)))
 
 test_exe = self.getBuildArtifact(test_name)
 exe = [test_exe, self.getBuildArtifact(self.inferior)]

``




https://github.com/llvm/llvm-project/pull/89981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-26 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/89981

>From aba61b23b402f350161139adfffc3799a3135c8a Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Wed, 24 Apr 2024 12:50:43 -0700
Subject: [PATCH] Add a new SBExpressionOptions::SetLanguage() API (NFCI)

that separates out language and version. To avoid reinventing the
wheel and introducing subtle incompatibilities, this API uses the
table of languages and versiond defined by the upcoming DWARF 6
standard (https://dwarfstd.org/languages-v6.html). While the DWARF 6
spec is not finialized, the list of languages is broadly considered
stable.

The primary motivation for this is to allow the Swift language plugin
to switch between language dialects between, e.g., Swift 5.9 and 6.0
with out introducing a ton of new language codes. On the main branch
this change is considered NFC.
---
 lldb/include/lldb/API/SBExpressionOptions.h   | 13 ++
 lldb/include/lldb/Expression/Expression.h |  7 +---
 .../lldb/Expression/LLVMUserExpression.h  |  2 +-
 lldb/include/lldb/Expression/UserExpression.h | 33 ---
 lldb/include/lldb/Symbol/TypeSystem.h | 10 ++---
 lldb/include/lldb/Target/StackFrame.h | 11 +++--
 lldb/include/lldb/Target/Target.h | 19 ++---
 lldb/include/lldb/lldb-private-types.h| 19 +
 .../Python/lldbsuite/test/configuration.py|  1 +
 lldb/packages/Python/lldbsuite/test/dotest.py |  3 ++
 .../Python/lldbsuite/test/dotest_args.py  |  6 +++
 .../Python/lldbsuite/test/lldbtest.py |  6 ++-
 lldb/source/API/CMakeLists.txt|  7 
 lldb/source/API/SBExpressionOptions.cpp   |  7 
 lldb/source/API/SBFrame.cpp   | 30 --
 lldb/source/Breakpoint/Watchpoint.cpp |  5 +--
 .../Commands/CommandObjectDWIMPrint.cpp   |  2 +-
 lldb/source/Commands/CommandObjectType.cpp|  2 +-
 lldb/source/Expression/LLVMUserExpression.cpp |  2 +-
 lldb/source/Expression/UserExpression.cpp | 14 ---
 lldb/source/Expression/UtilityFunction.cpp|  4 +-
 .../Clang/ClangExpressionParser.cpp   | 12 +++---
 .../Clang/ClangUserExpression.cpp | 19 -
 .../Clang/ClangUserExpression.h   |  6 +--
 .../TypeSystem/Clang/TypeSystemClang.cpp  |  2 +-
 .../TypeSystem/Clang/TypeSystemClang.h| 12 +++---
 lldb/source/Target/Language.cpp   | 34 
 lldb/source/Target/StackFrame.cpp | 23 +--
 lldb/source/Target/Target.cpp | 21 +-
 .../api/multithreaded/TestMultithreaded.py|  1 +
 lldb/test/API/lit.cfg.py  |  3 ++
 lldb/test/API/lit.site.cfg.py.in  |  1 +
 lldb/utils/TableGen/CMakeLists.txt|  1 +
 lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp| 40 +++
 lldb/utils/TableGen/LLDBTableGen.cpp  |  9 -
 lldb/utils/TableGen/LLDBTableGenBackends.h|  1 +
 36 files changed, 272 insertions(+), 116 deletions(-)
 create mode 100644 lldb/utils/TableGen/LLDBSBAPIDWARFEnum.cpp

diff --git a/lldb/include/lldb/API/SBExpressionOptions.h 
b/lldb/include/lldb/API/SBExpressionOptions.h
index e0ddfda5ba37a2..0742b975ed5ed0 100644
--- a/lldb/include/lldb/API/SBExpressionOptions.h
+++ b/lldb/include/lldb/API/SBExpressionOptions.h
@@ -15,6 +15,15 @@
 
 namespace lldb {
 
+/// Programming language type.
+///
+/// These enumerations use the same language enumerations as the DWARF
+/// specification for ease of use and consistency.
+enum SBSourceLanguageName : uint16_t {
+#define HANDLE_DW_LNAME(ID, NAME, DESC, LOWER_BOUND) eLanguageName##NAME = ID,
+#include "lldb/API/Languages.h"
+};
+  
 class LLDB_API SBExpressionOptions {
 public:
   SBExpressionOptions();
@@ -67,6 +76,10 @@ class LLDB_API SBExpressionOptions {
   void SetTrapExceptions(bool trap_exceptions = true);
 
   void SetLanguage(lldb::LanguageType language);
+  /// Set the language using a pair of language code and version as
+  /// defined by the DWARF 6 specification.
+  /// WARNING: These codes may change until DWARF 6 is finalized.
+  void SetLanguage(uint16_t dwarf_lname_code, uint32_t dwarf_lversion);
 
 #ifndef SWIG
   void SetCancelCallback(lldb::ExpressionCancelCallback callback, void *baton);
diff --git a/lldb/include/lldb/Expression/Expression.h 
b/lldb/include/lldb/Expression/Expression.h
index 3e61d78828bbbf..356fe4b82ae43a 100644
--- a/lldb/include/lldb/Expression/Expression.h
+++ b/lldb/include/lldb/Expression/Expression.h
@@ -47,11 +47,8 @@ class Expression {
   /// expression.  Text() should contain the definition of this function.
   virtual const char *FunctionName() = 0;
 
-  /// Return the language that should be used when parsing.  To use the
-  /// default, return eLanguageTypeUnknown.
-  virtual lldb::LanguageType Language() const {
-return lldb::eLanguageTypeUnknown;
-  }
+  /// Return the language that should be used when parsing.
+  virtual SourceLangua

[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-25 Thread Jonas Devlieghere via lldb-commits


@@ -67,6 +67,10 @@ class LLDB_API SBExpressionOptions {
   void SetTrapExceptions(bool trap_exceptions = true);
 
   void SetLanguage(lldb::LanguageType language);
+  /// Set the language using a pair of language code and version as
+  /// defined by the DWARF 6 specification.
+  /// WARNING: These codes may change until DWARF 6 is finalized.
+  void SetLanguage(uint16_t dwarf_lname_code, uint32_t dwarf_lversion);

JDevlieghere wrote:

This feels wrong. How would you feel about exposing `SourceLanguage` as 
`SBSourceLanguage` and having a SetLanguage overload that takes that as an 
argument? It seems like a small difference, but I think it conceptually makes 
sense to initialize an `SBSourceLanguage` with a dwarf code/version.

As an added benefit it's also more future proof, if we need to extend the 
class, or want to use it elsewhere in the SB API where we currently use 
`lldb::LanguageType`. A quick grep shows 21 instances of `lldb::LanguageType` 
and if we thread this through more I could imagine wanting to have the ability 
of passing an `SBSourceLanguage` like we do here. 

https://github.com/llvm/llvm-project/pull/89981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-25 Thread Adrian Prantl via lldb-commits


@@ -1203,26 +1203,23 @@ bool StackFrame::IsArtificial() const {
   return m_stack_frame_kind == StackFrame::Kind::Artificial;
 }
 
-lldb::LanguageType StackFrame::GetLanguage() {
+SourceLanguage StackFrame::GetLanguage() {
   CompileUnit *cu = GetSymbolContext(eSymbolContextCompUnit).comp_unit;
   if (cu)
 return cu->GetLanguage();
-  return lldb::eLanguageTypeUnknown;
+  return {};
 }
 
-lldb::LanguageType StackFrame::GuessLanguage() {
-  LanguageType lang_type = GetLanguage();
+SourceLanguage StackFrame::GuessLanguage() {
+  SourceLanguage lang_type = GetLanguage();
 
   if (lang_type == eLanguageTypeUnknown) {
-SymbolContext sc = GetSymbolContext(eSymbolContextFunction
-| eSymbolContextSymbol);
-if (sc.function) {
-  lang_type = sc.function->GetMangled().GuessLanguage();
-}
+SymbolContext sc =
+GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol);
+if (sc.function)
+  lang_type = LanguageType(sc.function->GetMangled().GuessLanguage());

adrian-prantl wrote:

Good point! I also wanted to make clear that my intention would be to 
eventually deprecate eLanguageType and replace all uses with the superior split 
SourceLanguage. I just had to stop _somewhere_ for this first iteration of the 
patch. But this is not meant to be the final state.

https://github.com/llvm/llvm-project/pull/89981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-25 Thread Michael Buch via lldb-commits

https://github.com/Michael137 edited 
https://github.com/llvm/llvm-project/pull/89981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-25 Thread Michael Buch via lldb-commits

https://github.com/Michael137 approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/89981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-25 Thread Michael Buch via lldb-commits


@@ -1203,26 +1203,23 @@ bool StackFrame::IsArtificial() const {
   return m_stack_frame_kind == StackFrame::Kind::Artificial;
 }
 
-lldb::LanguageType StackFrame::GetLanguage() {
+SourceLanguage StackFrame::GetLanguage() {
   CompileUnit *cu = GetSymbolContext(eSymbolContextCompUnit).comp_unit;
   if (cu)
 return cu->GetLanguage();
-  return lldb::eLanguageTypeUnknown;
+  return {};
 }
 
-lldb::LanguageType StackFrame::GuessLanguage() {
-  LanguageType lang_type = GetLanguage();
+SourceLanguage StackFrame::GuessLanguage() {
+  SourceLanguage lang_type = GetLanguage();
 
   if (lang_type == eLanguageTypeUnknown) {
-SymbolContext sc = GetSymbolContext(eSymbolContextFunction
-| eSymbolContextSymbol);
-if (sc.function) {
-  lang_type = sc.function->GetMangled().GuessLanguage();
-}
+SymbolContext sc =
+GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol);
+if (sc.function)
+  lang_type = LanguageType(sc.function->GetMangled().GuessLanguage());

Michael137 wrote:

This works because the `SourceLanguage(LanguageType)` constructor isn't marked 
explicit. Would it be clearer to mark it explicit and instead rewrite this as 
`SourceLanguage(sc.function->GetMangled().GuessLanguage())`

https://github.com/llvm/llvm-project/pull/89981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-24 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/89981

>From 5bd7d3da1cd1c9ec508e0fbd96c8d9f2509ee900 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Wed, 24 Apr 2024 12:50:43 -0700
Subject: [PATCH] Add a new SBExpressionOptions::SetLanguage() API (NFCI)

that separates out language and version. To avoid reinventing the
wheel and introducing subtle incompatibilities, this API uses the
table of languages and versiond defined by the upcoming DWARF 6
standard (https://dwarfstd.org/languages-v6.html). While the DWARF 6
spec is not finialized, the list of languages is broadly considered
stable.

The primary motivation for this is to allow the Swift language plugin
to switch between language dialects between, e.g., Swift 5.9 and 6.0
with out introducing a ton of new language codes. On the main branch
this change is considered NFC.
---
 lldb/include/lldb/API/SBExpressionOptions.h   |  4 +++
 lldb/include/lldb/Expression/Expression.h |  7 ++--
 .../lldb/Expression/LLVMUserExpression.h  |  2 +-
 lldb/include/lldb/Expression/UserExpression.h | 33 ++
 lldb/include/lldb/Symbol/TypeSystem.h | 10 +++---
 lldb/include/lldb/Target/StackFrame.h | 11 +++---
 lldb/include/lldb/Target/Target.h | 19 ---
 lldb/include/lldb/lldb-private-types.h| 19 +++
 lldb/source/API/SBExpressionOptions.cpp   |  7 
 lldb/source/API/SBFrame.cpp   | 30 +---
 lldb/source/Breakpoint/Watchpoint.cpp |  5 ++-
 .../Commands/CommandObjectDWIMPrint.cpp   |  2 +-
 lldb/source/Commands/CommandObjectType.cpp|  2 +-
 lldb/source/Expression/LLVMUserExpression.cpp |  2 +-
 lldb/source/Expression/UserExpression.cpp | 14 
 lldb/source/Expression/UtilityFunction.cpp|  4 +--
 .../Clang/ClangExpressionParser.cpp   | 12 +++
 .../Clang/ClangUserExpression.cpp | 19 ++-
 .../Clang/ClangUserExpression.h   |  6 ++--
 .../TypeSystem/Clang/TypeSystemClang.cpp  |  2 +-
 .../TypeSystem/Clang/TypeSystemClang.h| 12 +++
 lldb/source/Target/Language.cpp   | 34 +++
 lldb/source/Target/StackFrame.cpp | 23 ++---
 lldb/source/Target/Target.cpp | 21 ++--
 24 files changed, 187 insertions(+), 113 deletions(-)

diff --git a/lldb/include/lldb/API/SBExpressionOptions.h 
b/lldb/include/lldb/API/SBExpressionOptions.h
index e0ddfda5ba37a2..0f2d298d7513fe 100644
--- a/lldb/include/lldb/API/SBExpressionOptions.h
+++ b/lldb/include/lldb/API/SBExpressionOptions.h
@@ -67,6 +67,10 @@ class LLDB_API SBExpressionOptions {
   void SetTrapExceptions(bool trap_exceptions = true);
 
   void SetLanguage(lldb::LanguageType language);
+  /// Set the language using a pair of language code and version as
+  /// defined by the DWARF 6 specification.
+  /// WARNING: These codes may change until DWARF 6 is finalized.
+  void SetLanguage(uint16_t dwarf_lname_code, uint32_t dwarf_lversion);
 
 #ifndef SWIG
   void SetCancelCallback(lldb::ExpressionCancelCallback callback, void *baton);
diff --git a/lldb/include/lldb/Expression/Expression.h 
b/lldb/include/lldb/Expression/Expression.h
index 3e61d78828bbbf..356fe4b82ae43a 100644
--- a/lldb/include/lldb/Expression/Expression.h
+++ b/lldb/include/lldb/Expression/Expression.h
@@ -47,11 +47,8 @@ class Expression {
   /// expression.  Text() should contain the definition of this function.
   virtual const char *FunctionName() = 0;
 
-  /// Return the language that should be used when parsing.  To use the
-  /// default, return eLanguageTypeUnknown.
-  virtual lldb::LanguageType Language() const {
-return lldb::eLanguageTypeUnknown;
-  }
+  /// Return the language that should be used when parsing.
+  virtual SourceLanguage Language() const { return {}; }
 
   /// Return the Materializer that the parser should use when registering
   /// external values.
diff --git a/lldb/include/lldb/Expression/LLVMUserExpression.h 
b/lldb/include/lldb/Expression/LLVMUserExpression.h
index 7d32d17dbf544c..40b463933c07e8 100644
--- a/lldb/include/lldb/Expression/LLVMUserExpression.h
+++ b/lldb/include/lldb/Expression/LLVMUserExpression.h
@@ -52,7 +52,7 @@ class LLVMUserExpression : public UserExpression {
   };
 
   LLVMUserExpression(ExecutionContextScope &exe_scope, llvm::StringRef expr,
- llvm::StringRef prefix, lldb::LanguageType language,
+ llvm::StringRef prefix, SourceLanguage language,
  ResultType desired_type,
  const EvaluateExpressionOptions &options);
   ~LLVMUserExpression() override;
diff --git a/lldb/include/lldb/Expression/UserExpression.h 
b/lldb/include/lldb/Expression/UserExpression.h
index b6cfeec7e89933..b04d00b72e8faa 100644
--- a/lldb/include/lldb/Expression/UserExpression.h
+++ b/lldb/include/lldb/Expression/UserExpression.h
@@ -56,7 +56,7 @@ class UserExpression : pub

[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-24 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 9e9595183001991a7d31d8880c4a2b33594ca30f 
7e63653359ee0cfe251091017a4265aaea3770e3 -- 
lldb/include/lldb/API/SBExpressionOptions.h 
lldb/include/lldb/Expression/Expression.h 
lldb/include/lldb/Expression/LLVMUserExpression.h 
lldb/include/lldb/Expression/UserExpression.h 
lldb/include/lldb/Symbol/TypeSystem.h lldb/include/lldb/Target/StackFrame.h 
lldb/include/lldb/Target/Target.h lldb/include/lldb/lldb-private-types.h 
lldb/source/API/SBExpressionOptions.cpp lldb/source/API/SBFrame.cpp 
lldb/source/Breakpoint/Watchpoint.cpp 
lldb/source/Commands/CommandObjectDWIMPrint.cpp 
lldb/source/Commands/CommandObjectType.cpp 
lldb/source/Expression/LLVMUserExpression.cpp 
lldb/source/Expression/UserExpression.cpp 
lldb/source/Expression/UtilityFunction.cpp 
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp 
lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h 
lldb/source/Target/Language.cpp lldb/source/Target/StackFrame.cpp 
lldb/source/Target/Target.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Target/Language.cpp b/lldb/source/Target/Language.cpp
index 3d7bae0b82..d0bffe441f 100644
--- a/lldb/source/Target/Language.cpp
+++ b/lldb/source/Target/Language.cpp
@@ -19,8 +19,8 @@
 #include "lldb/Target/Target.h"
 #include "lldb/Utility/Stream.h"
 
-#include "llvm/Support/Threading.h"
 #include "llvm/BinaryFormat/Dwarf.h"
+#include "llvm/Support/Threading.h"
 
 using namespace lldb;
 using namespace lldb_private;

``




https://github.com/llvm/llvm-project/pull/89981
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-24 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Adrian Prantl (adrian-prantl)


Changes

that separates out language and version. To avoid reinventing the wheel and 
introducing subtle incompatibilities, this API uses the table of languages and 
versiond defined by the upcoming DWARF 6 standard 
(https://dwarfstd.org/languages-v6.html). While the DWARF 6 spec is not 
finialized, the list of languages is broadly considered stable.

The primary motivation for this is to allow the Swift language plugin to switch 
between language dialects between, e.g., Swift 5.9 and 6.0 with out introducing 
a ton of new language codes. On the main branch this change is considered NFC.

Depends on https://github.com/llvm/llvm-project/pull/89980

---

Patch is 34.69 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/89981.diff


24 Files Affected:

- (modified) lldb/include/lldb/API/SBExpressionOptions.h (+4) 
- (modified) lldb/include/lldb/Expression/Expression.h (+2-5) 
- (modified) lldb/include/lldb/Expression/LLVMUserExpression.h (+1-1) 
- (modified) lldb/include/lldb/Expression/UserExpression.h (+18-15) 
- (modified) lldb/include/lldb/Symbol/TypeSystem.h (+4-6) 
- (modified) lldb/include/lldb/Target/StackFrame.h (+5-6) 
- (modified) lldb/include/lldb/Target/Target.h (+14-5) 
- (modified) lldb/include/lldb/lldb-private-types.h (+19) 
- (modified) lldb/source/API/SBExpressionOptions.cpp (+7) 
- (modified) lldb/source/API/SBFrame.cpp (+17-13) 
- (modified) lldb/source/Breakpoint/Watchpoint.cpp (+2-3) 
- (modified) lldb/source/Commands/CommandObjectDWIMPrint.cpp (+1-1) 
- (modified) lldb/source/Commands/CommandObjectType.cpp (+1-1) 
- (modified) lldb/source/Expression/LLVMUserExpression.cpp (+1-1) 
- (modified) lldb/source/Expression/UserExpression.cpp (+8-6) 
- (modified) lldb/source/Expression/UtilityFunction.cpp (+2-2) 
- (modified) 
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp (+6-6) 
- (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp 
(+10-9) 
- (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h 
(+3-3) 
- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+1-1) 
- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h (+6-6) 
- (modified) lldb/source/Target/Language.cpp (+34) 
- (modified) lldb/source/Target/StackFrame.cpp (+10-13) 
- (modified) lldb/source/Target/Target.cpp (+11-10) 


``diff
diff --git a/lldb/include/lldb/API/SBExpressionOptions.h 
b/lldb/include/lldb/API/SBExpressionOptions.h
index e0ddfda5ba37a2..0f2d298d7513fe 100644
--- a/lldb/include/lldb/API/SBExpressionOptions.h
+++ b/lldb/include/lldb/API/SBExpressionOptions.h
@@ -67,6 +67,10 @@ class LLDB_API SBExpressionOptions {
   void SetTrapExceptions(bool trap_exceptions = true);
 
   void SetLanguage(lldb::LanguageType language);
+  /// Set the language using a pair of language code and version as
+  /// defined by the DWARF 6 specification.
+  /// WARNING: These codes may change until DWARF 6 is finalized.
+  void SetLanguage(uint16_t dwarf_lname_code, uint32_t dwarf_lversion);
 
 #ifndef SWIG
   void SetCancelCallback(lldb::ExpressionCancelCallback callback, void *baton);
diff --git a/lldb/include/lldb/Expression/Expression.h 
b/lldb/include/lldb/Expression/Expression.h
index 3e61d78828bbbf..356fe4b82ae43a 100644
--- a/lldb/include/lldb/Expression/Expression.h
+++ b/lldb/include/lldb/Expression/Expression.h
@@ -47,11 +47,8 @@ class Expression {
   /// expression.  Text() should contain the definition of this function.
   virtual const char *FunctionName() = 0;
 
-  /// Return the language that should be used when parsing.  To use the
-  /// default, return eLanguageTypeUnknown.
-  virtual lldb::LanguageType Language() const {
-return lldb::eLanguageTypeUnknown;
-  }
+  /// Return the language that should be used when parsing.
+  virtual SourceLanguage Language() const { return {}; }
 
   /// Return the Materializer that the parser should use when registering
   /// external values.
diff --git a/lldb/include/lldb/Expression/LLVMUserExpression.h 
b/lldb/include/lldb/Expression/LLVMUserExpression.h
index 7d32d17dbf544c..40b463933c07e8 100644
--- a/lldb/include/lldb/Expression/LLVMUserExpression.h
+++ b/lldb/include/lldb/Expression/LLVMUserExpression.h
@@ -52,7 +52,7 @@ class LLVMUserExpression : public UserExpression {
   };
 
   LLVMUserExpression(ExecutionContextScope &exe_scope, llvm::StringRef expr,
- llvm::StringRef prefix, lldb::LanguageType language,
+ llvm::StringRef prefix, SourceLanguage language,
  ResultType desired_type,
  const EvaluateExpressionOptions &options);
   ~LLVMUserExpression() override;
diff --git a/lldb/include/lldb/Expression/UserExpression.h 
b/lldb/include/lldb/Expression/UserExpression.h
index b6cfeec7e89933..b04d00b72e8faa 100644
--- a/lldb/include/lldb/Expression/UserExpression

[Lldb-commits] [lldb] Add a new SBExpressionOptions::SetLanguage() API (NFCI) (PR #89981)

2024-04-24 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl created 
https://github.com/llvm/llvm-project/pull/89981

that separates out language and version. To avoid reinventing the wheel and 
introducing subtle incompatibilities, this API uses the table of languages and 
versiond defined by the upcoming DWARF 6 standard 
(https://dwarfstd.org/languages-v6.html). While the DWARF 6 spec is not 
finialized, the list of languages is broadly considered stable.

The primary motivation for this is to allow the Swift language plugin to switch 
between language dialects between, e.g., Swift 5.9 and 6.0 with out introducing 
a ton of new language codes. On the main branch this change is considered NFC.

Depends on https://github.com/llvm/llvm-project/pull/89980

>From 7e63653359ee0cfe251091017a4265aaea3770e3 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Wed, 24 Apr 2024 12:50:43 -0700
Subject: [PATCH] Add a new SBExpressionOptions::SetLanguage() API (NFCI)

that separates out language and version. To avoid reinventing the
wheel and introducing subtle incompatibilities, this API uses the
table of languages and versiond defined by the upcoming DWARF 6
standard (https://dwarfstd.org/languages-v6.html). While the DWARF 6
spec is not finialized, the list of languages is broadly considered
stable.

The primary motivation for this is to allow the Swift language plugin
to switch between language dialects between, e.g., Swift 5.9 and 6.0
with out introducing a ton of new language codes. On the main branch
this change is considered NFC.
---
 lldb/include/lldb/API/SBExpressionOptions.h   |  4 +++
 lldb/include/lldb/Expression/Expression.h |  7 ++--
 .../lldb/Expression/LLVMUserExpression.h  |  2 +-
 lldb/include/lldb/Expression/UserExpression.h | 33 ++
 lldb/include/lldb/Symbol/TypeSystem.h | 10 +++---
 lldb/include/lldb/Target/StackFrame.h | 11 +++---
 lldb/include/lldb/Target/Target.h | 19 ---
 lldb/include/lldb/lldb-private-types.h| 19 +++
 lldb/source/API/SBExpressionOptions.cpp   |  7 
 lldb/source/API/SBFrame.cpp   | 30 +---
 lldb/source/Breakpoint/Watchpoint.cpp |  5 ++-
 .../Commands/CommandObjectDWIMPrint.cpp   |  2 +-
 lldb/source/Commands/CommandObjectType.cpp|  2 +-
 lldb/source/Expression/LLVMUserExpression.cpp |  2 +-
 lldb/source/Expression/UserExpression.cpp | 14 
 lldb/source/Expression/UtilityFunction.cpp|  4 +--
 .../Clang/ClangExpressionParser.cpp   | 12 +++
 .../Clang/ClangUserExpression.cpp | 19 ++-
 .../Clang/ClangUserExpression.h   |  6 ++--
 .../TypeSystem/Clang/TypeSystemClang.cpp  |  2 +-
 .../TypeSystem/Clang/TypeSystemClang.h| 12 +++
 lldb/source/Target/Language.cpp   | 34 +++
 lldb/source/Target/StackFrame.cpp | 23 ++---
 lldb/source/Target/Target.cpp | 21 ++--
 24 files changed, 187 insertions(+), 113 deletions(-)

diff --git a/lldb/include/lldb/API/SBExpressionOptions.h 
b/lldb/include/lldb/API/SBExpressionOptions.h
index e0ddfda5ba37a2..0f2d298d7513fe 100644
--- a/lldb/include/lldb/API/SBExpressionOptions.h
+++ b/lldb/include/lldb/API/SBExpressionOptions.h
@@ -67,6 +67,10 @@ class LLDB_API SBExpressionOptions {
   void SetTrapExceptions(bool trap_exceptions = true);
 
   void SetLanguage(lldb::LanguageType language);
+  /// Set the language using a pair of language code and version as
+  /// defined by the DWARF 6 specification.
+  /// WARNING: These codes may change until DWARF 6 is finalized.
+  void SetLanguage(uint16_t dwarf_lname_code, uint32_t dwarf_lversion);
 
 #ifndef SWIG
   void SetCancelCallback(lldb::ExpressionCancelCallback callback, void *baton);
diff --git a/lldb/include/lldb/Expression/Expression.h 
b/lldb/include/lldb/Expression/Expression.h
index 3e61d78828bbbf..356fe4b82ae43a 100644
--- a/lldb/include/lldb/Expression/Expression.h
+++ b/lldb/include/lldb/Expression/Expression.h
@@ -47,11 +47,8 @@ class Expression {
   /// expression.  Text() should contain the definition of this function.
   virtual const char *FunctionName() = 0;
 
-  /// Return the language that should be used when parsing.  To use the
-  /// default, return eLanguageTypeUnknown.
-  virtual lldb::LanguageType Language() const {
-return lldb::eLanguageTypeUnknown;
-  }
+  /// Return the language that should be used when parsing.
+  virtual SourceLanguage Language() const { return {}; }
 
   /// Return the Materializer that the parser should use when registering
   /// external values.
diff --git a/lldb/include/lldb/Expression/LLVMUserExpression.h 
b/lldb/include/lldb/Expression/LLVMUserExpression.h
index 7d32d17dbf544c..40b463933c07e8 100644
--- a/lldb/include/lldb/Expression/LLVMUserExpression.h
+++ b/lldb/include/lldb/Expression/LLVMUserExpression.h
@@ -52,7 +52,7 @@ class LLVMUserExpression : public UserExpression {
   };
 
   LLVMUserExpression(E