Skip to content

Commit

Permalink
DebugInfo: Remove DIDescriptor from the DIBuilder API
Browse files Browse the repository at this point in the history
As a step toward killing `DIDescriptor` and its subclasses, remove it
from the `DIBuilder` API.  Replace the subclasses with appropriate
pointers from the new debug info hierarchy.  There are a couple of
possible surprises in type choices for out-of-tree frontends:

  - Subroutine types: `MDSubroutineType`, not `MDCompositeTypeBase`.
  - Composite types: `MDCompositeType`, not `MDCompositeTypeBase`.
  - Scopes: `MDScope`, not `MDNode`.
  - Generic debug info nodes: `DebugNode`, not `MDNode`.

This is part of PR23080.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235111 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
dexonsmith committed Apr 16, 2015
1 parent e271153 commit afc6740
Show file tree
Hide file tree
Showing 5 changed files with 407 additions and 485 deletions.
36 changes: 16 additions & 20 deletions bindings/go/llvm/DIBuilderBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ LLVMMetadataRef LLVMDIBuilderCreateLexicalBlock(LLVMDIBuilderRef Dref,
unsigned Line,
unsigned Column) {
DIBuilder *D = unwrap(Dref);
DILexicalBlock LB =
D->createLexicalBlock(DIDescriptor(unwrap<MDLocalScope>(Scope)),
unwrap<MDFile>(File), Line, Column);
auto *LB = D->createLexicalBlock(unwrap<MDLocalScope>(Scope),
unwrap<MDFile>(File), Line, Column);
return wrap(LB);
}

Expand All @@ -69,9 +68,8 @@ LLVMMetadataRef LLVMDIBuilderCreateLexicalBlockFile(LLVMDIBuilderRef Dref,
LLVMMetadataRef File,
unsigned Discriminator) {
DIBuilder *D = unwrap(Dref);
DILexicalBlockFile LBF =
D->createLexicalBlockFile(DIDescriptor(unwrap<MDLocalScope>(Scope)),
unwrap<MDFile>(File), Discriminator);
DILexicalBlockFile LBF = D->createLexicalBlockFile(
unwrap<MDLocalScope>(Scope), unwrap<MDFile>(File), Discriminator);
return wrap(LBF);
}

Expand All @@ -82,9 +80,9 @@ LLVMMetadataRef LLVMDIBuilderCreateFunction(
unsigned ScopeLine, unsigned Flags, int IsOptimized, LLVMValueRef Func) {
DIBuilder *D = unwrap(Dref);
DISubprogram SP = D->createFunction(
DIDescriptor(unwrap<MDScope>(Scope)), Name, LinkageName,
unwrap<MDScope>(Scope), Name, LinkageName,
File ? unwrap<MDFile>(File) : nullptr, Line,
unwrap<MDCompositeTypeBase>(CompositeType), IsLocalToUnit, IsDefinition,
unwrap<MDSubroutineType>(CompositeType), IsLocalToUnit, IsDefinition,
ScopeLine, Flags, IsOptimized, unwrap<Function>(Func));
return wrap(SP);
}
Expand All @@ -95,8 +93,8 @@ LLVMMetadataRef LLVMDIBuilderCreateLocalVariable(
int AlwaysPreserve, unsigned Flags, unsigned ArgNo) {
DIBuilder *D = unwrap(Dref);
DIVariable V = D->createLocalVariable(
Tag, DIDescriptor(unwrap<MDScope>(Scope)), Name, unwrap<MDFile>(File),
Line, unwrap<MDType>(Ty), AlwaysPreserve, Flags, ArgNo);
Tag, unwrap<MDScope>(Scope), Name, unwrap<MDFile>(File), Line,
unwrap<MDType>(Ty), AlwaysPreserve, Flags, ArgNo);
return wrap(V);
}

