summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2013-05-22 23:22:18 +0000
committerDavid Blaikie <dblaikie@gmail.com>2013-05-22 23:22:18 +0000
commit5174c84add18b6827ab7ab7771bd5a715f320bcc (patch)
treef990dc29fbe7409a3ef91fe389696dc1bf317972 /llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
parentabdb1d69ab9834bae2f049b78ad706b707e5e652 (diff)
downloadbcm5719-llvm-5174c84add18b6827ab7ab7771bd5a715f320bcc.tar.gz
bcm5719-llvm-5174c84add18b6827ab7ab7771bd5a715f320bcc.zip
Solidify the assumption that a DW_TAG_subprogram's type is a DW_TAG_subroutine_type
There were bits & pieces of code lying around that may've given the impression that debug info metadata supported the possibility that a subprogram's type could be specified by a non-subroutine type describing the return type of a void function. This support was incomplete & unnecessary. Asserts & API have been changed to make the desired usage more clear. llvm-svn: 182532
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp31
1 files changed, 12 insertions, 19 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index 7f0c33bb05c..90ca034c976 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -1208,13 +1208,11 @@ DIE *CompileUnit::getOrCreateSubprogramDIE(DISubprogram SP) {
// Add Return Type.
DICompositeType SPTy = SP.getType();
- DIArray Args = SPTy.getTypeArray();
- unsigned SPTag = SPTy.getTag();
+ assert(SPTy.getTag() == dwarf::DW_TAG_subroutine_type &&
+ "the type of a subprogram should be a subroutine");
- if (Args.getNumElements() == 0 || SPTag != dwarf::DW_TAG_subroutine_type)
- addType(SPDie, SPTy);
- else
- addType(SPDie, DIType(Args.getElement(0)));
+ DIArray Args = SPTy.getTypeArray();
+ addType(SPDie, DIType(Args.getElement(0)));
unsigned VK = SP.getVirtuality();
if (VK) {
@@ -1232,19 +1230,14 @@ DIE *CompileUnit::getOrCreateSubprogramDIE(DISubprogram SP) {
// Add arguments. Do not add arguments for subprogram definition. They will
// be handled while processing variables.
- DICompositeType SPTy = SP.getType();
- DIArray Args = SPTy.getTypeArray();
- unsigned SPTag = SPTy.getTag();
-
- if (SPTag == dwarf::DW_TAG_subroutine_type)
- for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
- DIE *Arg = new DIE(dwarf::DW_TAG_formal_parameter);
- DIType ATy = DIType(Args.getElement(i));
- addType(Arg, ATy);
- if (ATy.isArtificial())
- addFlag(Arg, dwarf::DW_AT_artificial);
- SPDie->addChild(Arg);
- }
+ for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
+ DIE *Arg = new DIE(dwarf::DW_TAG_formal_parameter);
+ DIType ATy = DIType(Args.getElement(i));
+ addType(Arg, ATy);
+ if (ATy.isArtificial())
+ addFlag(Arg, dwarf::DW_AT_artificial);
+ SPDie->addChild(Arg);
+ }
}
if (SP.isArtificial())
OpenPOWER on IntegriCloud