#include "llvm/IR/DebugInfoMetadata.h"
#include "LLVMContextImpl.h"
#include "MetadataImpl.h"
+#include "llvm/IR/Function.h"
using namespace llvm;
// Fixup column.
adjustColumn(Column);
+ assert(Scope && "Expected scope");
if (Storage == Uniqued) {
if (auto *N =
getUniqued(Context.pImpl->MDLocations,
}
MDBasicType *MDBasicType::getImpl(LLVMContext &Context, unsigned Tag,
- MDString *Name, unsigned SizeInBits,
- unsigned AlignInBits, unsigned Encoding,
+ MDString *Name, uint64_t SizeInBits,
+ uint64_t AlignInBits, unsigned Encoding,
StorageType Storage, bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(
MDDerivedType *MDDerivedType::getImpl(
LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
- unsigned Line, Metadata *Scope, Metadata *BaseType, unsigned SizeInBits,
- unsigned AlignInBits, unsigned OffsetInBits, unsigned Flags,
+ unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
+ uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags,
Metadata *ExtraData, StorageType Storage, bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(MDDerivedType, (Tag, getString(Name), File, Line, Scope,
MDCompositeType *MDCompositeType::getImpl(
LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
- unsigned Line, Metadata *Scope, Metadata *BaseType, unsigned SizeInBits,
- unsigned AlignInBits, unsigned OffsetInBits, unsigned Flags,
+ unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
+ uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags,
Metadata *Elements, unsigned RuntimeLang, Metadata *VTableHolder,
Metadata *TemplateParams, MDString *Identifier, StorageType Storage,
bool ShouldCreate) {
bool ShouldCreate) {
DEFINE_GETIMPL_LOOKUP(MDSubroutineType, (Flags, TypeArray));
Metadata *Ops[] = {nullptr, nullptr, nullptr, nullptr,
- TypeArray, nullptr, nullptr};
+ TypeArray, nullptr, nullptr, nullptr};
DEFINE_GETIMPL_STORE(MDSubroutineType, (Flags), Ops);
}
assert(isCanonical(Filename) && "Expected canonical MDString");
assert(isCanonical(Directory) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(MDFile, (getString(Filename), getString(Directory)));
- Metadata *NodeOps[] = {Filename, Directory};
- Metadata *Ops[] = {MDTuple::get(Context, NodeOps)};
- return storeImpl(new (ArrayRef<Metadata *>(Ops).size())
- MDFile(Context, Storage, Ops),
- Storage, Context.pImpl->MDFiles);
+ Metadata *Ops[] = {Filename, Directory};
+ DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(MDFile, Ops);
}
MDCompileUnit *MDCompileUnit::getImpl(
(SourceLanguage, IsOptimized, RuntimeVersion, EmissionKind), Ops);
}
+MDSubprogram *MDLocalScope::getSubprogram() const {
+ if (auto *Block = dyn_cast<MDLexicalBlockBase>(this))
+ return Block->getScope()->getSubprogram();
+ return const_cast<MDSubprogram *>(cast<MDSubprogram>(this));
+}
+
MDSubprogram *MDSubprogram::getImpl(
LLVMContext &Context, Metadata *Scope, MDString *Name,
MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
Ops);
}
+void MDSubprogram::replaceFunction(Function *F) {
+ replaceFunction(F ? ConstantAsMetadata::get(F)
+ : static_cast<ConstantAsMetadata *>(nullptr));
+}
+
MDLexicalBlock *MDLexicalBlock::getImpl(LLVMContext &Context, Metadata *Scope,
Metadata *File, unsigned Line,
unsigned Column, StorageType Storage,
bool ShouldCreate) {
+ assert(Scope && "Expected scope");
DEFINE_GETIMPL_LOOKUP(MDLexicalBlock, (Scope, File, Line, Column));
Metadata *Ops[] = {File, Scope};
DEFINE_GETIMPL_STORE(MDLexicalBlock, (Line, Column), Ops);
unsigned Discriminator,
StorageType Storage,
bool ShouldCreate) {
+ assert(Scope && "Expected scope");
DEFINE_GETIMPL_LOOKUP(MDLexicalBlockFile, (Scope, File, Discriminator));
Metadata *Ops[] = {File, Scope};
DEFINE_GETIMPL_STORE(MDLexicalBlockFile, (Discriminator), Ops);
DEFINE_GETIMPL_STORE(MDNamespace, (Line), Ops);
}
-MDTemplateTypeParameter *
-MDTemplateTypeParameter::getImpl(LLVMContext &Context, Metadata *Scope,
- MDString *Name, Metadata *Type,
- StorageType Storage, bool ShouldCreate) {
+MDTemplateTypeParameter *MDTemplateTypeParameter::getImpl(LLVMContext &Context,
+ MDString *Name,
+ Metadata *Type,
+ StorageType Storage,
+ bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString");
- DEFINE_GETIMPL_LOOKUP(MDTemplateTypeParameter,
- (Scope, getString(Name), Type));
- Metadata *Ops[] = {Scope, Name, Type};
+ DEFINE_GETIMPL_LOOKUP(MDTemplateTypeParameter, (getString(Name), Type));
+ Metadata *Ops[] = {Name, Type};
DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(MDTemplateTypeParameter, Ops);
}
MDTemplateValueParameter *MDTemplateValueParameter::getImpl(
- LLVMContext &Context, unsigned Tag, Metadata *Scope, MDString *Name,
- Metadata *Type, Metadata *Value, StorageType Storage, bool ShouldCreate) {
+ LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *Type,
+ Metadata *Value, StorageType Storage, bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(MDTemplateValueParameter,
- (Tag, Scope, getString(Name), Type, Value));
- Metadata *Ops[] = {Scope, Name, Type, Value};
+ (Tag, getString(Name), Type, Value));
+ Metadata *Ops[] = {Name, Type, Value};
DEFINE_GETIMPL_STORE(MDTemplateValueParameter, (Tag), Ops);
}
LLVMContext &Context, unsigned Tag, Metadata *Scope, MDString *Name,
Metadata *File, unsigned Line, Metadata *Type, unsigned Arg, unsigned Flags,
Metadata *InlinedAt, StorageType Storage, bool ShouldCreate) {
+ // Truncate Arg to 8 bits.
+ //
+ // FIXME: This is gross (and should be changed to an assert or removed), but
+ // it matches historical behaviour for now.
+ Arg &= (1u << 8) - 1;
+
+ assert(Scope && "Expected scope");
assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(MDLocalVariable, (Tag, Scope, getString(Name), File,
Line, Type, Arg, Flags, InlinedAt));