Expand Down Expand Up @@ -138,9 +136,9 @@ LLVMMetadataRef LLVMDIBuilderCreateStructType(
LLVMMetadataRef ElementTypes) {
DIBuilder *D = unwrap(Dref);
DICompositeType CT = D->createStructType(
DIDescriptor(unwrap<MDScope>(Scope)), Name,
File ? unwrap<MDFile>(File) : nullptr, Line, SizeInBits, AlignInBits,
Flags, DerivedFrom ? unwrap<MDType>(DerivedFrom) : nullptr,
unwrap<MDScope>(Scope), Name, File ? unwrap<MDFile>(File) : nullptr, Line,
SizeInBits, AlignInBits, Flags,
DerivedFrom ? unwrap<MDType>(DerivedFrom) : nullptr,
ElementTypes ? DIArray(unwrap<MDTuple>(ElementTypes)) : nullptr);
return wrap(CT);
}
Expand All @@ -152,9 +150,8 @@ LLVMMetadataRef LLVMDIBuilderCreateReplaceableCompositeType(
unsigned Flags) {
DIBuilder *D = unwrap(Dref);
DICompositeType CT = D->createReplaceableCompositeType(
Tag, Name, DIDescriptor(unwrap<MDScope>(Scope)),
File ? unwrap<MDFile>(File) : nullptr, Line, RuntimeLang, SizeInBits,
AlignInBits, Flags);
Tag, Name, unwrap<MDScope>(Scope), File ? unwrap<MDFile>(File) : nullptr,
Line, RuntimeLang, SizeInBits, AlignInBits, Flags);
return wrap(CT);
}

Expand All @@ -166,9 +163,8 @@ LLVMDIBuilderCreateMemberType(LLVMDIBuilderRef Dref, LLVMMetadataRef Scope,
unsigned Flags, LLVMMetadataRef Ty) {
DIBuilder *D = unwrap(Dref);
DIDerivedType DT = D->createMemberType(
DIDescriptor(unwrap<MDScope>(Scope)), Name,
File ? unwrap<MDFile>(File) : nullptr, Line, SizeInBits, AlignInBits,
OffsetInBits, Flags, unwrap<MDType>(Ty));
unwrap<MDScope>(Scope), Name, File ? unwrap<MDFile>(File) : nullptr, Line,
SizeInBits, AlignInBits, OffsetInBits, Flags, unwrap<MDType>(Ty));
return wrap(DT);
}

Expand All @@ -191,7 +187,7 @@ LLVMMetadataRef LLVMDIBuilderCreateTypedef(LLVMDIBuilderRef Dref,
DIBuilder *D = unwrap(Dref);
DIDerivedType DT = D->createTypedef(
unwrap<MDType>(Ty), Name, File ? unwrap<MDFile>(File) : nullptr, Line,
Context ? DIDescriptor(unwrap<MDScope>(Context)) : DIDescriptor());
Context ? unwrap<MDScope>(Context) : nullptr);
return wrap(DT);
}

Expand Down
4 changes: 2 additions & 2 deletions examples/Kaleidoscope/Chapter8/toy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ void DebugInfo::emitLocation(ExprAST *AST) {
DebugLoc::get(AST->getLine(), AST->getCol(), Scope));
}

static DICompositeType CreateFunctionType(unsigned NumArgs, DIFile Unit) {
static MDSubroutineType *CreateFunctionType(unsigned NumArgs, DIFile Unit) {
SmallVector<Metadata *, 8> EltTys;
DIType DblTy = KSDbgInfo.getDoubleTy();

Expand Down Expand Up @@ -1226,7 +1226,7 @@ Function *PrototypeAST::Codegen() {
// Create a subprogram DIE for this function.
DIFile Unit = DBuilder->createFile(KSDbgInfo.TheCU->getFilename(),
KSDbgInfo.TheCU->getDirectory());
DIDescriptor FContext = Unit;
MDScope *FContext = Unit;
unsigned LineNo = Line;
unsigned ScopeLine = Line;
DISubprogram SP = DBuilder->createFunction(
Expand Down
Loading

0 comments on commit afc6740

Please sign in to comment.