[lldb][NFC] Assert on invalid cursors positions when creating CompletionRequest
authorRaphael Isemann <teemperor@gmail.com>
Fri, 9 Aug 2019 14:32:50 +0000 (14:32 +0000)
committerRaphael Isemann <teemperor@gmail.com>
Fri, 9 Aug 2019 14:32:50 +0000 (14:32 +0000)
Before we just triggered undefined behavior on invalid positions.

llvm-svn: 368444

lldb/source/Utility/CompletionRequest.cpp

index ca109a9a716ae52b54c42d5d0a14db50e0fe727f..6a8ab160c4169a2e724130d799eb3e0a5ee2539d 100644 (file)
@@ -16,6 +16,7 @@ CompletionRequest::CompletionRequest(llvm::StringRef command_line,
                                      CompletionResult &result)
     : m_command(command_line), m_raw_cursor_pos(raw_cursor_pos),
       m_result(result) {
+  assert(raw_cursor_pos <= command_line.size() && "Out of bounds cursor?");
 
   // We parse the argument up to the cursor, so the last argument in
   // parsed_line is the one containing the cursor, and the cursor is after the