From: Jonas Devlieghere Date: Wed, 28 Jun 2023 00:01:53 +0000 (-0700) Subject: [lldb] Assert index is valid in DWARFDeclContext X-Git-Tag: upstream/17.0.6~3621 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7d04c886f9e77efa5d73a7b1e2f3cdac395bf8ee;p=platform%2Fupstream%2Fllvm.git [lldb] Assert index is valid in DWARFDeclContext Replace the comment with an assert to enforce the correct index is used. Differential revision: https://reviews.llvm.org/D153921 --- diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h index fa776f2..13e3dfb 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h +++ b/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 -#include #include "lldb/Utility/ConstString.h" #include "DWARFDefines.h" +#include +#include +#include + // DWARFDeclContext // // A class that represents a declaration context all the way down to a @@ -53,12 +55,12 @@ public: 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]; }