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
diff --git a/lib/IR/DIBuilder.cpp b/lib/IR/DIBuilder.cpp
index 0d18bed..ee53dff 100644
--- a/lib/IR/DIBuilder.cpp
+++ b/lib/IR/DIBuilder.cpp
@@ -104,6 +104,7 @@
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_compile_unit),
createFilePathPair(VMContext, Filename, Directory),
+ NULL, // Imported modules
ConstantInt::get(Type::getInt32Ty(VMContext), Lang),
MDString::get(VMContext, Producer),
ConstantInt::get(Type::getInt1Ty(VMContext), isOptimized),
@@ -115,7 +116,9 @@
TempGVs,
MDString::get(VMContext, SplitName)
};
- TheCU = DICompileUnit(MDNode::get(VMContext, Elts));
+ DICompileUnit CU(MDNode::get(VMContext, Elts));
+ assert(CU.Verify() && "The compile unit should be valid");
+ TheCU = CU;
// Create a named metadata so that it is easier to find cu in a module.
NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu");
@@ -127,9 +130,12 @@
DIFile DIBuilder::createFile(StringRef Filename, StringRef Directory) {
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_file_type),
- createFilePathPair(VMContext, Filename, Directory)
+ createFilePathPair(VMContext, Filename, Directory),
+ NULL // Imported modules
};
- return DIFile(MDNode::get(VMContext, Elts));
+ DIFile F(MDNode::get(VMContext, Elts));
+ assert(F.Verify() && "The DIFile should be valid");
+ return F;
}
/// createEnumerator - Create a single enumerator value.
@@ -140,7 +146,9 @@
MDString::get(VMContext, Name),
ConstantInt::get(Type::getInt64Ty(VMContext), Val)
};
- return DIEnumerator(MDNode::get(VMContext, Elts));
+ DIEnumerator E(MDNode::get(VMContext, Elts));
+ assert(E.Verify() && "The enumerator should be valid");
+ return E;
}
/// createNullPtrType - Create C++0x nullptr type.
@@ -151,6 +159,7 @@
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_unspecified_type),
NULL, // Filename
+ Constant::getNullValue(Type::getInt32Ty(VMContext)), // Imported modules
NULL, //TheCU,
MDString::get(VMContext, Name),
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Line
@@ -160,7 +169,9 @@
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Flags;
ConstantInt::get(Type::getInt32Ty(VMContext), 0) // Encoding
};
- return DIType(MDNode::get(VMContext, Elts));
+ DIType T(MDNode::get(VMContext, Elts));
+ assert(T.Verify() && "The nullptr type should be valid");
+ return T;
}
/// createBasicType - Create debugging information entry for a basic
@@ -174,6 +185,7 @@
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_base_type),
NULL, // File/directory name
+ NULL, // Imported modules
NULL, //TheCU,
MDString::get(VMContext, Name),
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Line
@@ -183,7 +195,9 @@
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Flags;
ConstantInt::get(Type::getInt32Ty(VMContext), Encoding)
};
- return DIBasicType(MDNode::get(VMContext, Elts));
+ DIBasicType T(MDNode::get(VMContext, Elts));
+ assert(T.Verify() && "The basic type should be valid");
+ return T;
}
/// createQualifiedType - Create debugging information entry for a qualified
@@ -193,6 +207,7 @@
Value *Elts[] = {
GetTagConstant(VMContext, Tag),
NULL, // Filename
+ NULL, // Imported modules
NULL, //TheCU,
MDString::get(VMContext, StringRef()), // Empty name.
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Line
@@ -202,7 +217,9 @@
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Flags
FromTy
};
- return DIDerivedType(MDNode::get(VMContext, Elts));
+ DIDerivedType T(MDNode::get(VMContext, Elts));
+ assert(T.Verify() && "The derived type should be valid");
+ return T;
}
/// createPointerType - Create debugging information entry for a pointer.
@@ -213,6 +230,7 @@
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_pointer_type),
NULL, // Filename
+ NULL, // Imported modules
NULL, //TheCU,
MDString::get(VMContext, Name),
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Line
@@ -222,7 +240,9 @@
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Flags
PointeeTy
};
- return DIDerivedType(MDNode::get(VMContext, Elts));
+ DIDerivedType T(MDNode::get(VMContext, Elts));
+ assert(T.Verify() && "The pointer type should be valid");
+ return T;
}
DIDerivedType DIBuilder::createMemberPointerType(DIType PointeeTy, DIType Base) {
@@ -230,6 +250,7 @@
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_ptr_to_member_type),
NULL, // Filename
+ NULL, // Imported modules
NULL, //TheCU,
NULL,
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Line
@@ -240,7 +261,9 @@
PointeeTy,
Base
};
- return DIDerivedType(MDNode::get(VMContext, Elts));
+ DIDerivedType T(MDNode::get(VMContext, Elts));
+ assert(T.Verify() && "The member pointer type should be valid");
+ return T;
}
/// createReferenceType - Create debugging information entry for a reference
@@ -251,6 +274,7 @@
Value *Elts[] = {
GetTagConstant(VMContext, Tag),
NULL, // Filename
+ NULL, // Imported modules
NULL, // TheCU,
NULL, // Name
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Line
@@ -260,7 +284,9 @@
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Flags
RTy
};
- return DIDerivedType(MDNode::get(VMContext, Elts));
+ DIDerivedType T(MDNode::get(VMContext, Elts));
+ assert(T.Verify() && "The reference type should be valid");
+ return T;
}
/// createTypedef - Create debugging information entry for a typedef.
@@ -271,6 +297,7 @@
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_typedef),
File.getFileNode(),
+ NULL, // Imported modules
getNonCompileUnitScope(Context),
MDString::get(VMContext, Name),
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
@@ -280,7 +307,9 @@
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Flags
Ty
};
- return DIDerivedType(MDNode::get(VMContext, Elts));
+ DIDerivedType T(MDNode::get(VMContext, Elts));
+ assert(T.Verify() && "The typedef Type should be valid");
+ return T;
}
/// createFriend - Create debugging information entry for a 'friend'.
@@ -291,6 +320,7 @@
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_friend),
NULL,
+ NULL, // Imported modules
Ty,
NULL, // Name
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Line
@@ -300,7 +330,9 @@
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Flags
FriendTy
};
- return DIType(MDNode::get(VMContext, Elts));
+ DIType T(MDNode::get(VMContext, Elts));
+ assert(T.Verify() && "The friend type should be valid");
+ return T;
}
/// createInheritance - Create debugging information entry to establish
@@ -312,6 +344,7 @@
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_inheritance),
NULL,
+ NULL, // Imported modules
Ty,
NULL, // Name
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Line
@@ -321,7 +354,9 @@
ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
BaseTy
};
- return DIDerivedType(MDNode::get(VMContext, Elts));
+ DIDerivedType T(MDNode::get(VMContext, Elts));
+ assert(T.Verify() && "The inheritance type should be valid");
+ return T;
}
/// createMemberType - Create debugging information entry for a member.
@@ -333,6 +368,7 @@
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_member),
File.getFileNode(),
+ NULL, // Imported modules
getNonCompileUnitScope(Scope),
MDString::get(VMContext, Name),
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
@@ -342,7 +378,9 @@
ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
Ty
};
- return DIDerivedType(MDNode::get(VMContext, Elts));
+ DIDerivedType T(MDNode::get(VMContext, Elts));
+ assert(T.Verify() && "The member type should be valid");
+ return T;
}
/// createStaticMemberType - Create debugging information entry for a
@@ -356,6 +394,7 @@
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_member),
File.getFileNode(),
+ NULL, // Imported modules
getNonCompileUnitScope(Scope),
MDString::get(VMContext, Name),
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
@@ -366,7 +405,9 @@
Ty,
Val
};
- return DIType(MDNode::get(VMContext, Elts));
+ DIType T(MDNode::get(VMContext, Elts));
+ assert(T.Verify() && "The static member type should be valid");
+ return T;
}
/// createObjCIVar - Create debugging information entry for Objective-C
@@ -382,6 +423,7 @@
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_member),
File.getFileNode(),
+ NULL, // Imported modules
getNonCompileUnitScope(File),
MDString::get(VMContext, Name),
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
@@ -395,7 +437,9 @@
MDString::get(VMContext, SetterName),
ConstantInt::get(Type::getInt32Ty(VMContext), PropertyAttributes)
};
- return DIType(MDNode::get(VMContext, Elts));
+ DIType T(MDNode::get(VMContext, Elts));
+ assert(T.Verify() && "The Objective-C IVar type should be valid");
+ return T;
}
/// createObjCIVar - Create debugging information entry for Objective-C
@@ -409,6 +453,7 @@
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_member),
File.getFileNode(),
+ NULL, // Imported modules
getNonCompileUnitScope(File),
MDString::get(VMContext, Name),
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
@@ -419,7 +464,9 @@
Ty,
PropertyNode
};
- return DIType(MDNode::get(VMContext, Elts));
+ DIType T(MDNode::get(VMContext, Elts));
+ assert(T.Verify() && "The Objective-C IVar type should be valid");
+ return T;
}
/// createObjCProperty - Create debugging information entry for Objective-C
@@ -440,7 +487,9 @@
ConstantInt::get(Type::getInt32Ty(VMContext), PropertyAttributes),
Ty
};
- return DIObjCProperty(MDNode::get(VMContext, Elts));
+ DIObjCProperty P(MDNode::get(VMContext, Elts));
+ assert(P.Verify() && "The Objective-C property should be valid");
+ return P;
}
/// createTemplateTypeParameter - Create debugging information for template
@@ -458,7 +507,9 @@
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
ConstantInt::get(Type::getInt32Ty(VMContext), ColumnNo)
};
- return DITemplateTypeParameter(MDNode::get(VMContext, Elts));
+ DITemplateTypeParameter P(MDNode::get(VMContext, Elts));
+ assert(P.Verify() && "The template type parameter should be valid");
+ return P;
}
/// createTemplateValueParameter - Create debugging information for template
@@ -478,7 +529,9 @@
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
ConstantInt::get(Type::getInt32Ty(VMContext), ColumnNo)
};
- return DITemplateValueParameter(MDNode::get(VMContext, Elts));
+ DITemplateValueParameter P(MDNode::get(VMContext, Elts));
+ assert(P.Verify() && "The template value parameter should be valid");
+ return P;
}
/// createClassType - Create debugging information entry for a class.
@@ -497,6 +550,7 @@
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_class_type),
File.getFileNode(),
+ NULL, // Imported modules
getNonCompileUnitScope(Context),
MDString::get(VMContext, Name),
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
@@ -529,6 +583,7 @@
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_structure_type),
File.getFileNode(),
+ NULL, // Imported modules
getNonCompileUnitScope(Context),
MDString::get(VMContext, Name),
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
@@ -556,6 +611,7 @@
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_union_type),
File.getFileNode(),
+ NULL, // Imported modules
getNonCompileUnitScope(Scope),
MDString::get(VMContext, Name),
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
@@ -568,7 +624,9 @@
ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeLang),
Constant::getNullValue(Type::getInt32Ty(VMContext))
};
- return DICompositeType(MDNode::get(VMContext, Elts));
+ DICompositeType T(MDNode::get(VMContext, Elts));
+ assert(T.Verify() && "The union type should be valid");
+ return T;
}
/// createSubroutineType - Create subroutine type.
@@ -578,6 +636,7 @@
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_subroutine_type),
Constant::getNullValue(Type::getInt32Ty(VMContext)),
+ Constant::getNullValue(Type::getInt32Ty(VMContext)), // Imported modules
Constant::getNullValue(Type::getInt32Ty(VMContext)),
MDString::get(VMContext, ""),
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
@@ -590,7 +649,9 @@
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
Constant::getNullValue(Type::getInt32Ty(VMContext))
};
- return DICompositeType(MDNode::get(VMContext, Elts));
+ DICompositeType T(MDNode::get(VMContext, Elts));
+ assert(T.Verify() && "The subroutine type should be valid");
+ return T;
}
/// createEnumerationType - Create debugging information entry for an
@@ -603,6 +664,7 @@
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_enumeration_type),
File.getFileNode(),
+ NULL, // Imported modules
getNonCompileUnitScope(Scope),
MDString::get(VMContext, Name),
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
@@ -617,7 +679,9 @@
};
MDNode *Node = MDNode::get(VMContext, Elts);
AllEnumTypes.push_back(Node);
- return DICompositeType(Node);
+ DICompositeType T(Node);
+ assert(T.Verify() && "The enumeration type should be valid");
+ return T;
}
/// createArrayType - Create debugging information entry for an array.
@@ -627,6 +691,7 @@
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_array_type),
NULL, // Filename/Directory,
+ Constant::getNullValue(Type::getInt32Ty(VMContext)), // Imported modules
NULL, //TheCU,
MDString::get(VMContext, ""),
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
@@ -639,7 +704,9 @@
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
Constant::getNullValue(Type::getInt32Ty(VMContext))
};
- return DICompositeType(MDNode::get(VMContext, Elts));
+ DICompositeType T(MDNode::get(VMContext, Elts));
+ assert(T.Verify() && "The array type should be valid");
+ return T;
}
/// createVectorType - Create debugging information entry for a vector.
@@ -650,6 +717,7 @@
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_array_type),
NULL, // Filename/Directory,
+ Constant::getNullValue(Type::getInt32Ty(VMContext)), // Imported modules
NULL, //TheCU,
MDString::get(VMContext, ""),
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
@@ -662,7 +730,9 @@
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
Constant::getNullValue(Type::getInt32Ty(VMContext))
};
- return DIType(MDNode::get(VMContext, Elts));
+ DIType T(MDNode::get(VMContext, Elts));
+ assert(T.Verify() && "The vector type should be valid");
+ return T;
}
/// createArtificialType - Create a new DIType with "artificial" flag set.
@@ -684,9 +754,11 @@
CurFlags = CurFlags | DIType::FlagArtificial;
// Flags are stored at this slot.
- Elts[8] = ConstantInt::get(Type::getInt32Ty(VMContext), CurFlags);
+ Elts[9] = ConstantInt::get(Type::getInt32Ty(VMContext), CurFlags);
- return DIType(MDNode::get(VMContext, Elts));
+ DIType T(MDNode::get(VMContext, Elts));
+ assert(T.Verify() && "The artificial type should be valid");
+ return T;
}
/// createObjectPointerType - Create a new type with both the object pointer
@@ -709,9 +781,11 @@
CurFlags = CurFlags | (DIType::FlagObjectPointer | DIType::FlagArtificial);
// Flags are stored at this slot.
- Elts[8] = ConstantInt::get(Type::getInt32Ty(VMContext), CurFlags);
+ Elts[9] = ConstantInt::get(Type::getInt32Ty(VMContext), CurFlags);
- return DIType(MDNode::get(VMContext, Elts));
+ DIType T(MDNode::get(VMContext, Elts));
+ assert(T.Verify() && "The object pointer type should be valid");
+ return T;
}
/// retainType - Retain DIType in a module even if it is not referenced
@@ -740,6 +814,7 @@
Value *Elts[] = {
GetTagConstant(VMContext, Tag),
F.getFileNode(),
+ NULL, // Imported modules
getNonCompileUnitScope(Scope),
MDString::get(VMContext, Name),
ConstantInt::get(Type::getInt32Ty(VMContext), Line),
@@ -911,6 +986,7 @@
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_subprogram),
File.getFileNode(),
+ NULL, // Imported modules
getNonCompileUnitScope(Context),
MDString::get(VMContext, Name),
MDString::get(VMContext, Name),
@@ -958,6 +1034,7 @@
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_subprogram),
F.getFileNode(),
+ NULL, // Imported modules
getNonCompileUnitScope(Context),
MDString::get(VMContext, Name),
MDString::get(VMContext, Name),
@@ -993,6 +1070,7 @@
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_namespace),
File.getFileNode(),
+ NULL, // Imported modules
getNonCompileUnitScope(Scope),
MDString::get(VMContext, Name),
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo)
@@ -1010,6 +1088,7 @@
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_lexical_block),
File.getFileNode(),
+ NULL, // Imported modules
Scope
};
DILexicalBlockFile R(MDNode::get(VMContext, Elts));
@@ -1026,6 +1105,7 @@
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_lexical_block),
File.getFileNode(),
+ NULL, // Imported modules
getNonCompileUnitScope(Scope),
ConstantInt::get(Type::getInt32Ty(VMContext), Line),
ConstantInt::get(Type::getInt32Ty(VMContext), Col),
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 @@
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 @@
/// 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::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 @@
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 @@
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 @@
/// 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 @@
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 @@
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 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 @@
/// \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 @@
/// \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 @@
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 @@
/// 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<MDNode>(DbgNode->getOperand(10));
+ return dyn_cast_or_null<MDNode>(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<MDNode> 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<MDNode> N(*this);
- N->replaceOperandWith(12, ContainingType);
+ N->replaceOperandWith(13, ContainingType);
DbgNode = N;
}
@@ -660,21 +673,21 @@
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<MDNode>(DbgNode->getOperand(18));
+ return dyn_cast_or_null<MDNode>(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<MDNode>(DbgNode->getOperand(18)))
+ if (MDNode *T = dyn_cast_or_null<MDNode>(DbgNode->getOperand(19)))
return DIArray(T);
return DIArray();
}
@@ -692,16 +705,7 @@
}
DIArray DICompileUnit::getEnumTypes() const {
- if (!DbgNode || DbgNode->getNumOperands() < 12)
- return DIArray();
-
- if (MDNode *N = dyn_cast_or_null<MDNode>(DbgNode->getOperand(7)))
- 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<MDNode>(DbgNode->getOperand(8)))
@@ -709,8 +713,8 @@
return DIArray();
}
-DIArray DICompileUnit::getSubprograms() const {
- if (!DbgNode || DbgNode->getNumOperands() < 12)
+DIArray DICompileUnit::getRetainedTypes() const {
+ if (!DbgNode || DbgNode->getNumOperands() < 13)
return DIArray();
if (MDNode *N = dyn_cast_or_null<MDNode>(DbgNode->getOperand(9)))
@@ -718,9 +722,8 @@
return DIArray();
}
-
-DIArray DICompileUnit::getGlobalVariables() const {
- if (!DbgNode || DbgNode->getNumOperands() < 12)
+DIArray DICompileUnit::getSubprograms() const {
+ if (!DbgNode || DbgNode->getNumOperands() < 13)
return DIArray();
if (MDNode *N = dyn_cast_or_null<MDNode>(DbgNode->getOperand(10)))
@@ -728,6 +731,16 @@
return DIArray();
}
+
+DIArray DICompileUnit::getGlobalVariables() const {
+ if (!DbgNode || DbgNode->getNumOperands() < 13)
+ return DIArray();
+
+ if (MDNode *N = dyn_cast_or_null<MDNode>(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<char> &Out) {
@@ -1035,6 +1048,8 @@
DINameSpace(DbgNode).printInternal(OS);
} else if (this->isScope()) {
DIScope(DbgNode).printInternal(OS);
+ } else if (this->isImportedModule()) {
+ DIImportedModule(DbgNode).printInternal(OS);
}
}
@@ -1170,6 +1185,12 @@
<< ", 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.