Debug info: (Bugfix) Make sure artificial functions like _GLOBAL__I_a
are not associated with any source lines.
Previously, if the Location of a Decl was empty, EmitFunctionStart would
just keep using CurLoc, which would sometimes be correct (e.g., thunks)
but in other cases would just point to a hilariously random location.
This patch fixes this by completely eliminating all uses of CurLoc from
EmitFunctionStart and rather have clients explicitly pass in a
SourceLocation for the function header and the function body.
rdar://problem/14985269
llvm-svn: 205999
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index 15b08d4..c1cbfde 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -1135,6 +1135,7 @@
// Begin generating the function.
StartFunction(blockDecl, fnType->getReturnType(), fn, fnInfo, args,
+ blockDecl->getLocation(),
blockInfo.getBlockExpr()->getBody()->getLocStart());
// Okay. Undo some of what StartFunction did.
@@ -1306,7 +1307,7 @@
false);
// Create a scope with an artificial location for the body of this function.
ArtificialLocation AL(*this, Builder);
- StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation());
+ StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation(), SourceLocation());
AL.Emit();
llvm::Type *structPtrTy = blockInfo.StructureType->getPointerTo();
@@ -1476,7 +1477,7 @@
false, false);
// Create a scope with an artificial location for the body of this function.
ArtificialLocation AL(*this, Builder);
- StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation());
+ StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation(), SourceLocation());
AL.Emit();
llvm::Type *structPtrTy = blockInfo.StructureType->getPointerTo();
@@ -1765,7 +1766,7 @@
SC_Static,
false, false);
- CGF.StartFunction(FD, R, Fn, FI, args, SourceLocation());
+ CGF.StartFunction(FD, R, Fn, FI, args, SourceLocation(), SourceLocation());
if (byrefInfo.needsCopy()) {
llvm::Type *byrefPtrType = byrefType.getPointerTo(0);
@@ -1834,7 +1835,7 @@
SourceLocation(), II, R, 0,
SC_Static,
false, false);
- CGF.StartFunction(FD, R, Fn, FI, args, SourceLocation());
+ CGF.StartFunction(FD, R, Fn, FI, args, SourceLocation(), SourceLocation());
if (byrefInfo.needsDispose()) {
llvm::Value *V = CGF.GetAddrOfLocalVar(&src);