ArrayRef<VarDecl *> ArrayIndexes;
if (MemberInit->getNumArrayIndices())
ArrayIndexes = MemberInit->getArrayIndexes();
- CGF.EmitInitializerForField(Field, LHS, MemberInit->getInit(), ArrayIndexes);
+ CGF.EmitInitializerForField(Field, LHS, MemberInit->getInit(), ArrayIndexes,
+ MemberInit->getMemberLocation());
}
-void CodeGenFunction::EmitInitializerForField(FieldDecl *Field,
- LValue LHS, Expr *Init,
- ArrayRef<VarDecl *> ArrayIndexes) {
+void CodeGenFunction::EmitInitializerForField(FieldDecl *Field, LValue LHS,
+ Expr *Init,
+ ArrayRef<VarDecl *> ArrayIndexes,
+ SourceLocation DbgLoc) {
QualType FieldType = Field->getType();
switch (getEvaluationKind(FieldType)) {
case TEK_Scalar:
if (LHS.isSimple()) {
- EmitExprAsInit(Init, Field, LHS, false);
+ EmitExprAsInit(Init, Field, LHS, false, DbgLoc);
} else {
RValue RHS = RValue::get(EmitScalarExpr(Init));
EmitStoreThroughLValue(RHS, LHS);
lvalue.setAddress(CGF.BuildBlockByrefAddress(lvalue.getAddress(), var));
}
-void CodeGenFunction::EmitScalarInit(const Expr *init,
- const ValueDecl *D,
- LValue lvalue,
- bool capturedByInit) {
+void CodeGenFunction::EmitScalarInit(const Expr *init, const ValueDecl *D,
+ LValue lvalue, bool capturedByInit,
+ SourceLocation DbgLoc) {
Qualifiers::ObjCLifetime lifetime = lvalue.getObjCLifetime();
if (!lifetime) {
llvm::Value *value = EmitScalarExpr(init);
if (capturedByInit)
drillIntoBlockVariable(*this, lvalue, cast<VarDecl>(D));
- EmitStoreThroughLValue(RValue::get(value), lvalue, true);
+ EmitStoreThroughLValue(RValue::get(value), lvalue, true, DbgLoc);
return;
}
/// \param alignment the alignment of the address
/// \param capturedByInit true if the variable is a __block variable
/// whose address is potentially changed by the initializer
-void CodeGenFunction::EmitExprAsInit(const Expr *init,
- const ValueDecl *D,
- LValue lvalue,
- bool capturedByInit) {
+void CodeGenFunction::EmitExprAsInit(const Expr *init, const ValueDecl *D,
+ LValue lvalue, bool capturedByInit,
+ SourceLocation DbgLoc) {
QualType type = D->getType();
if (type->isReferenceType()) {
RValue rvalue = EmitReferenceBindingToExpr(init);
if (capturedByInit)
drillIntoBlockVariable(*this, lvalue, cast<VarDecl>(D));
- EmitStoreThroughLValue(rvalue, lvalue, true);
+ EmitStoreThroughLValue(rvalue, lvalue, true, DbgLoc);
return;
}
switch (getEvaluationKind(type)) {
case TEK_Scalar:
- EmitScalarInit(init, D, lvalue, capturedByInit);
+ EmitScalarInit(init, D, lvalue, capturedByInit, DbgLoc);
return;
case TEK_Complex: {
ComplexPairTy complex = EmitComplexExpr(init);
/// lvalue, where both are guaranteed to the have the same type, and that type
/// is 'Ty'.
void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst,
- bool isInit) {
+ bool isInit,
+ SourceLocation DbgLoc) {
+ if (auto *DI = getDebugInfo())
+ DI->EmitLocation(Builder, DbgLoc);
+
if (!Dst.isSimple()) {
if (Dst.isVectorElt()) {
// Read/modify/write the vector, inserting the new element.
FunctionArgList &Args);
void EmitInitializerForField(FieldDecl *Field, LValue LHS, Expr *Init,
- ArrayRef<VarDecl *> ArrayIndexes);
+ ArrayRef<VarDecl *> ArrayIndexes,
+ SourceLocation DbgLoc = SourceLocation());
/// InitializeVTablePointer - Initialize the vtable pointer of the given
/// subobject.
/// EmitExprAsInit - Emits the code necessary to initialize a
/// location in memory with the given initializer.
- void EmitExprAsInit(const Expr *init, const ValueDecl *D,
- LValue lvalue, bool capturedByInit);
+ void EmitExprAsInit(const Expr *init, const ValueDecl *D, LValue lvalue,
+ bool capturedByInit,
+ SourceLocation DbgLoc = SourceLocation());
/// hasVolatileMember - returns true if aggregate type has a volatile
/// member.
/// This function can be called with a null (unreachable) insert point.
void EmitVarDecl(const VarDecl &D);
- void EmitScalarInit(const Expr *init, const ValueDecl *D,
- LValue lvalue, bool capturedByInit);
+ void EmitScalarInit(const Expr *init, const ValueDecl *D, LValue lvalue,
+ bool capturedByInit,
+ SourceLocation DbgLoc = SourceLocation());
void EmitScalarInit(llvm::Value *init, LValue lvalue);
typedef void SpecialInitFn(CodeGenFunction &Init, const VarDecl &D,
/// EmitStoreThroughLValue - Store the specified rvalue into the specified
/// lvalue, where both are guaranteed to the have the same type, and that type
/// is 'Ty'.
- void EmitStoreThroughLValue(RValue Src, LValue Dst, bool isInit=false);
+ void EmitStoreThroughLValue(RValue Src, LValue Dst, bool isInit = false,
+ SourceLocation DbgLoc = SourceLocation());
void EmitStoreThroughExtVectorComponentLValue(RValue Src, LValue Dst);
void EmitStoreThroughGlobalRegLValue(RValue Src, LValue Dst);
// RUN: %clang_cc1 -g -std=c++11 -S -emit-llvm %s -o - | FileCheck %s
-int src(); int* sink();
+int &src(); int* sink();
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
- (
- )
- +
- 3
- )
- =
- src
- (
- )
- +
- 42
- ;
- // CHECK: store {{.*}}, !dbg [[DBG1:!.*]]
+ sink() = src();
+ // CHECK: store {{.*}}, !dbg [[DBG_F1:!.*]]
}
-// CHECK: [[DBG1]] = metadata !{i32 100, {{.*}}
+struct foo {
+ int i;
+ int &j;
+ foo();
+};
+
+foo::foo()
+ :
+#line 200
+ i
+ (src()),
+ j
+ (src())
+ // CHECK: store i32 {{.*}} !dbg [[DBG_FOO_VALUE:!.*]]
+ // CHECK: store i32* {{.*}} !dbg [[DBG_FOO_REF:!.*]]
+{
+}
+
+// CHECK: [[DBG_F1]] = metadata !{i32 100,
+// CHECK: [[DBG_FOO_VALUE]] = metadata !{i32 200,
+// CHECK: [[DBG_FOO_REF]] = metadata !{i32 202,