зеркало из https://github.com/microsoft/clang-1.git
Move Sema::GetNonReferenceType to QualType::getNonReferenceType and make it inline
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57951 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
4a76b292c9
Коммит
e0a5d5fe8e
|
@ -158,28 +158,11 @@ public:
|
|||
return QualType(getTypePtr(), TQs|getCVRQualifiers());
|
||||
}
|
||||
|
||||
inline QualType getUnqualifiedType() const;
|
||||
QualType getUnqualifiedType() const;
|
||||
bool isMoreQualifiedThan(QualType Other) const;
|
||||
bool isAtLeastAsQualifiedAs(QualType Other) const;
|
||||
QualType getNonReferenceType() const;
|
||||
|
||||
/// isMoreQualifiedThan - Determine whether this type is more
|
||||
/// qualified than the Other type. For example, "const volatile int"
|
||||
/// is more qualified than "const int", "volatile int", and
|
||||
/// "int". However, it is not more qualified than "const volatile
|
||||
/// int".
|
||||
bool isMoreQualifiedThan(QualType Other) const {
|
||||
unsigned MyQuals = this->getCVRQualifiers();
|
||||
unsigned OtherQuals = Other.getCVRQualifiers();
|
||||
return MyQuals != OtherQuals && (MyQuals | OtherQuals) == MyQuals;
|
||||
}
|
||||
|
||||
/// isAtLeastAsQualifiedAs - Determine whether this type is at last
|
||||
/// as qualified as the Other type. For example, "const volatile
|
||||
/// int" is at least as qualified as "const int", "volatile int",
|
||||
/// "int", and "const volatile int".
|
||||
bool isAtLeastAsQualifiedAs(QualType Other) const {
|
||||
unsigned MyQuals = this->getCVRQualifiers();
|
||||
unsigned OtherQuals = Other.getCVRQualifiers();
|
||||
return (MyQuals | OtherQuals) == MyQuals;
|
||||
}
|
||||
|
||||
/// operator==/!= - Indicate whether the specified types and qualifiers are
|
||||
/// identical.
|
||||
|
@ -1370,6 +1353,45 @@ inline unsigned QualType::getAddressSpace() const {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/// isMoreQualifiedThan - Determine whether this type is more
|
||||
/// qualified than the Other type. For example, "const volatile int"
|
||||
/// is more qualified than "const int", "volatile int", and
|
||||
/// "int". However, it is not more qualified than "const volatile
|
||||
/// int".
|
||||
inline bool QualType::isMoreQualifiedThan(QualType Other) const {
|
||||
// FIXME: Handle address spaces
|
||||
unsigned MyQuals = this->getCVRQualifiers();
|
||||
unsigned OtherQuals = Other.getCVRQualifiers();
|
||||
return MyQuals != OtherQuals && (MyQuals | OtherQuals) == MyQuals;
|
||||
}
|
||||
|
||||
/// isAtLeastAsQualifiedAs - Determine whether this type is at last
|
||||
/// as qualified as the Other type. For example, "const volatile
|
||||
/// int" is at least as qualified as "const int", "volatile int",
|
||||
/// "int", and "const volatile int".
|
||||
inline bool QualType::isAtLeastAsQualifiedAs(QualType Other) const {
|
||||
// FIXME: Handle address spaces
|
||||
unsigned MyQuals = this->getCVRQualifiers();
|
||||
unsigned OtherQuals = Other.getCVRQualifiers();
|
||||
return (MyQuals | OtherQuals) == MyQuals;
|
||||
}
|
||||
|
||||
/// getNonReferenceType - If Type is a reference type (e.g., const
|
||||
/// int&), returns the type that the reference refers to ("const
|
||||
/// int"). Otherwise, returns the type itself. This routine is used
|
||||
/// throughout Sema to implement C++ 5p6:
|
||||
///
|
||||
/// If an expression initially has the type "reference to T" (8.3.2,
|
||||
/// 8.5.3), the type is adjusted to "T" prior to any further
|
||||
/// analysis, the expression designates the object or function
|
||||
/// denoted by the reference, and the expression is an lvalue.
|
||||
inline QualType QualType::getNonReferenceType() const {
|
||||
if (const ReferenceType *RefType = (*this)->getAsReferenceType())
|
||||
return RefType->getPointeeType();
|
||||
else
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const TypedefType* Type::getAsTypedefType() const {
|
||||
return dyn_cast<TypedefType>(this);
|
||||
}
|
||||
|
|
|
@ -259,7 +259,6 @@ public:
|
|||
QualType ConvertDeclSpecToType(const DeclSpec &DS);
|
||||
void ProcessTypeAttributeList(QualType &Result, const AttributeList *AL);
|
||||
QualType GetTypeForDeclarator(Declarator &D, Scope *S);
|
||||
QualType GetNonReferenceType(QualType Type);
|
||||
|
||||
QualType ObjCGetTypeForMethodDefinition(DeclTy *D);
|
||||
|
||||
|
|
|
@ -450,7 +450,7 @@ Sema::ExprResult Sema::ActOnIdentifierExpr(Scope *S, SourceLocation Loc,
|
|||
}
|
||||
// If this reference is not in a block or if the referenced variable is
|
||||
// within the block, create a normal DeclRefExpr.
|
||||
return new DeclRefExpr(VD, GetNonReferenceType(VD->getType()), Loc);
|
||||
return new DeclRefExpr(VD, VD->getType().getNonReferenceType(), Loc);
|
||||
}
|
||||
|
||||
Sema::ExprResult Sema::ActOnPredefinedExpr(SourceLocation Loc,
|
||||
|
|
|
@ -500,23 +500,6 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S) {
|
|||
return T;
|
||||
}
|
||||
|
||||
/// GetNonReferenceType - If Type is a reference type (e.g., const
|
||||
/// int&), returns the type that the reference refers to ("const
|
||||
/// int"). Otherwise, returns the type itself. This routine is used
|
||||
/// throughout to implement C++ 5p6:
|
||||
///
|
||||
/// If an expression initially has the type "reference to T" (8.3.2,
|
||||
/// 8.5.3), the type is adjusted to "T" prior to any further
|
||||
/// analysis, the expression designates the object or function
|
||||
/// denoted by the reference, and the expression is an lvalue.
|
||||
QualType Sema::GetNonReferenceType(QualType Type)
|
||||
{
|
||||
if (const ReferenceType *RefType = Type->getAsReferenceType())
|
||||
return RefType->getPointeeType();
|
||||
else
|
||||
return Type;
|
||||
}
|
||||
|
||||
/// ObjCGetTypeForMethodDefinition - Builds the type for a method definition
|
||||
/// declarator
|
||||
QualType Sema::ObjCGetTypeForMethodDefinition(DeclTy *D) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче