From d63c1dbd4b1f9b58b446cddc399d81eedc4e795f Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Thu, 14 Mar 2019 17:39:39 +0000 Subject: [PATCH] Safer casting in ClangExpressionParser code completion Summary: Makes the code a bit safer in the unlikely situation that we don't get a ClangUserExpression when doing code completion. Reviewers: aprantl, jingham Reviewed By: aprantl Subscribers: labath, jdoerfert, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D59359 llvm-svn: 356174 --- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp index c0ea863..7589c37 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -857,8 +857,8 @@ bool ClangExpressionParser::Complete(CompletionRequest &request, unsigned line, // 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(&m_expr); - CodeComplete CC(request, m_compiler->getLangOpts(), llvm_expr.GetUserText(), + ClangUserExpression *llvm_expr = cast(&m_expr); + CodeComplete CC(request, m_compiler->getLangOpts(), llvm_expr->GetUserText(), typed_pos); // We don't need a code generator for parsing. m_code_generator.reset(); -- 2.7.4