asmith created this revision.
asmith added reviewers: zturner, lldb-commits.
For `int main()`, the number of arguments is zero. Trying to access the element
of a null array causes trouble.
Repository:
rL LLVM
https://reviews.llvm.org/D41427
Files:
source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
Index: source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
===================================================================
--- source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
+++ source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
@@ -141,7 +141,7 @@
} else if (auto func_sig = llvm::dyn_cast<PDBSymbolTypeFunctionSig>(&type)) {
auto arg_enum = func_sig->getArguments();
uint32_t num_args = arg_enum->getChildCount();
- std::vector<CompilerType> arg_list(num_args);
+ std::vector<CompilerType> arg_list;
while (auto arg = arg_enum->getNext()) {
lldb_private::Type *arg_type =
m_ast.GetSymbolFile()->ResolveTypeUID(arg->getSymIndexId());
@@ -152,6 +152,8 @@
CompilerType arg_ast_type = arg_type->GetFullCompilerType();
arg_list.push_back(arg_ast_type);
}
+ lldbassert(arg_list.size() <= num_args);
+
auto pdb_return_type = func_sig->getReturnType();
lldb_private::Type *return_type =
m_ast.GetSymbolFile()->ResolveTypeUID(pdb_return_type->getSymIndexId());
@@ -166,7 +168,7 @@
if (func_sig->isVolatileType())
type_quals |= clang::Qualifiers::Volatile;
CompilerType func_sig_ast_type = m_ast.CreateFunctionType(
- return_ast_type, &arg_list[0], num_args, false, type_quals);
+ return_ast_type, arg_list.data(), arg_list.size(), false, type_quals);
return std::make_shared<lldb_private::Type>(
func_sig->getSymIndexId(), m_ast.GetSymbolFile(), ConstString(), 0,
Index: source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
===================================================================
--- source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
+++ source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
@@ -141,7 +141,7 @@
} else if (auto func_sig = llvm::dyn_cast<PDBSymbolTypeFunctionSig>(&type)) {
auto arg_enum = func_sig->getArguments();
uint32_t num_args = arg_enum->getChildCount();
- std::vector<CompilerType> arg_list(num_args);
+ std::vector<CompilerType> arg_list;
while (auto arg = arg_enum->getNext()) {
lldb_private::Type *arg_type =
m_ast.GetSymbolFile()->ResolveTypeUID(arg->getSymIndexId());
@@ -152,6 +152,8 @@
CompilerType arg_ast_type = arg_type->GetFullCompilerType();
arg_list.push_back(arg_ast_type);
}
+ lldbassert(arg_list.size() <= num_args);
+
auto pdb_return_type = func_sig->getReturnType();
lldb_private::Type *return_type =
m_ast.GetSymbolFile()->ResolveTypeUID(pdb_return_type->getSymIndexId());
@@ -166,7 +168,7 @@
if (func_sig->isVolatileType())
type_quals |= clang::Qualifiers::Volatile;
CompilerType func_sig_ast_type = m_ast.CreateFunctionType(
- return_ast_type, &arg_list[0], num_args, false, type_quals);
+ return_ast_type, arg_list.data(), arg_list.size(), false, type_quals);
return std::make_shared<lldb_private::Type>(
func_sig->getSymIndexId(), m_ast.GetSymbolFile(), ConstString(), 0,
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits