[Lldb-commits] [PATCH] D153921: [lldb] Assert index is valid in DWARFDeclContext

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jun 27 18:24:03 PDT 2023


This revision was automatically updated to reflect the committed changes.
JDevlieghere marked an inline comment as done.
Closed by commit rG7d04c886f9e7: [lldb] Assert index is valid in DWARFDeclContext (authored by JDevlieghere).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D153921?vs=535137&id=535209#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153921/new/

https://reviews.llvm.org/D153921

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
@@ -9,11 +9,13 @@
 #ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDECLCONTEXT_H
 #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDECLCONTEXT_H
 
-#include <string>
-#include <vector>
 #include "lldb/Utility/ConstString.h"
 #include "DWARFDefines.h"
 
+#include <cassert>
+#include <string>
+#include <vector>
+
 // DWARFDeclContext
 //
 // A class that represents a declaration context all the way down to a
@@ -53,12 +55,12 @@
   uint32_t GetSize() const { return m_entries.size(); }
 
   Entry &operator[](uint32_t idx) {
-    // "idx" must be valid
+    assert(idx < m_entries.size() && "invalid index");
     return m_entries[idx];
   }
 
   const Entry &operator[](uint32_t idx) const {
-    // "idx" must be valid
+    assert(idx < m_entries.size() && "invalid index");
     return m_entries[idx];
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153921.535209.patch
Type: text/x-patch
Size: 1067 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230628/acadaeee/attachment.bin>


More information about the lldb-commits mailing list