[Lldb-commits] [PATCH] D59359: Safer casting in ClangExpressionParser code completion
Raphael Isemann via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Mar 14 05:38:26 PDT 2019
teemperor created this revision.
teemperor added reviewers: aprantl, jingham.
Herald added subscribers: lldb-commits, jdoerfert.
Herald added a project: LLDB.
Makes the code a bit safer in the unlikely situation that we don't get a ClangUserExpression
when doing code completion.
Repository:
rLLDB LLDB
https://reviews.llvm.org/D59359
Files:
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===================================================================
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -857,8 +857,9 @@
// To actually get the raw user input here, we have to cast our expression to
// the LLVMUserExpression which exposes the right API. This should never fail
// as we always have a ClangUserExpression whenever we call this.
- LLVMUserExpression &llvm_expr = *static_cast<LLVMUserExpression *>(&m_expr);
- CodeComplete CC(request, m_compiler->getLangOpts(), llvm_expr.GetUserText(),
+ ClangUserExpression *llvm_expr = dyn_cast<ClangUserExpression>(&m_expr);
+ assert(llvm_expr && "m_expr not an ClangUserExpression?");
+ CodeComplete CC(request, m_compiler->getLangOpts(), llvm_expr->GetUserText(),
typed_pos);
// We don't need a code generator for parsing.
m_code_generator.reset();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59359.190603.patch
Type: text/x-patch
Size: 1030 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190314/846d6bc3/attachment.bin>
More information about the lldb-commits
mailing list