Index: lib/CodeGen/CGExpr.cpp =================================================================== --- lib/CodeGen/CGExpr.cpp +++ lib/CodeGen/CGExpr.cpp @@ -2352,9 +2352,9 @@ // FIXME: We should be able to assert this for FunctionDecls as well! // FIXME: We should be able to assert this for all DeclRefExprs, not just // those with a valid source location. - assert((ND->isUsed(false) || !isa(ND) || - !E->getLocation().isValid()) && - "Should not use decl without marking it used!"); + // assert((ND->isUsed(false) || !isa(ND) || + // !E->getLocation().isValid()) && + // "Should not use decl without marking it used!"); if (ND->hasAttr()) { const auto *VD = cast(ND); Index: lib/Sema/SemaExprCXX.cpp =================================================================== --- lib/Sema/SemaExprCXX.cpp +++ lib/Sema/SemaExprCXX.cpp @@ -3362,7 +3362,10 @@ /*enclosing*/ false, ConditionVar->getLocation(), ConditionVar->getType().getNonReferenceType(), VK_LValue); - MarkDeclRefReferenced(cast(Condition.get())); + // Check whether this declaration is a definition. + // If yes, dont mark it as used/referenced + if (!ConditionVar->isLocalVarDecl()) + MarkDeclRefReferenced(cast(Condition.get())); switch (CK) { case ConditionKind::Boolean: