/// this DBG_VALUE instruction.
DIVariable getDebugVariable() const {
assert(isDebugValue() && "not a DBG_VALUE");
- DIVariable Var(getOperand(2).getMetadata());
- assert(Var.Verify() && "not a DIVariable");
- return Var;
+ return cast<MDLocalVariable>(getOperand(2).getMetadata());
}
/// \brief Return the complex address expression referenced by
const MachineInstrBuilder &addMetadata(const MDNode *MD) const {
MI->addOperand(*MF, MachineOperand::CreateMetadata(MD));
- assert((MI->isDebugValue() ? MI->getDebugVariable().Verify() : true) &&
+ assert((MI->isDebugValue() ? MI->getDebugVariable().isVariable() : true) &&
"first MDNode argument of a DBG_VALUE not a DIVariable");
return *this;
}
const MCInstrDesc &MCID, bool IsIndirect,
unsigned Reg, unsigned Offset,
const MDNode *Variable, const MDNode *Expr) {
- assert(DIVariable(Variable).Verify() && "not a DIVariable");
+ assert(isa<MDLocalVariable>(Variable) && "not a DIVariable");
assert(DIExpression(Expr)->isValid() && "not a DIExpression");
assert(DIVariable(Variable)->isValidLocationForIntrinsic(DL) &&
"Expected inlined-at fields to agree");
const MCInstrDesc &MCID, bool IsIndirect,
unsigned Reg, unsigned Offset,
const MDNode *Variable, const MDNode *Expr) {
- assert(DIVariable(Variable).Verify() && "not a DIVariable");
+ assert(isa<MDLocalVariable>(Variable) && "not a DIVariable");
assert(DIExpression(Expr)->isValid() && "not a DIExpression");
MachineFunction &MF = *BB.getParent();
MachineInstr *MI =
public:
explicit DIDescriptor(const MDNode *N = nullptr) : DbgNode(N) {}
- bool Verify() const;
-
MDNode *get() const { return const_cast<MDNode *>(DbgNode); }
operator MDNode *() const { return get(); }
MDNode *operator->() const { return get(); }
int64_t getLo() const { return get()->getLo(); }
int64_t getCount() const { return get()->getCount(); }
- bool Verify() const;
};
/// \brief This descriptor holds an array of nodes with type T.
StringRef getName() const { return get()->getName(); }
int64_t getEnumValue() const { return get()->getValue(); }
- bool Verify() const;
};
template <typename T> class DIRef;
return *get();
}
- bool Verify() const;
-
DIScopeRef getContext() const { return DIScopeRef::get(get()->getScope()); }
StringRef getName() const { return get()->getName(); }
unsigned getLineNumber() const { return get()->getLine(); }
}
unsigned getEncoding() const { return get()->getEncoding(); }
-
- bool Verify() const;
};
/// \brief A simple derived type
return nullptr;
}
-
- bool Verify() const;
};
/// \brief Types that refer to multiple other types.
return DIArray(get()->getTemplateParams());
}
MDString *getIdentifier() const { return get()->getRawIdentifier(); }
-
- bool Verify() const;
};
class DISubroutineType : public DICompositeType {
/// \brief Retrieve the MDNode for the directory/file pair.
MDNode *getFileNode() const { return get(); }
- bool Verify() const;
};
/// \brief A wrapper for a compile unit.
return get()->getSplitDebugFilename();
}
unsigned getEmissionKind() const { return get()->getEmissionKind(); }
-
- bool Verify() const;
};
/// \brief This is a wrapper for a subprogram (e.g. a function).
return DITypeRef::get(get()->getContainingType());
}
- bool Verify() const;
-
/// \brief Check if this provides debugging information for the function F.
bool describes(const Function *F);
return N->getColumn();
return 0;
}
- bool Verify() const;
};
/// \brief This is a wrapper for a lexical block with a filename change.
unsigned getColumnNumber() const { return getScope().getColumnNumber(); }
DILexicalBlock getScope() const { return DILexicalBlock(get()->getScope()); }
unsigned getDiscriminator() const { return get()->getDiscriminator(); }
- bool Verify() const;
};
/// \brief A wrapper for a C++ style name space.
StringRef getName() const { return get()->getName(); }
unsigned getLineNumber() const { return get()->getLine(); }
DIScope getContext() const { return DIScope(get()->getScope()); }
- bool Verify() const;
};
/// \brief This is a wrapper for template type parameter.
StringRef getName() const { return get()->getName(); }
DITypeRef getType() const { return DITypeRef::get(get()->getType()); }
- bool Verify() const;
};
/// \brief This is a wrapper for template value parameter.
StringRef getName() const { return get()->getName(); }
DITypeRef getType() const { return DITypeRef::get(get()->getType()); }
Metadata *getValue() const { return get()->getValue(); }
- bool Verify() const;
};
/// \brief This is a wrapper for a global variable.
DIDerivedType getStaticDataMemberDeclaration() const {
return DIDerivedType(get()->getStaticDataMemberDeclaration());
}
-
- bool Verify() const;
};
/// \brief This is a wrapper for a variable (e.g. parameter, local, global etc).
/// \brief If this variable is inlined then return inline location.
MDNode *getInlinedAt() const { return DIDescriptor(get()->getInlinedAt()); }
- bool Verify() const;
-
/// \brief Check if this is a "__block" variable (Apple Blocks).
bool isBlockByrefVariable(const DITypeIdentifierMap &Map) const {
return (getType().resolve(Map)).isBlockByrefStruct();
return *get();
}
- // Don't call this. Call isValid() directly.
- bool Verify() const = delete;
-
/// \brief Return the number of elements in the complex expression.
unsigned getNumElements() const { return get()->getNumElements(); }
}
StringRef getFilename() const { return getScope().getFilename(); }
StringRef getDirectory() const { return getScope().getDirectory(); }
- bool Verify() const;
bool atSameLineAs(const DILocation &Other) const {
return (getLineNumber() == Other.getLineNumber() &&
getFilename() == Other.getFilename());
/// \note Objective-C doesn't have an ODR, so there is no benefit in storing
/// the type as a DITypeRef here.
DIType getType() const { return DIType(get()->getType()); }
-
- bool Verify() const;
};
/// \brief An imported module (C++ using directive or similar).
}
unsigned getLineNumber() const { return get()->getLine(); }
StringRef getName() const { return get()->getName(); }
- bool Verify() const;
};
/// \brief Find subprogram that is enclosing this scope.
}
Value(const MDNode *Var, const MDNode *Expr, MachineLocation Loc)
: Variable(Var), Expression(Expr), EntryKind(E_Location), Loc(Loc) {
- assert(DIVariable(Var).Verify());
+ assert(isa<MDLocalVariable>(Var));
assert(DIExpression(Expr)->isValid());
}
std::unique_ptr<DIE>
DwarfCompileUnit::constructImportedEntityDIE(const DIImportedEntity &Module) {
- assert(Module.Verify() &&
- "Use one of the MDNode * overloads to handle invalid metadata");
std::unique_ptr<DIE> IMDie = make_unique<DIE>((dwarf::Tag)Module.getTag());
insertDIE(Module, IMDie.get());
DIE *EntityDie;
void DwarfDebug::constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
const MDNode *N) {
DIImportedEntity Module(N);
- assert(Module.Verify());
if (DIE *D = TheCU.getOrCreateContextDIE(Module.getContext()))
D->addChild(TheCU.constructImportedEntityDIE(Module));
}
Streamer);
// Regular entry.
if (Value.isInt()) {
- DIBasicType BTy(DV.getType().resolve(TypeIdentifierMap));
- if (BTy.Verify() && (BTy.getEncoding() == dwarf::DW_ATE_signed ||
- BTy.getEncoding() == dwarf::DW_ATE_signed_char))
+ MDType *T = DV.getType().resolve(TypeIdentifierMap);
+ auto *B = dyn_cast<MDBasicType>(T);
+ if (B && (B->getEncoding() == dwarf::DW_ATE_signed ||
+ B->getEncoding() == dwarf::DW_ATE_signed_char))
DwarfExpr.AddSignedConstant(Value.getInt());
else
DwarfExpr.AddUnsignedConstant(Value.getInt());
: Var(V), Expr(1, E), TheDIE(nullptr), DotDebugLocOffset(~0U),
MInsn(nullptr), DD(DD) {
FrameIndex.push_back(FI);
- assert(Var.Verify());
assert(!E || E->isValid());
}
/// addSourceLine - Add location information to specified debug information
/// entry.
void DwarfUnit::addSourceLine(DIE &Die, DINameSpace NS) {
- assert(NS.Verify());
-
addSourceLine(Die, NS.getLineNumber(), NS.getFilename(), NS.getDirectory());
}
/// getOrCreateStaticMemberDIE - Create new DIE for C++ static member.
DIE *DwarfUnit::getOrCreateStaticMemberDIE(DIDerivedType DT) {
- if (!DT.Verify())
+ if (!DT)
return nullptr;
// Construct the context before querying for the existence of the DIE in case
Metadata *NS, unsigned Line, StringRef Name,
SmallVectorImpl<TrackingMDNodeRef> &AllImportedModules) {
DIImportedEntity M = MDImportedEntity::get(C, Tag, Context, NS, Line, Name);
- assert(M.Verify() && "Imported module should be valid");
AllImportedModules.emplace_back(M.get());
return M;
}
DINameSpace DIBuilder::createNameSpace(DIDescriptor Scope, StringRef Name,
DIFile File, unsigned LineNo) {
- DINameSpace R = MDNamespace::get(VMContext, getNonCompileUnitScope(Scope),
- File, Name, LineNo);
- assert(R.Verify() &&
- "createNameSpace should return a verifiable DINameSpace");
- return R;
+ return MDNamespace::get(VMContext, getNonCompileUnitScope(Scope), File, Name,
+ LineNo);
}
DILexicalBlockFile DIBuilder::createLexicalBlockFile(DIDescriptor Scope,
DIFile File,
unsigned Discriminator) {
- DILexicalBlockFile R = MDLexicalBlockFile::get(
- VMContext, Scope, File.getFileNode(), Discriminator);
- assert(
- R.Verify() &&
- "createLexicalBlockFile should return a verifiable DILexicalBlockFile");
- return R;
+ return MDLexicalBlockFile::get(VMContext, Scope, File.getFileNode(),
+ Discriminator);
}
DILexicalBlock DIBuilder::createLexicalBlock(DIDescriptor Scope, DIFile File,
unsigned Line, unsigned Col) {
// Make these distinct, to avoid merging two lexical blocks on the same
// file/line/column.
- DILexicalBlock R = MDLexicalBlock::getDistinct(
- VMContext, getNonCompileUnitScope(Scope), File.getFileNode(), Line, Col);
- assert(R.Verify() &&
- "createLexicalBlock should return a verifiable DILexicalBlock");
- return R;
+ return MDLexicalBlock::getDistinct(VMContext, getNonCompileUnitScope(Scope),
+ File.getFileNode(), Line, Col);
}
static Value *getDbgIntrinsicValueImpl(LLVMContext &VMContext, Value *V) {
return Flags;
}
-bool DIDescriptor::Verify() const {
- return DbgNode &&
- (DIDerivedType(DbgNode).Verify() ||
- DICompositeType(DbgNode).Verify() || DIBasicType(DbgNode).Verify() ||
- DIVariable(DbgNode).Verify() || DISubprogram(DbgNode).Verify() ||
- DIGlobalVariable(DbgNode).Verify() || DIFile(DbgNode).Verify() ||
- DICompileUnit(DbgNode).Verify() || DINameSpace(DbgNode).Verify() ||
- DILexicalBlock(DbgNode).Verify() ||
- DILexicalBlockFile(DbgNode).Verify() ||
- DISubrange(DbgNode).Verify() || DIEnumerator(DbgNode).Verify() ||
- DIObjCProperty(DbgNode).Verify() ||
- DITemplateTypeParameter(DbgNode).Verify() ||
- DITemplateValueParameter(DbgNode).Verify() ||
- DIImportedEntity(DbgNode).Verify());
-}
-
static Metadata *getField(const MDNode *DbgNode, unsigned Elt) {
if (!DbgNode || Elt >= DbgNode->getNumOperands())
return nullptr;
Node->replaceAllUsesWith(D);
}
-bool DICompileUnit::Verify() const { return isCompileUnit(); }
-bool DIObjCProperty::Verify() const { return isObjCProperty(); }
-
#ifndef NDEBUG
/// \brief Check if a value can be a reference to a type.
static bool isTypeRef(const Metadata *MD) {
}
#endif
-bool DIType::Verify() const { return isType(); }
-bool DIBasicType::Verify() const { return isBasicType(); }
-bool DIDerivedType::Verify() const { return isDerivedType(); }
-bool DICompositeType::Verify() const { return isCompositeType(); }
-bool DISubprogram::Verify() const { return isSubprogram(); }
-bool DIGlobalVariable::Verify() const { return isGlobalVariable(); }
-bool DIVariable::Verify() const { return isVariable(); }
-
-bool DILocation::Verify() const {
- return dyn_cast_or_null<MDLocation>(DbgNode);
-}
-bool DINameSpace::Verify() const {
- return dyn_cast_or_null<MDNamespace>(DbgNode);
-}
-bool DIFile::Verify() const { return dyn_cast_or_null<MDFile>(DbgNode); }
-bool DIEnumerator::Verify() const {
- return dyn_cast_or_null<MDEnumerator>(DbgNode);
-}
-bool DISubrange::Verify() const {
- return dyn_cast_or_null<MDSubrange>(DbgNode);
-}
-bool DILexicalBlock::Verify() const {
- return dyn_cast_or_null<MDLexicalBlock>(DbgNode);
-}
-bool DILexicalBlockFile::Verify() const {
- return dyn_cast_or_null<MDLexicalBlockFile>(DbgNode);
-}
-bool DITemplateTypeParameter::Verify() const {
- return dyn_cast_or_null<MDTemplateTypeParameter>(DbgNode);
-}
-bool DITemplateValueParameter::Verify() const {
- return dyn_cast_or_null<MDTemplateValueParameter>(DbgNode);
-}
-bool DIImportedEntity::Verify() const {
- return dyn_cast_or_null<MDImportedEntity>(DbgNode);
-}
-
void DICompositeType::setArraysHelper(MDNode *Elements, MDNode *TParams) {
TypedTrackingMDRef<MDCompositeTypeBase> N(get());
if (Elements)
}
void DICompileUnit::replaceSubprograms(DIArray Subprograms) {
- assert(Verify() && "Expected compile unit");
get()->replaceSubprograms(cast_or_null<MDTuple>(Subprograms.get()));
}
void DICompileUnit::replaceGlobalVariables(DIArray GlobalVariables) {
- assert(Verify() && "Expected compile unit");
get()->replaceGlobalVariables(cast_or_null<MDTuple>(GlobalVariables.get()));
}
DILocation DILocation::copyWithNewScope(LLVMContext &Ctx,
DILexicalBlockFile NewScope) {
- assert(Verify());
assert(NewScope && "Expected valid scope");
const auto *Old = cast<MDLocation>(DbgNode);
DIVariable llvm::createInlinedVariable(MDNode *DV, MDNode *InlinedScope,
LLVMContext &VMContext) {
- assert(DIVariable(DV).Verify() && "Expected a DIVariable");
return cast<MDLocalVariable>(DV)
->withInline(cast_or_null<MDLocation>(InlinedScope));
}
DIVariable llvm::cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext) {
- assert(DIVariable(DV).Verify() && "Expected a DIVariable");
return cast<MDLocalVariable>(DV)->withoutInline();
}
DenseSet<const MDNode *> VisitedSet;
for (DICompileUnit DIC : F.compile_units()) {
- assert(DIC.Verify() && "DIC must verify as a DICompileUnit.");
-
// Create our live subprogram list.
DIArray SPs = DIC.getSubprograms();
bool SubprogramChange = false;
for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i) {
DISubprogram DISP(SPs.getElement(i));
- assert(DISP.Verify() && "DISP must verify as a DISubprogram.");
// Make sure we visit each subprogram only once.
if (!VisitedSet.insert(DISP).second)
bool GlobalVariableChange = false;
for (unsigned i = 0, e = GVs.getNumElements(); i != e; ++i) {
DIGlobalVariable DIG(GVs.getElement(i));
- assert(DIG.Verify() && "DIG must verify as DIGlobalVariable.");
// Make sure we only visit each global variable only once.
if (!VisitedSet.insert(DIG).second)
auto CU = DIB.createCompileUnit(dwarf::DW_LANG_Cobol74, "F.CBL", "/",
"llvm-cobol74", true, "", 0);
auto Type = DIB.createSubroutineType(File, DIB.getOrCreateTypeArray(None));
- auto SP = DIB.createFunction(CU, "foo", "", File, 1, Type,
- false, true, 1, 0, true, F);
- EXPECT_TRUE(SP.Verify());
+ DIB.createFunction(CU, "foo", "", File, 1, Type, false, true, 1, 0, true, F);
AllocaInst *I = Builder.CreateAlloca(Builder.getInt8Ty());
auto BarSP = DIB.createFunction(CU, "bar", "", File, 1, Type, false, true, 1,
0, true, nullptr);