summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter/ScriptInterpreterPython.cpp
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2015-06-15 23:12:29 +0000
committerEnrico Granata <egranata@apple.com>2015-06-15 23:12:29 +0000
commit3ab6669eeb64edfe31959cf65d8b27dda1ed931f (patch)
tree456bf30f434e547e54186c7615b039851339a40d /lldb/source/Interpreter/ScriptInterpreterPython.cpp
parent8e7a58d7ccfc254a30b582e536e9c3dc583dd8e2 (diff)
downloadbcm5719-llvm-3ab6669eeb64edfe31959cf65d8b27dda1ed931f.tar.gz
bcm5719-llvm-3ab6669eeb64edfe31959cf65d8b27dda1ed931f.zip
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 llvm-svn: 239779
Diffstat (limited to 'lldb/source/Interpreter/ScriptInterpreterPython.cpp')
-rw-r--r--lldb/source/Interpreter/ScriptInterpreterPython.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
index 188f7285776..8f60793550c 100644
--- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp
+++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
@@ -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::LoadScriptingModule(const char *pathname, bool can_relo
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;
OpenPOWER on IntegriCloud