[Lldb-commits] [lldb] 50f1985 - [lldb][NFC] Delete the original UserExpression before trying to reparse it with FixIts.

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Thu Mar 19 10:11:27 PDT 2020


Author: Raphael Isemann
Date: 2020-03-19T18:10:57+01:00
New Revision: 50f198535363c6882b02c3dde7bec31e723c4762

URL: https://github.com/llvm/llvm-project/commit/50f198535363c6882b02c3dde7bec31e723c4762
DIFF: https://github.com/llvm/llvm-project/commit/50f198535363c6882b02c3dde7bec31e723c4762.diff

LOG: [lldb][NFC] Delete the original UserExpression before trying to reparse it with FixIts.

Currently when an expression fails to parse and we have a FixIt, we keep
the failed UserExpression around while trying to parse the expression with
applied fixits. This means that we have this rather confusing control flow:

1. Original expression created and parsing attempted.
2. Expression with applied FixIts is created and parsing attempted.
3. Original expression is destroyed and parser deconstructed.
4. Expression with applied FixIts is destroyed and parser deconstructed.

This patch just deletes the original expression so that step 2 and 3 are
swapped and the whole process looks more like just sequentially parsing two
expressions (which is what we actually do here).

Doesn't fix anything just makes the code less fragile.

Added: 
    

Modified: 
    lldb/source/Expression/UserExpression.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Expression/UserExpression.cpp b/lldb/source/Expression/UserExpression.cpp
index 0243cc0c3750..5bd2321e48dd 100644
--- a/lldb/source/Expression/UserExpression.cpp
+++ b/lldb/source/Expression/UserExpression.cpp
@@ -259,6 +259,10 @@ UserExpression::Evaluate(ExecutionContext &exe_ctx,
 
   // If there is a fixed expression, try to parse it:
   if (!parse_success) {
+    // Delete the expression that failed to parse before attempting to parse
+    // the next expression.
+    user_expression_sp.reset();
+
     execution_results = lldb::eExpressionParseError;
     if (fixed_expression && !fixed_expression->empty() &&
         options.GetAutoApplyFixIts()) {


        


More information about the lldb-commits mailing list