Changeset View
Changeset View
Standalone View
Standalone View
lib/AST/ExprConstant.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | static QualType getType(APValue::LValueBase B) { | ||||
const Expr *Base = B.get<const Expr*>(); | const Expr *Base = B.get<const Expr*>(); | ||||
// For a materialized temporary, the type of the temporary we materialized | // For a materialized temporary, the type of the temporary we materialized | ||||
// may not be the type of the expression. | // may not be the type of the expression. | ||||
if (const MaterializeTemporaryExpr *MTE = | if (const MaterializeTemporaryExpr *MTE = | ||||
dyn_cast<MaterializeTemporaryExpr>(Base)) { | dyn_cast<MaterializeTemporaryExpr>(Base)) { | ||||
SmallVector<const Expr *, 2> CommaLHSs; | SmallVector<const Expr *, 2> CommaLHSs; | ||||
SmallVector<SubobjectAdjustment, 2> Adjustments; | SmallVector<SubobjectAdjustment, 2> Adjustments; | ||||
SmallVector<const CastExpr *, 2> SkippedCasts; | |||||
const Expr *Temp = MTE->GetTemporaryExpr(); | const Expr *Temp = MTE->GetTemporaryExpr(); | ||||
const Expr *Inner = Temp->skipRValueSubobjectAdjustments(CommaLHSs, | const Expr *Inner = Temp->skipRValueSubobjectAdjustments( | ||||
Adjustments); | CommaLHSs, Adjustments, SkippedCasts); | ||||
// Keep any cv-qualifiers from the reference if we generated a temporary | // Keep any cv-qualifiers from the reference if we generated a temporary | ||||
// for it directly. Otherwise use the type after adjustment. | // for it directly. Otherwise use the type after adjustment. | ||||
if (!Adjustments.empty()) | if (!Adjustments.empty()) | ||||
return Inner->getType(); | return Inner->getType(); | ||||
} | } | ||||
return Base->getType(); | return Base->getType(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 5,251 Lines • ▼ Show 20 Lines | bool LValueExprEvaluator::VisitVarDecl(const Expr *E, const VarDecl *VD) { | ||||
return Success(*V, E); | return Success(*V, E); | ||||
} | } | ||||
bool LValueExprEvaluator::VisitMaterializeTemporaryExpr( | bool LValueExprEvaluator::VisitMaterializeTemporaryExpr( | ||||
const MaterializeTemporaryExpr *E) { | const MaterializeTemporaryExpr *E) { | ||||
// Walk through the expression to find the materialized temporary itself. | // Walk through the expression to find the materialized temporary itself. | ||||
SmallVector<const Expr *, 2> CommaLHSs; | SmallVector<const Expr *, 2> CommaLHSs; | ||||
SmallVector<SubobjectAdjustment, 2> Adjustments; | SmallVector<SubobjectAdjustment, 2> Adjustments; | ||||
const Expr *Inner = E->GetTemporaryExpr()-> | SmallVector<const CastExpr *, 2> SkippedCasts; | ||||
skipRValueSubobjectAdjustments(CommaLHSs, Adjustments); | const Expr *Inner = E->GetTemporaryExpr()->skipRValueSubobjectAdjustments( | ||||
CommaLHSs, Adjustments, SkippedCasts); | |||||
// If we passed any comma operators, evaluate their LHSs. | // If we passed any comma operators, evaluate their LHSs. | ||||
for (unsigned I = 0, N = CommaLHSs.size(); I != N; ++I) | for (unsigned I = 0, N = CommaLHSs.size(); I != N; ++I) | ||||
if (!EvaluateIgnoredValue(Info, CommaLHSs[I])) | if (!EvaluateIgnoredValue(Info, CommaLHSs[I])) | ||||
return false; | return false; | ||||
// A materialized temporary with static storage duration can appear within the | // A materialized temporary with static storage duration can appear within the | ||||
// result of a constant expression evaluation, so we need to preserve its | // result of a constant expression evaluation, so we need to preserve its | ||||
▲ Show 20 Lines • Show All 5,963 Lines • Show Last 20 Lines |