[Lldb-commits] [lldb] r356174 - Safer casting in ClangExpressionParser code completion

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Thu Mar 14 10:39:40 PDT 2019


Author: teemperor
Date: Thu Mar 14 10:39:39 2019
New Revision: 356174

URL: http://llvm.org/viewvc/llvm-project?rev=356174&view=rev
Log:
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

Modified:
    lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp?rev=356174&r1=356173&r2=356174&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp Thu Mar 14 10:39:39 2019
@@ -857,8 +857,8 @@ bool ClangExpressionParser::Complete(Com
   // 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 = cast<ClangUserExpression>(&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();




More information about the lldb-commits mailing list