summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGExprScalar.cpp16
-rw-r--r--clang/lib/CodeGen/CGStmt.cpp18
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h13
3 files changed, 30 insertions, 17 deletions
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp
index 1be7b4230a3..ab5aa28206a 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -358,10 +358,7 @@ public:
Value *VisitExprWithCleanups(ExprWithCleanups *E) {
CGF.enterFullExpression(E);
CodeGenFunction::RunCleanupsScope Scope(CGF);
- auto *V = Visit(E->getSubExpr());
- if (CGDebugInfo *DI = CGF.getDebugInfo())
- DI->EmitLocation(Builder, E->getLocEnd(), false);
- return V;
+ return Visit(E->getSubExpr());
}
Value *VisitCXXNewExpr(const CXXNewExpr *E) {
return CGF.EmitCXXNewExpr(E);
@@ -2942,12 +2939,13 @@ Value *ScalarExprEmitter::VisitBinLAnd(const BinaryOperator *E) {
// Reaquire the RHS block, as there may be subblocks inserted.
RHSBlock = Builder.GetInsertBlock();
- // Emit an unconditional branch from this block to ContBlock. Insert an entry
- // into the phi node for the edge with the value of RHSCond.
- if (CGF.getDebugInfo())
+ // Emit an unconditional branch from this block to ContBlock.
+ {
// There is no need to emit line number for unconditional branch.
- Builder.SetCurrentDebugLocation(llvm::DebugLoc());
- CGF.EmitBlock(ContBlock);
+ SuppressDebugLocation S(Builder);
+ CGF.EmitBlock(ContBlock);
+ }
+ // Insert an entry into the phi node for the edge with the value of RHSCond.
PN->addIncoming(RHSCond, RHSBlock);
// ZExt result to int.
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index cd86eeb1216..b9d74b675a6 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -524,18 +524,20 @@ void CodeGenFunction::EmitIfStmt(const IfStmt &S) {
// Emit the 'else' code if present.
if (const Stmt *Else = S.getElse()) {
- // There is no need to emit line number for unconditional branch.
- if (getDebugInfo())
- Builder.SetCurrentDebugLocation(llvm::DebugLoc());
- EmitBlock(ElseBlock);
+ {
+ // There is no need to emit line number for unconditional branch.
+ SuppressDebugLocation S(Builder);
+ EmitBlock(ElseBlock);
+ }
{
RunCleanupsScope ElseScope(*this);
EmitStmt(Else);
}
- // There is no need to emit line number for unconditional branch.
- if (getDebugInfo())
- Builder.SetCurrentDebugLocation(llvm::DebugLoc());
- EmitBranch(ContBlock);
+ {
+ // There is no need to emit line number for unconditional branch.
+ SuppressDebugLocation S(Builder);
+ EmitBranch(ContBlock);
+ }
}
// Emit the continuation block for code after the if.
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index c04fc3e9e70..a2d92ff18cc 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -93,6 +93,19 @@ enum TypeEvaluationKind {
TEK_Aggregate
};
+class SuppressDebugLocation {
+ llvm::DebugLoc CurLoc;
+ llvm::IRBuilderBase &Builder;
+public:
+ SuppressDebugLocation(llvm::IRBuilderBase &Builder)
+ : CurLoc(Builder.getCurrentDebugLocation()), Builder(Builder) {
+ Builder.SetCurrentDebugLocation(llvm::DebugLoc());
+ }
+ ~SuppressDebugLocation() {
+ Builder.SetCurrentDebugLocation(CurLoc);
+ }
+};
+
/// CodeGenFunction - This class organizes the per-function state that is used
/// while generating LLVM code.
class CodeGenFunction : public CodeGenTypeCache {
OpenPOWER on IntegriCloud