summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp9
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.h4
-rw-r--r--clang/lib/CodeGen/CGExpr.cpp4
-rw-r--r--clang/lib/CodeGen/CGExprAgg.cpp2
-rw-r--r--clang/lib/CodeGen/CGExprCXX.cpp2
-rw-r--r--clang/lib/CodeGen/CGExprComplex.cpp2
-rw-r--r--clang/lib/CodeGen/CGExprScalar.cpp2
-rw-r--r--clang/test/CodeGenCXX/debug-info-line.cpp20
8 files changed, 31 insertions, 14 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 17a8f063c5a..38a1184bd72 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -65,6 +65,10 @@ ArtificialLocation::ArtificialLocation(CodeGenFunction &CGF)
ApplyDebugLocation::ApplyDebugLocation(CodeGenFunction &CGF,
SourceLocation TemporaryLocation)
: CGF(CGF) {
+ init(TemporaryLocation);
+}
+
+void ApplyDebugLocation::init(SourceLocation TemporaryLocation) {
if (auto *DI = CGF.getDebugInfo()) {
OriginalLocation = CGF.Builder.getCurrentDebugLocation();
if (TemporaryLocation.isInvalid())
@@ -74,6 +78,11 @@ ApplyDebugLocation::ApplyDebugLocation(CodeGenFunction &CGF,
}
}
+ApplyDebugLocation::ApplyDebugLocation(CodeGenFunction &CGF, const Expr *E)
+ : CGF(CGF) {
+ init(E->getExprLoc());
+}
+
ApplyDebugLocation::ApplyDebugLocation(CodeGenFunction &CGF, llvm::DebugLoc Loc)
: CGF(CGF) {
if (CGF.getDebugInfo()) {
diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h
index bcce9000183..8e00c1b0482 100644
--- a/clang/lib/CodeGen/CGDebugInfo.h
+++ b/clang/lib/CodeGen/CGDebugInfo.h
@@ -444,6 +444,9 @@ private:
};
class ApplyDebugLocation {
+private:
+ void init(SourceLocation TemporaryLocation);
+
protected:
llvm::DebugLoc OriginalLocation;
CodeGenFunction &CGF;
@@ -451,6 +454,7 @@ protected:
public:
ApplyDebugLocation(CodeGenFunction &CGF,
SourceLocation TemporaryLocation = SourceLocation());
+ ApplyDebugLocation(CodeGenFunction &CGF, const Expr *E);
ApplyDebugLocation(CodeGenFunction &CGF, llvm::DebugLoc Loc);
~ApplyDebugLocation();
};
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 6fdd1104803..3a45d77e2c2 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -807,7 +807,7 @@ LValue CodeGenFunction::EmitCheckedLValue(const Expr *E, TypeCheckKind TCK) {
/// length type, this is not possible.
///
LValue CodeGenFunction::EmitLValue(const Expr *E) {
- ApplyDebugLocation DL(*this, E->getLocStart());
+ ApplyDebugLocation DL(*this, E);
switch (E->getStmtClass()) {
default: return EmitUnsupportedLValue(E, "l-value expression");
@@ -3060,7 +3060,7 @@ RValue CodeGenFunction::EmitRValueForField(LValue LV,
RValue CodeGenFunction::EmitCallExpr(const CallExpr *E,
ReturnValueSlot ReturnValue) {
- ApplyDebugLocation DL(*this, E->getLocStart());
+ ApplyDebugLocation DL(*this, E);
// Builtins never have block type.
if (E->getCallee()->getType()->isBlockPointerType())
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index 4cba4781afc..80b16dd5ba3 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -99,7 +99,7 @@ public:
//===--------------------------------------------------------------------===//
void Visit(Expr *E) {
- ApplyDebugLocation DL(CGF, E->getLocStart());
+ ApplyDebugLocation DL(CGF, E);
StmtVisitor<AggExprEmitter>::Visit(E);
}
diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp
index 6d63b3ae9cf..cead8a429df 100644
--- a/clang/lib/CodeGen/CGExprCXX.cpp
+++ b/clang/lib/CodeGen/CGExprCXX.cpp
@@ -1016,7 +1016,7 @@ static void EmitNewInitializer(CodeGenFunction &CGF, const CXXNewExpr *E,
llvm::Value *NewPtr,
llvm::Value *NumElements,
llvm::Value *AllocSizeWithoutCookie) {
- ApplyDebugLocation DL(CGF, E->getStartLoc());
+ ApplyDebugLocation DL(CGF, E);
if (E->isArray())
CGF.EmitNewArrayInitializer(E, ElementType, NewPtr, NumElements,
AllocSizeWithoutCookie);
diff --git a/clang/lib/CodeGen/CGExprComplex.cpp b/clang/lib/CodeGen/CGExprComplex.cpp
index 2cbd42b7ee5..b6adbf64f82 100644
--- a/clang/lib/CodeGen/CGExprComplex.cpp
+++ b/clang/lib/CodeGen/CGExprComplex.cpp
@@ -95,7 +95,7 @@ public:
//===--------------------------------------------------------------------===//
ComplexPairTy Visit(Expr *E) {
- ApplyDebugLocation DL(CGF, E->getLocStart());
+ ApplyDebugLocation DL(CGF, E);
return StmtVisitor<ComplexExprEmitter, ComplexPairTy>::Visit(E);
}
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp
index a9cbf05da10..2e2821b6230 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -196,7 +196,7 @@ public:
//===--------------------------------------------------------------------===//
Value *Visit(Expr *E) {
- ApplyDebugLocation DL(CGF, E->getLocStart());
+ ApplyDebugLocation DL(CGF, E);
return StmtVisitor<ScalarExprEmitter, Value*>::Visit(E);
}
diff --git a/clang/test/CodeGenCXX/debug-info-line.cpp b/clang/test/CodeGenCXX/debug-info-line.cpp
index 87ea576ccab..340222eba5b 100644
--- a/clang/test/CodeGenCXX/debug-info-line.cpp
+++ b/clang/test/CodeGenCXX/debug-info-line.cpp
@@ -10,11 +10,11 @@ extern "C" __complex float *complex_sink();
// CHECK-LABEL: define
void f1() {
-#line 100
- * // The store for the assignment should be attributed to the start of the
- // assignment expression here, regardless of the location of subexpressions.
- sink() = src();
+ *sink()
// CHECK: store {{.*}}, !dbg [[DBG_F1:!.*]]
+#line 100
+ = //
+ src();
}
struct foo {
@@ -38,16 +38,20 @@ foo::foo()
// CHECK-LABEL: define {{.*}}f2{{.*}}
void f2() {
+ // CHECK: store float {{.*}} !dbg [[DBG_F2:!.*]]
+ *complex_sink()
#line 300
- * // CHECK: store float {{.*}} !dbg [[DBG_F2:!.*]]
- complex_sink() = complex_src();
+ = //
+ complex_src();
}
// CHECK-LABEL: define
void f3() {
+ // CHECK: store float {{.*}} !dbg [[DBG_F3:!.*]]
+ *complex_sink()
#line 400
- * // CHECK: store float {{.*}} !dbg [[DBG_F3:!.*]]
- complex_sink() += complex_src();
+ += //
+ complex_src();
}
// CHECK-LABEL: define
OpenPOWER on IntegriCloud