[Lldb-commits] [lldb] r239779 - If a candidate keyword contains quotes, it's clearly not a keyword, so bail out early

Enrico Granata egranata at apple.com
Mon Jun 15 16:12:30 PDT 2015


Author: enrico
Date: Mon Jun 15 18:12:29 2015
New Revision: 239779

URL: http://llvm.org/viewvc/llvm-project?rev=239779&view=rev
Log:
If a candidate keyword contains quotes, it's clearly not a keyword, so bail out early

There are other characters we could optimize for (any non-letter pretty much), but keyword.iskeyword() will handle them, whereas quotes do have the potential to confuse us, so they actually need custom handling

Fixes rdar://problem/21022787


Modified:
    lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp

Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=239779&r1=239778&r2=239779&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original)
+++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Mon Jun 15 18:12:29 2015
@@ -45,6 +45,8 @@
 #include "lldb/Host/windows/ConnectionGenericFileWindows.h"
 #endif
 
+#include "llvm/ADT/StringRef.h"
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -2615,6 +2617,16 @@ ScriptInterpreterPython::LoadScriptingMo
 bool
 ScriptInterpreterPython::IsReservedWord (const char* word)
 {
+    if (!word || !word[0])
+        return false;
+    
+    llvm::StringRef word_sr(word);
+
+    // filter out a few characters that would just confuse us
+    // and that are clearly not keyword material anyway
+    if (word_sr.find_first_of("'\"") != llvm::StringRef::npos)
+        return false;
+    
     StreamString command_stream;
     command_stream.Printf("keyword.iskeyword('%s')", word);
     bool result;





More information about the lldb-commits mailing list