diff options
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.h')
-rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.h | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h index 2f0c3f51d41..1d61d14950e 100644 --- a/clang/lib/CodeGen/CGDebugInfo.h +++ b/clang/lib/CodeGen/CGDebugInfo.h @@ -447,22 +447,23 @@ private: /// location or preferred location of the specified Expr. class ApplyDebugLocation { private: - void init(SourceLocation TemporaryLocation, bool MarkAsPrologue = false); + void init(SourceLocation TemporaryLocation, bool DefaultToEmpty = false); + ApplyDebugLocation(CodeGenFunction &CGF, bool DefaultToEmpty, + SourceLocation TemporaryLocation); -protected: llvm::DebugLoc OriginalLocation; CodeGenFunction &CGF; - public: - enum { Artificial = false, MarkAsPrologue = true, NoLocation = true }; /// \brief Set the location to the (valid) TemporaryLocation. ApplyDebugLocation(CodeGenFunction &CGF, SourceLocation TemporaryLocation); - /// \brief Apply TemporaryLocation if it is valid, or apply a default - /// location: If MarkAsPrologue is true, the IRBuilder will be set to not - /// attach debug locations, thus marking the instructions as - /// prologue. Otherwise this switches to an artificial debug location that has - /// a valid scope, but no line information. + ApplyDebugLocation(CodeGenFunction &CGF, const Expr *E); + ApplyDebugLocation(CodeGenFunction &CGF, llvm::DebugLoc Loc); + + ~ApplyDebugLocation(); + + /// \brief Apply TemporaryLocation if it is valid. Otherwise switch to an + /// artificial debug location that has a valid scope, but no line information. /// /// Artificial locations are useful when emitting compiler-generated helper /// functions that have no source location associated with them. The DWARF @@ -470,11 +471,32 @@ public: /// indicate code that can not be attributed to any source location. Note that /// passing an empty SourceLocation to CGDebugInfo::setLocation() will result /// in the last valid location being reused. - ApplyDebugLocation(CodeGenFunction &CGF, bool MarkAsPrologue, - SourceLocation TemporaryLocation = SourceLocation()); - ApplyDebugLocation(CodeGenFunction &CGF, const Expr *E); - ApplyDebugLocation(CodeGenFunction &CGF, llvm::DebugLoc Loc); - ~ApplyDebugLocation(); + static ApplyDebugLocation CreateArtificial(CodeGenFunction &CGF) { + return ApplyDebugLocation(CGF, false, SourceLocation()); + } + /// \brief Apply TemporaryLocation if it is valid. Otherwise switch to an + /// artificial debug location that has a valid scope, but no line information. + static ApplyDebugLocation CreateDefaultArtificial(CodeGenFunction &CGF, + SourceLocation TemporaryLocation) { + return ApplyDebugLocation(CGF, false, TemporaryLocation); + } + + /// \brief Set the IRBuilder to not attach debug locations. Note that passing + /// an empty SourceLocation to CGDebugInfo::setLocation() will result in the + /// last valid location being reused. Note that all instructions that do not + /// have a location at the beginning of a function are counted towards to + /// funciton prologue. + static ApplyDebugLocation CreateEmpty(CodeGenFunction &CGF) { + return ApplyDebugLocation(CGF, true, SourceLocation()); + } + + /// \brief Apply TemporaryLocation if it is valid. Otherwise set the IRBuilder + /// to not attach debug locations. + static ApplyDebugLocation CreateDefaultEmpty(CodeGenFunction &CGF, + SourceLocation TemporaryLocation) { + return ApplyDebugLocation(CGF, true, TemporaryLocation); + } + }; |