зеркало из https://github.com/microsoft/clang.git
convert more code to use ASTContext to get canonical types instead
of doing it directly. This is required for PR2189. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54102 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
717250a205
Коммит
28be73f74c
|
@ -74,7 +74,7 @@ public:
|
|||
LV_DuplicateVectorComponents,
|
||||
LV_InvalidExpression
|
||||
};
|
||||
isLvalueResult isLvalue() const;
|
||||
isLvalueResult isLvalue(ASTContext &Ctx) const;
|
||||
|
||||
/// isModifiableLvalue - C99 6.3.2.1: an lvalue that does not have array type,
|
||||
/// does not have an incomplete type, does not have a const-qualified type,
|
||||
|
@ -91,7 +91,7 @@ public:
|
|||
MLV_ConstQualified,
|
||||
MLV_ArrayType
|
||||
};
|
||||
isModifiableLvalueResult isModifiableLvalue() const;
|
||||
isModifiableLvalueResult isModifiableLvalue(ASTContext &Ctx) const;
|
||||
|
||||
bool isNullPointerConstant(ASTContext &Ctx) const;
|
||||
|
||||
|
|
|
@ -1542,15 +1542,15 @@ bool ASTContext::pointerTypesAreCompatible(QualType lhs, QualType rhs) {
|
|||
lhs.getAddressSpace() != rhs.getAddressSpace())
|
||||
return false;
|
||||
|
||||
QualType ltype = cast<PointerType>(lhs.getCanonicalType())->getPointeeType();
|
||||
QualType rtype = cast<PointerType>(rhs.getCanonicalType())->getPointeeType();
|
||||
QualType ltype = lhs->getAsPointerType()->getPointeeType();
|
||||
QualType rtype = rhs->getAsPointerType()->getPointeeType();
|
||||
|
||||
return typesAreCompatible(ltype, rtype);
|
||||
}
|
||||
|
||||
bool ASTContext::functionTypesAreCompatible(QualType lhs, QualType rhs) {
|
||||
const FunctionType *lbase = cast<FunctionType>(lhs.getCanonicalType());
|
||||
const FunctionType *rbase = cast<FunctionType>(rhs.getCanonicalType());
|
||||
const FunctionType *lbase = lhs->getAsFunctionType();
|
||||
const FunctionType *rbase = rhs->getAsFunctionType();
|
||||
const FunctionTypeProto *lproto = dyn_cast<FunctionTypeProto>(lbase);
|
||||
const FunctionTypeProto *rproto = dyn_cast<FunctionTypeProto>(rbase);
|
||||
|
||||
|
@ -1673,8 +1673,8 @@ static bool areCompatObjCInterfaces(const ObjCInterfaceType *LHS,
|
|||
/// C99 6.2.7p1: Two types have compatible types if their types are the
|
||||
/// same. See 6.7.[2,3,5] for additional rules.
|
||||
bool ASTContext::typesAreCompatible(QualType LHS_NC, QualType RHS_NC) {
|
||||
QualType LHS = LHS_NC.getCanonicalType();
|
||||
QualType RHS = RHS_NC.getCanonicalType();
|
||||
QualType LHS = getCanonicalType(LHS_NC);
|
||||
QualType RHS = getCanonicalType(RHS_NC);
|
||||
|
||||
// C++ [expr]: If an expression initially has the type "reference to T", the
|
||||
// type is adjusted to "T" prior to any further analysis, the expression
|
||||
|
|
|
@ -387,13 +387,13 @@ bool Expr::hasLocalSideEffect() const {
|
|||
/// - (__real__ e) and (__imag__ e) where e is an lvalue [GNU extension]
|
||||
/// - reference type [C++ [expr]]
|
||||
///
|
||||
Expr::isLvalueResult Expr::isLvalue() const {
|
||||
Expr::isLvalueResult Expr::isLvalue(ASTContext &Ctx) const {
|
||||
// first, check the type (C99 6.3.2.1)
|
||||
if (TR->isFunctionType()) // from isObjectType()
|
||||
return LV_NotObjectType;
|
||||
|
||||
// Allow qualified void which is an incomplete type other than void (yuck).
|
||||
if (TR->isVoidType() && !TR.getCanonicalType().getCVRQualifiers())
|
||||
if (TR->isVoidType() && !Ctx.getCanonicalType(TR).getCVRQualifiers())
|
||||
return LV_IncompleteVoidType;
|
||||
|
||||
if (TR->isReferenceType()) // C++ [expr]
|
||||
|
@ -406,7 +406,7 @@ Expr::isLvalueResult Expr::isLvalue() const {
|
|||
case ArraySubscriptExprClass: // C99 6.5.3p4 (e1[e2] == (*((e1)+(e2))))
|
||||
// For vectors, make sure base is an lvalue (i.e. not a function call).
|
||||
if (cast<ArraySubscriptExpr>(this)->getBase()->getType()->isVectorType())
|
||||
return cast<ArraySubscriptExpr>(this)->getBase()->isLvalue();
|
||||
return cast<ArraySubscriptExpr>(this)->getBase()->isLvalue(Ctx);
|
||||
return LV_Valid;
|
||||
case DeclRefExprClass: { // C99 6.5.1p2
|
||||
const Decl *RefdDecl = cast<DeclRefExpr>(this)->getDecl();
|
||||
|
@ -416,7 +416,7 @@ Expr::isLvalueResult Expr::isLvalue() const {
|
|||
}
|
||||
case MemberExprClass: { // C99 6.5.2.3p4
|
||||
const MemberExpr *m = cast<MemberExpr>(this);
|
||||
return m->isArrow() ? LV_Valid : m->getBase()->isLvalue();
|
||||
return m->isArrow() ? LV_Valid : m->getBase()->isLvalue(Ctx);
|
||||
}
|
||||
case UnaryOperatorClass:
|
||||
if (cast<UnaryOperator>(this)->getOpcode() == UnaryOperator::Deref)
|
||||
|
@ -425,10 +425,10 @@ Expr::isLvalueResult Expr::isLvalue() const {
|
|||
if (cast<UnaryOperator>(this)->getOpcode() == UnaryOperator::Real ||
|
||||
cast<UnaryOperator>(this)->getOpcode() == UnaryOperator::Imag ||
|
||||
cast<UnaryOperator>(this)->getOpcode() == UnaryOperator::Extension)
|
||||
return cast<UnaryOperator>(this)->getSubExpr()->isLvalue(); // GNU.
|
||||
return cast<UnaryOperator>(this)->getSubExpr()->isLvalue(Ctx); // GNU.
|
||||
break;
|
||||
case ParenExprClass: // C99 6.5.1p5
|
||||
return cast<ParenExpr>(this)->getSubExpr()->isLvalue();
|
||||
return cast<ParenExpr>(this)->getSubExpr()->isLvalue(Ctx);
|
||||
case CompoundLiteralExprClass: // C99 6.5.2.5p5
|
||||
return LV_Valid;
|
||||
case ExtVectorElementExprClass:
|
||||
|
@ -444,7 +444,7 @@ Expr::isLvalueResult Expr::isLvalue() const {
|
|||
== PreDefinedExpr::CXXThis
|
||||
? LV_InvalidExpression : LV_Valid);
|
||||
case CXXDefaultArgExprClass:
|
||||
return cast<CXXDefaultArgExpr>(this)->getExpr()->isLvalue();
|
||||
return cast<CXXDefaultArgExpr>(this)->getExpr()->isLvalue(Ctx);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -456,8 +456,8 @@ Expr::isLvalueResult Expr::isLvalue() const {
|
|||
/// if it is a structure or union, does not have any member (including,
|
||||
/// recursively, any member or element of all contained aggregates or unions)
|
||||
/// with a const-qualified type.
|
||||
Expr::isModifiableLvalueResult Expr::isModifiableLvalue() const {
|
||||
isLvalueResult lvalResult = isLvalue();
|
||||
Expr::isModifiableLvalueResult Expr::isModifiableLvalue(ASTContext &Ctx) const {
|
||||
isLvalueResult lvalResult = isLvalue(Ctx);
|
||||
|
||||
switch (lvalResult) {
|
||||
case LV_Valid: break;
|
||||
|
@ -473,7 +473,7 @@ Expr::isModifiableLvalueResult Expr::isModifiableLvalue() const {
|
|||
if (TR->isIncompleteType())
|
||||
return MLV_IncompleteType;
|
||||
|
||||
if (const RecordType *r = dyn_cast<RecordType>(TR.getCanonicalType())) {
|
||||
if (const RecordType *r = TR->getAsRecordType()) {
|
||||
if (r->hasConstFields())
|
||||
return MLV_ConstQualified;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ void Sema::DefaultFunctionArrayConversion(Expr *&E) {
|
|||
// to type'...". In C99 this was changed to: C99 6.3.2.1p3: "an expression
|
||||
// that has type 'array of type' ...". The relevant change is "an lvalue"
|
||||
// (C90) to "an expression" (C99).
|
||||
if (getLangOptions().C99 || E->isLvalue() == Expr::LV_Valid)
|
||||
if (getLangOptions().C99 || E->isLvalue(Context) == Expr::LV_Valid)
|
||||
ImpCastExprToType(E, Context.getArrayDecayedType(Ty));
|
||||
}
|
||||
}
|
||||
|
@ -1864,7 +1864,7 @@ inline QualType Sema::CheckAssignmentOperands( // C99 6.5.16.1
|
|||
{
|
||||
QualType lhsType = lex->getType();
|
||||
QualType rhsType = compoundType.isNull() ? rex->getType() : compoundType;
|
||||
Expr::isModifiableLvalueResult mlval = lex->isModifiableLvalue();
|
||||
Expr::isModifiableLvalueResult mlval = lex->isModifiableLvalue(Context);
|
||||
|
||||
switch (mlval) { // C99 6.5.16p2
|
||||
case Expr::MLV_Valid:
|
||||
|
@ -1952,7 +1952,7 @@ QualType Sema::CheckIncrementDecrementOperand(Expr *op, SourceLocation OpLoc) {
|
|||
}
|
||||
// At this point, we know we have a real, complex or pointer type.
|
||||
// Now make sure the operand is a modifiable lvalue.
|
||||
Expr::isModifiableLvalueResult mlval = op->isModifiableLvalue();
|
||||
Expr::isModifiableLvalueResult mlval = op->isModifiableLvalue(Context);
|
||||
if (mlval != Expr::MLV_Valid) {
|
||||
// FIXME: emit a more precise diagnostic...
|
||||
Diag(OpLoc, diag::err_typecheck_invalid_lvalue_incr_decr,
|
||||
|
@ -2015,7 +2015,7 @@ QualType Sema::CheckAddressOfOperand(Expr *op, SourceLocation OpLoc) {
|
|||
// expressions here, but the result of one is always an lvalue anyway.
|
||||
}
|
||||
ValueDecl *dcl = getPrimaryDecl(op);
|
||||
Expr::isLvalueResult lval = op->isLvalue();
|
||||
Expr::isLvalueResult lval = op->isLvalue(Context);
|
||||
|
||||
if (lval != Expr::LV_Valid) { // C99 6.5.3.2p1
|
||||
if (!dcl || !isa<FunctionDecl>(dcl)) {// allow function designators
|
||||
|
|
|
@ -712,7 +712,7 @@ Sema::StmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
|
|||
|
||||
// Check that the output exprs are valid lvalues.
|
||||
Expr *OutputExpr = (Expr *)Exprs[i];
|
||||
Expr::isLvalueResult Result = OutputExpr->isLvalue();
|
||||
Expr::isLvalueResult Result = OutputExpr->isLvalue(Context);
|
||||
if (Result != Expr::LV_Valid) {
|
||||
ParenExpr *PE = cast<ParenExpr>(OutputExpr);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче