1 //===-- ClangExpressionSourceCode.h -----------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef liblldb_ClangExpressionSourceCode_h
10 #define liblldb_ClangExpressionSourceCode_h
11 
12 #include "lldb/Expression/Expression.h"
13 #include "lldb/Expression/ExpressionSourceCode.h"
14 #include "lldb/lldb-enumerations.h"
15 #include "llvm/ADT/ArrayRef.h"
16 #include "llvm/ADT/StringRef.h"
17 
18 #include <string>
19 
20 namespace lldb_private {
21 
22 class ExecutionContext;
23 
24 class ClangExpressionSourceCode : public ExpressionSourceCode {
25 public:
26   static const char *g_expression_prefix;
27 
28   static ClangExpressionSourceCode *CreateWrapped(const char *prefix,
29                                              const char *body) {
30     return new ClangExpressionSourceCode("$__lldb_expr", prefix, body, true);
31   }
32 
33   uint32_t GetNumBodyLines();
34 
35   bool GetText(std::string &text, lldb::LanguageType wrapping_language,
36                bool static_method,
37                ExecutionContext &exe_ctx,
38                bool add_locals) const;
39 
40   // Given a string returned by GetText, find the beginning and end of the body
41   // passed to CreateWrapped. Return true if the bounds could be found.  This
42   // will also work on text with FixItHints applied.
43   static bool GetOriginalBodyBounds(std::string transformed_text,
44                                     lldb::LanguageType wrapping_language,
45                                     size_t &start_loc, size_t &end_loc);
46 
47 protected:
48   ClangExpressionSourceCode(const char *name, const char *prefix, const char *body,
49                        bool wrap) :
50       ExpressionSourceCode(name, prefix, body, wrap) {}
51 };
52 
53 } // namespace lldb_private
54 
55 #endif
56