diff options
author | David Blaikie <dblaikie@gmail.com> | 2014-10-14 16:43:46 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2014-10-14 16:43:46 +0000 |
commit | 8e6c36eb802b2b6268e74027eff70a7bb29716f1 (patch) | |
tree | dc453bae0a1a678f82638c6ce91caea383d0a54f /clang/lib/CodeGen/CodeGenFunction.cpp | |
parent | d7e27eac19ffd36e1376e33de147803413e36886 (diff) | |
download | bcm5719-llvm-8e6c36eb802b2b6268e74027eff70a7bb29716f1.tar.gz bcm5719-llvm-8e6c36eb802b2b6268e74027eff70a7bb29716f1.zip |
DebugInfo: Don't leak location information from one function into the prologue of the next function.
CodeGenFunction objects aren't really designed to be reused for more
than one function, and doing so can leak debug info location information
from one function into the prologue of the next.
Add an assertion in to catch reuses of CodeGenFunction, which
surprisingly only caught the ObjC atomic getter/setter cases. Fix those
and add a test to demonstrate the issue.
The test is a bit slim, because we're just testing for the absence of a
debug location on the prologue instructions, which by itself probably
wouldn't be the end of the world - but the particular debug location
that was ending up there was for the previous function's last
instruction. This produced debug info for another function within this
function, which is something I'm trying to remove all cases of as its a
substantial source of bugs, especially around inlining (see r219215).
llvm-svn: 219690
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 9f359185381..354939a23e2 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -36,7 +36,7 @@ using namespace CodeGen; CodeGenFunction::CodeGenFunction(CodeGenModule &cgm, bool suppressNewContext) : CodeGenTypeCache(cgm), CGM(cgm), Target(cgm.getTarget()), Builder(cgm.getModule().getContext(), llvm::ConstantFolder(), - CGBuilderInserterTy(this)), + CGBuilderInserterTy(this)), CurFn(nullptr), CapturedStmtInfo(nullptr), SanOpts(&CGM.getLangOpts().Sanitize), IsSanitizerScope(false), CurFuncIsThunk(false), AutoreleaseResult(false), SawAsmBlock(false), BlockInfo(nullptr), BlockPointer(nullptr), @@ -565,6 +565,9 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, const FunctionArgList &Args, SourceLocation Loc, SourceLocation StartLoc) { + assert(!CurFn && + "Do not use a CodeGenFunction object for more than one function"); + const Decl *D = GD.getDecl(); DidCallStackSave = false; |