aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/IR/MetadataTest.cpp
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2015-06-29 23:03:47 +0000
committerAdrian Prantl <aprantl@apple.com>2015-06-29 23:03:47 +0000
commitab1243fe6c01ee7a28a0cb34dc60eaf24eafaf8f (patch)
treef5963f34d34701774537554b8fe7e56239f2bbc7 /llvm/unittests/IR/MetadataTest.cpp
parent706b80d8965339496a4af13bdbcc5472ab809acc (diff)
downloadllvm-ab1243fe6c01ee7a28a0cb34dc60eaf24eafaf8f.zip
llvm-ab1243fe6c01ee7a28a0cb34dc60eaf24eafaf8f.tar.gz
llvm-ab1243fe6c01ee7a28a0cb34dc60eaf24eafaf8f.tar.bz2
Add a DIModule metadata node to the IR.
It is meant to be used to record modules @imported by the current compile unit, so a debugger an import the same modules to replicate this environment before dropping into the expression evaluator. DIModule is a sibling to DINamespace and behaves quite similarly. In addition to the name of the module it also records the module configuration details that are necessary to uniquely identify the module. This includes the configuration macros (e.g., -DNDEBUG), the include path where the module.map file is to be found, and the isysroot. The idea is that the backend will turn this into a DW_TAG_module. http://reviews.llvm.org/D9614 rdar://problem/20965932 llvm-svn: 241017
Diffstat (limited to 'llvm/unittests/IR/MetadataTest.cpp')
-rw-r--r--llvm/unittests/IR/MetadataTest.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/llvm/unittests/IR/MetadataTest.cpp b/llvm/unittests/IR/MetadataTest.cpp
index c1da068..b58615c 100644
--- a/llvm/unittests/IR/MetadataTest.cpp
+++ b/llvm/unittests/IR/MetadataTest.cpp
@@ -1704,6 +1704,40 @@ TEST_F(DINamespaceTest, get) {
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
}
+typedef MetadataTest DIModuleTest;
+
+TEST_F(DIModuleTest, get) {
+ DIScope *Scope = getFile();
+ StringRef Name = "module";
+ StringRef ConfigMacro = "-DNDEBUG";
+ StringRef Includes = "-I.";
+ StringRef Sysroot = "/";
+
+ auto *N = DIModule::get(Context, Scope, Name, ConfigMacro, Includes, Sysroot);
+
+ EXPECT_EQ(dwarf::DW_TAG_module, N->getTag());
+ EXPECT_EQ(Scope, N->getScope());
+ EXPECT_EQ(Name, N->getName());
+ EXPECT_EQ(ConfigMacro, N->getConfigurationMacros());
+ EXPECT_EQ(Includes, N->getIncludePath());
+ EXPECT_EQ(Sysroot, N->getISysRoot());
+ EXPECT_EQ(N, DIModule::get(Context, Scope, Name,
+ ConfigMacro, Includes, Sysroot));
+ EXPECT_NE(N, DIModule::get(Context, getFile(), Name,
+ ConfigMacro, Includes, Sysroot));
+ EXPECT_NE(N, DIModule::get(Context, Scope, "other",
+ ConfigMacro, Includes, Sysroot));
+ EXPECT_NE(N, DIModule::get(Context, Scope, Name,
+ "other", Includes, Sysroot));
+ EXPECT_NE(N, DIModule::get(Context, Scope, Name,
+ ConfigMacro, "other", Sysroot));
+ EXPECT_NE(N, DIModule::get(Context, Scope, Name,
+ ConfigMacro, Includes, "other"));
+
+ TempDIModule Temp = N->clone();
+ EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
+}
+
typedef MetadataTest DITemplateTypeParameterTest;
TEST_F(DITemplateTypeParameterTest, get) {