Index: include/clang/AST/Expr.h =================================================================== --- include/clang/AST/Expr.h +++ include/clang/AST/Expr.h @@ -850,11 +850,13 @@ /// the LHSs of comma expressions and adjustments needed along the path. const Expr *skipRValueSubobjectAdjustments( SmallVectorImpl &CommaLHS, - SmallVectorImpl &Adjustments) const; + SmallVectorImpl &Adjustments, + SmallVectorImpl &SkippedCasts) const; const Expr *skipRValueSubobjectAdjustments() const { SmallVector CommaLHSs; SmallVector Adjustments; - return skipRValueSubobjectAdjustments(CommaLHSs, Adjustments); + SmallVector SkippedCasts; + return skipRValueSubobjectAdjustments(CommaLHSs, Adjustments, SkippedCasts); } static bool classof(const Stmt *T) { Index: lib/AST/Expr.cpp =================================================================== --- lib/AST/Expr.cpp +++ lib/AST/Expr.cpp @@ -76,7 +76,8 @@ const Expr *Expr::skipRValueSubobjectAdjustments( SmallVectorImpl &CommaLHSs, - SmallVectorImpl &Adjustments) const { + SmallVectorImpl &Adjustments, + SmallVectorImpl &SkippedCasts) const { const Expr *E = this; while (true) { E = E->IgnoreParens(); @@ -93,6 +94,7 @@ } if (CE->getCastKind() == CK_NoOp) { + SkippedCasts.emplace_back(CE); E = CE->getSubExpr(); continue; } Index: lib/AST/ExprConstant.cpp =================================================================== --- lib/AST/ExprConstant.cpp +++ lib/AST/ExprConstant.cpp @@ -88,9 +88,10 @@ dyn_cast(Base)) { SmallVector CommaLHSs; SmallVector Adjustments; + SmallVector SkippedCasts; const Expr *Temp = MTE->GetTemporaryExpr(); - const Expr *Inner = Temp->skipRValueSubobjectAdjustments(CommaLHSs, - Adjustments); + const Expr *Inner = Temp->skipRValueSubobjectAdjustments( + CommaLHSs, Adjustments, SkippedCasts); // Keep any cv-qualifiers from the reference if we generated a temporary // for it directly. Otherwise use the type after adjustment. if (!Adjustments.empty()) @@ -5358,8 +5359,9 @@ // Walk through the expression to find the materialized temporary itself. SmallVector CommaLHSs; SmallVector Adjustments; - const Expr *Inner = E->GetTemporaryExpr()-> - skipRValueSubobjectAdjustments(CommaLHSs, Adjustments); + SmallVector SkippedCasts; + const Expr *Inner = E->GetTemporaryExpr()->skipRValueSubobjectAdjustments( + CommaLHSs, Adjustments, SkippedCasts); // If we passed any comma operators, evaluate their LHSs. for (unsigned I = 0, N = CommaLHSs.size(); I != N; ++I) Index: lib/Analysis/CFG.cpp =================================================================== --- lib/Analysis/CFG.cpp +++ lib/Analysis/CFG.cpp @@ -1539,8 +1539,9 @@ // Skip sub-object accesses into rvalues. SmallVector CommaLHSs; SmallVector Adjustments; - const Expr *SkippedInit = - Init->skipRValueSubobjectAdjustments(CommaLHSs, Adjustments); + SmallVector SkippedCasts; + const Expr *SkippedInit = Init->skipRValueSubobjectAdjustments( + CommaLHSs, Adjustments, SkippedCasts); if (SkippedInit != Init) { Init = SkippedInit; continue; @@ -4384,11 +4385,12 @@ BindToTemporary = (MTE->getStorageDuration() != SD_FullExpression); SmallVector CommaLHSs; SmallVector Adjustments; + SmallVector SkippedCasts; // Find the expression whose lifetime needs to be extended. - E = const_cast( - cast(E) - ->GetTemporaryExpr() - ->skipRValueSubobjectAdjustments(CommaLHSs, Adjustments)); + E = const_cast(cast(E) + ->GetTemporaryExpr() + ->skipRValueSubobjectAdjustments( + CommaLHSs, Adjustments, SkippedCasts)); // Visit the skipped comma operator left-hand sides for other temporaries. for (const Expr *CommaLHS : CommaLHSs) { VisitForTemporaryDtors(const_cast(CommaLHS), Index: lib/CodeGen/CGExpr.cpp =================================================================== --- lib/CodeGen/CGExpr.cpp +++ lib/CodeGen/CGExpr.cpp @@ -467,7 +467,8 @@ SmallVector CommaLHSs; SmallVector Adjustments; - E = E->skipRValueSubobjectAdjustments(CommaLHSs, Adjustments); + SmallVector SkippedCasts; + E = E->skipRValueSubobjectAdjustments(CommaLHSs, Adjustments, SkippedCasts); for (const auto &Ignored : CommaLHSs) EmitIgnoredExpr(Ignored); Index: lib/CodeGen/CGExprConstant.cpp =================================================================== --- lib/CodeGen/CGExprConstant.cpp +++ lib/CodeGen/CGExprConstant.cpp @@ -1829,14 +1829,14 @@ return CGM.GetAddrOfUuidDescriptor(E); } -ConstantLValue -ConstantLValueEmitter::VisitMaterializeTemporaryExpr( - const MaterializeTemporaryExpr *E) { +ConstantLValue ConstantLValueEmitter::VisitMaterializeTemporaryExpr( + const MaterializeTemporaryExpr *E) { assert(E->getStorageDuration() == SD_Static); SmallVector CommaLHSs; SmallVector Adjustments; - const Expr *Inner = E->GetTemporaryExpr() - ->skipRValueSubobjectAdjustments(CommaLHSs, Adjustments); + SmallVector SkippedCasts; + const Expr *Inner = E->GetTemporaryExpr()->skipRValueSubobjectAdjustments( + CommaLHSs, Adjustments, SkippedCasts); return CGM.GetAddrOfGlobalTemporary(E, Inner); } Index: lib/Sema/JumpDiagnostics.cpp =================================================================== --- lib/Sema/JumpDiagnostics.cpp +++ lib/Sema/JumpDiagnostics.cpp @@ -531,9 +531,10 @@ if (MTE->getStorageDuration() == SD_Automatic) { SmallVector CommaLHS; SmallVector Adjustments; + SmallVector SkippedCasts; const Expr *ExtendedObject = MTE->GetTemporaryExpr()->skipRValueSubobjectAdjustments( - CommaLHS, Adjustments); + CommaLHS, Adjustments, SkippedCasts); if (ExtendedObject->getType().isDestructedType()) { Scopes.push_back(GotoScope(ParentScope, 0, diag::note_exits_temporary_dtor, Index: lib/StaticAnalyzer/Core/ExprEngine.cpp =================================================================== --- lib/StaticAnalyzer/Core/ExprEngine.cpp +++ lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -358,9 +358,10 @@ SmallVector CommaLHSs; SmallVector Adjustments; + SmallVector SkippedCasts; const Expr *Init = InitWithAdjustments->skipRValueSubobjectAdjustments( - CommaLHSs, Adjustments); + CommaLHSs, Adjustments, SkippedCasts); // Take the region for Init, i.e. for the whole object. If we do not remember // the region in which the object originally was constructed, come up with