summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test/expression_command/completion/main.cpp
diff options
context:
space:
mode:
authorRaphael Isemann <teemperor@gmail.com>2018-08-30 17:29:37 +0000
committerRaphael Isemann <teemperor@gmail.com>2018-08-30 17:29:37 +0000
commit748297341171927b0693e4ac78fa0a223df5ea3c (patch)
treeabc0edd1ac8b1fbb35b2c4fe04eb63d557f9c554 /lldb/packages/Python/lldbsuite/test/expression_command/completion/main.cpp
parent0a35b7668bd605879f21ab16d80ac2f658ab5453 (diff)
downloadbcm5719-llvm-748297341171927b0693e4ac78fa0a223df5ea3c.tar.gz
bcm5719-llvm-748297341171927b0693e4ac78fa0a223df5ea3c.zip
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
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/expression_command/completion/main.cpp')
-rw-r--r--lldb/packages/Python/lldbsuite/test/expression_command/completion/main.cpp35
1 files changed, 35 insertions, 0 deletions
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
+}
OpenPOWER on IntegriCloud