From 4776bce28cb7d669329222c3d9cf6a97d6881c96 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Wed, 20 Mar 2013 00:26:26 +0000 Subject: Refactor the DIFile (2nd) parameter to DITypes to be an MDNode reference to a raw directory/file pair This makes DIType's first non-tag parameter the same as DIFile's, allowing them to both share the common implementation of getFilename/getDirectory in DIScope. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177467 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/DebugInfo.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/IR/DebugInfo.cpp') diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index 1a5454e..d1db3ab 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -539,6 +539,11 @@ bool DINameSpace::Verify() const { return DbgNode->getNumOperands() == 5; } +/// \brief Retrieve the MDNode for the directory/file pair. +MDNode *DIFile::getFileNode() const { + return const_cast(getNodeField(DbgNode, 1)); +} + /// \brief Verify that the file descriptor is well formed. bool DIFile::Verify() const { return isFile() && DbgNode->getNumOperands() == 2; @@ -669,8 +674,6 @@ StringRef DIScope::getFilename() const { return DICompileUnit(DbgNode).getFilename(); if (isNameSpace()) return DINameSpace(DbgNode).getFilename(); - if (isType()) - return DIType(DbgNode).getFilename(); return ::getStringField(getNodeField(DbgNode, 1), 0); } @@ -687,8 +690,6 @@ StringRef DIScope::getDirectory() const { return DICompileUnit(DbgNode).getDirectory(); if (isNameSpace()) return DINameSpace(DbgNode).getDirectory(); - if (isType()) - return DIType(DbgNode).getDirectory(); return ::getStringField(getNodeField(DbgNode, 1), 1); } -- cgit v1.1 From 1cd30fd994aa8825c10d073f0f1ae9c6ba358ae4 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Wed, 20 Mar 2013 05:14:14 +0000 Subject: Provide more details for DINameSpace debug info in the IR comment annotations Sorry for the version skew - I should've committed this before the corresponding Clang test case. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177486 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/DebugInfo.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/IR/DebugInfo.cpp') diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index d1db3ab..dd7ba23 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -1033,6 +1033,8 @@ void DIDescriptor::print(raw_ostream &OS) const { DIVariable(DbgNode).printInternal(OS); } else if (this->isObjCProperty()) { DIObjCProperty(DbgNode).printInternal(OS); + } else if (this->isNameSpace()) { + DINameSpace(DbgNode).printInternal(OS); } else if (this->isScope()) { DIScope(DbgNode).printInternal(OS); } @@ -1106,6 +1108,14 @@ void DICompositeType::printInternal(raw_ostream &OS) const { OS << " [" << A.getNumElements() << " elements]"; } +void DINameSpace::printInternal(raw_ostream &OS) const { + StringRef Name = getName(); + if (!Name.empty()) + OS << " [" << Name << ']'; + + OS << " [line " << getLineNumber() << ']'; +} + void DISubprogram::printInternal(raw_ostream &OS) const { // TODO : Print context OS << " [line " << getLineNumber() << ']'; -- cgit v1.1 From 6115ed0e4347f17504f72e4d37545b4230b2cb50 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Wed, 20 Mar 2013 19:39:15 +0000 Subject: Refactor file/directory path in namespace debug info to refer directly to the pair rather than the DIFile (paired to a Clang test - excuse the buildbot skew/fallout) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177566 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/DebugInfo.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'lib/IR/DebugInfo.cpp') diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index dd7ba23..897ebb5 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -672,8 +672,6 @@ StringRef DIScope::getFilename() const { return DISubprogram(DbgNode).getFilename(); if (isCompileUnit()) return DICompileUnit(DbgNode).getFilename(); - if (isNameSpace()) - return DINameSpace(DbgNode).getFilename(); return ::getStringField(getNodeField(DbgNode, 1), 0); } @@ -688,8 +686,6 @@ StringRef DIScope::getDirectory() const { return DISubprogram(DbgNode).getDirectory(); if (isCompileUnit()) return DICompileUnit(DbgNode).getDirectory(); - if (isNameSpace()) - return DINameSpace(DbgNode).getDirectory(); return ::getStringField(getNodeField(DbgNode, 1), 1); } -- cgit v1.1 From 404ecce8903f83271c82e368c834a9697799c296 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Wed, 20 Mar 2013 22:34:33 +0000 Subject: Remove unused field in DICompileUnit git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177590 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/DebugInfo.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'lib/IR/DebugInfo.cpp') diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index 897ebb5..e236e18 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -417,7 +417,7 @@ bool DICompileUnit::Verify() const { if (N.empty()) return false; // It is possible that directory and produce string is empty. - return DbgNode->getNumOperands() == 13; + return DbgNode->getNumOperands() == 12; } /// Verify - Verify that an ObjC property is well formed. @@ -690,38 +690,38 @@ StringRef DIScope::getDirectory() const { } DIArray DICompileUnit::getEnumTypes() const { - if (!DbgNode || DbgNode->getNumOperands() < 13) + if (!DbgNode || DbgNode->getNumOperands() < 12) return DIArray(); - if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(8))) + if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(7))) return DIArray(N); return DIArray(); } DIArray DICompileUnit::getRetainedTypes() const { - if (!DbgNode || DbgNode->getNumOperands() < 13) + if (!DbgNode || DbgNode->getNumOperands() < 12) return DIArray(); - if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(9))) + if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(8))) return DIArray(N); return DIArray(); } DIArray DICompileUnit::getSubprograms() const { - if (!DbgNode || DbgNode->getNumOperands() < 13) + if (!DbgNode || DbgNode->getNumOperands() < 12) return DIArray(); - if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(10))) + if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(9))) return DIArray(N); return DIArray(); } DIArray DICompileUnit::getGlobalVariables() const { - if (!DbgNode || DbgNode->getNumOperands() < 13) + if (!DbgNode || DbgNode->getNumOperands() < 12) return DIArray(); - if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(11))) + if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(10))) return DIArray(N); return DIArray(); } -- cgit v1.1 From 00c5c5d46731834caa0ca3280e0dcc43202dd3c8 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Wed, 20 Mar 2013 23:58:12 +0000 Subject: Debug info: refactor the first field of DICompileUnit to be a raw file/directory pair This removes the DICompileUnit special case from DIScope. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177610 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/DebugInfo.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'lib/IR/DebugInfo.cpp') diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index e236e18..701cf1f 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -670,8 +670,6 @@ StringRef DIScope::getFilename() const { return DILexicalBlock(DbgNode).getFilename(); if (isSubprogram()) return DISubprogram(DbgNode).getFilename(); - if (isCompileUnit()) - return DICompileUnit(DbgNode).getFilename(); return ::getStringField(getNodeField(DbgNode, 1), 0); } @@ -684,8 +682,6 @@ StringRef DIScope::getDirectory() const { return DILexicalBlock(DbgNode).getDirectory(); if (isSubprogram()) return DISubprogram(DbgNode).getDirectory(); - if (isCompileUnit()) - return DICompileUnit(DbgNode).getDirectory(); return ::getStringField(getNodeField(DbgNode, 1), 1); } -- cgit v1.1 From ebb5183a2f16abc7c88241bb42412465f52c2a61 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Thu, 21 Mar 2013 20:28:52 +0000 Subject: Remove unused field in DISubprogram git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177661 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/DebugInfo.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/IR/DebugInfo.cpp') diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index 701cf1f..bc5e415 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -485,7 +485,7 @@ bool DISubprogram::Verify() const { DICompositeType Ty = getType(); if (!Ty.Verify()) return false; - return DbgNode->getNumOperands() == 21; + return DbgNode->getNumOperands() == 20; } /// Verify - Verify that a global variable descriptor is well formed. @@ -642,21 +642,21 @@ bool DISubprogram::describes(const Function *F) { unsigned DISubprogram::isOptimized() const { assert (DbgNode && "Invalid subprogram descriptor!"); - if (DbgNode->getNumOperands() == 16) - return getUnsignedField(15); + if (DbgNode->getNumOperands() == 15) + return getUnsignedField(14); return 0; } MDNode *DISubprogram::getVariablesNodes() const { - if (!DbgNode || DbgNode->getNumOperands() <= 19) + if (!DbgNode || DbgNode->getNumOperands() <= 18) return NULL; - return dyn_cast_or_null(DbgNode->getOperand(19)); + return dyn_cast_or_null(DbgNode->getOperand(18)); } DIArray DISubprogram::getVariables() const { - if (!DbgNode || DbgNode->getNumOperands() <= 19) + if (!DbgNode || DbgNode->getNumOperands() <= 18) return DIArray(); - if (MDNode *T = dyn_cast_or_null(DbgNode->getOperand(19))) + if (MDNode *T = dyn_cast_or_null(DbgNode->getOperand(18))) return DIArray(T); return DIArray(); } -- cgit v1.1 From bb4e619cd9ff34708e3baaf0aac70275a917e0ba Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Thu, 21 Mar 2013 23:08:34 +0000 Subject: Refactor the filename/directory information in DISubprogram to refer directly to the pair rather than the DIFile. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177677 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/DebugInfo.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'lib/IR/DebugInfo.cpp') diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index bc5e415..91968d8 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -668,8 +668,6 @@ StringRef DIScope::getFilename() const { return DILexicalBlockFile(DbgNode).getFilename(); if (isLexicalBlock()) return DILexicalBlock(DbgNode).getFilename(); - if (isSubprogram()) - return DISubprogram(DbgNode).getFilename(); return ::getStringField(getNodeField(DbgNode, 1), 0); } @@ -680,8 +678,6 @@ StringRef DIScope::getDirectory() const { return DILexicalBlockFile(DbgNode).getDirectory(); if (isLexicalBlock()) return DILexicalBlock(DbgNode).getDirectory(); - if (isSubprogram()) - return DISubprogram(DbgNode).getDirectory(); return ::getStringField(getNodeField(DbgNode, 1), 1); } -- cgit v1.1 From 4b52a88e90b341ff2a3d1dbad6eb5ea731228156 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Fri, 22 Mar 2013 17:33:20 +0000 Subject: Refactor out the DIFile parameter to DILexicalBlock to refer to the raw file/directory pair git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177742 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/DebugInfo.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'lib/IR/DebugInfo.cpp') diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index 91968d8..9902334 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -666,8 +666,6 @@ StringRef DIScope::getFilename() const { return StringRef(); if (isLexicalBlockFile()) return DILexicalBlockFile(DbgNode).getFilename(); - if (isLexicalBlock()) - return DILexicalBlock(DbgNode).getFilename(); return ::getStringField(getNodeField(DbgNode, 1), 0); } @@ -676,8 +674,6 @@ StringRef DIScope::getDirectory() const { return StringRef(); if (isLexicalBlockFile()) return DILexicalBlockFile(DbgNode).getDirectory(); - if (isLexicalBlock()) - return DILexicalBlock(DbgNode).getDirectory(); return ::getStringField(getNodeField(DbgNode, 1), 1); } -- cgit v1.1 From 8faed2745c849fb35f6edf411263dfa564ef3643 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Fri, 22 Mar 2013 20:18:46 +0000 Subject: Swap the DIFile in DILexicalBlockFile out for the raw name/directory pair This is the last change in transitioning all DIScopes to have a common prefix. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177756 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/DebugInfo.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'lib/IR/DebugInfo.cpp') diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index 9902334..5ab6426 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -664,16 +664,12 @@ DIArray DISubprogram::getVariables() const { StringRef DIScope::getFilename() const { if (!DbgNode) return StringRef(); - if (isLexicalBlockFile()) - return DILexicalBlockFile(DbgNode).getFilename(); return ::getStringField(getNodeField(DbgNode, 1), 0); } StringRef DIScope::getDirectory() const { if (!DbgNode) return StringRef(); - if (isLexicalBlockFile()) - return DILexicalBlockFile(DbgNode).getDirectory(); return ::getStringField(getNodeField(DbgNode, 1), 1); } -- cgit v1.1 From d072a166d6c77ebcfb4fde796e0784a56020b9a4 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Tue, 26 Mar 2013 21:59:17 +0000 Subject: Debug Info: Provide a means to update the members of a composite type This will be used to factor out some uses of magic number operand offsets inside Clang where these fields were updated in an effort to resolve forward declarations/circular references. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178078 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/DebugInfo.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib/IR/DebugInfo.cpp') diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index 5ab6426..1916f5e 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -25,6 +25,7 @@ #include "llvm/IR/Module.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Dwarf.h" +#include "llvm/Support/ValueHandle.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; using namespace llvm::dwarf; @@ -615,6 +616,16 @@ MDNode *DIDerivedType::getObjCProperty() const { return dyn_cast_or_null(DbgNode->getOperand(10)); } +/// \brief Set the array of member DITypes +void DICompositeType::setTypeArray(DIArray Elements, DIArray TParams) { + assert(!TParams || DbgNode->getNumOperands() == 14 && "If you're setting the template parameters this should include a slot for that"); + TrackingVH N(*this); + N->replaceOperandWith(10, Elements); + if (TParams) + N->replaceOperandWith(13, TParams); + DbgNode = N; +} + /// isInlinedFnArgument - Return true if this variable provides debugging /// information for an inlined function arguments. bool DIVariable::isInlinedFnArgument(const Function *CurFn) { -- cgit v1.1 From f34ea642e6402538f217db67a734a8530a36eed0 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Tue, 26 Mar 2013 23:46:36 +0000 Subject: DebugInfo: more support for mutating DICompositeType to reduce magic number usage in Clang git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178090 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/DebugInfo.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib/IR/DebugInfo.cpp') diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index 1916f5e..b74522f 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -616,7 +616,7 @@ MDNode *DIDerivedType::getObjCProperty() const { return dyn_cast_or_null(DbgNode->getOperand(10)); } -/// \brief Set the array of member DITypes +/// \brief Set the array of member DITypes. void DICompositeType::setTypeArray(DIArray Elements, DIArray TParams) { assert(!TParams || DbgNode->getNumOperands() == 14 && "If you're setting the template parameters this should include a slot for that"); TrackingVH N(*this); @@ -626,6 +626,13 @@ void DICompositeType::setTypeArray(DIArray Elements, DIArray TParams) { DbgNode = N; } +/// \brief Set the containing type. +void DICompositeType::setContainingType(DICompositeType ContainingType) { + TrackingVH N(*this); + N->replaceOperandWith(12, ContainingType); + DbgNode = N; +} + /// isInlinedFnArgument - Return true if this variable provides debugging /// information for an inlined function arguments. bool DIVariable::isInlinedFnArgument(const Function *CurFn) { -- cgit v1.1 From 342d92c7a0adeabc9ab00f3f0d88d739fe7da4c7 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Wed, 27 Mar 2013 00:07:26 +0000 Subject: Adding DIImportedModules to DIScopes. This is just the basic groundwork for supporting DW_TAG_imported_module but I wanted to commit this before pushing support further into Clang or LLVM so that this rather churny change is isolated from the rest of the work. The major churn here is obviously adding another field (within the common DIScope prefix) to all DIScopes (files, classes, namespaces, lexical scopes, etc). This should be the last big churny change needed for DW_TAG_imported_module/using directive support/PR14606. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178099 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/DebugInfo.cpp | 87 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 54 insertions(+), 33 deletions(-) (limited to 'lib/IR/DebugInfo.cpp') diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index b74522f..80563e9 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -64,7 +64,8 @@ bool DIDescriptor::Verify() const { DISubrange(DbgNode).Verify() || DIEnumerator(DbgNode).Verify() || DIObjCProperty(DbgNode).Verify() || DITemplateTypeParameter(DbgNode).Verify() || - DITemplateValueParameter(DbgNode).Verify()); + DITemplateValueParameter(DbgNode).Verify() || + DIImportedModule(DbgNode).Verify()); } static Value *getField(const MDNode *DbgNode, unsigned Elt) { @@ -313,13 +314,13 @@ bool DIDescriptor::isNameSpace() const { /// lexical block with an extra file. bool DIDescriptor::isLexicalBlockFile() const { return DbgNode && getTag() == dwarf::DW_TAG_lexical_block && - (DbgNode->getNumOperands() == 3); + (DbgNode->getNumOperands() == 4); } /// isLexicalBlock - Return true if the specified tag is DW_TAG_lexical_block. bool DIDescriptor::isLexicalBlock() const { return DbgNode && getTag() == dwarf::DW_TAG_lexical_block && - (DbgNode->getNumOperands() > 3); + (DbgNode->getNumOperands() > 4); } /// isSubrange - Return true if the specified tag is DW_TAG_subrange_type. @@ -336,6 +337,12 @@ bool DIDescriptor::isEnumerator() const { bool DIDescriptor::isObjCProperty() const { return DbgNode && getTag() == dwarf::DW_TAG_APPLE_property; } + +/// \brief Return true if the specified tag is DW_TAG_imported_module. +bool DIDescriptor::isImportedModule() const { + return DbgNode && getTag() == dwarf::DW_TAG_imported_module; +} + //===----------------------------------------------------------------------===// // Simple Descriptor Constructors and other Methods //===----------------------------------------------------------------------===// @@ -418,7 +425,7 @@ bool DICompileUnit::Verify() const { if (N.empty()) return false; // It is possible that directory and produce string is empty. - return DbgNode->getNumOperands() == 12; + return DbgNode->getNumOperands() == 13; } /// Verify - Verify that an ObjC property is well formed. @@ -449,6 +456,7 @@ bool DIType::Verify() const { Tag != dwarf::DW_TAG_array_type && Tag != dwarf::DW_TAG_enumeration_type && Tag != dwarf::DW_TAG_subroutine_type && + Tag != dwarf::DW_TAG_friend && getFilename().empty()) return false; return true; @@ -456,13 +464,13 @@ bool DIType::Verify() const { /// Verify - Verify that a basic type descriptor is well formed. bool DIBasicType::Verify() const { - return isBasicType() && DbgNode->getNumOperands() == 10; + return isBasicType() && DbgNode->getNumOperands() == 11; } /// Verify - Verify that a derived type descriptor is well formed. bool DIDerivedType::Verify() const { - return isDerivedType() && DbgNode->getNumOperands() >= 10 && - DbgNode->getNumOperands() <= 14; + return isDerivedType() && DbgNode->getNumOperands() >= 11 && + DbgNode->getNumOperands() <= 15; } /// Verify - Verify that a composite type descriptor is well formed. @@ -472,7 +480,7 @@ bool DICompositeType::Verify() const { if (getContext() && !getContext().Verify()) return false; - return DbgNode->getNumOperands() >= 10 && DbgNode->getNumOperands() <= 14; + return DbgNode->getNumOperands() >= 11 && DbgNode->getNumOperands() <= 15; } /// Verify - Verify that a subprogram descriptor is well formed. @@ -486,7 +494,7 @@ bool DISubprogram::Verify() const { DICompositeType Ty = getType(); if (!Ty.Verify()) return false; - return DbgNode->getNumOperands() == 20; + return DbgNode->getNumOperands() == 21; } /// Verify - Verify that a global variable descriptor is well formed. @@ -537,7 +545,7 @@ bool DILocation::Verify() const { bool DINameSpace::Verify() const { if (!isNameSpace()) return false; - return DbgNode->getNumOperands() == 5; + return DbgNode->getNumOperands() == 6; } /// \brief Retrieve the MDNode for the directory/file pair. @@ -547,7 +555,7 @@ MDNode *DIFile::getFileNode() const { /// \brief Verify that the file descriptor is well formed. bool DIFile::Verify() const { - return isFile() && DbgNode->getNumOperands() == 2; + return isFile() && DbgNode->getNumOperands() == 3; } /// \brief Verify that the enumerator descriptor is well formed. @@ -562,12 +570,12 @@ bool DISubrange::Verify() const { /// \brief Verify that the lexical block descriptor is well formed. bool DILexicalBlock::Verify() const { - return isLexicalBlock() && DbgNode->getNumOperands() == 6; + return isLexicalBlock() && DbgNode->getNumOperands() == 7; } /// \brief Verify that the file-scoped lexical block descriptor is well formed. bool DILexicalBlockFile::Verify() const { - return isLexicalBlockFile() && DbgNode->getNumOperands() == 3; + return isLexicalBlockFile() && DbgNode->getNumOperands() == 4; } /// \brief Verify that the template type parameter descriptor is well formed. @@ -580,6 +588,11 @@ bool DITemplateValueParameter::Verify() const { return isTemplateValueParameter() && DbgNode->getNumOperands() == 8; } +/// \brief Verify that the imported module descriptor is well formed. +bool DIImportedModule::Verify() const { + return isImportedModule() && DbgNode->getNumOperands() == 2; +} + /// getOriginalTypeSize - If this type is derived from a base type then /// return base type size. uint64_t DIDerivedType::getOriginalTypeSize() const { @@ -611,25 +624,25 @@ uint64_t DIDerivedType::getOriginalTypeSize() const { /// getObjCProperty - Return property node, if this ivar is associated with one. MDNode *DIDerivedType::getObjCProperty() const { - if (DbgNode->getNumOperands() <= 10) + if (DbgNode->getNumOperands() <= 11) return NULL; - return dyn_cast_or_null(DbgNode->getOperand(10)); + return dyn_cast_or_null(DbgNode->getOperand(11)); } /// \brief Set the array of member DITypes. void DICompositeType::setTypeArray(DIArray Elements, DIArray TParams) { - assert(!TParams || DbgNode->getNumOperands() == 14 && "If you're setting the template parameters this should include a slot for that"); + assert(!TParams || DbgNode->getNumOperands() == 15 && "If you're setting the template parameters this should include a slot for that"); TrackingVH N(*this); - N->replaceOperandWith(10, Elements); + N->replaceOperandWith(11, Elements); if (TParams) - N->replaceOperandWith(13, TParams); + N->replaceOperandWith(14, TParams); DbgNode = N; } /// \brief Set the containing type. void DICompositeType::setContainingType(DICompositeType ContainingType) { TrackingVH N(*this); - N->replaceOperandWith(12, ContainingType); + N->replaceOperandWith(13, ContainingType); DbgNode = N; } @@ -660,21 +673,21 @@ bool DISubprogram::describes(const Function *F) { unsigned DISubprogram::isOptimized() const { assert (DbgNode && "Invalid subprogram descriptor!"); - if (DbgNode->getNumOperands() == 15) - return getUnsignedField(14); + if (DbgNode->getNumOperands() == 16) + return getUnsignedField(15); return 0; } MDNode *DISubprogram::getVariablesNodes() const { - if (!DbgNode || DbgNode->getNumOperands() <= 18) + if (!DbgNode || DbgNode->getNumOperands() <= 19) return NULL; - return dyn_cast_or_null(DbgNode->getOperand(18)); + return dyn_cast_or_null(DbgNode->getOperand(19)); } DIArray DISubprogram::getVariables() const { - if (!DbgNode || DbgNode->getNumOperands() <= 18) + if (!DbgNode || DbgNode->getNumOperands() <= 19) return DIArray(); - if (MDNode *T = dyn_cast_or_null(DbgNode->getOperand(18))) + if (MDNode *T = dyn_cast_or_null(DbgNode->getOperand(19))) return DIArray(T); return DIArray(); } @@ -692,38 +705,38 @@ StringRef DIScope::getDirectory() const { } DIArray DICompileUnit::getEnumTypes() const { - if (!DbgNode || DbgNode->getNumOperands() < 12) + if (!DbgNode || DbgNode->getNumOperands() < 13) return DIArray(); - if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(7))) + if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(8))) return DIArray(N); return DIArray(); } DIArray DICompileUnit::getRetainedTypes() const { - if (!DbgNode || DbgNode->getNumOperands() < 12) + if (!DbgNode || DbgNode->getNumOperands() < 13) return DIArray(); - if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(8))) + if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(9))) return DIArray(N); return DIArray(); } DIArray DICompileUnit::getSubprograms() const { - if (!DbgNode || DbgNode->getNumOperands() < 12) + if (!DbgNode || DbgNode->getNumOperands() < 13) return DIArray(); - if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(9))) + if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(10))) return DIArray(N); return DIArray(); } DIArray DICompileUnit::getGlobalVariables() const { - if (!DbgNode || DbgNode->getNumOperands() < 12) + if (!DbgNode || DbgNode->getNumOperands() < 13) return DIArray(); - if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(10))) + if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(11))) return DIArray(N); return DIArray(); } @@ -1035,6 +1048,8 @@ void DIDescriptor::print(raw_ostream &OS) const { DINameSpace(DbgNode).printInternal(OS); } else if (this->isScope()) { DIScope(DbgNode).printInternal(OS); + } else if (this->isImportedModule()) { + DIImportedModule(DbgNode).printInternal(OS); } } @@ -1170,6 +1185,12 @@ void DIObjCProperty::printInternal(raw_ostream &OS) const { << ", properties " << getUnsignedField(6) << ']'; } +void DIImportedModule::printInternal(raw_ostream &OS) const { + StringRef Name = getNameSpace().getName(); + if (!Name.empty()) + OS << " [" << Name << ']'; +} + static void printDebugLoc(DebugLoc DL, raw_ostream &CommentOS, const LLVMContext &Ctx) { if (!DL.isUnknown()) { // Print source line info. -- cgit v1.1 From 2b393fb134c621a7f0824eaea35ad94eae7da062 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Wed, 27 Mar 2013 15:03:14 +0000 Subject: Silence warning about mixing || in &&, fix up 80-cols. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178144 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/DebugInfo.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/IR/DebugInfo.cpp') diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index 80563e9..f703bd2 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -631,7 +631,9 @@ MDNode *DIDerivedType::getObjCProperty() const { /// \brief Set the array of member DITypes. void DICompositeType::setTypeArray(DIArray Elements, DIArray TParams) { - assert(!TParams || DbgNode->getNumOperands() == 15 && "If you're setting the template parameters this should include a slot for that"); + assert((!TParams || DbgNode->getNumOperands() == 15) && + "If you're setting the template parameters this should include a slot " + "for that!"); TrackingVH N(*this); N->replaceOperandWith(11, Elements); if (TParams) -- cgit v1.1 From 354504320b4984eebf918bec02dc4c248e0b309b Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Wed, 27 Mar 2013 17:50:12 +0000 Subject: Fix comment git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178155 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/DebugInfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/IR/DebugInfo.cpp') diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index f703bd2..a1d18e1 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -333,7 +333,7 @@ bool DIDescriptor::isEnumerator() const { return DbgNode && getTag() == dwarf::DW_TAG_enumerator; } -/// isObjCProperty - Return true if the specified tag is DW_TAG +/// isObjCProperty - Return true if the specified tag is DW_TAG_APPLE_property. bool DIDescriptor::isObjCProperty() const { return DbgNode && getTag() == dwarf::DW_TAG_APPLE_property; } -- cgit v1.1 From 72dfb052ab74a9e642256212a50c9b805ce5c943 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Thu, 28 Mar 2013 02:44:59 +0000 Subject: Revert "Adding DIImportedModules to DIScopes." This reverts commit 342d92c7a0adeabc9ab00f3f0d88d739fe7da4c7. Turns out we're going with a different schema design to represent DW_TAG_imported_modules so we won't need this extra field. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178215 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/DebugInfo.cpp | 87 ++++++++++++++++++++-------------------------------- 1 file changed, 33 insertions(+), 54 deletions(-) (limited to 'lib/IR/DebugInfo.cpp') diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index a1d18e1..0ffe99d 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -64,8 +64,7 @@ bool DIDescriptor::Verify() const { DISubrange(DbgNode).Verify() || DIEnumerator(DbgNode).Verify() || DIObjCProperty(DbgNode).Verify() || DITemplateTypeParameter(DbgNode).Verify() || - DITemplateValueParameter(DbgNode).Verify() || - DIImportedModule(DbgNode).Verify()); + DITemplateValueParameter(DbgNode).Verify()); } static Value *getField(const MDNode *DbgNode, unsigned Elt) { @@ -314,13 +313,13 @@ bool DIDescriptor::isNameSpace() const { /// lexical block with an extra file. bool DIDescriptor::isLexicalBlockFile() const { return DbgNode && getTag() == dwarf::DW_TAG_lexical_block && - (DbgNode->getNumOperands() == 4); + (DbgNode->getNumOperands() == 3); } /// isLexicalBlock - Return true if the specified tag is DW_TAG_lexical_block. bool DIDescriptor::isLexicalBlock() const { return DbgNode && getTag() == dwarf::DW_TAG_lexical_block && - (DbgNode->getNumOperands() > 4); + (DbgNode->getNumOperands() > 3); } /// isSubrange - Return true if the specified tag is DW_TAG_subrange_type. @@ -337,12 +336,6 @@ bool DIDescriptor::isEnumerator() const { bool DIDescriptor::isObjCProperty() const { return DbgNode && getTag() == dwarf::DW_TAG_APPLE_property; } - -/// \brief Return true if the specified tag is DW_TAG_imported_module. -bool DIDescriptor::isImportedModule() const { - return DbgNode && getTag() == dwarf::DW_TAG_imported_module; -} - //===----------------------------------------------------------------------===// // Simple Descriptor Constructors and other Methods //===----------------------------------------------------------------------===// @@ -425,7 +418,7 @@ bool DICompileUnit::Verify() const { if (N.empty()) return false; // It is possible that directory and produce string is empty. - return DbgNode->getNumOperands() == 13; + return DbgNode->getNumOperands() == 12; } /// Verify - Verify that an ObjC property is well formed. @@ -456,7 +449,6 @@ bool DIType::Verify() const { Tag != dwarf::DW_TAG_array_type && Tag != dwarf::DW_TAG_enumeration_type && Tag != dwarf::DW_TAG_subroutine_type && - Tag != dwarf::DW_TAG_friend && getFilename().empty()) return false; return true; @@ -464,13 +456,13 @@ bool DIType::Verify() const { /// Verify - Verify that a basic type descriptor is well formed. bool DIBasicType::Verify() const { - return isBasicType() && DbgNode->getNumOperands() == 11; + return isBasicType() && DbgNode->getNumOperands() == 10; } /// Verify - Verify that a derived type descriptor is well formed. bool DIDerivedType::Verify() const { - return isDerivedType() && DbgNode->getNumOperands() >= 11 && - DbgNode->getNumOperands() <= 15; + return isDerivedType() && DbgNode->getNumOperands() >= 10 && + DbgNode->getNumOperands() <= 14; } /// Verify - Verify that a composite type descriptor is well formed. @@ -480,7 +472,7 @@ bool DICompositeType::Verify() const { if (getContext() && !getContext().Verify()) return false; - return DbgNode->getNumOperands() >= 11 && DbgNode->getNumOperands() <= 15; + return DbgNode->getNumOperands() >= 10 && DbgNode->getNumOperands() <= 14; } /// Verify - Verify that a subprogram descriptor is well formed. @@ -494,7 +486,7 @@ bool DISubprogram::Verify() const { DICompositeType Ty = getType(); if (!Ty.Verify()) return false; - return DbgNode->getNumOperands() == 21; + return DbgNode->getNumOperands() == 20; } /// Verify - Verify that a global variable descriptor is well formed. @@ -545,7 +537,7 @@ bool DILocation::Verify() const { bool DINameSpace::Verify() const { if (!isNameSpace()) return false; - return DbgNode->getNumOperands() == 6; + return DbgNode->getNumOperands() == 5; } /// \brief Retrieve the MDNode for the directory/file pair. @@ -555,7 +547,7 @@ MDNode *DIFile::getFileNode() const { /// \brief Verify that the file descriptor is well formed. bool DIFile::Verify() const { - return isFile() && DbgNode->getNumOperands() == 3; + return isFile() && DbgNode->getNumOperands() == 2; } /// \brief Verify that the enumerator descriptor is well formed. @@ -570,12 +562,12 @@ bool DISubrange::Verify() const { /// \brief Verify that the lexical block descriptor is well formed. bool DILexicalBlock::Verify() const { - return isLexicalBlock() && DbgNode->getNumOperands() == 7; + return isLexicalBlock() && DbgNode->getNumOperands() == 6; } /// \brief Verify that the file-scoped lexical block descriptor is well formed. bool DILexicalBlockFile::Verify() const { - return isLexicalBlockFile() && DbgNode->getNumOperands() == 4; + return isLexicalBlockFile() && DbgNode->getNumOperands() == 3; } /// \brief Verify that the template type parameter descriptor is well formed. @@ -588,11 +580,6 @@ bool DITemplateValueParameter::Verify() const { return isTemplateValueParameter() && DbgNode->getNumOperands() == 8; } -/// \brief Verify that the imported module descriptor is well formed. -bool DIImportedModule::Verify() const { - return isImportedModule() && DbgNode->getNumOperands() == 2; -} - /// getOriginalTypeSize - If this type is derived from a base type then /// return base type size. uint64_t DIDerivedType::getOriginalTypeSize() const { @@ -624,27 +611,27 @@ uint64_t DIDerivedType::getOriginalTypeSize() const { /// getObjCProperty - Return property node, if this ivar is associated with one. MDNode *DIDerivedType::getObjCProperty() const { - if (DbgNode->getNumOperands() <= 11) + if (DbgNode->getNumOperands() <= 10) return NULL; - return dyn_cast_or_null(DbgNode->getOperand(11)); + return dyn_cast_or_null(DbgNode->getOperand(10)); } /// \brief Set the array of member DITypes. void DICompositeType::setTypeArray(DIArray Elements, DIArray TParams) { - assert((!TParams || DbgNode->getNumOperands() == 15) && + assert((!TParams || DbgNode->getNumOperands() == 14) && "If you're setting the template parameters this should include a slot " "for that!"); TrackingVH N(*this); - N->replaceOperandWith(11, Elements); + N->replaceOperandWith(10, Elements); if (TParams) - N->replaceOperandWith(14, TParams); + N->replaceOperandWith(13, TParams); DbgNode = N; } /// \brief Set the containing type. void DICompositeType::setContainingType(DICompositeType ContainingType) { TrackingVH N(*this); - N->replaceOperandWith(13, ContainingType); + N->replaceOperandWith(12, ContainingType); DbgNode = N; } @@ -675,21 +662,21 @@ bool DISubprogram::describes(const Function *F) { unsigned DISubprogram::isOptimized() const { assert (DbgNode && "Invalid subprogram descriptor!"); - if (DbgNode->getNumOperands() == 16) - return getUnsignedField(15); + if (DbgNode->getNumOperands() == 15) + return getUnsignedField(14); return 0; } MDNode *DISubprogram::getVariablesNodes() const { - if (!DbgNode || DbgNode->getNumOperands() <= 19) + if (!DbgNode || DbgNode->getNumOperands() <= 18) return NULL; - return dyn_cast_or_null(DbgNode->getOperand(19)); + return dyn_cast_or_null(DbgNode->getOperand(18)); } DIArray DISubprogram::getVariables() const { - if (!DbgNode || DbgNode->getNumOperands() <= 19) + if (!DbgNode || DbgNode->getNumOperands() <= 18) return DIArray(); - if (MDNode *T = dyn_cast_or_null(DbgNode->getOperand(19))) + if (MDNode *T = dyn_cast_or_null(DbgNode->getOperand(18))) return DIArray(T); return DIArray(); } @@ -707,38 +694,38 @@ StringRef DIScope::getDirectory() const { } DIArray DICompileUnit::getEnumTypes() const { - if (!DbgNode || DbgNode->getNumOperands() < 13) + if (!DbgNode || DbgNode->getNumOperands() < 12) return DIArray(); - if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(8))) + if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(7))) return DIArray(N); return DIArray(); } DIArray DICompileUnit::getRetainedTypes() const { - if (!DbgNode || DbgNode->getNumOperands() < 13) + if (!DbgNode || DbgNode->getNumOperands() < 12) return DIArray(); - if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(9))) + if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(8))) return DIArray(N); return DIArray(); } DIArray DICompileUnit::getSubprograms() const { - if (!DbgNode || DbgNode->getNumOperands() < 13) + if (!DbgNode || DbgNode->getNumOperands() < 12) return DIArray(); - if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(10))) + if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(9))) return DIArray(N); return DIArray(); } DIArray DICompileUnit::getGlobalVariables() const { - if (!DbgNode || DbgNode->getNumOperands() < 13) + if (!DbgNode || DbgNode->getNumOperands() < 12) return DIArray(); - if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(11))) + if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(10))) return DIArray(N); return DIArray(); } @@ -1050,8 +1037,6 @@ void DIDescriptor::print(raw_ostream &OS) const { DINameSpace(DbgNode).printInternal(OS); } else if (this->isScope()) { DIScope(DbgNode).printInternal(OS); - } else if (this->isImportedModule()) { - DIImportedModule(DbgNode).printInternal(OS); } } @@ -1187,12 +1172,6 @@ void DIObjCProperty::printInternal(raw_ostream &OS) const { << ", properties " << getUnsignedField(6) << ']'; } -void DIImportedModule::printInternal(raw_ostream &OS) const { - StringRef Name = getNameSpace().getName(); - if (!Name.empty()) - OS << " [" << Name << ']'; -} - static void printDebugLoc(DebugLoc DL, raw_ostream &CommentOS, const LLVMContext &Ctx) { if (!DL.isUnknown()) { // Print source line info. -- cgit v1.1 From 2ca02c655d158b2c4aaf004c597073adf67b8967 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Wed, 17 Apr 2013 03:41:36 +0000 Subject: PR15149/r174304 improvement - print hex for unknown dwarf language codes & add a test case CR feedback from Rafael Espindola and Paul Robinson. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179664 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/DebugInfo.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/IR/DebugInfo.cpp') diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index 0ffe99d..10beb69 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -1054,8 +1054,13 @@ void DIScope::printInternal(raw_ostream &OS) const { void DICompileUnit::printInternal(raw_ostream &OS) const { DIScope::printInternal(OS); - if (const char *Lang = dwarf::LanguageString(getLanguage())) - OS << " [" << Lang << ']'; + OS << " ["; + unsigned Lang = getLanguage(); + if (const char *LangStr = dwarf::LanguageString(Lang)) + OS << LangStr; + else + (OS << "lang 0x").write_hex(Lang); + OS << ']'; } void DIEnumerator::printInternal(raw_ostream &OS) const { -- cgit v1.1 From bcb81360a26cba066fae3acbe25b8ac161af6881 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Fri, 19 Apr 2013 06:57:04 +0000 Subject: PR14606: debug info imported_module support Adding another CU-wide list, in this case of imported_modules (since they should be relatively rare, it seemed better to add a list where each element had a "context" value, rather than add a (usually empty) list to every scope). This takes care of DW_TAG_imported_module, but to fully address PR14606 we'll need to expand this to cover DW_TAG_imported_declaration too. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179836 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/DebugInfo.cpp | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'lib/IR/DebugInfo.cpp') diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index 10beb69..ec83dca 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -64,7 +64,8 @@ bool DIDescriptor::Verify() const { DISubrange(DbgNode).Verify() || DIEnumerator(DbgNode).Verify() || DIObjCProperty(DbgNode).Verify() || DITemplateTypeParameter(DbgNode).Verify() || - DITemplateValueParameter(DbgNode).Verify()); + DITemplateValueParameter(DbgNode).Verify() || + DIImportedModule(DbgNode).Verify()); } static Value *getField(const MDNode *DbgNode, unsigned Elt) { @@ -336,6 +337,12 @@ bool DIDescriptor::isEnumerator() const { bool DIDescriptor::isObjCProperty() const { return DbgNode && getTag() == dwarf::DW_TAG_APPLE_property; } + +/// \brief Return true if the specified tag is DW_TAG_imported_module. +bool DIDescriptor::isImportedModule() const { + return DbgNode && getTag() == dwarf::DW_TAG_imported_module; +} + //===----------------------------------------------------------------------===// // Simple Descriptor Constructors and other Methods //===----------------------------------------------------------------------===// @@ -418,7 +425,7 @@ bool DICompileUnit::Verify() const { if (N.empty()) return false; // It is possible that directory and produce string is empty. - return DbgNode->getNumOperands() == 12; + return DbgNode->getNumOperands() == 13; } /// Verify - Verify that an ObjC property is well formed. @@ -580,6 +587,11 @@ bool DITemplateValueParameter::Verify() const { return isTemplateValueParameter() && DbgNode->getNumOperands() == 8; } +/// \brief Verify that the imported module descriptor is well formed. +bool DIImportedModule::Verify() const { + return isImportedModule() && DbgNode->getNumOperands() == 4; +} + /// getOriginalTypeSize - If this type is derived from a base type then /// return base type size. uint64_t DIDerivedType::getOriginalTypeSize() const { @@ -694,7 +706,7 @@ StringRef DIScope::getDirectory() const { } DIArray DICompileUnit::getEnumTypes() const { - if (!DbgNode || DbgNode->getNumOperands() < 12) + if (!DbgNode || DbgNode->getNumOperands() < 13) return DIArray(); if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(7))) @@ -703,7 +715,7 @@ DIArray DICompileUnit::getEnumTypes() const { } DIArray DICompileUnit::getRetainedTypes() const { - if (!DbgNode || DbgNode->getNumOperands() < 12) + if (!DbgNode || DbgNode->getNumOperands() < 13) return DIArray(); if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(8))) @@ -712,7 +724,7 @@ DIArray DICompileUnit::getRetainedTypes() const { } DIArray DICompileUnit::getSubprograms() const { - if (!DbgNode || DbgNode->getNumOperands() < 12) + if (!DbgNode || DbgNode->getNumOperands() < 13) return DIArray(); if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(9))) @@ -722,7 +734,7 @@ DIArray DICompileUnit::getSubprograms() const { DIArray DICompileUnit::getGlobalVariables() const { - if (!DbgNode || DbgNode->getNumOperands() < 12) + if (!DbgNode || DbgNode->getNumOperands() < 13) return DIArray(); if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(10))) @@ -730,6 +742,15 @@ DIArray DICompileUnit::getGlobalVariables() const { return DIArray(); } +DIArray DICompileUnit::getImportedModules() const { + if (!DbgNode || DbgNode->getNumOperands() < 13) + return DIArray(); + + if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(11))) + return DIArray(N); + return DIArray(); +} + /// fixupObjcLikeName - Replace contains special characters used /// in a typical Objective-C names with '.' in a given string. static void fixupObjcLikeName(StringRef Str, SmallVectorImpl &Out) { -- cgit v1.1 From 41201ed06fa4fb246f5a7e9e2b62168814eca6ff Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Fri, 19 Apr 2013 07:47:16 +0000 Subject: Revert "PR14606: debug info imported_module support" This reverts commit r179836 as it seems to have caused test failures. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179840 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/DebugInfo.cpp | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) (limited to 'lib/IR/DebugInfo.cpp') diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index ec83dca..10beb69 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -64,8 +64,7 @@ bool DIDescriptor::Verify() const { DISubrange(DbgNode).Verify() || DIEnumerator(DbgNode).Verify() || DIObjCProperty(DbgNode).Verify() || DITemplateTypeParameter(DbgNode).Verify() || - DITemplateValueParameter(DbgNode).Verify() || - DIImportedModule(DbgNode).Verify()); + DITemplateValueParameter(DbgNode).Verify()); } static Value *getField(const MDNode *DbgNode, unsigned Elt) { @@ -337,12 +336,6 @@ bool DIDescriptor::isEnumerator() const { bool DIDescriptor::isObjCProperty() const { return DbgNode && getTag() == dwarf::DW_TAG_APPLE_property; } - -/// \brief Return true if the specified tag is DW_TAG_imported_module. -bool DIDescriptor::isImportedModule() const { - return DbgNode && getTag() == dwarf::DW_TAG_imported_module; -} - //===----------------------------------------------------------------------===// // Simple Descriptor Constructors and other Methods //===----------------------------------------------------------------------===// @@ -425,7 +418,7 @@ bool DICompileUnit::Verify() const { if (N.empty()) return false; // It is possible that directory and produce string is empty. - return DbgNode->getNumOperands() == 13; + return DbgNode->getNumOperands() == 12; } /// Verify - Verify that an ObjC property is well formed. @@ -587,11 +580,6 @@ bool DITemplateValueParameter::Verify() const { return isTemplateValueParameter() && DbgNode->getNumOperands() == 8; } -/// \brief Verify that the imported module descriptor is well formed. -bool DIImportedModule::Verify() const { - return isImportedModule() && DbgNode->getNumOperands() == 4; -} - /// getOriginalTypeSize - If this type is derived from a base type then /// return base type size. uint64_t DIDerivedType::getOriginalTypeSize() const { @@ -706,7 +694,7 @@ StringRef DIScope::getDirectory() const { } DIArray DICompileUnit::getEnumTypes() const { - if (!DbgNode || DbgNode->getNumOperands() < 13) + if (!DbgNode || DbgNode->getNumOperands() < 12) return DIArray(); if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(7))) @@ -715,7 +703,7 @@ DIArray DICompileUnit::getEnumTypes() const { } DIArray DICompileUnit::getRetainedTypes() const { - if (!DbgNode || DbgNode->getNumOperands() < 13) + if (!DbgNode || DbgNode->getNumOperands() < 12) return DIArray(); if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(8))) @@ -724,7 +712,7 @@ DIArray DICompileUnit::getRetainedTypes() const { } DIArray DICompileUnit::getSubprograms() const { - if (!DbgNode || DbgNode->getNumOperands() < 13) + if (!DbgNode || DbgNode->getNumOperands() < 12) return DIArray(); if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(9))) @@ -734,7 +722,7 @@ DIArray DICompileUnit::getSubprograms() const { DIArray DICompileUnit::getGlobalVariables() const { - if (!DbgNode || DbgNode->getNumOperands() < 13) + if (!DbgNode || DbgNode->getNumOperands() < 12) return DIArray(); if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(10))) @@ -742,15 +730,6 @@ DIArray DICompileUnit::getGlobalVariables() const { return DIArray(); } -DIArray DICompileUnit::getImportedModules() const { - if (!DbgNode || DbgNode->getNumOperands() < 13) - return DIArray(); - - if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(11))) - return DIArray(N); - return DIArray(); -} - /// fixupObjcLikeName - Replace contains special characters used /// in a typical Objective-C names with '.' in a given string. static void fixupObjcLikeName(StringRef Str, SmallVectorImpl &Out) { -- cgit v1.1 From c462db6d66e683fb837c03d661483106a869a407 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Mon, 22 Apr 2013 06:12:31 +0000 Subject: Revert "Revert "PR14606: debug info imported_module support"" This reverts commit r179840 with a fix to test/DebugInfo/two-cus-from-same-file.ll I'm not sure why that test only failed on ARM & MIPS and not X86 Linux, even though the debug info was clearly invalid on all of them, but this ought to fix it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179996 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/DebugInfo.cpp | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'lib/IR/DebugInfo.cpp') diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index 10beb69..ec83dca 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -64,7 +64,8 @@ bool DIDescriptor::Verify() const { DISubrange(DbgNode).Verify() || DIEnumerator(DbgNode).Verify() || DIObjCProperty(DbgNode).Verify() || DITemplateTypeParameter(DbgNode).Verify() || - DITemplateValueParameter(DbgNode).Verify()); + DITemplateValueParameter(DbgNode).Verify() || + DIImportedModule(DbgNode).Verify()); } static Value *getField(const MDNode *DbgNode, unsigned Elt) { @@ -336,6 +337,12 @@ bool DIDescriptor::isEnumerator() const { bool DIDescriptor::isObjCProperty() const { return DbgNode && getTag() == dwarf::DW_TAG_APPLE_property; } + +/// \brief Return true if the specified tag is DW_TAG_imported_module. +bool DIDescriptor::isImportedModule() const { + return DbgNode && getTag() == dwarf::DW_TAG_imported_module; +} + //===----------------------------------------------------------------------===// // Simple Descriptor Constructors and other Methods //===----------------------------------------------------------------------===// @@ -418,7 +425,7 @@ bool DICompileUnit::Verify() const { if (N.empty()) return false; // It is possible that directory and produce string is empty. - return DbgNode->getNumOperands() == 12; + return DbgNode->getNumOperands() == 13; } /// Verify - Verify that an ObjC property is well formed. @@ -580,6 +587,11 @@ bool DITemplateValueParameter::Verify() const { return isTemplateValueParameter() && DbgNode->getNumOperands() == 8; } +/// \brief Verify that the imported module descriptor is well formed. +bool DIImportedModule::Verify() const { + return isImportedModule() && DbgNode->getNumOperands() == 4; +} + /// getOriginalTypeSize - If this type is derived from a base type then /// return base type size. uint64_t DIDerivedType::getOriginalTypeSize() const { @@ -694,7 +706,7 @@ StringRef DIScope::getDirectory() const { } DIArray DICompileUnit::getEnumTypes() const { - if (!DbgNode || DbgNode->getNumOperands() < 12) + if (!DbgNode || DbgNode->getNumOperands() < 13) return DIArray(); if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(7))) @@ -703,7 +715,7 @@ DIArray DICompileUnit::getEnumTypes() const { } DIArray DICompileUnit::getRetainedTypes() const { - if (!DbgNode || DbgNode->getNumOperands() < 12) + if (!DbgNode || DbgNode->getNumOperands() < 13) return DIArray(); if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(8))) @@ -712,7 +724,7 @@ DIArray DICompileUnit::getRetainedTypes() const { } DIArray DICompileUnit::getSubprograms() const { - if (!DbgNode || DbgNode->getNumOperands() < 12) + if (!DbgNode || DbgNode->getNumOperands() < 13) return DIArray(); if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(9))) @@ -722,7 +734,7 @@ DIArray DICompileUnit::getSubprograms() const { DIArray DICompileUnit::getGlobalVariables() const { - if (!DbgNode || DbgNode->getNumOperands() < 12) + if (!DbgNode || DbgNode->getNumOperands() < 13) return DIArray(); if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(10))) @@ -730,6 +742,15 @@ DIArray DICompileUnit::getGlobalVariables() const { return DIArray(); } +DIArray DICompileUnit::getImportedModules() const { + if (!DbgNode || DbgNode->getNumOperands() < 13) + return DIArray(); + + if (MDNode *N = dyn_cast_or_null(DbgNode->getOperand(11))) + return DIArray(N); + return DIArray(); +} + /// fixupObjcLikeName - Replace contains special characters used /// in a typical Objective-C names with '.' in a given string. static void fixupObjcLikeName(StringRef Str, SmallVectorImpl &Out) { -- cgit v1.1