Index: lib/CodeGen/CGDebugInfo.h =================================================================== --- lib/CodeGen/CGDebugInfo.h +++ lib/CodeGen/CGDebugInfo.h @@ -361,7 +361,8 @@ /// Emit metadata to indicate a change in line/column information in /// the source file. If the location is invalid, the previous /// location will be reused. - void EmitLocation(CGBuilderTy &Builder, SourceLocation Loc); + /// \param Covered True if the Loc must have coverage information + void EmitLocation(CGBuilderTy &Builder, SourceLocation Loc, bool Covered = true); /// Emit a call to llvm.dbg.function.start to indicate /// start of a new function. @@ -641,7 +642,7 @@ /// location or preferred location of the specified Expr. class ApplyDebugLocation { private: - void init(SourceLocation TemporaryLocation, bool DefaultToEmpty = false); + void init(SourceLocation TemporaryLocation, bool DefaultToEmpty = false, bool Covered = true); ApplyDebugLocation(CodeGenFunction &CGF, bool DefaultToEmpty, SourceLocation TemporaryLocation); @@ -650,7 +651,7 @@ public: /// Set the location to the (valid) TemporaryLocation. - ApplyDebugLocation(CodeGenFunction &CGF, SourceLocation TemporaryLocation); + ApplyDebugLocation(CodeGenFunction &CGF, SourceLocation TemporaryLocation, bool Covered = true); ApplyDebugLocation(CodeGenFunction &CGF, const Expr *E); ApplyDebugLocation(CodeGenFunction &CGF, llvm::DebugLoc Loc); ApplyDebugLocation(ApplyDebugLocation &&Other) : CGF(Other.CGF) { Index: lib/CodeGen/CGDebugInfo.cpp =================================================================== --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -76,9 +76,10 @@ } ApplyDebugLocation::ApplyDebugLocation(CodeGenFunction &CGF, - SourceLocation TemporaryLocation) + SourceLocation TemporaryLocation, + bool Covered) : CGF(&CGF) { - init(TemporaryLocation); + init(TemporaryLocation, false /* DefaultToEmpty */, Covered); } ApplyDebugLocation::ApplyDebugLocation(CodeGenFunction &CGF, @@ -89,7 +90,8 @@ } void ApplyDebugLocation::init(SourceLocation TemporaryLocation, - bool DefaultToEmpty) { + bool DefaultToEmpty, + bool Covered) { auto *DI = CGF->getDebugInfo(); if (!DI) { CGF = nullptr; @@ -102,7 +104,7 @@ return; if (TemporaryLocation.isValid()) { - DI->EmitLocation(CGF->Builder, TemporaryLocation); + DI->EmitLocation(CGF->Builder, TemporaryLocation, Covered); return; } @@ -3444,7 +3446,7 @@ setInlinedAt(llvm::DebugLoc(CurInlinedAt).getInlinedAt()); } -void CGDebugInfo::EmitLocation(CGBuilderTy &Builder, SourceLocation Loc) { +void CGDebugInfo::EmitLocation(CGBuilderTy &Builder, SourceLocation Loc, bool Covered) { // Update our current location setLocation(Loc); @@ -3453,7 +3455,7 @@ llvm::MDNode *Scope = LexicalBlockStack.back(); Builder.SetCurrentDebugLocation(llvm::DebugLoc::get( - getLineNumber(CurLoc), getColumnNumber(CurLoc), Scope, CurInlinedAt)); + getLineNumber(CurLoc), getColumnNumber(CurLoc), Scope, CurInlinedAt, Covered)); } void CGDebugInfo::CreateLexicalBlock(SourceLocation Loc) { @@ -3500,7 +3502,7 @@ assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!"); // Provide an entry in the line table for the end of the block. - EmitLocation(Builder, Loc); + EmitLocation(Builder, Loc, false /* Covered */); if (DebugKind <= codegenoptions::DebugLineTablesOnly) return; @@ -3516,7 +3518,7 @@ // Pop all regions for this function. while (LexicalBlockStack.size() != RCount) { // Provide an entry in the line table for the end of the block. - EmitLocation(Builder, CurLoc); + EmitLocation(Builder, CurLoc, false /* Covered */); LexicalBlockStack.pop_back(); } FnBeginRegionCount.pop_back(); Index: lib/CodeGen/CodeGenFunction.h =================================================================== --- lib/CodeGen/CodeGenFunction.h +++ lib/CodeGen/CodeGenFunction.h @@ -785,7 +785,7 @@ // If we should perform a cleanup, force them now. Note that // this ends the cleanup scope before rescoping any labels. if (PerformCleanup) { - ApplyDebugLocation DL(CGF, Range.getEnd()); + ApplyDebugLocation DL(CGF, Range.getEnd(), false /* Covered */); ForceCleanup(); } } Index: lib/CodeGen/CodeGenFunction.cpp =================================================================== --- lib/CodeGen/CodeGenFunction.cpp +++ lib/CodeGen/CodeGenFunction.cpp @@ -1174,7 +1174,7 @@ } // Emit a location at the end of the prologue. if (CGDebugInfo *DI = getDebugInfo()) - DI->EmitLocation(Builder, StartLoc); + DI->EmitLocation(Builder, StartLoc, false /* Covered */); // TODO: Do we need to handle this in two places like we do with // target-features/target-cpu?