Otherwise we're losing type information for these functions.
return cast<llvm::DISubroutineType>(getOrCreateType(FnType, F));
}
+QualType
+CGDebugInfo::getFunctionType(const FunctionDecl *FD, QualType RetTy,
+ const SmallVectorImpl<const VarDecl *> &Args) {
+ CallingConv CC = CallingConv::CC_C;
+ if (FD)
+ if (const auto *SrcFnTy = FD->getType()->getAs<FunctionType>())
+ CC = SrcFnTy->getCallConv();
+ SmallVector<QualType, 16> ArgTypes;
+ for (const VarDecl *VD : Args)
+ ArgTypes.push_back(VD->getType());
+ return CGM.getContext().getFunctionType(RetTy, ArgTypes,
+ FunctionProtoType::ExtProtoInfo(CC));
+}
+
void CGDebugInfo::emitFunctionStart(GlobalDecl GD, SourceLocation Loc,
SourceLocation ScopeLoc, QualType FnType,
llvm::Function *Fn, bool CurFuncIsThunk) {
/// location will be reused.
void EmitLocation(CGBuilderTy &Builder, SourceLocation Loc);
+ QualType getFunctionType(const FunctionDecl *FD, QualType RetTy,
+ const SmallVectorImpl<const VarDecl *> &Args);
+
/// Emit a call to llvm.dbg.function.start to indicate
/// start of a new function.
/// \param Loc The location of the function header.
// Generate function declaration DISuprogram in order to be used
// in debug info about call sites.
if (CGDebugInfo *DI = getDebugInfo()) {
- if (auto *CalleeDecl = dyn_cast_or_null<FunctionDecl>(TargetDecl))
- DI->EmitFuncDeclForCallSite(CallOrInvoke, QualType(FnType, 0),
+ if (auto *CalleeDecl = dyn_cast_or_null<FunctionDecl>(TargetDecl)) {
+ FunctionArgList Args;
+ QualType ResTy = BuildFunctionArgList(CalleeDecl, Args);
+ DI->EmitFuncDeclForCallSite(CallOrInvoke,
+ DI->getFunctionType(CalleeDecl, ResTy, Args),
CalleeDecl);
+ }
}
return Call;
// Reconstruct the type from the argument list so that implicit parameters,
// such as 'this' and 'vtt', show up in the debug info. Preserve the calling
// convention.
- CallingConv CC = CallingConv::CC_C;
- if (FD)
- if (const auto *SrcFnTy = FD->getType()->getAs<FunctionType>())
- CC = SrcFnTy->getCallConv();
- SmallVector<QualType, 16> ArgTypes;
- for (const VarDecl *VD : Args)
- ArgTypes.push_back(VD->getType());
- QualType FnType = getContext().getFunctionType(
- RetTy, ArgTypes, FunctionProtoType::ExtProtoInfo(CC));
- DI->emitFunctionStart(GD, Loc, StartLoc, FnType, CurFn, CurFuncIsThunk);
+ DI->emitFunctionStart(GD, Loc, StartLoc,
+ DI->getFunctionType(FD, RetTy, Args), CurFn,
+ CurFuncIsThunk);
}
if (ShouldInstrumentFunction()) {
// RUN: | FileCheck %s -check-prefix=NO-DECLS-FOR-EXTERN
// DECLS-FOR-EXTERN-NOT: !DICompileUnit({{.*}}retainedTypes: !{{[0-9]+}}
+// DECLS-FOR-EXTERN: [[INT_TYPE:![0-9]+]] = !DIBasicType(name: "int",
// DECLS-FOR-EXTERN: !DISubprogram(name: "fn1"
+// DECLS-FOR-EXTERN-SAME: type: [[FN1_TYPE:![0-9]+]],
+// DECLS-FOR-EXTERN: [[FN1_TYPE]] = !DISubroutineType(types: [[FN1_TYPES:![0-9]+]])
+// DECLS-FOR-EXTERN: [[FN1_TYPES]] = !{[[X_TYPE:![0-9]+]],
+// DECLS-FOR-EXTERN: [[X_TYPE]] = !DIDerivedType(tag: DW_TAG_typedef, name: "x",
+// DECLS-FOR-EXTERN-SAME: baseType: [[INT_TYPE]])
// DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "memcmp"
// DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "__some_reserved_name"
// NO-DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "memcmp"
// NO-DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "__some_reserved_name"
-extern int fn1(int a, int b);
+typedef int x;
+extern x fn1(int a, int b);
extern int memcmp(const void *s1, const void *s2, unsigned long n);
extern void __some_reserved_name(void);