diff options
author | David Blaikie <dblaikie@gmail.com> | 2015-08-12 23:49:57 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2015-08-12 23:49:57 +0000 |
commit | d7057d9e52dd8fa7d928a7097b0d34b581b74782 (patch) | |
tree | b1265d7b1a05b81d4e1ccc90fe11253b88cc3ec8 /clang/lib/CodeGen | |
parent | 3f3af2cf744e3f87f050551ae9712540bde929b0 (diff) | |
download | bcm5719-llvm-d7057d9e52dd8fa7d928a7097b0d34b581b74782.tar.gz bcm5719-llvm-d7057d9e52dd8fa7d928a7097b0d34b581b74782.zip |
Wdeprecated: ApplyDebugLocation is returned by value yet if it is ever copied (rather than RVO'd) that would be broken, make it movable instead
llvm-svn: 244838
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 55 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.h | 5 |
2 files changed, 36 insertions, 24 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 276b21a82d1..ac31722899a 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -56,54 +56,63 @@ CGDebugInfo::~CGDebugInfo() { ApplyDebugLocation::ApplyDebugLocation(CodeGenFunction &CGF, SourceLocation TemporaryLocation) - : CGF(CGF) { + : CGF(&CGF) { init(TemporaryLocation); } ApplyDebugLocation::ApplyDebugLocation(CodeGenFunction &CGF, bool DefaultToEmpty, SourceLocation TemporaryLocation) - : CGF(CGF) { + : CGF(&CGF) { init(TemporaryLocation, DefaultToEmpty); } void ApplyDebugLocation::init(SourceLocation TemporaryLocation, bool DefaultToEmpty) { - if (auto *DI = CGF.getDebugInfo()) { - OriginalLocation = CGF.Builder.getCurrentDebugLocation(); - if (TemporaryLocation.isInvalid()) { - if (DefaultToEmpty) - CGF.Builder.SetCurrentDebugLocation(llvm::DebugLoc()); - else { - // Construct a location that has a valid scope, but no line info. - assert(!DI->LexicalBlockStack.empty()); - CGF.Builder.SetCurrentDebugLocation( - llvm::DebugLoc::get(0, 0, DI->LexicalBlockStack.back())); - } - } else - DI->EmitLocation(CGF.Builder, TemporaryLocation); + auto *DI = CGF->getDebugInfo(); + if (!DI) { + CGF = nullptr; + return; + } + + OriginalLocation = CGF->Builder.getCurrentDebugLocation(); + if (TemporaryLocation.isValid()) { + DI->EmitLocation(CGF->Builder, TemporaryLocation); + return; } + + if (DefaultToEmpty) { + CGF->Builder.SetCurrentDebugLocation(llvm::DebugLoc()); + return; + } + + // Construct a location that has a valid scope, but no line info. + assert(!DI->LexicalBlockStack.empty()); + CGF->Builder.SetCurrentDebugLocation( + llvm::DebugLoc::get(0, 0, DI->LexicalBlockStack.back())); } ApplyDebugLocation::ApplyDebugLocation(CodeGenFunction &CGF, const Expr *E) - : CGF(CGF) { + : CGF(&CGF) { init(E->getExprLoc()); } ApplyDebugLocation::ApplyDebugLocation(CodeGenFunction &CGF, llvm::DebugLoc Loc) - : CGF(CGF) { - if (CGF.getDebugInfo()) { - OriginalLocation = CGF.Builder.getCurrentDebugLocation(); - if (Loc) - CGF.Builder.SetCurrentDebugLocation(std::move(Loc)); + : CGF(&CGF) { + if (!CGF.getDebugInfo()) { + this->CGF = nullptr; + return; } + OriginalLocation = CGF.Builder.getCurrentDebugLocation(); + if (Loc) + CGF.Builder.SetCurrentDebugLocation(std::move(Loc)); } ApplyDebugLocation::~ApplyDebugLocation() { // Query CGF so the location isn't overwritten when location updates are // temporarily disabled (for C++ default function arguments) - if (CGF.getDebugInfo()) - CGF.Builder.SetCurrentDebugLocation(std::move(OriginalLocation)); + if (CGF) + CGF->Builder.SetCurrentDebugLocation(std::move(OriginalLocation)); } void CGDebugInfo::setLocation(SourceLocation Loc) { diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h index 33204fb3622..9c62f6c9541 100644 --- a/clang/lib/CodeGen/CGDebugInfo.h +++ b/clang/lib/CodeGen/CGDebugInfo.h @@ -502,13 +502,16 @@ private: SourceLocation TemporaryLocation); llvm::DebugLoc OriginalLocation; - CodeGenFunction &CGF; + CodeGenFunction *CGF; public: /// Set the location to the (valid) TemporaryLocation. ApplyDebugLocation(CodeGenFunction &CGF, SourceLocation TemporaryLocation); ApplyDebugLocation(CodeGenFunction &CGF, const Expr *E); ApplyDebugLocation(CodeGenFunction &CGF, llvm::DebugLoc Loc); + ApplyDebugLocation(ApplyDebugLocation &&Other) : CGF(Other.CGF) { + Other.CGF = nullptr; + } ~ApplyDebugLocation(); |