[Lldb-commits] [lldb] [LLDB] Add DIL code for handling plain variable names. (PR #120971)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Thu Mar 20 05:10:38 PDT 2025


================
@@ -0,0 +1,104 @@
+//===-- DILParser.h ---------------------------------------------*- C++ -*-===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_VALUEOBJECT_DILPARSER_H
+#define LLDB_VALUEOBJECT_DILPARSER_H
+
+#include "lldb/Target/ExecutionContextScope.h"
+#include "lldb/Utility/Status.h"
+#include "lldb/ValueObject/DILAST.h"
+#include "lldb/ValueObject/DILLexer.h"
+#include <memory>
+#include <optional>
+#include <string>
+#include <tuple>
+#include <vector>
+
+namespace lldb_private::dil {
+
+enum class ErrorCode : unsigned char {
+  kOk = 0,
+  kInvalidExpressionSyntax,
+  kUndeclaredIdentifier,
+  kUnknown,
+};
----------------
labath wrote:

```suggestion
class DILError: public llvm::ErrorInfo<DILError, DiagnosticError> {
public:
  enum ErrorCode : unsigned char {
    kInvalidExpressionSyntax,
    kUndeclaredIdentifier,
    kUnknown,
  };
  DILError(ErrorCode code, std::string message, DiagnosticDetail detail);
  
  llvm::ArrayRef<DiagnosticDetail> GetDetails() const override { return m_detail; }
  
  std::error_code convertToErrorCode() const override { return llvm::inconvertibleErrorCode(); }

  std::unique_ptr<CloneableError> Clone() const override { return std::make_unique<cloneableError>(m_message, m_detail); }

  // Implement similarly to ExpressionError
  std::string message() const override;
  void log(llvm::raw_ostream &OS) const override;
};
```

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


More information about the lldb-commits mailing list