diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2015-10-20 04:24:12 +0000 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2015-10-20 04:24:12 +0000 |
commit | 2bf9b4c0d18dd03d967f3fd5bb6b5d156b1ed3a7 (patch) | |
tree | f078924c5b5ba712ea756475a952a58acaac2dc7 /clang/lib/CodeGen | |
parent | 8f18917a9050e87c8f6ff84493f3eff8467378d2 (diff) | |
download | bcm5719-llvm-2bf9b4c0d18dd03d967f3fd5bb6b5d156b1ed3a7.tar.gz bcm5719-llvm-2bf9b4c0d18dd03d967f3fd5bb6b5d156b1ed3a7.zip |
[DEBUG INFO] Emit debug info for type used in explicit cast only.
Currently debug info for types used in explicit cast only is not emitted. It happened after a patch for better alignment handling. This patch fixes this bug.
Differential Revision: http://reviews.llvm.org/D13582
llvm-svn: 250795
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGExpr.cpp | 16 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGExprAgg.cpp | 2 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGExprCXX.cpp | 1 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGExprComplex.cpp | 2 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGExprConstant.cpp | 2 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGExprScalar.cpp | 7 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.h | 5 |
7 files changed, 26 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index ece83371db9..f61f63470c7 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -780,6 +780,16 @@ EmitComplexPrePostIncDec(const UnaryOperator *E, LValue LV, return isPre ? IncVal : InVal; } +void CodeGenModule::EmitExplicitCastExprType(const ExplicitCastExpr *E, + CodeGenFunction *CGF) { + // Bind VLAs in the cast type. + if (CGF && E->getType()->isVariablyModifiedType()) + CGF->EmitVariablyModifiedType(E->getType()); + + if (CGDebugInfo *DI = getModuleDebugInfo()) + DI->EmitExplicitCastType(E->getType()); +} + //===----------------------------------------------------------------------===// // LValue Expression Emission //===----------------------------------------------------------------------===// @@ -795,9 +805,8 @@ Address CodeGenFunction::EmitPointerWithAlignment(const Expr *E, // Casts: if (const CastExpr *CE = dyn_cast<CastExpr>(E)) { - // Bind VLAs in the cast type. - if (E->getType()->isVariablyModifiedType()) - EmitVariablyModifiedType(E->getType()); + if (const auto *ECE = dyn_cast<ExplicitCastExpr>(CE)) + CGM.EmitExplicitCastExprType(ECE, this); switch (CE->getCastKind()) { // Non-converting casts (but not C's implicit conversion from void*). @@ -3427,6 +3436,7 @@ LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) { // This must be a reinterpret_cast (or c-style equivalent). const auto *CE = cast<ExplicitCastExpr>(E); + CGM.EmitExplicitCastExprType(CE, this); LValue LV = EmitLValue(E->getSubExpr()); Address V = Builder.CreateBitCast(LV.getAddress(), ConvertType(CE->getTypeAsWritten())); diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp index a229d94ad9e..906ffa4fb54 100644 --- a/clang/lib/CodeGen/CGExprAgg.cpp +++ b/clang/lib/CodeGen/CGExprAgg.cpp @@ -571,6 +571,8 @@ static Expr *findPeephole(Expr *op, CastKind kind) { } void AggExprEmitter::VisitCastExpr(CastExpr *E) { + if (const auto *ECE = dyn_cast<ExplicitCastExpr>(E)) + CGF.CGM.EmitExplicitCastExprType(ECE, &CGF); switch (E->getCastKind()) { case CK_Dynamic: { // FIXME: Can this actually happen? We have no test coverage for it. diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp index 599dc9a8dbc..ae4e02d53f0 100644 --- a/clang/lib/CodeGen/CGExprCXX.cpp +++ b/clang/lib/CodeGen/CGExprCXX.cpp @@ -1806,6 +1806,7 @@ static llvm::Value *EmitDynamicCastToNull(CodeGenFunction &CGF, llvm::Value *CodeGenFunction::EmitDynamicCast(Address ThisAddr, const CXXDynamicCastExpr *DCE) { + CGM.EmitExplicitCastExprType(DCE, this); QualType DestTy = DCE->getTypeAsWritten(); if (DCE->isAlwaysNull()) diff --git a/clang/lib/CodeGen/CGExprComplex.cpp b/clang/lib/CodeGen/CGExprComplex.cpp index 2f9d0cab249..4b45bce098a 100644 --- a/clang/lib/CodeGen/CGExprComplex.cpp +++ b/clang/lib/CodeGen/CGExprComplex.cpp @@ -154,6 +154,8 @@ public: return EmitCast(E->getCastKind(), E->getSubExpr(), E->getType()); } ComplexPairTy VisitCastExpr(CastExpr *E) { + if (const auto *ECE = dyn_cast<ExplicitCastExpr>(E)) + CGF.CGM.EmitExplicitCastExprType(ECE, &CGF); return EmitCast(E->getCastKind(), E->getSubExpr(), E->getType()); } ComplexPairTy VisitCallExpr(const CallExpr *E); diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp index 1f4b1dcbe02..bbd04dd7514 100644 --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/lib/CodeGen/CGExprConstant.cpp @@ -636,6 +636,8 @@ public: } llvm::Constant *VisitCastExpr(CastExpr* E) { + if (const auto *ECE = dyn_cast<ExplicitCastExpr>(E)) + CGM.EmitExplicitCastExprType(ECE, CGF); Expr *subExpr = E->getSubExpr(); llvm::Constant *C = CGM.EmitConstantExpr(subExpr, subExpr->getType(), CGF); if (!C) return nullptr; diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 6a40e4ed86f..602ce4bf5ef 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -314,12 +314,7 @@ public: return EmitNullValue(E->getType()); } Value *VisitExplicitCastExpr(ExplicitCastExpr *E) { - if (E->getType()->isVariablyModifiedType()) - CGF.EmitVariablyModifiedType(E->getType()); - - if (CGDebugInfo *DI = CGF.getDebugInfo()) - DI->EmitExplicitCastType(E->getType()); - + CGF.CGM.EmitExplicitCastExprType(E, &CGF); return VisitCastExpr(E); } Value *VisitCastExpr(CastExpr *E); diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h index c188789a502..eac5c8ee8d1 100644 --- a/clang/lib/CodeGen/CodeGenModule.h +++ b/clang/lib/CodeGen/CodeGenModule.h @@ -921,6 +921,11 @@ public: QualType DestType, CodeGenFunction *CGF = nullptr); + /// \brief Emit type info if type of an expression is a variably modified + /// type. Also emit proper debug info for cast types. + void EmitExplicitCastExprType(const ExplicitCastExpr *E, + CodeGenFunction *CGF = nullptr); + /// Return the result of value-initializing the given type, i.e. a null /// expression of the given type. This is usually, but not always, an LLVM /// null constant. |