[llvm] Fix crash due to un-checked error in LVReaderHandler::handleArchive method (PR #118951)
Carlos Alberto Enciso via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 13 05:27:16 PST 2024
================
@@ -193,6 +196,72 @@ void checkElementPropertiesMsvcCodeview(LVReader *Reader) {
EXPECT_EQ(Lines->size(), 0x0eu);
}
+// Check the logical elements basic properties (MSVC library - Codeview).
+void checkElementPropertiesMsvcLibraryCodeview(LVReader *Reader) {
+ LVScopeRoot *Root = Reader->getScopesRoot();
+ LVScopeCompileUnit *CompileUnit =
+ static_cast<LVScopeCompileUnit *>(getFirstScopeChild(Root));
+ LVScopeFunction *Function =
+ static_cast<LVScopeFunction *>(getFirstScopeChild(CompileUnit));
+
+ EXPECT_EQ(Root->getFileFormatName(), "COFF-x86-64");
+ EXPECT_EQ(Root->getName(), CodeViewMsvcLibContentName);
+
+ EXPECT_EQ(CompileUnit->getBaseAddress(), 0u);
+ EXPECT_TRUE(CompileUnit->getProducer().starts_with("Microsoft"));
+ EXPECT_EQ(CompileUnit->getName(), "test.cpp");
+
+ EXPECT_EQ(Function->lineCount(), 14u);
+ EXPECT_EQ(Function->scopeCount(), 1u);
+ EXPECT_EQ(Function->symbolCount(), 3u);
+ EXPECT_EQ(Function->typeCount(), 0u);
+ EXPECT_EQ(Function->rangeCount(), 1u);
+
+ const LVLocations *Ranges = Function->getRanges();
+ ASSERT_NE(Ranges, nullptr);
+ ASSERT_EQ(Ranges->size(), 1u);
+ LVLocations::const_iterator IterLocation = Ranges->begin();
----------------
CarlosAlbertoEnciso wrote:
Check the iterator for `end`
ASSERT_NE(IterLocation, Ranges->end());
https://github.com/llvm/llvm-project/pull/118951
More information about the llvm-commits
mailing list