[Lldb-commits] [lldb] r266138 - Use the FormatEntity work for great good - parse summary strings before accepting them, and fail to add any strings that fail parsing

Enrico Granata via lldb-commits lldb-commits at lists.llvm.org
Tue Apr 12 14:57:11 PDT 2016


Author: enrico
Date: Tue Apr 12 16:57:11 2016
New Revision: 266138

URL: http://llvm.org/viewvc/llvm-project?rev=266138&view=rev
Log:
Use the FormatEntity work for great good - parse summary strings before accepting them, and fail to add any strings that fail parsing


Modified:
    lldb/trunk/source/Commands/CommandObjectType.cpp

Modified: lldb/trunk/source/Commands/CommandObjectType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=266138&r1=266137&r2=266138&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectType.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectType.cpp Tue Apr 12 16:57:11 2016
@@ -1718,20 +1718,23 @@ CommandObjectTypeSummaryAdd::Execute_Str
         return false;
     }
     
-    Error error;
-    
-    lldb::TypeSummaryImplSP entry(new StringSummaryFormat(m_options.m_flags,
-                                                        format_cstr));
-    
-    if (error.Fail())
+    std::unique_ptr<StringSummaryFormat> string_format(new StringSummaryFormat(m_options.m_flags, format_cstr));
+    if (!string_format)
     {
-        result.AppendError(error.AsCString());
+        result.AppendError("summary creation failed");
         result.SetStatus(eReturnStatusFailed);
         return false;
     }
+    if (string_format->m_error.Fail())
+    {
+        result.AppendErrorWithFormat("syntax error: %s", string_format->m_error.AsCString("<unknown>"));
+        result.SetStatus(eReturnStatusFailed);
+        return false;
+    }
+    lldb::TypeSummaryImplSP entry(string_format.release());
     
     // now I have a valid format, let's add it to every type
-    
+    Error error;
     for (size_t i = 0; i < argc; i++)
     {
         const char* typeA = command.GetArgumentAtIndex(i);




More information about the lldb-commits mailing list