summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/DebugInfo.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2010-03-08 22:27:22 +0000
committerDevang Patel <dpatel@apple.com>2010-03-08 22:27:22 +0000
commit2e520f6378e608b9abfafa2a01583ff771f30805 (patch)
treea7cdcd381c1a73a2cb5f10823063a21f6d51e8ad /llvm/lib/Analysis/DebugInfo.cpp
parentbc9210cb7034c87a30ad4179c2c4b2482137b4db (diff)
downloadbcm5719-llvm-2e520f6378e608b9abfafa2a01583ff771f30805.tar.gz
bcm5719-llvm-2e520f6378e608b9abfafa2a01583ff771f30805.zip
Introduce DIFile. This will be used to represent header files and source file(s) in debug info.
llvm-svn: 97994
Diffstat (limited to 'llvm/lib/Analysis/DebugInfo.cpp')
-rw-r--r--llvm/lib/Analysis/DebugInfo.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/DebugInfo.cpp b/llvm/lib/Analysis/DebugInfo.cpp
index 4ea1ce94b16..49b2e6b2c54 100644
--- a/llvm/lib/Analysis/DebugInfo.cpp
+++ b/llvm/lib/Analysis/DebugInfo.cpp
@@ -219,6 +219,11 @@ bool DIDescriptor::isCompileUnit() const {
return DbgNode && getTag() == dwarf::DW_TAG_compile_unit;
}
+/// isFile - Return true if the specified tag is DW_TAG_file_type.
+bool DIDescriptor::isFile() const {
+ return DbgNode && getTag() == dwarf::DW_TAG_file_type;
+}
+
/// isNameSpace - Return true if the specified tag is DW_TAG_namespace.
bool DIDescriptor::isNameSpace() const {
return DbgNode && getTag() == dwarf::DW_TAG_namespace;
@@ -424,6 +429,8 @@ StringRef DIScope::getFilename() const {
return DINameSpace(DbgNode).getFilename();
if (isType())
return DIType(DbgNode).getFilename();
+ if (isFile())
+ return DIFile(DbgNode).getFilename();
assert(0 && "Invalid DIScope!");
return StringRef();
}
@@ -441,6 +448,8 @@ StringRef DIScope::getDirectory() const {
return DINameSpace(DbgNode).getDirectory();
if (isType())
return DIType(DbgNode).getDirectory();
+ if (isFile())
+ return DIFile(DbgNode).getDirectory();
assert(0 && "Invalid DIScope!");
return StringRef();
}
@@ -661,6 +670,20 @@ DICompileUnit DIFactory::CreateCompileUnit(unsigned LangID,
return DICompileUnit(MDNode::get(VMContext, &Elts[0], 10));
}
+/// CreateFile - Create a new descriptor for the specified file.
+DIFile DIFactory::CreateFile(StringRef Filename,
+ StringRef Directory,
+ DICompileUnit CU) {
+ Value *Elts[] = {
+ GetTagConstant(dwarf::DW_TAG_file_type),
+ MDString::get(VMContext, Filename),
+ MDString::get(VMContext, Directory),
+ CU.getNode()
+ };
+
+ return DIFile(MDNode::get(VMContext, &Elts[0], 4));
+}
+
/// CreateEnumerator - Create a single enumerator value.
DIEnumerator DIFactory::CreateEnumerator(StringRef Name, uint64_t Val){
Value *Elts[] = {
OpenPOWER on IntegriCloud