/// isTemplateValueParameter - Return true if the specified tag is
/// DW_TAG_template_value_parameter.
bool DIDescriptor::isTemplateValueParameter() const {
- return DbgNode && getTag() == dwarf::DW_TAG_template_value_parameter;
+ return DbgNode && (getTag() == dwarf::DW_TAG_template_value_parameter ||
+ getTag() == dwarf::DW_TAG_GNU_template_template_param ||
+ getTag() == dwarf::DW_TAG_GNU_template_parameter_pack);
}
/// isCompileUnit - Return true if the specified tag is DW_TAG_compile_unit.
if (!isObjCProperty())
return false;
- DIType Ty = getType();
- if (!Ty.Verify()) return false;
-
// Don't worry about the rest of the strings for now.
return DbgNode->getNumOperands() == 8;
}
bool DIType::Verify() const {
if (!isType())
return false;
- if (getContext() && !getContext().Verify())
- return false;
unsigned Tag = getTag();
if (!isBasicType() && Tag != dwarf::DW_TAG_const_type &&
Tag != dwarf::DW_TAG_volatile_type && Tag != dwarf::DW_TAG_pointer_type &&
Tag != dwarf::DW_TAG_array_type &&
Tag != dwarf::DW_TAG_enumeration_type &&
Tag != dwarf::DW_TAG_subroutine_type &&
+ Tag != dwarf::DW_TAG_inheritance &&
+ Tag != dwarf::DW_TAG_friend &&
getFilename().empty())
return false;
return true;
bool DICompositeType::Verify() const {
if (!isCompositeType())
return false;
- if (getContext() && !getContext().Verify())
- return false;
return DbgNode->getNumOperands() >= 10 && DbgNode->getNumOperands() <= 14;
}
if (!isSubprogram())
return false;
- if (getContext() && !getContext().Verify())
- return false;
-
- DICompositeType Ty = getType();
- if (!Ty.Verify())
- return false;
return DbgNode->getNumOperands() == 20;
}
if (getDisplayName().empty())
return false;
- if (getContext() && !getContext().Verify())
- return false;
-
- DIType Ty = getType();
- if (!Ty.Verify())
- return false;
-
- if (!getGlobal() && !getConstant())
- return false;
-
return DbgNode->getNumOperands() == 13;
}
if (!isVariable())
return false;
- if (getContext() && !getContext().Verify())
- return false;
-
- DIType Ty = getType();
- if (!Ty.Verify())
- return false;
-
return DbgNode->getNumOperands() >= 8;
}
DIArray GVs = CU.getGlobalVariables();
for (unsigned i = 0, e = GVs.getNumElements(); i != e; ++i) {
DIGlobalVariable DIG(GVs.getElement(i));
- if (addGlobalVariable(DIG))
+ if (addGlobalVariable(DIG)) {
+ processScope(DIG.getContext());
processType(DIG.getType());
+ }
}
DIArray SPs = CU.getSubprograms();
for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i)
void DebugInfoFinder::processType(DIType DT) {
if (!addType(DT))
return;
+ processScope(DT.getContext());
if (DT.isCompositeType()) {
DICompositeType DCT(DT);
processType(DCT.getTypeDerivedFrom());
}
}
+void DebugInfoFinder::processScope(DIScope Scope) {
+ if (Scope.isType()) {
+ DIType Ty(Scope);
+ processType(Ty);
+ return;
+ }
+ if (!addScope(Scope))
+ return;
+ if (Scope.isLexicalBlock()) {
+ DILexicalBlock LB(Scope);
+ processScope(LB.getContext());
+ } else if (Scope.isLexicalBlockFile()) {
+ DILexicalBlockFile LBF = DILexicalBlockFile(Scope);
+ processScope(LBF.getScope());
+ } else if (Scope.isNameSpace()) {
+ DINameSpace NS(Scope);
+ processScope(NS.getContext());
+ }
+}
+
/// processLexicalBlock
void DebugInfoFinder::processLexicalBlock(DILexicalBlock LB) {
DIScope Context = LB.getContext();
void DebugInfoFinder::processSubprogram(DISubprogram SP) {
if (!addSubprogram(SP))
return;
+ processScope(SP.getContext());
processType(SP.getType());
}
return true;
}
+bool DebugInfoFinder::addScope(DIScope Scope) {
+ if (!Scope)
+ return false;
+ if (!NodesSeen.insert(Scope))
+ return false;
+ Scopes.push_back(Scope);
+ return true;
+}
+
//===----------------------------------------------------------------------===//
// DIDescriptor: dump routines for all descriptors.
//===----------------------------------------------------------------------===//
OS << " [artificial]";
if (isForwardDecl())
- OS << " [fwd]";
+ OS << " [decl]";
+ else if (getTag() == dwarf::DW_TAG_structure_type ||
+ getTag() == dwarf::DW_TAG_union_type ||
+ getTag() == dwarf::DW_TAG_enumeration_type ||
+ getTag() == dwarf::DW_TAG_class_type)
+ OS << " [def]";
if (isVector())
OS << " [vector]";
if (isStaticMember())
const LLVMContext &Ctx) {
if (!DL.isUnknown()) { // Print source line info.
DIScope Scope(DL.getScope(Ctx));
+ assert(Scope.isScope() &&
+ "Scope of a DebugLoc should be a DIScope.");
// Omit the directory, because it's likely to be long and uninteresting.
- if (Scope.Verify())
- CommentOS << Scope.getFilename();
- else
- CommentOS << "<unknown>";
+ CommentOS << Scope.getFilename();
CommentOS << ':' << DL.getLine();
if (DL.getCol() != 0)
CommentOS << ':' << DL.getCol();