Skip to content

Commit 4c7b28d

Browse files
committed
[lldb][NFC] Minor refactorings to (Clang)ExpressionSourceCode
llvm-svn: 368082
1 parent fc33e33 commit 4c7b28d

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

lldb/include/lldb/Expression/ExpressionSourceCode.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,27 @@
1717
namespace lldb_private {
1818

1919
class ExpressionSourceCode {
20+
protected:
21+
enum Wrapping : bool {
22+
Wrap = true,
23+
NoWrap = false,
24+
};
25+
2026
public:
21-
bool NeedsWrapping() const { return m_wrap; }
27+
bool NeedsWrapping() const { return m_wrap == Wrap; }
2228

2329
const char *GetName() const { return m_name.c_str(); }
2430

2531
protected:
26-
ExpressionSourceCode(const char *name, const char *prefix, const char *body,
27-
bool wrap)
28-
: m_name(name), m_prefix(prefix), m_body(body), m_wrap(wrap) {}
32+
ExpressionSourceCode(llvm::StringRef name, llvm::StringRef prefix,
33+
llvm::StringRef body, Wrapping wrap)
34+
: m_name(name.str()), m_prefix(prefix.str()), m_body(body.str()),
35+
m_wrap(wrap) {}
2936

3037
std::string m_name;
3138
std::string m_prefix;
3239
std::string m_body;
33-
bool m_wrap;
40+
Wrapping m_wrap;
3441
};
3542

3643
} // namespace lldb_private

lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ class ClangExpressionSourceCode : public ExpressionSourceCode {
2525
public:
2626
static const char *g_expression_prefix;
2727

28-
static ClangExpressionSourceCode *CreateWrapped(const char *prefix,
29-
const char *body) {
30-
return new ClangExpressionSourceCode("$__lldb_expr", prefix, body, true);
28+
static ClangExpressionSourceCode *CreateWrapped(llvm::StringRef prefix,
29+
llvm::StringRef body) {
30+
return new ClangExpressionSourceCode("$__lldb_expr", prefix, body, Wrap);
3131
}
3232

3333
/// Generates the source code that will evaluate the expression.
@@ -59,9 +59,9 @@ class ClangExpressionSourceCode : public ExpressionSourceCode {
5959
size_t &start_loc, size_t &end_loc);
6060

6161
protected:
62-
ClangExpressionSourceCode(const char *name, const char *prefix, const char *body,
63-
bool wrap) :
64-
ExpressionSourceCode(name, prefix, body, wrap) {}
62+
ClangExpressionSourceCode(llvm::StringRef name, llvm::StringRef prefix,
63+
llvm::StringRef body, Wrapping wrap)
64+
: ExpressionSourceCode(name, prefix, body, wrap) {}
6565
};
6666

6767
} // namespace lldb_private

0 commit comments

Comments
 (0)