Skip to content

Commit 7d04c88

Browse files
committed
[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
1 parent 5456f16 commit 7d04c88

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDECLCONTEXT_H
1010
#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDECLCONTEXT_H
1111

12-
#include <string>
13-
#include <vector>
1412
#include "lldb/Utility/ConstString.h"
1513
#include "DWARFDefines.h"
1614

15+
#include <cassert>
16+
#include <string>
17+
#include <vector>
18+
1719
// DWARFDeclContext
1820
//
1921
// A class that represents a declaration context all the way down to a
@@ -53,12 +55,12 @@ class DWARFDeclContext {
5355
uint32_t GetSize() const { return m_entries.size(); }
5456

5557
Entry &operator[](uint32_t idx) {
56-
// "idx" must be valid
58+
assert(idx < m_entries.size() && "invalid index");
5759
return m_entries[idx];
5860
}
5961

6062
const Entry &operator[](uint32_t idx) const {
61-
// "idx" must be valid
63+
assert(idx < m_entries.size() && "invalid index");
6264
return m_entries[idx];
6365
}
6466

0 commit comments

Comments
 (0)