[lldb][NFC] Fix all formatting errors in .cpp file headers
Summary:
A *.cpp file header in LLDB (and in LLDB) should like this:
```
//===-- TestUtilities.cpp -------------------------------------------------===//
```
However in LLDB most of our source files have arbitrary changes to this format and
these changes are spreading through LLDB as folks usually just use the existing
source files as templates for their new files (most notably the unnecessary
editor language indicator `-*- C++ -*-` is spreading and in every review
someone is pointing out that this is wrong, resulting in people pointing out that this
is done in the same way in other files).
This patch removes most of these inconsistencies including the editor language indicators,
all the different missing/additional '-' characters, files that center the file name, missing
trailing `===//` (mostly caused by clang-format breaking the line).
Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D73258
2020-01-24 15:23:27 +08:00
|
|
|
//===-- TestLineEntry.cpp -------------------------------------------------===//
|
2019-05-07 23:37:28 +08:00
|
|
|
//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
|
|
|
|
#include "Plugins/SymbolFile/DWARF/DWARFASTParserClang.h"
|
|
|
|
#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
|
[lldb] Move clang-based files out of Symbol
Summary:
This change represents the move of ClangASTImporter, ClangASTMetadata,
ClangExternalASTSourceCallbacks, ClangUtil, CxxModuleHandler, and
TypeSystemClang from lldbSource to lldbPluginExpressionParserClang.h
This explicitly removes knowledge of clang internals from lldbSymbol,
moving towards a more generic core implementation of lldb.
Reviewers: JDevlieghere, davide, aprantl, teemperor, clayborg, labath, jingham, shafik
Subscribers: emaste, mgorny, arphaman, jfb, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D73661
2020-01-30 03:59:28 +08:00
|
|
|
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
|
2019-12-23 17:38:12 +08:00
|
|
|
#include "TestingSupport/SubsystemRAII.h"
|
2019-05-07 23:37:28 +08:00
|
|
|
#include "TestingSupport/TestUtilities.h"
|
|
|
|
|
|
|
|
#include "lldb/Core/Module.h"
|
|
|
|
#include "lldb/Host/FileSystem.h"
|
|
|
|
#include "lldb/Host/HostInfo.h"
|
|
|
|
#include "lldb/Symbol/CompileUnit.h"
|
|
|
|
#include "lldb/Symbol/SymbolContext.h"
|
|
|
|
|
|
|
|
#include "llvm/Support/FileUtilities.h"
|
|
|
|
#include "llvm/Support/Program.h"
|
|
|
|
#include "llvm/Testing/Support/Error.h"
|
|
|
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
using namespace lldb;
|
|
|
|
|
|
|
|
class LineEntryTest : public testing::Test {
|
2019-12-23 17:38:12 +08:00
|
|
|
SubsystemRAII<FileSystem, HostInfo, ObjectFileMachO, SymbolFileDWARF,
|
[lldb][NFC] Rename ClangASTContext to TypeSystemClang
Summary:
This commit renames ClangASTContext to TypeSystemClang to better reflect what this class is actually supposed to do
(implement the TypeSystem interface for Clang). It also gets rid of the very confusing situation that we have both a
`clang::ASTContext` and a `ClangASTContext` in clang (which sometimes causes Clang people to think I'm fiddling
with Clang's ASTContext when I'm actually just doing LLDB work).
I also have plans to potentially have multiple clang::ASTContext instances associated with one ClangASTContext so
the ASTContext naming will then become even more confusing to people.
Reviewers: #lldb, aprantl, shafik, clayborg, labath, JDevlieghere, davide, espindola, jdoerfert, xiaobai
Reviewed By: clayborg, labath, xiaobai
Subscribers: wuzish, emaste, nemanjai, mgorny, kbarton, MaskRay, arphaman, jfb, usaxena95, jingham, xiaobai, abidh, JDevlieghere, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D72684
2020-01-23 17:04:13 +08:00
|
|
|
TypeSystemClang>
|
2019-12-23 17:38:12 +08:00
|
|
|
subsystem;
|
|
|
|
|
2019-05-07 23:37:28 +08:00
|
|
|
public:
|
unittests: Use yaml2obj as a library instead of an external process
Summary:
Recently, yaml2obj has been turned into a library. This means we can use
it from our unit tests directly, instead of shelling out to an external
process. This patch does just that.
Reviewers: JDevlieghere, aadsm, espindola, jdoerfert
Subscribers: emaste, mgorny, arichardson, MaskRay, jhenderson, abrachet, lldb-commits
Differential Revision: https://reviews.llvm.org/D65949
llvm-svn: 369374
2019-08-20 20:28:36 +08:00
|
|
|
void SetUp() override;
|
2019-05-07 23:37:28 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
llvm::Expected<LineEntry> GetLineEntryForLine(uint32_t line);
|
unittests: Use yaml2obj as a library instead of an external process
Summary:
Recently, yaml2obj has been turned into a library. This means we can use
it from our unit tests directly, instead of shelling out to an external
process. This patch does just that.
Reviewers: JDevlieghere, aadsm, espindola, jdoerfert
Subscribers: emaste, mgorny, arichardson, MaskRay, jhenderson, abrachet, lldb-commits
Differential Revision: https://reviews.llvm.org/D65949
llvm-svn: 369374
2019-08-20 20:28:36 +08:00
|
|
|
llvm::Optional<TestFile> m_file;
|
2019-05-07 23:37:28 +08:00
|
|
|
ModuleSP m_module_sp;
|
|
|
|
};
|
|
|
|
|
unittests: Use yaml2obj as a library instead of an external process
Summary:
Recently, yaml2obj has been turned into a library. This means we can use
it from our unit tests directly, instead of shelling out to an external
process. This patch does just that.
Reviewers: JDevlieghere, aadsm, espindola, jdoerfert
Subscribers: emaste, mgorny, arichardson, MaskRay, jhenderson, abrachet, lldb-commits
Differential Revision: https://reviews.llvm.org/D65949
llvm-svn: 369374
2019-08-20 20:28:36 +08:00
|
|
|
void LineEntryTest::SetUp() {
|
|
|
|
auto ExpectedFile = TestFile::fromYamlFile("inlined-functions.yaml");
|
|
|
|
ASSERT_THAT_EXPECTED(ExpectedFile, llvm::Succeeded());
|
|
|
|
m_file.emplace(std::move(*ExpectedFile));
|
2020-07-10 05:14:36 +08:00
|
|
|
m_module_sp = std::make_shared<Module>(m_file->moduleSpec());
|
2019-05-07 23:37:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
llvm::Expected<LineEntry> LineEntryTest::GetLineEntryForLine(uint32_t line) {
|
|
|
|
bool check_inlines = true;
|
|
|
|
bool exact = true;
|
|
|
|
SymbolContextList sc_comp_units;
|
|
|
|
SymbolContextList sc_line_entries;
|
|
|
|
FileSpec file_spec("inlined-functions.cpp");
|
unittests: Use yaml2obj as a library instead of an external process
Summary:
Recently, yaml2obj has been turned into a library. This means we can use
it from our unit tests directly, instead of shelling out to an external
process. This patch does just that.
Reviewers: JDevlieghere, aadsm, espindola, jdoerfert
Subscribers: emaste, mgorny, arichardson, MaskRay, jhenderson, abrachet, lldb-commits
Differential Revision: https://reviews.llvm.org/D65949
llvm-svn: 369374
2019-08-20 20:28:36 +08:00
|
|
|
m_module_sp->ResolveSymbolContextsForFileSpec(file_spec, line, check_inlines,
|
|
|
|
lldb::eSymbolContextCompUnit,
|
|
|
|
sc_comp_units);
|
2019-05-07 23:37:28 +08:00
|
|
|
if (sc_comp_units.GetSize() == 0)
|
|
|
|
return llvm::createStringError(llvm::inconvertibleErrorCode(),
|
|
|
|
"No comp unit found on the test object.");
|
|
|
|
sc_comp_units[0].comp_unit->ResolveSymbolContext(
|
|
|
|
file_spec, line, check_inlines, exact, eSymbolContextLineEntry,
|
|
|
|
sc_line_entries);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(LineEntryTest, GetSameLineContiguousAddressRangeNoInlines) {
|
|
|
|
auto line_entry = GetLineEntryForLine(18);
|
|
|
|
ASSERT_THAT_EXPECTED(line_entry, llvm::Succeeded());
|
|
|
|
bool include_inlined_functions = false;
|
|
|
|
auto range =
|
|
|
|
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());
|
|
|
|
bool include_inlined_functions = true;
|
|
|
|
auto range =
|
|
|
|
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());
|
|
|
|
bool include_inlined_functions = true;
|
|
|
|
auto range =
|
|
|
|
line_entry->GetSameLineContiguousAddressRange(include_inlined_functions);
|
|
|
|
ASSERT_EQ(range.GetByteSize(), (uint64_t)0x33);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
# inlined-functions.cpp
|
|
|
|
inline __attribute__((always_inline)) int sum2(int a, int b) {
|
|
|
|
int result = a + b;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
int sum3(int a, int b, int c) {
|
|
|
|
int result = a + b + c;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline __attribute__((always_inline)) int sum4(int a, int b, int c, int d) {
|
|
|
|
int result = sum2(a, b) + sum2(c, d);
|
|
|
|
result += 0;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
sum3(3, 4, 5) + sum2(1, 2);
|
|
|
|
int sum = sum4(1, 2, 3, 4);
|
|
|
|
sum2(5, 6);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// g++ -c inlined-functions.cpp -o inlined-functions.o -g -Wno-unused-value
|
|
|
|
// obj2yaml inlined-functions.o > inlined-functions.yaml
|
|
|
|
|
|
|
|
# Dump of source line per address:
|
|
|
|
# inlined-functions.cpp is src.cpp for space considerations.
|
|
|
|
0x20: src.cpp:17
|
|
|
|
0x21: src.cpp:17
|
|
|
|
0x26: src.cpp:17
|
|
|
|
0x27: src.cpp:17
|
|
|
|
0x29: src.cpp:17
|
|
|
|
0x2e: src.cpp:17
|
|
|
|
0x2f: src.cpp:17
|
|
|
|
0x31: src.cpp:17
|
|
|
|
0x36: src.cpp:18
|
|
|
|
0x37: src.cpp:18
|
|
|
|
0x39: src.cpp:18
|
|
|
|
0x3e: src.cpp:18
|
|
|
|
0x3f: src.cpp:18
|
|
|
|
0x41: src.cpp:18
|
|
|
|
0x46: src.cpp:18
|
|
|
|
0x47: src.cpp:18
|
|
|
|
0x49: src.cpp:18
|
|
|
|
0x4e: src.cpp:18
|
|
|
|
0x4f: src.cpp:18
|
|
|
|
0x51: src.cpp:18
|
|
|
|
0x56: src.cpp:18
|
|
|
|
0x57: src.cpp:18
|
|
|
|
0x59: src.cpp:18
|
|
|
|
0x5e: src.cpp:18 -> sum2@src.cpp:2
|
|
|
|
0x5f: src.cpp:18 -> sum2@src.cpp:2
|
|
|
|
0x61: src.cpp:18 -> sum2@src.cpp:2
|
|
|
|
0x66: src.cpp:18 -> sum2@src.cpp:2
|
|
|
|
0x67: src.cpp:18 -> sum2@src.cpp:2
|
|
|
|
0x69: src.cpp:18 -> sum2@src.cpp:2
|
|
|
|
0x6e: src.cpp:18 -> sum2@src.cpp:2
|
|
|
|
0x6f: src.cpp:18 -> sum2@src.cpp:2
|
|
|
|
0x71: src.cpp:18 -> sum2@src.cpp:2
|
|
|
|
0x76: src.cpp:18 -> sum2@src.cpp:2
|
|
|
|
0x77: src.cpp:18 -> sum2@src.cpp:2
|
|
|
|
0x79: src.cpp:18 -> sum2@src.cpp:2
|
|
|
|
0x7e: src.cpp:18 -> sum2@src.cpp:2
|
|
|
|
0x7f: src.cpp:19 -> sum4@src.cpp:12
|
|
|
|
0x81: src.cpp:19 -> sum4@src.cpp:12
|
|
|
|
0x86: src.cpp:19 -> sum4@src.cpp:12
|
|
|
|
0x87: src.cpp:19 -> sum4@src.cpp:12
|
|
|
|
0x89: src.cpp:19 -> sum4@src.cpp:12
|
|
|
|
0x8e: src.cpp:19 -> sum4@src.cpp:12 -> sum2@src.cpp:2
|
|
|
|
0x8f: src.cpp:19 -> sum4@src.cpp:12 -> sum2@src.cpp:2
|
|
|
|
0x91: src.cpp:19 -> sum4@src.cpp:12 -> sum2@src.cpp:2
|
|
|
|
0x96: src.cpp:19 -> sum4@src.cpp:12 -> sum2@src.cpp:3
|
|
|
|
0x97: src.cpp:19 -> sum4@src.cpp:12
|
|
|
|
0x99: src.cpp:19 -> sum4@src.cpp:12
|
|
|
|
0x9e: src.cpp:19 -> sum4@src.cpp:12
|
|
|
|
0x9f: src.cpp:19 -> sum4@src.cpp:12
|
|
|
|
0xa1: src.cpp:19 -> sum4@src.cpp:12
|
|
|
|
0xa6: src.cpp:19 -> sum4@src.cpp:12 -> sum2@src.cpp:2
|
|
|
|
0xa7: src.cpp:19 -> sum4@src.cpp:12 -> sum2@src.cpp:2
|
|
|
|
0xa9: src.cpp:19 -> sum4@src.cpp:12 -> sum2@src.cpp:2
|
|
|
|
0xae: src.cpp:19 -> sum4@src.cpp:12
|
|
|
|
0xaf: src.cpp:19 -> sum4@src.cpp:12
|
|
|
|
0xb1: src.cpp:19 -> sum4@src.cpp:12
|
|
|
|
0xb6: src.cpp:19 -> sum4@src.cpp:13
|
|
|
|
0xb7: src.cpp:19 -> sum4@src.cpp:13
|
|
|
|
0xb9: src.cpp:19 -> sum4@src.cpp:14
|
|
|
|
0xbe: src.cpp:19
|
|
|
|
0xbf: src.cpp:19
|
|
|
|
0xc1: src.cpp:19
|
|
|
|
0xc6: src.cpp:19
|
|
|
|
0xc7: src.cpp:19
|
|
|
|
0xc9: src.cpp:19
|
|
|
|
0xce: src.cpp:20 -> sum2@src.cpp:2
|
|
|
|
0xcf: src.cpp:20 -> sum2@src.cpp:2
|
|
|
|
0xd1: src.cpp:20 -> sum2@src.cpp:2
|
|
|
|
0xd6: src.cpp:21
|
|
|
|
0xd7: src.cpp:21
|
|
|
|
0xd9: src.cpp:21
|
|
|
|
0xde: src.cpp:21
|
|
|
|
*/
|