*** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style. This kind of mass change has
*** two obvious implications:
Firstly, merging this particular commit into a downstream fork may be a huge
effort. Alternatively, it may be worth merging all changes up to this commit,
performing the same reformatting operation locally, and then discarding the
merge for this particular commit. The commands used to accomplish this
reformatting were as follows (with current working directory as the root of
the repository):
find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} +
find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ;
The version of clang-format used was 3.9.0, and autopep8 was 1.2.4.
Secondly, “blame” style tools will generally point to this commit instead of
a meaningful prior commit. There are alternatives available that will attempt
to look through this change and find the appropriate prior commit. YMMV.
llvm-svn: 280751
diff --git a/lldb/unittests/SymbolFile/PDB/Inputs/test-dwarf.cpp b/lldb/unittests/SymbolFile/PDB/Inputs/test-dwarf.cpp
index f86ff3d..a987e6a 100644
--- a/lldb/unittests/SymbolFile/PDB/Inputs/test-dwarf.cpp
+++ b/lldb/unittests/SymbolFile/PDB/Inputs/test-dwarf.cpp
@@ -1,14 +1,6 @@
// Compile with "cl /c /Zi /GR- test.cpp"
// Link with "link test.obj /debug /nodefaultlib /entry:main /out:test.exe"
-int __cdecl _purecall(void)
-{
- return 0;
-}
+int __cdecl _purecall(void) { return 0; }
-int
-main(int argc, char **argv)
-{
-
- return 0;
-}
+int main(int argc, char **argv) { return 0; }
diff --git a/lldb/unittests/SymbolFile/PDB/Inputs/test-pdb-alt.cpp b/lldb/unittests/SymbolFile/PDB/Inputs/test-pdb-alt.cpp
index d36f15e..33d7df0 100644
--- a/lldb/unittests/SymbolFile/PDB/Inputs/test-pdb-alt.cpp
+++ b/lldb/unittests/SymbolFile/PDB/Inputs/test-pdb-alt.cpp
@@ -1,9 +1,7 @@
// Compile with "cl /c /Zi /GR- test-pdb-alt.cpp"
-// Link with "link test-pdb.obj test-pdb-alt.obj /debug /nodefaultlib /entry:main /out:test-pdb.exe"
+// Link with "link test-pdb.obj test-pdb-alt.obj /debug /nodefaultlib
+// /entry:main /out:test-pdb.exe"
#include "test-pdb.h"
-int bar(int n)
-{
- return n-1;
-}
+int bar(int n) { return n - 1; }
diff --git a/lldb/unittests/SymbolFile/PDB/Inputs/test-pdb-nested.h b/lldb/unittests/SymbolFile/PDB/Inputs/test-pdb-nested.h
index fc63b50..d0a93d8 100644
--- a/lldb/unittests/SymbolFile/PDB/Inputs/test-pdb-nested.h
+++ b/lldb/unittests/SymbolFile/PDB/Inputs/test-pdb-nested.h
@@ -1,9 +1,6 @@
#ifndef TEST_PDB_NESTED_H
#define TEST_PDB_NESTED_H
-inline int baz(int n)
-{
- return n+1;
-}
+inline int baz(int n) { return n + 1; }
#endif
\ No newline at end of file
diff --git a/lldb/unittests/SymbolFile/PDB/Inputs/test-pdb-types.cpp b/lldb/unittests/SymbolFile/PDB/Inputs/test-pdb-types.cpp
index 9639a3f..89d69c1 100644
--- a/lldb/unittests/SymbolFile/PDB/Inputs/test-pdb-types.cpp
+++ b/lldb/unittests/SymbolFile/PDB/Inputs/test-pdb-types.cpp
@@ -1,5 +1,6 @@
// Compile with "cl /c /Zi /GR- /EHsc test-pdb-types.cpp"
-// Link with "link test-pdb-types.obj /debug /nodefaultlib /entry:main /out:test-pdb-types.exe"
+// Link with "link test-pdb-types.obj /debug /nodefaultlib /entry:main
+// /out:test-pdb-types.exe"
using namespace std;
@@ -21,42 +22,29 @@
static const int sizeof_bool = sizeof(bool);
static const int sizeof_wchar = sizeof(wchar_t);
-enum Enum
-{
- EValue1 = 1,
- EValue2 = 2,
+enum Enum {
+ EValue1 = 1,
+ EValue2 = 2,
};
-enum ShortEnum : short
-{
- ESValue1 = 1,
- ESValue2 = 2
-};
+enum ShortEnum : short { ESValue1 = 1, ESValue2 = 2 };
-namespace NS
-{
-class NSClass
-{
- float f;
- double d;
+namespace NS {
+class NSClass {
+ float f;
+ double d;
};
}
-class Class
-{
+class Class {
public:
- class NestedClass
- {
- Enum e;
- };
- ShortEnum se;
+ class NestedClass {
+ Enum e;
+ };
+ ShortEnum se;
};
-int
-test_func(int a, int b)
-{
- return a + b;
-}
+int test_func(int a, int b) { return a + b; }
typedef Class ClassTypedef;
typedef NS::NSClass NSClassTypedef;
@@ -71,16 +59,14 @@
static const int sizeof_NSClassTypedef = sizeof(NSClassTypedef);
static const int sizeof_GlobalArray = sizeof(GlobalArray);
-int
-main(int argc, char **argv)
-{
- ShortEnum e1;
- Enum e2;
- Class c1;
- Class::NestedClass c2;
- NS::NSClass c3;
+int main(int argc, char **argv) {
+ ShortEnum e1;
+ Enum e2;
+ Class c1;
+ Class::NestedClass c2;
+ NS::NSClass c3;
- ClassTypedef t1;
- NSClassTypedef t2;
- return test_func(1, 2);
+ ClassTypedef t1;
+ NSClassTypedef t2;
+ return test_func(1, 2);
}
diff --git a/lldb/unittests/SymbolFile/PDB/Inputs/test-pdb.cpp b/lldb/unittests/SymbolFile/PDB/Inputs/test-pdb.cpp
index c9bf057..77956ac 100644
--- a/lldb/unittests/SymbolFile/PDB/Inputs/test-pdb.cpp
+++ b/lldb/unittests/SymbolFile/PDB/Inputs/test-pdb.cpp
@@ -1,15 +1,9 @@
// Compile with "cl /c /Zi /GR- test-pdb.cpp"
-// Link with "link test-pdb.obj /debug /nodefaultlib /entry:main /out:test-pdb.exe"
+// Link with "link test-pdb.obj /debug /nodefaultlib /entry:main
+// /out:test-pdb.exe"
#include "test-pdb.h"
-int __cdecl _purecall(void)
-{
- return 0;
-}
+int __cdecl _purecall(void) { return 0; }
-int
-main(int argc, char **argv)
-{
- return foo(argc) + bar(argc);
-}
+int main(int argc, char **argv) { return foo(argc) + bar(argc); }
diff --git a/lldb/unittests/SymbolFile/PDB/Inputs/test-pdb.h b/lldb/unittests/SymbolFile/PDB/Inputs/test-pdb.h
index 273343b..077d9d6 100644
--- a/lldb/unittests/SymbolFile/PDB/Inputs/test-pdb.h
+++ b/lldb/unittests/SymbolFile/PDB/Inputs/test-pdb.h
@@ -5,9 +5,6 @@
int bar(int n);
-inline int foo(int n)
-{
- return baz(n)+1;
-}
+inline int foo(int n) { return baz(n) + 1; }
#endif
\ No newline at end of file
diff --git a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
index b303ae7..4d60251 100644
--- a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
+++ b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
@@ -42,126 +42,116 @@
using namespace lldb_private;
-class SymbolFilePDBTests : public testing::Test
-{
+class SymbolFilePDBTests : public testing::Test {
public:
- void
- SetUp() override
- {
+ void SetUp() override {
// Initialize and TearDown the plugin every time, so we get a brand new
// AST every time so that modifications to the AST from each test don't
// leak into the next test.
#if defined(_MSC_VER)
- ::CoInitializeEx(nullptr, COINIT_MULTITHREADED);
+ ::CoInitializeEx(nullptr, COINIT_MULTITHREADED);
#endif
- HostInfo::Initialize();
- ObjectFilePECOFF::Initialize();
- SymbolFileDWARF::Initialize();
- ClangASTContext::Initialize();
- SymbolFilePDB::Initialize();
+ HostInfo::Initialize();
+ ObjectFilePECOFF::Initialize();
+ SymbolFileDWARF::Initialize();
+ ClangASTContext::Initialize();
+ SymbolFilePDB::Initialize();
- llvm::StringRef exe_folder = llvm::sys::path::parent_path(TestMainArgv0);
- llvm::SmallString<128> inputs_folder = exe_folder;
- llvm::sys::path::append(inputs_folder, "Inputs");
+ llvm::StringRef exe_folder = llvm::sys::path::parent_path(TestMainArgv0);
+ llvm::SmallString<128> inputs_folder = exe_folder;
+ llvm::sys::path::append(inputs_folder, "Inputs");
- m_pdb_test_exe = inputs_folder;
- m_dwarf_test_exe = inputs_folder;
- m_types_test_exe = inputs_folder;
- llvm::sys::path::append(m_pdb_test_exe, "test-pdb.exe");
- llvm::sys::path::append(m_dwarf_test_exe, "test-dwarf.exe");
- llvm::sys::path::append(m_types_test_exe, "test-pdb-types.exe");
- }
+ m_pdb_test_exe = inputs_folder;
+ m_dwarf_test_exe = inputs_folder;
+ m_types_test_exe = inputs_folder;
+ llvm::sys::path::append(m_pdb_test_exe, "test-pdb.exe");
+ llvm::sys::path::append(m_dwarf_test_exe, "test-dwarf.exe");
+ llvm::sys::path::append(m_types_test_exe, "test-pdb-types.exe");
+ }
- void
- TearDown() override
- {
- SymbolFilePDB::Terminate();
- ClangASTContext::Initialize();
- SymbolFileDWARF::Terminate();
- ObjectFilePECOFF::Terminate();
- HostInfo::Terminate();
+ void TearDown() override {
+ SymbolFilePDB::Terminate();
+ ClangASTContext::Initialize();
+ SymbolFileDWARF::Terminate();
+ ObjectFilePECOFF::Terminate();
+ HostInfo::Terminate();
#if defined(_MSC_VER)
- ::CoUninitialize();
+ ::CoUninitialize();
#endif
- }
+ }
protected:
- llvm::SmallString<128> m_pdb_test_exe;
- llvm::SmallString<128> m_dwarf_test_exe;
- llvm::SmallString<128> m_types_test_exe;
+ llvm::SmallString<128> m_pdb_test_exe;
+ llvm::SmallString<128> m_dwarf_test_exe;
+ llvm::SmallString<128> m_types_test_exe;
- bool
- FileSpecMatchesAsBaseOrFull(const FileSpec &left, const FileSpec &right) const
- {
- // If the filenames don't match, the paths can't be equal
- if (!left.FileEquals(right))
- return false;
- // If BOTH have a directory, also compare the directories.
- if (left.GetDirectory() && right.GetDirectory())
- return left.DirectoryEquals(right);
+ bool FileSpecMatchesAsBaseOrFull(const FileSpec &left,
+ const FileSpec &right) const {
+ // If the filenames don't match, the paths can't be equal
+ if (!left.FileEquals(right))
+ return false;
+ // If BOTH have a directory, also compare the directories.
+ if (left.GetDirectory() && right.GetDirectory())
+ return left.DirectoryEquals(right);
- // If one has a directory but not the other, they match.
+ // If one has a directory but not the other, they match.
+ return true;
+ }
+
+ void VerifyLineEntry(lldb::ModuleSP module, const SymbolContext &sc,
+ const FileSpec &spec, LineTable <, uint32_t line,
+ lldb::addr_t addr) {
+ LineEntry entry;
+ Address address;
+ EXPECT_TRUE(module->ResolveFileAddress(addr, address));
+
+ EXPECT_TRUE(lt.FindLineEntryByAddress(address, entry));
+ EXPECT_EQ(line, entry.line);
+ EXPECT_EQ(address, entry.range.GetBaseAddress());
+
+ EXPECT_TRUE(FileSpecMatchesAsBaseOrFull(spec, entry.file));
+ }
+
+ bool ContainsCompileUnit(const SymbolContextList &sc_list,
+ const FileSpec &spec) const {
+ for (size_t i = 0; i < sc_list.GetSize(); ++i) {
+ const SymbolContext &sc = sc_list[i];
+ if (FileSpecMatchesAsBaseOrFull(*sc.comp_unit, spec))
return true;
}
+ return false;
+ }
- void
- VerifyLineEntry(lldb::ModuleSP module, const SymbolContext &sc, const FileSpec &spec, LineTable <, uint32_t line,
- lldb::addr_t addr)
- {
- LineEntry entry;
- Address address;
- EXPECT_TRUE(module->ResolveFileAddress(addr, address));
+ int GetGlobalConstantInteger(const llvm::pdb::IPDBSession &session,
+ llvm::StringRef var) const {
+ auto global = session.getGlobalScope();
+ auto results =
+ global->findChildren(llvm::pdb::PDB_SymType::Data, var,
+ llvm::pdb::PDB_NameSearchFlags::NS_Default);
+ uint32_t count = results->getChildCount();
+ if (count == 0)
+ return -1;
- EXPECT_TRUE(lt.FindLineEntryByAddress(address, entry));
- EXPECT_EQ(line, entry.line);
- EXPECT_EQ(address, entry.range.GetBaseAddress());
-
- EXPECT_TRUE(FileSpecMatchesAsBaseOrFull(spec, entry.file));
+ auto item = results->getChildAtIndex(0);
+ auto symbol = llvm::dyn_cast<llvm::pdb::PDBSymbolData>(item.get());
+ if (!symbol)
+ return -1;
+ llvm::pdb::Variant value = symbol->getValue();
+ switch (value.Type) {
+ case llvm::pdb::PDB_VariantType::Int16:
+ return value.Value.Int16;
+ case llvm::pdb::PDB_VariantType::Int32:
+ return value.Value.Int32;
+ case llvm::pdb::PDB_VariantType::UInt16:
+ return value.Value.UInt16;
+ case llvm::pdb::PDB_VariantType::UInt32:
+ return value.Value.UInt32;
+ default:
+ return 0;
}
-
- bool
- ContainsCompileUnit(const SymbolContextList &sc_list, const FileSpec &spec) const
- {
- for (size_t i = 0; i < sc_list.GetSize(); ++i)
- {
- const SymbolContext &sc = sc_list[i];
- if (FileSpecMatchesAsBaseOrFull(*sc.comp_unit, spec))
- return true;
- }
- return false;
- }
-
- int
- GetGlobalConstantInteger(const llvm::pdb::IPDBSession &session, llvm::StringRef var) const
- {
- auto global = session.getGlobalScope();
- auto results =
- global->findChildren(llvm::pdb::PDB_SymType::Data, var, llvm::pdb::PDB_NameSearchFlags::NS_Default);
- uint32_t count = results->getChildCount();
- if (count == 0)
- return -1;
-
- auto item = results->getChildAtIndex(0);
- auto symbol = llvm::dyn_cast<llvm::pdb::PDBSymbolData>(item.get());
- if (!symbol)
- return -1;
- llvm::pdb::Variant value = symbol->getValue();
- switch (value.Type)
- {
- case llvm::pdb::PDB_VariantType::Int16:
- return value.Value.Int16;
- case llvm::pdb::PDB_VariantType::Int32:
- return value.Value.Int32;
- case llvm::pdb::PDB_VariantType::UInt16:
- return value.Value.UInt16;
- case llvm::pdb::PDB_VariantType::UInt32:
- return value.Value.UInt32;
- default:
- return 0;
- }
- }
+ }
};
#if defined(HAVE_DIA_SDK)
@@ -170,414 +160,443 @@
#define REQUIRES_DIA_SDK(TestName) DISABLED_##TestName
#endif
-TEST_F(SymbolFilePDBTests, TestAbilitiesForDWARF)
-{
- // Test that when we have Dwarf debug info, SymbolFileDWARF is used.
- FileSpec fspec(m_dwarf_test_exe.c_str(), false);
- ArchSpec aspec("i686-pc-windows");
- lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
+TEST_F(SymbolFilePDBTests, TestAbilitiesForDWARF) {
+ // Test that when we have Dwarf debug info, SymbolFileDWARF is used.
+ FileSpec fspec(m_dwarf_test_exe.c_str(), false);
+ ArchSpec aspec("i686-pc-windows");
+ lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
- SymbolVendor *plugin = module->GetSymbolVendor();
- EXPECT_NE(nullptr, plugin);
- SymbolFile *symfile = plugin->GetSymbolFile();
- EXPECT_NE(nullptr, symfile);
- EXPECT_EQ(symfile->GetPluginName(), SymbolFileDWARF::GetPluginNameStatic());
+ SymbolVendor *plugin = module->GetSymbolVendor();
+ EXPECT_NE(nullptr, plugin);
+ SymbolFile *symfile = plugin->GetSymbolFile();
+ EXPECT_NE(nullptr, symfile);
+ EXPECT_EQ(symfile->GetPluginName(), SymbolFileDWARF::GetPluginNameStatic());
- uint32_t expected_abilities = SymbolFile::kAllAbilities;
- EXPECT_EQ(expected_abilities, symfile->CalculateAbilities());
+ uint32_t expected_abilities = SymbolFile::kAllAbilities;
+ EXPECT_EQ(expected_abilities, symfile->CalculateAbilities());
}
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestAbilitiesForPDB))
-{
- // Test that when we have PDB debug info, SymbolFilePDB is used.
- FileSpec fspec(m_pdb_test_exe.c_str(), false);
- ArchSpec aspec("i686-pc-windows");
- lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
+TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestAbilitiesForPDB)) {
+ // Test that when we have PDB debug info, SymbolFilePDB is used.
+ FileSpec fspec(m_pdb_test_exe.c_str(), false);
+ ArchSpec aspec("i686-pc-windows");
+ lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
- SymbolVendor *plugin = module->GetSymbolVendor();
- EXPECT_NE(nullptr, plugin);
- SymbolFile *symfile = plugin->GetSymbolFile();
- EXPECT_NE(nullptr, symfile);
- EXPECT_EQ(symfile->GetPluginName(), SymbolFilePDB::GetPluginNameStatic());
+ SymbolVendor *plugin = module->GetSymbolVendor();
+ EXPECT_NE(nullptr, plugin);
+ SymbolFile *symfile = plugin->GetSymbolFile();
+ EXPECT_NE(nullptr, symfile);
+ EXPECT_EQ(symfile->GetPluginName(), SymbolFilePDB::GetPluginNameStatic());
- uint32_t expected_abilities = SymbolFile::CompileUnits | SymbolFile::LineTables;
- EXPECT_EQ(expected_abilities, symfile->CalculateAbilities());
+ uint32_t expected_abilities =
+ SymbolFile::CompileUnits | SymbolFile::LineTables;
+ EXPECT_EQ(expected_abilities, symfile->CalculateAbilities());
}
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestResolveSymbolContextBasename))
-{
- // Test that attempting to call ResolveSymbolContext with only a basename finds all full paths
- // with the same basename
- FileSpec fspec(m_pdb_test_exe.c_str(), false);
- ArchSpec aspec("i686-pc-windows");
- lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
+TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestResolveSymbolContextBasename)) {
+ // Test that attempting to call ResolveSymbolContext with only a basename
+ // finds all full paths
+ // with the same basename
+ FileSpec fspec(m_pdb_test_exe.c_str(), false);
+ ArchSpec aspec("i686-pc-windows");
+ lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
- SymbolVendor *plugin = module->GetSymbolVendor();
- EXPECT_NE(nullptr, plugin);
- SymbolFile *symfile = plugin->GetSymbolFile();
+ SymbolVendor *plugin = module->GetSymbolVendor();
+ EXPECT_NE(nullptr, plugin);
+ SymbolFile *symfile = plugin->GetSymbolFile();
- FileSpec header_spec("test-pdb.cpp", false);
+ FileSpec header_spec("test-pdb.cpp", false);
+ SymbolContextList sc_list;
+ uint32_t result_count = symfile->ResolveSymbolContext(
+ header_spec, 0, false, lldb::eSymbolContextCompUnit, sc_list);
+ EXPECT_EQ(1u, result_count);
+ EXPECT_TRUE(ContainsCompileUnit(sc_list, header_spec));
+}
+
+TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestResolveSymbolContextFullPath)) {
+ // Test that attempting to call ResolveSymbolContext with a full path only
+ // finds the one source
+ // file that matches the full path.
+ FileSpec fspec(m_pdb_test_exe.c_str(), false);
+ ArchSpec aspec("i686-pc-windows");
+ lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
+
+ SymbolVendor *plugin = module->GetSymbolVendor();
+ EXPECT_NE(nullptr, plugin);
+ SymbolFile *symfile = plugin->GetSymbolFile();
+
+ FileSpec header_spec(
+ R"spec(D:\src\llvm\tools\lldb\unittests\SymbolFile\PDB\Inputs\test-pdb.cpp)spec",
+ false);
+ SymbolContextList sc_list;
+ uint32_t result_count = symfile->ResolveSymbolContext(
+ header_spec, 0, false, lldb::eSymbolContextCompUnit, sc_list);
+ EXPECT_GE(1u, result_count);
+ EXPECT_TRUE(ContainsCompileUnit(sc_list, header_spec));
+}
+
+TEST_F(SymbolFilePDBTests,
+ REQUIRES_DIA_SDK(TestLookupOfHeaderFileWithInlines)) {
+ // Test that when looking up a header file via ResolveSymbolContext (i.e. a
+ // file that was not by itself
+ // compiled, but only contributes to the combined code of other source files),
+ // a SymbolContext is returned
+ // for each compiland which has line contributions from the requested header.
+ FileSpec fspec(m_pdb_test_exe.c_str(), false);
+ ArchSpec aspec("i686-pc-windows");
+ lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
+
+ SymbolVendor *plugin = module->GetSymbolVendor();
+ EXPECT_NE(nullptr, plugin);
+ SymbolFile *symfile = plugin->GetSymbolFile();
+
+ FileSpec header_specs[] = {FileSpec("test-pdb.h", false),
+ FileSpec("test-pdb-nested.h", false)};
+ FileSpec main_cpp_spec("test-pdb.cpp", false);
+ FileSpec alt_cpp_spec("test-pdb-alt.cpp", false);
+ for (const auto &hspec : header_specs) {
SymbolContextList sc_list;
- uint32_t result_count = symfile->ResolveSymbolContext(header_spec, 0, false, lldb::eSymbolContextCompUnit, sc_list);
- EXPECT_EQ(1u, result_count);
- EXPECT_TRUE(ContainsCompileUnit(sc_list, header_spec));
+ uint32_t result_count = symfile->ResolveSymbolContext(
+ hspec, 0, true, lldb::eSymbolContextCompUnit, sc_list);
+ EXPECT_EQ(2u, result_count);
+ EXPECT_TRUE(ContainsCompileUnit(sc_list, main_cpp_spec));
+ EXPECT_TRUE(ContainsCompileUnit(sc_list, alt_cpp_spec));
+ }
}
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestResolveSymbolContextFullPath))
-{
- // Test that attempting to call ResolveSymbolContext with a full path only finds the one source
- // file that matches the full path.
- FileSpec fspec(m_pdb_test_exe.c_str(), false);
- ArchSpec aspec("i686-pc-windows");
- lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
+TEST_F(SymbolFilePDBTests,
+ REQUIRES_DIA_SDK(TestLookupOfHeaderFileWithNoInlines)) {
+ // Test that when looking up a header file via ResolveSymbolContext (i.e. a
+ // file that was not by itself
+ // compiled, but only contributes to the combined code of other source files),
+ // that if check_inlines
+ // is false, no SymbolContexts are returned.
+ FileSpec fspec(m_pdb_test_exe.c_str(), false);
+ ArchSpec aspec("i686-pc-windows");
+ lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
- SymbolVendor *plugin = module->GetSymbolVendor();
- EXPECT_NE(nullptr, plugin);
- SymbolFile *symfile = plugin->GetSymbolFile();
+ SymbolVendor *plugin = module->GetSymbolVendor();
+ EXPECT_NE(nullptr, plugin);
+ SymbolFile *symfile = plugin->GetSymbolFile();
- FileSpec header_spec(R"spec(D:\src\llvm\tools\lldb\unittests\SymbolFile\PDB\Inputs\test-pdb.cpp)spec", false);
+ FileSpec header_specs[] = {FileSpec("test-pdb.h", false),
+ FileSpec("test-pdb-nested.h", false)};
+ for (const auto &hspec : header_specs) {
SymbolContextList sc_list;
- uint32_t result_count = symfile->ResolveSymbolContext(header_spec, 0, false, lldb::eSymbolContextCompUnit, sc_list);
- EXPECT_GE(1u, result_count);
- EXPECT_TRUE(ContainsCompileUnit(sc_list, header_spec));
+ uint32_t result_count = symfile->ResolveSymbolContext(
+ hspec, 0, false, lldb::eSymbolContextCompUnit, sc_list);
+ EXPECT_EQ(0u, result_count);
+ }
}
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestLookupOfHeaderFileWithInlines))
-{
- // Test that when looking up a header file via ResolveSymbolContext (i.e. a file that was not by itself
- // compiled, but only contributes to the combined code of other source files), a SymbolContext is returned
- // for each compiland which has line contributions from the requested header.
- FileSpec fspec(m_pdb_test_exe.c_str(), false);
- ArchSpec aspec("i686-pc-windows");
- lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
+TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestLineTablesMatchAll)) {
+ // Test that when calling ResolveSymbolContext with a line number of 0, all
+ // line entries from
+ // the specified files are returned.
+ FileSpec fspec(m_pdb_test_exe.c_str(), false);
+ ArchSpec aspec("i686-pc-windows");
+ lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
- SymbolVendor *plugin = module->GetSymbolVendor();
- EXPECT_NE(nullptr, plugin);
- SymbolFile *symfile = plugin->GetSymbolFile();
+ SymbolVendor *plugin = module->GetSymbolVendor();
+ SymbolFile *symfile = plugin->GetSymbolFile();
- FileSpec header_specs[] = {FileSpec("test-pdb.h", false), FileSpec("test-pdb-nested.h", false)};
- FileSpec main_cpp_spec("test-pdb.cpp", false);
- FileSpec alt_cpp_spec("test-pdb-alt.cpp", false);
- for (const auto &hspec : header_specs)
- {
- SymbolContextList sc_list;
- uint32_t result_count = symfile->ResolveSymbolContext(hspec, 0, true, lldb::eSymbolContextCompUnit, sc_list);
- EXPECT_EQ(2u, result_count);
- EXPECT_TRUE(ContainsCompileUnit(sc_list, main_cpp_spec));
- EXPECT_TRUE(ContainsCompileUnit(sc_list, alt_cpp_spec));
- }
+ FileSpec source_file("test-pdb.cpp", false);
+ FileSpec header1("test-pdb.h", false);
+ FileSpec header2("test-pdb-nested.h", false);
+ uint32_t cus = symfile->GetNumCompileUnits();
+ EXPECT_EQ(2u, cus);
+
+ SymbolContextList sc_list;
+ uint32_t scope = lldb::eSymbolContextCompUnit | lldb::eSymbolContextLineEntry;
+
+ uint32_t count =
+ symfile->ResolveSymbolContext(source_file, 0, true, scope, sc_list);
+ EXPECT_EQ(1u, count);
+ SymbolContext sc;
+ EXPECT_TRUE(sc_list.GetContextAtIndex(0, sc));
+
+ LineTable *lt = sc.comp_unit->GetLineTable();
+ EXPECT_NE(nullptr, lt);
+ count = lt->GetSize();
+ // We expect one extra entry for termination (per function)
+ EXPECT_EQ(16u, count);
+
+ VerifyLineEntry(module, sc, source_file, *lt, 7, 0x401040);
+ VerifyLineEntry(module, sc, source_file, *lt, 8, 0x401043);
+ VerifyLineEntry(module, sc, source_file, *lt, 9, 0x401045);
+
+ VerifyLineEntry(module, sc, source_file, *lt, 13, 0x401050);
+ VerifyLineEntry(module, sc, source_file, *lt, 14, 0x401054);
+ VerifyLineEntry(module, sc, source_file, *lt, 15, 0x401070);
+
+ VerifyLineEntry(module, sc, header1, *lt, 9, 0x401090);
+ VerifyLineEntry(module, sc, header1, *lt, 10, 0x401093);
+ VerifyLineEntry(module, sc, header1, *lt, 11, 0x4010a2);
+
+ VerifyLineEntry(module, sc, header2, *lt, 5, 0x401080);
+ VerifyLineEntry(module, sc, header2, *lt, 6, 0x401083);
+ VerifyLineEntry(module, sc, header2, *lt, 7, 0x401089);
}
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestLookupOfHeaderFileWithNoInlines))
-{
- // Test that when looking up a header file via ResolveSymbolContext (i.e. a file that was not by itself
- // compiled, but only contributes to the combined code of other source files), that if check_inlines
- // is false, no SymbolContexts are returned.
- FileSpec fspec(m_pdb_test_exe.c_str(), false);
- ArchSpec aspec("i686-pc-windows");
- lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
+TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestLineTablesMatchSpecific)) {
+ // Test that when calling ResolveSymbolContext with a specific line number,
+ // only line entries
+ // which match the requested line are returned.
+ FileSpec fspec(m_pdb_test_exe.c_str(), false);
+ ArchSpec aspec("i686-pc-windows");
+ lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
- SymbolVendor *plugin = module->GetSymbolVendor();
- EXPECT_NE(nullptr, plugin);
- SymbolFile *symfile = plugin->GetSymbolFile();
+ SymbolVendor *plugin = module->GetSymbolVendor();
+ SymbolFile *symfile = plugin->GetSymbolFile();
- FileSpec header_specs[] = {FileSpec("test-pdb.h", false), FileSpec("test-pdb-nested.h", false)};
- for (const auto &hspec : header_specs)
- {
- SymbolContextList sc_list;
- uint32_t result_count = symfile->ResolveSymbolContext(hspec, 0, false, lldb::eSymbolContextCompUnit, sc_list);
- EXPECT_EQ(0u, result_count);
- }
+ FileSpec source_file("test-pdb.cpp", false);
+ FileSpec header1("test-pdb.h", false);
+ FileSpec header2("test-pdb-nested.h", false);
+ uint32_t cus = symfile->GetNumCompileUnits();
+ EXPECT_EQ(2u, cus);
+
+ SymbolContextList sc_list;
+ uint32_t scope = lldb::eSymbolContextCompUnit | lldb::eSymbolContextLineEntry;
+
+ // First test with line 7, and verify that only line 7 entries are added.
+ uint32_t count =
+ symfile->ResolveSymbolContext(source_file, 7, true, scope, sc_list);
+ EXPECT_EQ(1u, count);
+ SymbolContext sc;
+ EXPECT_TRUE(sc_list.GetContextAtIndex(0, sc));
+
+ LineTable *lt = sc.comp_unit->GetLineTable();
+ EXPECT_NE(nullptr, lt);
+ count = lt->GetSize();
+ // We expect one extra entry for termination
+ EXPECT_EQ(3u, count);
+
+ VerifyLineEntry(module, sc, source_file, *lt, 7, 0x401040);
+ VerifyLineEntry(module, sc, header2, *lt, 7, 0x401089);
+
+ sc_list.Clear();
+ // Then test with line 9, and verify that only line 9 entries are added.
+ count = symfile->ResolveSymbolContext(source_file, 9, true, scope, sc_list);
+ EXPECT_EQ(1u, count);
+ EXPECT_TRUE(sc_list.GetContextAtIndex(0, sc));
+
+ lt = sc.comp_unit->GetLineTable();
+ EXPECT_NE(nullptr, lt);
+ count = lt->GetSize();
+ // We expect one extra entry for termination
+ EXPECT_EQ(3u, count);
+
+ VerifyLineEntry(module, sc, source_file, *lt, 9, 0x401045);
+ VerifyLineEntry(module, sc, header1, *lt, 9, 0x401090);
}
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestLineTablesMatchAll))
-{
- // Test that when calling ResolveSymbolContext with a line number of 0, all line entries from
- // the specified files are returned.
- FileSpec fspec(m_pdb_test_exe.c_str(), false);
- ArchSpec aspec("i686-pc-windows");
- lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
+TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestSimpleClassTypes)) {
+ FileSpec fspec(m_types_test_exe.c_str(), false);
+ ArchSpec aspec("i686-pc-windows");
+ lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
- SymbolVendor *plugin = module->GetSymbolVendor();
- SymbolFile *symfile = plugin->GetSymbolFile();
-
- FileSpec source_file("test-pdb.cpp", false);
- FileSpec header1("test-pdb.h", false);
- FileSpec header2("test-pdb-nested.h", false);
- uint32_t cus = symfile->GetNumCompileUnits();
- EXPECT_EQ(2u, cus);
-
- SymbolContextList sc_list;
- uint32_t scope = lldb::eSymbolContextCompUnit | lldb::eSymbolContextLineEntry;
-
- uint32_t count = symfile->ResolveSymbolContext(source_file, 0, true, scope, sc_list);
- EXPECT_EQ(1u, count);
- SymbolContext sc;
- EXPECT_TRUE(sc_list.GetContextAtIndex(0, sc));
-
- LineTable *lt = sc.comp_unit->GetLineTable();
- EXPECT_NE(nullptr, lt);
- count = lt->GetSize();
- // We expect one extra entry for termination (per function)
- EXPECT_EQ(16u, count);
-
- VerifyLineEntry(module, sc, source_file, *lt, 7, 0x401040);
- VerifyLineEntry(module, sc, source_file, *lt, 8, 0x401043);
- VerifyLineEntry(module, sc, source_file, *lt, 9, 0x401045);
-
- VerifyLineEntry(module, sc, source_file, *lt, 13, 0x401050);
- VerifyLineEntry(module, sc, source_file, *lt, 14, 0x401054);
- VerifyLineEntry(module, sc, source_file, *lt, 15, 0x401070);
-
- VerifyLineEntry(module, sc, header1, *lt, 9, 0x401090);
- VerifyLineEntry(module, sc, header1, *lt, 10, 0x401093);
- VerifyLineEntry(module, sc, header1, *lt, 11, 0x4010a2);
-
- VerifyLineEntry(module, sc, header2, *lt, 5, 0x401080);
- VerifyLineEntry(module, sc, header2, *lt, 6, 0x401083);
- VerifyLineEntry(module, sc, header2, *lt, 7, 0x401089);
+ SymbolVendor *plugin = module->GetSymbolVendor();
+ SymbolFilePDB *symfile =
+ static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
+ const llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
+ SymbolContext sc;
+ llvm::DenseSet<SymbolFile *> searched_files;
+ TypeMap results;
+ EXPECT_EQ(1u, symfile->FindTypes(sc, ConstString("Class"), nullptr, false, 0,
+ searched_files, results));
+ EXPECT_EQ(1u, results.GetSize());
+ lldb::TypeSP udt_type = results.GetTypeAtIndex(0);
+ EXPECT_EQ(ConstString("Class"), udt_type->GetName());
+ CompilerType compiler_type = udt_type->GetForwardCompilerType();
+ EXPECT_TRUE(ClangASTContext::IsClassType(compiler_type.GetOpaqueQualType()));
+ EXPECT_EQ(uint64_t(GetGlobalConstantInteger(session, "sizeof_Class")),
+ udt_type->GetByteSize());
}
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestLineTablesMatchSpecific))
-{
- // Test that when calling ResolveSymbolContext with a specific line number, only line entries
- // which match the requested line are returned.
- FileSpec fspec(m_pdb_test_exe.c_str(), false);
- ArchSpec aspec("i686-pc-windows");
- lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
+TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestNestedClassTypes)) {
+ FileSpec fspec(m_types_test_exe.c_str(), false);
+ ArchSpec aspec("i686-pc-windows");
+ lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
- SymbolVendor *plugin = module->GetSymbolVendor();
- SymbolFile *symfile = plugin->GetSymbolFile();
-
- FileSpec source_file("test-pdb.cpp", false);
- FileSpec header1("test-pdb.h", false);
- FileSpec header2("test-pdb-nested.h", false);
- uint32_t cus = symfile->GetNumCompileUnits();
- EXPECT_EQ(2u, cus);
-
- SymbolContextList sc_list;
- uint32_t scope = lldb::eSymbolContextCompUnit | lldb::eSymbolContextLineEntry;
-
- // First test with line 7, and verify that only line 7 entries are added.
- uint32_t count = symfile->ResolveSymbolContext(source_file, 7, true, scope, sc_list);
- EXPECT_EQ(1u, count);
- SymbolContext sc;
- EXPECT_TRUE(sc_list.GetContextAtIndex(0, sc));
-
- LineTable *lt = sc.comp_unit->GetLineTable();
- EXPECT_NE(nullptr, lt);
- count = lt->GetSize();
- // We expect one extra entry for termination
- EXPECT_EQ(3u, count);
-
- VerifyLineEntry(module, sc, source_file, *lt, 7, 0x401040);
- VerifyLineEntry(module, sc, header2, *lt, 7, 0x401089);
-
- sc_list.Clear();
- // Then test with line 9, and verify that only line 9 entries are added.
- count = symfile->ResolveSymbolContext(source_file, 9, true, scope, sc_list);
- EXPECT_EQ(1u, count);
- EXPECT_TRUE(sc_list.GetContextAtIndex(0, sc));
-
- lt = sc.comp_unit->GetLineTable();
- EXPECT_NE(nullptr, lt);
- count = lt->GetSize();
- // We expect one extra entry for termination
- EXPECT_EQ(3u, count);
-
- VerifyLineEntry(module, sc, source_file, *lt, 9, 0x401045);
- VerifyLineEntry(module, sc, header1, *lt, 9, 0x401090);
+ SymbolVendor *plugin = module->GetSymbolVendor();
+ SymbolFilePDB *symfile =
+ static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
+ const llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
+ SymbolContext sc;
+ llvm::DenseSet<SymbolFile *> searched_files;
+ TypeMap results;
+ EXPECT_EQ(1u, symfile->FindTypes(sc, ConstString("Class::NestedClass"),
+ nullptr, false, 0, searched_files, results));
+ EXPECT_EQ(1u, results.GetSize());
+ lldb::TypeSP udt_type = results.GetTypeAtIndex(0);
+ EXPECT_EQ(ConstString("Class::NestedClass"), udt_type->GetName());
+ CompilerType compiler_type = udt_type->GetForwardCompilerType();
+ EXPECT_TRUE(ClangASTContext::IsClassType(compiler_type.GetOpaqueQualType()));
+ EXPECT_EQ(uint64_t(GetGlobalConstantInteger(session, "sizeof_NestedClass")),
+ udt_type->GetByteSize());
}
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestSimpleClassTypes))
-{
- FileSpec fspec(m_types_test_exe.c_str(), false);
- ArchSpec aspec("i686-pc-windows");
- lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
+TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestClassInNamespace)) {
+ FileSpec fspec(m_types_test_exe.c_str(), false);
+ ArchSpec aspec("i686-pc-windows");
+ lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
- SymbolVendor *plugin = module->GetSymbolVendor();
- SymbolFilePDB *symfile = static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
- const llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
- SymbolContext sc;
- llvm::DenseSet<SymbolFile *> searched_files;
+ SymbolVendor *plugin = module->GetSymbolVendor();
+ SymbolFilePDB *symfile =
+ static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
+ const llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
+ SymbolContext sc;
+ llvm::DenseSet<SymbolFile *> searched_files;
+ TypeMap results;
+ EXPECT_EQ(1u, symfile->FindTypes(sc, ConstString("NS::NSClass"), nullptr,
+ false, 0, searched_files, results));
+ EXPECT_EQ(1u, results.GetSize());
+ lldb::TypeSP udt_type = results.GetTypeAtIndex(0);
+ EXPECT_EQ(ConstString("NS::NSClass"), udt_type->GetName());
+ CompilerType compiler_type = udt_type->GetForwardCompilerType();
+ EXPECT_TRUE(ClangASTContext::IsClassType(compiler_type.GetOpaqueQualType()));
+ EXPECT_EQ(GetGlobalConstantInteger(session, "sizeof_NSClass"),
+ udt_type->GetByteSize());
+}
+
+TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestEnumTypes)) {
+ FileSpec fspec(m_types_test_exe.c_str(), false);
+ ArchSpec aspec("i686-pc-windows");
+ lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
+
+ SymbolVendor *plugin = module->GetSymbolVendor();
+ SymbolFilePDB *symfile =
+ static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
+ const llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
+ SymbolContext sc;
+ llvm::DenseSet<SymbolFile *> searched_files;
+ const char *EnumsToCheck[] = {"Enum", "ShortEnum"};
+ for (auto Enum : EnumsToCheck) {
TypeMap results;
- EXPECT_EQ(1u, symfile->FindTypes(sc, ConstString("Class"), nullptr, false, 0, searched_files, results));
+ EXPECT_EQ(1u, symfile->FindTypes(sc, ConstString(Enum), nullptr, false, 0,
+ searched_files, results));
EXPECT_EQ(1u, results.GetSize());
- lldb::TypeSP udt_type = results.GetTypeAtIndex(0);
- EXPECT_EQ(ConstString("Class"), udt_type->GetName());
- CompilerType compiler_type = udt_type->GetForwardCompilerType();
- EXPECT_TRUE(ClangASTContext::IsClassType(compiler_type.GetOpaqueQualType()));
- EXPECT_EQ(uint64_t(GetGlobalConstantInteger(session, "sizeof_Class")), udt_type->GetByteSize());
+ lldb::TypeSP enum_type = results.GetTypeAtIndex(0);
+ EXPECT_EQ(ConstString(Enum), enum_type->GetName());
+ CompilerType compiler_type = enum_type->GetFullCompilerType();
+ EXPECT_TRUE(ClangASTContext::IsEnumType(compiler_type.GetOpaqueQualType()));
+ clang::EnumDecl *enum_decl = ClangASTContext::GetAsEnumDecl(compiler_type);
+ EXPECT_NE(nullptr, enum_decl);
+ EXPECT_EQ(2, std::distance(enum_decl->enumerator_begin(),
+ enum_decl->enumerator_end()));
+
+ std::string sizeof_var = "sizeof_";
+ sizeof_var.append(Enum);
+ EXPECT_EQ(GetGlobalConstantInteger(session, sizeof_var.c_str()),
+ enum_type->GetByteSize());
+ }
}
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestNestedClassTypes))
-{
- FileSpec fspec(m_types_test_exe.c_str(), false);
- ArchSpec aspec("i686-pc-windows");
- lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
+TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestArrayTypes)) {
+ // In order to get this test working, we need to support lookup by symbol
+ // name. Because array
+ // types themselves do not have names, only the symbols have names (i.e. the
+ // name of the array).
+}
- SymbolVendor *plugin = module->GetSymbolVendor();
- SymbolFilePDB *symfile = static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
- const llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
- SymbolContext sc;
- llvm::DenseSet<SymbolFile *> searched_files;
+TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestFunctionTypes)) {
+ // In order to get this test working, we need to support lookup by symbol
+ // name. Because array
+ // types themselves do not have names, only the symbols have names (i.e. the
+ // name of the array).
+}
+
+TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestTypedefs)) {
+ FileSpec fspec(m_types_test_exe.c_str(), false);
+ ArchSpec aspec("i686-pc-windows");
+ lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
+
+ SymbolVendor *plugin = module->GetSymbolVendor();
+ SymbolFilePDB *symfile =
+ static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
+ const llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
+ SymbolContext sc;
+ llvm::DenseSet<SymbolFile *> searched_files;
+ TypeMap results;
+
+ const char *TypedefsToCheck[] = {"ClassTypedef", "NSClassTypedef"};
+ for (auto Typedef : TypedefsToCheck) {
TypeMap results;
- EXPECT_EQ(1u, symfile->FindTypes(sc, ConstString("Class::NestedClass"), nullptr, false, 0, searched_files, results));
+ EXPECT_EQ(1u, symfile->FindTypes(sc, ConstString(Typedef), nullptr, false,
+ 0, searched_files, results));
EXPECT_EQ(1u, results.GetSize());
- lldb::TypeSP udt_type = results.GetTypeAtIndex(0);
- EXPECT_EQ(ConstString("Class::NestedClass"), udt_type->GetName());
- CompilerType compiler_type = udt_type->GetForwardCompilerType();
- EXPECT_TRUE(ClangASTContext::IsClassType(compiler_type.GetOpaqueQualType()));
- EXPECT_EQ(uint64_t(GetGlobalConstantInteger(session, "sizeof_NestedClass")), udt_type->GetByteSize());
+ lldb::TypeSP typedef_type = results.GetTypeAtIndex(0);
+ EXPECT_EQ(ConstString(Typedef), typedef_type->GetName());
+ CompilerType compiler_type = typedef_type->GetFullCompilerType();
+ ClangASTContext *clang_type_system =
+ llvm::dyn_cast_or_null<ClangASTContext>(compiler_type.GetTypeSystem());
+ EXPECT_TRUE(
+ clang_type_system->IsTypedefType(compiler_type.GetOpaqueQualType()));
+
+ std::string sizeof_var = "sizeof_";
+ sizeof_var.append(Typedef);
+ EXPECT_EQ(GetGlobalConstantInteger(session, sizeof_var.c_str()),
+ typedef_type->GetByteSize());
+ }
}
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestClassInNamespace))
-{
- FileSpec fspec(m_types_test_exe.c_str(), false);
- ArchSpec aspec("i686-pc-windows");
- lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
+TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestRegexNameMatch)) {
+ FileSpec fspec(m_types_test_exe.c_str(), false);
+ ArchSpec aspec("i686-pc-windows");
+ lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
- SymbolVendor *plugin = module->GetSymbolVendor();
- SymbolFilePDB *symfile = static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
- const llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
- SymbolContext sc;
- llvm::DenseSet<SymbolFile *> searched_files;
- TypeMap results;
- EXPECT_EQ(1u, symfile->FindTypes(sc, ConstString("NS::NSClass"), nullptr, false, 0, searched_files, results));
- EXPECT_EQ(1u, results.GetSize());
- lldb::TypeSP udt_type = results.GetTypeAtIndex(0);
- EXPECT_EQ(ConstString("NS::NSClass"), udt_type->GetName());
- CompilerType compiler_type = udt_type->GetForwardCompilerType();
- EXPECT_TRUE(ClangASTContext::IsClassType(compiler_type.GetOpaqueQualType()));
- EXPECT_EQ(GetGlobalConstantInteger(session, "sizeof_NSClass"), udt_type->GetByteSize());
+ SymbolVendor *plugin = module->GetSymbolVendor();
+ SymbolFilePDB *symfile =
+ static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
+ SymbolContext sc;
+ llvm::DenseSet<SymbolFile *> searched_files;
+ TypeMap results;
+ uint32_t num_results = symfile->FindTypes(sc, ConstString(".*"), nullptr,
+ false, 0, searched_files, results);
+ EXPECT_GT(num_results, 1u);
+ EXPECT_EQ(num_results, results.GetSize());
}
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestEnumTypes))
-{
- FileSpec fspec(m_types_test_exe.c_str(), false);
- ArchSpec aspec("i686-pc-windows");
- lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
+TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestMaxMatches)) {
+ FileSpec fspec(m_types_test_exe.c_str(), false);
+ ArchSpec aspec("i686-pc-windows");
+ lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
- SymbolVendor *plugin = module->GetSymbolVendor();
- SymbolFilePDB *symfile = static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
- const llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
- SymbolContext sc;
- llvm::DenseSet<SymbolFile *> searched_files;
- const char *EnumsToCheck[] = {"Enum", "ShortEnum"};
- for (auto Enum : EnumsToCheck)
- {
- TypeMap results;
- EXPECT_EQ(1u, symfile->FindTypes(sc, ConstString(Enum), nullptr, false, 0, searched_files, results));
- EXPECT_EQ(1u, results.GetSize());
- lldb::TypeSP enum_type = results.GetTypeAtIndex(0);
- EXPECT_EQ(ConstString(Enum), enum_type->GetName());
- CompilerType compiler_type = enum_type->GetFullCompilerType();
- EXPECT_TRUE(ClangASTContext::IsEnumType(compiler_type.GetOpaqueQualType()));
- clang::EnumDecl *enum_decl = ClangASTContext::GetAsEnumDecl(compiler_type);
- EXPECT_NE(nullptr, enum_decl);
- EXPECT_EQ(2, std::distance(enum_decl->enumerator_begin(), enum_decl->enumerator_end()));
-
- std::string sizeof_var = "sizeof_";
- sizeof_var.append(Enum);
- EXPECT_EQ(GetGlobalConstantInteger(session, sizeof_var.c_str()), enum_type->GetByteSize());
- }
+ SymbolVendor *plugin = module->GetSymbolVendor();
+ SymbolFilePDB *symfile =
+ static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
+ SymbolContext sc;
+ llvm::DenseSet<SymbolFile *> searched_files;
+ TypeMap results;
+ uint32_t num_results = symfile->FindTypes(sc, ConstString(".*"), nullptr,
+ false, 0, searched_files, results);
+ // Try to limit ourselves from 1 to 10 results, otherwise we could be doing
+ // this thousands of times.
+ // The idea is just to make sure that for a variety of values, the number of
+ // limited results always
+ // comes out to the number we are expecting.
+ uint32_t iterations = std::min(num_results, 10u);
+ for (uint32_t i = 1; i <= iterations; ++i) {
+ uint32_t num_limited_results = symfile->FindTypes(
+ sc, ConstString(".*"), nullptr, false, i, searched_files, results);
+ EXPECT_EQ(i, num_limited_results);
+ EXPECT_EQ(num_limited_results, results.GetSize());
+ }
}
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestArrayTypes))
-{
- // In order to get this test working, we need to support lookup by symbol name. Because array
- // types themselves do not have names, only the symbols have names (i.e. the name of the array).
-}
+TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestNullName)) {
+ FileSpec fspec(m_types_test_exe.c_str(), false);
+ ArchSpec aspec("i686-pc-windows");
+ lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestFunctionTypes))
-{
- // In order to get this test working, we need to support lookup by symbol name. Because array
- // types themselves do not have names, only the symbols have names (i.e. the name of the array).
-}
-
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestTypedefs))
-{
- FileSpec fspec(m_types_test_exe.c_str(), false);
- ArchSpec aspec("i686-pc-windows");
- lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
-
- SymbolVendor *plugin = module->GetSymbolVendor();
- SymbolFilePDB *symfile = static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
- const llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
- SymbolContext sc;
- llvm::DenseSet<SymbolFile *> searched_files;
- TypeMap results;
-
- const char *TypedefsToCheck[] = {"ClassTypedef", "NSClassTypedef"};
- for (auto Typedef : TypedefsToCheck)
- {
- TypeMap results;
- EXPECT_EQ(1u, symfile->FindTypes(sc, ConstString(Typedef), nullptr, false, 0, searched_files, results));
- EXPECT_EQ(1u, results.GetSize());
- lldb::TypeSP typedef_type = results.GetTypeAtIndex(0);
- EXPECT_EQ(ConstString(Typedef), typedef_type->GetName());
- CompilerType compiler_type = typedef_type->GetFullCompilerType();
- ClangASTContext *clang_type_system = llvm::dyn_cast_or_null<ClangASTContext>(compiler_type.GetTypeSystem());
- EXPECT_TRUE(clang_type_system->IsTypedefType(compiler_type.GetOpaqueQualType()));
-
- std::string sizeof_var = "sizeof_";
- sizeof_var.append(Typedef);
- EXPECT_EQ(GetGlobalConstantInteger(session, sizeof_var.c_str()), typedef_type->GetByteSize());
- }
-}
-
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestRegexNameMatch))
-{
- FileSpec fspec(m_types_test_exe.c_str(), false);
- ArchSpec aspec("i686-pc-windows");
- lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
-
- SymbolVendor *plugin = module->GetSymbolVendor();
- SymbolFilePDB *symfile = static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
- SymbolContext sc;
- llvm::DenseSet<SymbolFile *> searched_files;
- TypeMap results;
- uint32_t num_results = symfile->FindTypes(sc, ConstString(".*"), nullptr, false, 0, searched_files, results);
- EXPECT_GT(num_results, 1u);
- EXPECT_EQ(num_results, results.GetSize());
-}
-
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestMaxMatches))
-{
- FileSpec fspec(m_types_test_exe.c_str(), false);
- ArchSpec aspec("i686-pc-windows");
- lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
-
- SymbolVendor *plugin = module->GetSymbolVendor();
- SymbolFilePDB *symfile = static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
- SymbolContext sc;
- llvm::DenseSet<SymbolFile *> searched_files;
- TypeMap results;
- uint32_t num_results = symfile->FindTypes(sc, ConstString(".*"), nullptr, false, 0, searched_files, results);
- // Try to limit ourselves from 1 to 10 results, otherwise we could be doing this thousands of times.
- // The idea is just to make sure that for a variety of values, the number of limited results always
- // comes out to the number we are expecting.
- uint32_t iterations = std::min(num_results, 10u);
- for (uint32_t i = 1; i <= iterations; ++i)
- {
- uint32_t num_limited_results = symfile->FindTypes(sc, ConstString(".*"), nullptr, false, i, searched_files, results);
- EXPECT_EQ(i, num_limited_results);
- EXPECT_EQ(num_limited_results, results.GetSize());
- }
-}
-
-TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestNullName))
-{
- FileSpec fspec(m_types_test_exe.c_str(), false);
- ArchSpec aspec("i686-pc-windows");
- lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
-
- SymbolVendor *plugin = module->GetSymbolVendor();
- SymbolFilePDB *symfile = static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
- SymbolContext sc;
- llvm::DenseSet<SymbolFile *> searched_files;
- TypeMap results;
- uint32_t num_results = symfile->FindTypes(sc, ConstString(), nullptr, false, 0, searched_files, results);
- EXPECT_EQ(0u, num_results);
- EXPECT_EQ(0u, results.GetSize());
+ SymbolVendor *plugin = module->GetSymbolVendor();
+ SymbolFilePDB *symfile =
+ static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
+ SymbolContext sc;
+ llvm::DenseSet<SymbolFile *> searched_files;
+ TypeMap results;
+ uint32_t num_results = symfile->FindTypes(sc, ConstString(), nullptr, false,
+ 0, searched_files, results);
+ EXPECT_EQ(0u, num_results);
+ EXPECT_EQ(0u, results.GetSize());
}