Kaydet (Commit) b4c9c0d1 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

More clang::*Type vs. llvm::*Type ambiguities

Change-Id: I21133976793ab018c633dda077029666308526db
üst 5bbfa7ab
......@@ -26,8 +26,8 @@ bool areSimilar(QualType type1, QualType type2) {
if (!t2->isPointerType()) {
return false;
}
auto t1a = t1->getAs<PointerType>();
auto t2a = t2->getAs<PointerType>();
auto t1a = t1->getAs<clang::PointerType>();
auto t2a = t2->getAs<clang::PointerType>();
t1 = t1a->getPointeeType().getTypePtr();
t2 = t2a->getPointeeType().getTypePtr();
} else if (t1->isMemberPointerType()) {
......@@ -77,7 +77,7 @@ bool areSimilar(QualType type1, QualType type2) {
QualType resolvePointers(QualType type) {
while (type->isPointerType()) {
type = type->getAs<PointerType>()->getPointeeType();
type = type->getAs<clang::PointerType>()->getPointeeType();
}
return type;
}
......
......@@ -91,7 +91,7 @@ public:
if (auto const t = td->getAs<ReferenceType>()) {
td = t->getPointeeType();
}
while (auto const t = td->getAs<PointerType>()) {
while (auto const t = td->getAs<clang::PointerType>()) {
td = t->getPointeeType();
}
auto const rtd = td->getAs<RecordType>();
......@@ -104,7 +104,7 @@ public:
return true;
}
auto ts = expr->getSubExpr()->getType();
while (auto const t = ts->getAs<PointerType>()) {
while (auto const t = ts->getAs<clang::PointerType>()) {
ts = t->getPointeeType();
}
auto const rts = ts->getAs<RecordType>();
......
......@@ -22,12 +22,12 @@ bool isAlwaysNull(CXXDynamicCastExpr const * expr) {
QualType SrcType = expr->getSubExpr()->getType();
QualType DestType = expr->getType();
if (const PointerType *SrcPTy = SrcType->getAs<PointerType>()) {
if (const clang::PointerType *SrcPTy = SrcType->getAs<clang::PointerType>()) {
SrcType = SrcPTy->getPointeeType();
#if 0
DestType = DestType->castAs<PointerType>()->getPointeeType();
#else
auto DstPTy = DestType->getAs<PointerType>();
auto DstPTy = DestType->getAs<clang::PointerType>();
if (!DstPTy)
return false;
DestType = DstPTy->getPointeeType();
......
......@@ -412,7 +412,7 @@ bool ImplicitBoolConversion::TraverseCXXMemberCallExpr(CXXMemberCallExpr * expr)
= ignoreParenImpCastAndComma(expr->getImplicitObjectArgument())
->getType();
if (dyn_cast<MemberExpr>(expr->getCallee())->isArrow()) {
ty = ty->getAs<PointerType>()->getPointeeType();
ty = ty->getAs<clang::PointerType>()->getPointeeType();
}
TemplateSpecializationType const * ct
= ty->getAs<TemplateSpecializationType>();
......@@ -913,7 +913,8 @@ bool ImplicitBoolConversion::isExternCFunctionCall(
if (d != nullptr) {
FunctionDecl const * fd = dyn_cast<FunctionDecl>(d);
if (fd != nullptr) {
PointerType const * pt = fd->getType()->getAs<PointerType>();
clang::PointerType const * pt = fd->getType()
->getAs<clang::PointerType>();
QualType t2(pt == nullptr ? fd->getType() : pt->getPointeeType());
*functionType = t2->getAs<FunctionProtoType>();
assert(
......@@ -927,7 +928,8 @@ bool ImplicitBoolConversion::isExternCFunctionCall(
}
VarDecl const * vd = dyn_cast<VarDecl>(d);
if (vd != nullptr) {
PointerType const * pt = vd->getType()->getAs<PointerType>();
clang::PointerType const * pt = vd->getType()
->getAs<clang::PointerType>();
*functionType
= ((pt == nullptr ? vd->getType() : pt->getPointeeType())
->getAs<FunctionProtoType>());
......
......@@ -110,16 +110,16 @@ bool isDerivedFrom(const CXXRecordDecl *decl, DeclChecker base) {
}
bool containsXInterfaceSubclass(const Type* pType0);
bool containsXInterfaceSubclass(const clang::Type* pType0);
bool containsXInterfaceSubclass(const QualType& qType) {
return containsXInterfaceSubclass(qType.getTypePtr());
}
bool containsXInterfaceSubclass(const Type* pType0) {
bool containsXInterfaceSubclass(const clang::Type* pType0) {
if (!pType0)
return false;
const Type* pType = pType0->getUnqualifiedDesugaredType();
const clang::Type* pType = pType0->getUnqualifiedDesugaredType();
if (!pType)
return false;
const CXXRecordDecl* pRecordDecl = pType->getAsCXXRecordDecl();
......@@ -229,7 +229,7 @@ bool containsXInterfaceSubclass(const Type* pType0) {
// ignore
return false;
} else if (pType->isArrayType()) {
const ArrayType* pArrayType = dyn_cast<ArrayType>(pType);
const clang::ArrayType* pArrayType = dyn_cast<clang::ArrayType>(pType);
QualType elementType = pArrayType->getElementType();
return containsXInterfaceSubclass(elementType);
} else {
......@@ -237,10 +237,10 @@ bool containsXInterfaceSubclass(const Type* pType0) {
}
}
bool containsSvRefBaseSubclass(const Type* pType0) {
bool containsSvRefBaseSubclass(const clang::Type* pType0) {
if (!pType0)
return false;
const Type* pType = pType0->getUnqualifiedDesugaredType();
const clang::Type* pType = pType0->getUnqualifiedDesugaredType();
if (!pType)
return false;
const CXXRecordDecl* pRecordDecl = pType->getAsCXXRecordDecl();
......@@ -269,7 +269,7 @@ bool containsSvRefBaseSubclass(const Type* pType0) {
// ignore
return false;
} else if (pType->isArrayType()) {
const ArrayType* pArrayType = dyn_cast<ArrayType>(pType);
const clang::ArrayType* pArrayType = dyn_cast<clang::ArrayType>(pType);
QualType elementType = pArrayType->getElementType();
return containsSvRefBaseSubclass(elementType.getTypePtr());
} else {
......@@ -277,10 +277,10 @@ bool containsSvRefBaseSubclass(const Type* pType0) {
}
}
bool containsSalhelperReferenceObjectSubclass(const Type* pType0) {
bool containsSalhelperReferenceObjectSubclass(const clang::Type* pType0) {
if (!pType0)
return false;
const Type* pType = pType0->getUnqualifiedDesugaredType();
const clang::Type* pType = pType0->getUnqualifiedDesugaredType();
if (!pType)
return false;
const CXXRecordDecl* pRecordDecl = pType->getAsCXXRecordDecl();
......@@ -311,7 +311,7 @@ bool containsSalhelperReferenceObjectSubclass(const Type* pType0) {
// ignore
return false;
} else if (pType->isArrayType()) {
const ArrayType* pArrayType = dyn_cast<ArrayType>(pType);
const clang::ArrayType* pArrayType = dyn_cast<clang::ArrayType>(pType);
QualType elementType = pArrayType->getElementType();
return containsSalhelperReferenceObjectSubclass(elementType.getTypePtr());
} else {
......
......@@ -262,7 +262,8 @@ bool SalBool::VisitCallExpr(CallExpr * expr) {
FunctionDecl const * fd = dyn_cast<FunctionDecl>(d);
if (fd != nullptr) {
if (!hasBoolOverload(fd, false)) {
PointerType const * pt = fd->getType()->getAs<PointerType>();
clang::PointerType const * pt = fd->getType()
->getAs<clang::PointerType>();
QualType t2(
pt == nullptr ? fd->getType() : pt->getPointeeType());
ft = t2->getAs<FunctionProtoType>();
......@@ -275,7 +276,8 @@ bool SalBool::VisitCallExpr(CallExpr * expr) {
} else {
VarDecl const * vd = dyn_cast<VarDecl>(d);
if (vd != nullptr) {
PointerType const * pt = vd->getType()->getAs<PointerType>();
clang::PointerType const * pt = vd->getType()
->getAs<clang::PointerType>();
ft = (pt == nullptr ? vd->getType() : pt->getPointeeType())
->getAs<FunctionProtoType>();
}
......@@ -290,7 +292,7 @@ bool SalBool::VisitCallExpr(CallExpr * expr) {
b = !t.isConstQualified() && isSalBool(t);
} else if (t->isPointerType()) {
for (;;) {
auto t2 = t->getAs<PointerType>();
auto t2 = t->getAs<clang::PointerType>();
if (t2 == nullptr) {
break;
}
......@@ -479,7 +481,7 @@ bool SalBool::VisitReturnStmt(ReturnStmt const * stmt) {
return true;
}
for (;;) {
auto t2 = t->getAs<PointerType>();
auto t2 = t->getAs<clang::PointerType>();
if (t2 == nullptr) {
break;
}
......
......@@ -337,7 +337,7 @@ void UseUniquePtr::CheckForDeleteOfPOD(const CompoundStmt* compoundStmt)
if (tagDecl->isUnion())
continue;
auto pointerType = dyn_cast<PointerType>(fieldDecl->getType()->getUnqualifiedDesugaredType());
auto pointerType = dyn_cast<clang::PointerType>(fieldDecl->getType()->getUnqualifiedDesugaredType());
QualType elementType = pointerType->getPointeeType();
auto tc = loplugin::TypeCheck(elementType);
if (!elementType.isPODType(compiler.getASTContext())
......
......@@ -47,7 +47,7 @@ public:
bool VisitCXXConstructExpr(const CXXConstructExpr *);
bool VisitBinaryOperator(const BinaryOperator *);
private:
void checkAssignmentForVclPtrToRawConversion(const SourceLocation& sourceLoc, const Type* lhsType, const Expr* rhs);
void checkAssignmentForVclPtrToRawConversion(const SourceLocation& sourceLoc, const clang::Type* lhsType, const Expr* rhs);
bool isDisposeCallingSuperclassDispose(const CXXMethodDecl* pMethodDecl);
bool mbCheckingMemcpy = false;
};
......@@ -85,7 +85,7 @@ bool isDerivedFromVclReferenceBase(const CXXRecordDecl *decl) {
return false;
}
bool containsVclReferenceBaseSubclass(const Type* pType0);
bool containsVclReferenceBaseSubclass(const clang::Type* pType0);
bool containsVclReferenceBaseSubclass(const QualType& qType) {
auto check = loplugin::TypeCheck(qType);
......@@ -99,10 +99,10 @@ bool containsVclReferenceBaseSubclass(const QualType& qType) {
return containsVclReferenceBaseSubclass(qType.getTypePtr());
}
bool containsVclReferenceBaseSubclass(const Type* pType0) {
bool containsVclReferenceBaseSubclass(const clang::Type* pType0) {
if (!pType0)
return false;
const Type* pType = pType0->getUnqualifiedDesugaredType();
const clang::Type* pType = pType0->getUnqualifiedDesugaredType();
if (!pType)
return false;
const CXXRecordDecl* pRecordDecl = pType->getAsCXXRecordDecl();
......@@ -132,7 +132,7 @@ bool containsVclReferenceBaseSubclass(const Type* pType0) {
QualType pointeeType = pType->getPointeeType();
return containsVclReferenceBaseSubclass(pointeeType);
} else if (pType->isArrayType()) {
const ArrayType* pArrayType = dyn_cast<ArrayType>(pType);
const clang::ArrayType* pArrayType = dyn_cast<clang::ArrayType>(pType);
QualType elementType = pArrayType->getElementType();
return containsVclReferenceBaseSubclass(elementType);
} else {
......@@ -276,9 +276,9 @@ bool VCLWidgets::VisitBinaryOperator(const BinaryOperator * binaryOperator)
// Look for places where we are accidentally assigning a returned-by-value VclPtr<T> to a T*, which generally
// ends up in a use-after-free.
void VCLWidgets::checkAssignmentForVclPtrToRawConversion(const SourceLocation& spellingLocation, const Type* lhsType, const Expr* rhs)
void VCLWidgets::checkAssignmentForVclPtrToRawConversion(const SourceLocation& spellingLocation, const clang::Type* lhsType, const Expr* rhs)
{
if (!lhsType || !isa<PointerType>(lhsType)) {
if (!lhsType || !isa<clang::PointerType>(lhsType)) {
return;
}
if (!rhs) {
......@@ -736,7 +736,7 @@ bool VCLWidgets::isDisposeCallingSuperclassDispose(const CXXMethodDecl* pMethodD
return true;
}
bool containsVclPtr(const Type* pType0);
bool containsVclPtr(const clang::Type* pType0);
bool containsVclPtr(const QualType& qType) {
auto check = loplugin::TypeCheck(qType);
......@@ -750,16 +750,16 @@ bool containsVclPtr(const QualType& qType) {
return containsVclPtr(qType.getTypePtr());
}
bool containsVclPtr(const Type* pType0) {
bool containsVclPtr(const clang::Type* pType0) {
if (!pType0)
return false;
const Type* pType = pType0->getUnqualifiedDesugaredType();
const clang::Type* pType = pType0->getUnqualifiedDesugaredType();
if (!pType)
return false;
if (pType->isPointerType()) {
return false;
} else if (pType->isArrayType()) {
const ArrayType* pArrayType = dyn_cast<ArrayType>(pType);
const clang::ArrayType* pArrayType = dyn_cast<clang::ArrayType>(pType);
QualType elementType = pArrayType->getElementType();
return containsVclPtr(elementType);
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment