[Lldb-commits] [lldb] 7d04c88 - [lldb] Assert index is valid in DWARFDeclContext
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Tue Jun 27 18:23:57 PDT 2023
Author: Jonas Devlieghere
Date: 2023-06-27T18:23:35-07:00
New Revision: 7d04c886f9e77efa5d73a7b1e2f3cdac395bf8ee
URL: https://github.com/llvm/llvm-project/commit/7d04c886f9e77efa5d73a7b1e2f3cdac395bf8ee
DIFF: https://github.com/llvm/llvm-project/commit/7d04c886f9e77efa5d73a7b1e2f3cdac395bf8ee.diff
LOG: [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
Added:
Modified:
lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
Removed:
################################################################################
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
index fa776f27d5019..13e3dfb70c0cc 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 <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 @@ class DWARFDeclContext {
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];
}
More information about the lldb-commits
mailing list