Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/Sema/SemaType.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 8,885 Lines • ▼ Show 20 Lines | QualType Sema::BuildTypeofExprType(Expr *E, SourceLocation Loc) { | ||||
if (!E->isTypeDependent()) { | if (!E->isTypeDependent()) { | ||||
QualType T = E->getType(); | QualType T = E->getType(); | ||||
if (const TagType *TT = T->getAs<TagType>()) | if (const TagType *TT = T->getAs<TagType>()) | ||||
DiagnoseUseOfDecl(TT->getDecl(), E->getExprLoc()); | DiagnoseUseOfDecl(TT->getDecl(), E->getExprLoc()); | ||||
} | } | ||||
return Context.getTypeOfExprType(E); | return Context.getTypeOfExprType(E); | ||||
} | } | ||||
/// getDecltypeForParenthesizedExpr - Given an expr, will return the type for | |||||
/// that expression, as in [dcl.type.simple]p4 but without taking id-expressions | |||||
/// and class member access into account. | |||||
QualType Sema::getDecltypeForParenthesizedExpr(Expr *E) { | |||||
// C++11 [dcl.type.simple]p4: | |||||
// [...] | |||||
QualType T = E->getType(); | |||||
switch (E->getValueKind()) { | |||||
// - otherwise, if e is an xvalue, decltype(e) is T&&, where T is the | |||||
// type of e; | |||||
case VK_XValue: | |||||
return Context.getRValueReferenceType(T); | |||||
// - otherwise, if e is an lvalue, decltype(e) is T&, where T is the | |||||
// type of e; | |||||
case VK_LValue: | |||||
return Context.getLValueReferenceType(T); | |||||
// - otherwise, decltype(e) is the type of e. | |||||
case VK_PRValue: | |||||
return T; | |||||
} | |||||
llvm_unreachable("Unknown value kind"); | |||||
} | |||||
/// getDecltypeForExpr - Given an expr, will return the decltype for | /// getDecltypeForExpr - Given an expr, will return the decltype for | ||||
/// that expression, according to the rules in C++11 | /// that expression, according to the rules in C++11 | ||||
/// [dcl.type.simple]p4 and C++11 [expr.lambda.prim]p18. | /// [dcl.type.simple]p4 and C++11 [expr.lambda.prim]p18. | ||||
static QualType getDecltypeForExpr(Sema &S, Expr *E) { | static QualType getDecltypeForExpr(Sema &S, Expr *E) { | ||||
if (E->isTypeDependent()) | if (E->isTypeDependent()) | ||||
return S.Context.DependentTy; | return S.Context.DependentTy; | ||||
Expr *IDExpr = E; | Expr *IDExpr = E; | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | if (isa<ParenExpr>(IDExpr)) { | ||||
QualType T = S.getCapturedDeclRefType(Var, DRE->getLocation()); | QualType T = S.getCapturedDeclRefType(Var, DRE->getLocation()); | ||||
if (!T.isNull()) | if (!T.isNull()) | ||||
return S.Context.getLValueReferenceType(T); | return S.Context.getLValueReferenceType(T); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
return S.getDecltypeForParenthesizedExpr(E); | return S.Context.getReferenceQualifiedType(E); | ||||
} | } | ||||
QualType Sema::BuildDecltypeType(Expr *E, SourceLocation Loc, | QualType Sema::BuildDecltypeType(Expr *E, SourceLocation Loc, | ||||
bool AsUnevaluated) { | bool AsUnevaluated) { | ||||
assert(!E->hasPlaceholderType() && "unexpected placeholder"); | assert(!E->hasPlaceholderType() && "unexpected placeholder"); | ||||
if (AsUnevaluated && CodeSynthesisContexts.empty() && | if (AsUnevaluated && CodeSynthesisContexts.empty() && | ||||
!E->isInstantiationDependent() && E->HasSideEffects(Context, false)) { | !E->isInstantiationDependent() && E->HasSideEffects(Context, false)) { | ||||
▲ Show 20 Lines • Show All 83 Lines • Show Last 20 Lines |