JDevlieghere created this revision.
JDevlieghere added a reviewer: fdeazeve.
Herald added a subscriber: arphaman.
Herald added a project: All.
JDevlieghere requested review of this revision.

Address my own comment from D153867 <https://reviews.llvm.org/D153867>.


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];
   }
 


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];
   }
 
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
  • [Lldb-commits]... Jonas Devlieghere via Phabricator via lldb-commits
    • [Lldb-com... Felipe de Azevedo Piovezan via Phabricator via lldb-commits
    • [Lldb-com... Felipe de Azevedo Piovezan via Phabricator via lldb-commits
    • [Lldb-com... Jonas Devlieghere via Phabricator via lldb-commits
    • [Lldb-com... Jonas Devlieghere via Phabricator via lldb-commits

Reply via email to