Mercurial > hg > CbC > CbC_llvm
diff lldb/unittests/Symbol/TestLineEntry.cpp @ 236:c4bab56944e8 llvm-original
LLVM 16
author | kono |
---|---|
date | Wed, 09 Nov 2022 17:45:10 +0900 |
parents | 79ff65ed7e25 |
children | 1f2b6ac9f198 |
line wrap: on
line diff
--- a/lldb/unittests/Symbol/TestLineEntry.cpp Wed Jul 21 10:27:27 2021 +0900 +++ b/lldb/unittests/Symbol/TestLineEntry.cpp Wed Nov 09 17:45:10 2022 +0900 @@ -1,10 +1,8 @@ //===-- TestLineEntry.cpp -------------------------------------------------===// // -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -40,7 +38,8 @@ void SetUp() override; protected: - llvm::Expected<LineEntry> GetLineEntryForLine(uint32_t line); + llvm::Expected<SymbolContextList> + GetLineEntriesForLine(uint32_t line, llvm::Optional<uint16_t> column); llvm::Optional<TestFile> m_file; ModuleSP m_module_sp; }; @@ -52,8 +51,9 @@ m_module_sp = std::make_shared<Module>(m_file->moduleSpec()); } -llvm::Expected<LineEntry> LineEntryTest::GetLineEntryForLine(uint32_t line) { // TODO: Handle SourceLocationSpec column information +llvm::Expected<SymbolContextList> LineEntryTest::GetLineEntriesForLine( + uint32_t line, llvm::Optional<uint16_t> column = llvm::None) { SymbolContextList sc_comp_units; SymbolContextList sc_line_entries; FileSpec file_spec("inlined-functions.cpp"); @@ -64,7 +64,7 @@ return llvm::createStringError(llvm::inconvertibleErrorCode(), "No comp unit found on the test object."); - SourceLocationSpec location_spec(file_spec, line, /*column=*/llvm::None, + SourceLocationSpec location_spec(file_spec, line, column, /*check_inlines=*/true, /*exact_match=*/true); @@ -73,33 +73,53 @@ if (sc_line_entries.GetSize() == 0) return llvm::createStringError(llvm::inconvertibleErrorCode(), "No line entry found on the test object."); - return sc_line_entries[0].line_entry; + return sc_line_entries; +} + +// This tests if we can get all line entries that match the passed line, if +// no column is specified. +TEST_F(LineEntryTest, GetAllExactLineMatchesWithoutColumn) { + auto sc_line_entries = GetLineEntriesForLine(12); + ASSERT_THAT_EXPECTED(sc_line_entries, llvm::Succeeded()); + ASSERT_EQ(sc_line_entries->NumLineEntriesWithLine(12), 6u); +} + +// This tests if we can get exact line and column matches. +TEST_F(LineEntryTest, GetAllExactLineColumnMatches) { + auto sc_line_entries = GetLineEntriesForLine(12, 39); + ASSERT_THAT_EXPECTED(sc_line_entries, llvm::Succeeded()); + ASSERT_EQ(sc_line_entries->NumLineEntriesWithLine(12), 1u); + auto line_entry = sc_line_entries.get()[0].line_entry; + ASSERT_EQ(line_entry.column, 39); } TEST_F(LineEntryTest, GetSameLineContiguousAddressRangeNoInlines) { - auto line_entry = GetLineEntryForLine(18); - ASSERT_THAT_EXPECTED(line_entry, llvm::Succeeded()); + auto sc_line_entries = GetLineEntriesForLine(18); + ASSERT_THAT_EXPECTED(sc_line_entries, llvm::Succeeded()); + auto line_entry = sc_line_entries.get()[0].line_entry; bool include_inlined_functions = false; auto range = - line_entry->GetSameLineContiguousAddressRange(include_inlined_functions); + line_entry.GetSameLineContiguousAddressRange(include_inlined_functions); ASSERT_EQ(range.GetByteSize(), (uint64_t)0x24); } TEST_F(LineEntryTest, GetSameLineContiguousAddressRangeOneInline) { - auto line_entry = GetLineEntryForLine(18); - ASSERT_THAT_EXPECTED(line_entry, llvm::Succeeded()); + auto sc_line_entries = GetLineEntriesForLine(18); + ASSERT_THAT_EXPECTED(sc_line_entries, llvm::Succeeded()); + auto line_entry = sc_line_entries.get()[0].line_entry; bool include_inlined_functions = true; auto range = - line_entry->GetSameLineContiguousAddressRange(include_inlined_functions); + line_entry.GetSameLineContiguousAddressRange(include_inlined_functions); ASSERT_EQ(range.GetByteSize(), (uint64_t)0x49); } TEST_F(LineEntryTest, GetSameLineContiguousAddressRangeNestedInline) { - auto line_entry = GetLineEntryForLine(12); - ASSERT_THAT_EXPECTED(line_entry, llvm::Succeeded()); + auto sc_line_entries = GetLineEntriesForLine(12); + ASSERT_THAT_EXPECTED(sc_line_entries, llvm::Succeeded()); + auto line_entry = sc_line_entries.get()[0].line_entry; bool include_inlined_functions = true; auto range = - line_entry->GetSameLineContiguousAddressRange(include_inlined_functions); + line_entry.GetSameLineContiguousAddressRange(include_inlined_functions); ASSERT_EQ(range.GetByteSize(), (uint64_t)0x33); }