r202185 - Debug info: Generate debug info for variadic functions.
Adrian Prantl
aprantl at apple.com
Tue Feb 25 11:38:11 PST 2014
Author: adrian
Date: Tue Feb 25 13:38:11 2014
New Revision: 202185
URL: http://llvm.org/viewvc/llvm-project?rev=202185&view=rev
Log:
Debug info: Generate debug info for variadic functions.
Paired commit with LLVM.
rdar://problem/13690847
Added:
cfe/trunk/test/CodeGenCXX/debug-info-varargs.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=202185&r1=202184&r2=202185&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Feb 25 13:38:11 2014
@@ -765,6 +765,8 @@ llvm::DIType CGDebugInfo::CreateType(con
else if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(Ty)) {
for (unsigned i = 0, e = FPT->getNumParams(); i != e; ++i)
EltTys.push_back(getOrCreateType(FPT->getParamType(i), Unit));
+ if (FPT->isVariadic())
+ EltTys.push_back(DBuilder.createUnspecifiedParameter());
}
llvm::DIArray EltTypeArray = DBuilder.getOrCreateArray(EltTys);
@@ -2437,6 +2439,20 @@ llvm::DICompositeType CGDebugInfo::getOr
llvm::DIArray EltTypeArray = DBuilder.getOrCreateArray(Elts);
return DBuilder.createSubroutineType(F, EltTypeArray);
}
+
+ // Variadic function.
+ if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
+ if (FD->isVariadic()) {
+ SmallVector<llvm::Value *, 16> EltTys;
+ EltTys.push_back(getOrCreateType(FD->getReturnType(), F));
+ if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(FnType))
+ for (unsigned i = 0, e = FPT->getNumParams(); i != e; ++i)
+ EltTys.push_back(getOrCreateType(FPT->getParamType(i), F));
+ EltTys.push_back(DBuilder.createUnspecifiedParameter());
+ llvm::DIArray EltTypeArray = DBuilder.getOrCreateArray(EltTys);
+ return DBuilder.createSubroutineType(F, EltTypeArray);
+ }
+
return llvm::DICompositeType(getOrCreateType(FnType, F));
}
Added: cfe/trunk/test/CodeGenCXX/debug-info-varargs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-varargs.cpp?rev=202185&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info-varargs.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/debug-info-varargs.cpp Tue Feb 25 13:38:11 2014
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -emit-llvm -g %s -o - | FileCheck %s
+
+struct A
+{
+ // CHECK-DAG: ", i32 [[@LINE+1]], metadata ![[ATY:[0-9]+]]{{.*}}[ DW_TAG_subprogram ]{{.*}}[a]
+ void a(int c, ...) {}
+ // CHECK-DAG: ![[ATY]] ={{.*}} metadata ![[AARGS:[0-9]+]], i32 0, null, null, null} ; [ DW_TAG_subroutine_type ]
+ // CHECK-DAG: ![[AARGS]] = {{.*}} metadata ![[UNSPEC:[0-9]+]]}
+ // CHECK-DAG: ![[UNSPEC]] = metadata !{i32 786456}
+};
+
+ // CHECK-DAG: ", i32 [[@LINE+1]], metadata ![[BTY:[0-9]+]]{{.*}}[ DW_TAG_subprogram ]{{.*}}[b]
+void b(int c, ...) {
+ // CHECK-DAG: ![[BTY]] ={{.*}} metadata ![[BARGS:[0-9]+]], i32 0, null, null, null} ; [ DW_TAG_subroutine_type ]
+ // CHECK-DAG: ![[BARGS]] = {{.*}} metadata ![[UNSPEC:[0-9]+]]}
+
+ A a;
+
+ // CHECK-DAG: metadata ![[PST:[0-9]+]], i32 0, i32 0} ; [ DW_TAG_auto_variable ] [fptr] [line [[@LINE+1]]]
+ void (*fptr)(int, ...) = b;
+ // CHECK-DAG: ![[PST]] ={{.*}} metadata ![[ST:[0-9]+]]} ; [ DW_TAG_pointer_type ]
+ // CHECK-DAG: ![[ST]] ={{.*}} metadata ![[ARGS:[0-9]+]], i32 0, null, null, null} ; [ DW_TAG_subroutine_type ]
+ // CHECK-DAG: ![[ARGS]] = {{.*}} metadata ![[UNSPEC]]}
+}
More information about the cfe-commits
mailing list