From 748297341171927b0693e4ac78fa0a223df5ea3c Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Thu, 30 Aug 2018 17:29:37 +0000 Subject: Added initial code completion support for the `expr` command Summary: This patch adds initial code completion support for the `expr` command. We now have a completion handler in the expression CommandObject that essentially just attempts to parse the given user expression with Clang with an attached code completion consumer. We filter and prepare the code completions provided by Clang and send them back to the completion API. The current completion is limited to variables that are in the current scope. This includes local variables and all types used by local variables. We however don't do any completion of symbols that are not used in the local scope (or in some other way already in the ASTContext). This is partly because there is not yet any code that manually searches for additiona information in the debug information. Another cause is that for some reason the existing code for loading these additional symbols when requested by Clang doesn't seem to work. This will be fixed in a future patch. Reviewers: jingham, teemperor Reviewed By: teemperor Subscribers: labath, aprantl, JDevlieghere, friss, lldb-commits Differential Revision: https://reviews.llvm.org/D48465 llvm-svn: 341086 --- .../test/expression_command/completion/main.cpp | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 lldb/packages/Python/lldbsuite/test/expression_command/completion/main.cpp (limited to 'lldb/packages/Python/lldbsuite/test/expression_command/completion/main.cpp') diff --git a/lldb/packages/Python/lldbsuite/test/expression_command/completion/main.cpp b/lldb/packages/Python/lldbsuite/test/expression_command/completion/main.cpp new file mode 100644 index 00000000000..908bebbebff --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/expression_command/completion/main.cpp @@ -0,0 +1,35 @@ +namespace LongNamespaceName { class NestedClass { long m; }; } + +// Defined in other.cpp, we only have a forward declaration here. +struct ForwardDecl; +extern ForwardDecl fwd_decl; + +class LongClassName { long i ; }; + +class Expr { +public: + int FooNoArgsBar() { return 1; } + int FooWithArgsBar(int i) { return i; } + int FooWithMultipleArgsBar(int i, int j) { return i + j; } + int FooUnderscoreBar_() { return 4; } + int FooNumbersBar1() { return 8; } + int MemberVariableBar = 0; + Expr &Self() { return *this; } + static int StaticMemberMethodBar() { return 82; } +}; + +int main() +{ + LongClassName a; + LongNamespaceName::NestedClass NestedFoo; + long SomeLongVarNameWithCapitals = 44; + int SomeIntVar = 33; + Expr some_expr; + some_expr.FooNoArgsBar(); + some_expr.FooWithArgsBar(1); + some_expr.FooUnderscoreBar_(); + some_expr.FooNumbersBar1(); + Expr::StaticMemberMethodBar(); + ForwardDecl *fwd_decl_ptr = &fwd_decl; + return 0; // Break here +} -- cgit v1.2.3