mirror of
https://github.com/intel/llvm.git
synced 2026-01-26 12:26:52 +08:00
Some refactoring of member access for
performace sake. Also added a test case. llvm-svn: 77502
This commit is contained in:
@@ -1031,23 +1031,21 @@ Sema::PerformObjectMemberConversion(Expr *&From, NamedDecl *Member) {
|
||||
dyn_cast<CXXRecordDecl>(FD->getDeclContext())) {
|
||||
QualType DestType =
|
||||
Context.getCanonicalType(Context.getTypeDeclType(RD));
|
||||
if (!DestType->isDependentType() &&
|
||||
!From->getType()->isDependentType()) {
|
||||
QualType FromRecordType = From->getType();
|
||||
QualType DestRecordType = DestType;
|
||||
if (FromRecordType->getAsPointerType()) {
|
||||
DestType = Context.getPointerType(DestType);
|
||||
FromRecordType = FromRecordType->getPointeeType();
|
||||
}
|
||||
if (IsDerivedFrom(FromRecordType, DestRecordType) &&
|
||||
CheckDerivedToBaseConversion(FromRecordType,
|
||||
DestRecordType,
|
||||
From->getSourceRange().getBegin(),
|
||||
From->getSourceRange()))
|
||||
return true;
|
||||
|
||||
ImpCastExprToType(From, DestType, /*isLvalue=*/true);
|
||||
if (DestType->isDependentType() || From->getType()->isDependentType())
|
||||
return false;
|
||||
QualType FromRecordType = From->getType();
|
||||
QualType DestRecordType = DestType;
|
||||
if (FromRecordType->getAsPointerType()) {
|
||||
DestType = Context.getPointerType(DestType);
|
||||
FromRecordType = FromRecordType->getPointeeType();
|
||||
}
|
||||
if (!Context.hasSameUnqualifiedType(FromRecordType, DestRecordType) &&
|
||||
CheckDerivedToBaseConversion(FromRecordType,
|
||||
DestRecordType,
|
||||
From->getSourceRange().getBegin(),
|
||||
From->getSourceRange()))
|
||||
return true;
|
||||
ImpCastExprToType(From, DestType, /*isLvalue=*/true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
16
clang/test/SemaCXX/access-control-check.cpp
Normal file
16
clang/test/SemaCXX/access-control-check.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
// RUN: clang-cc -fsyntax-only -faccess-control -verify %s
|
||||
|
||||
class M {
|
||||
int iM;
|
||||
};
|
||||
|
||||
class P {
|
||||
int iP;
|
||||
int PPR();
|
||||
};
|
||||
|
||||
class N : M,P {
|
||||
N() {}
|
||||
// FIXME. No access violation is reported in method call or member access.
|
||||
int PR() { return iP + PPR(); }
|
||||
};
|
||||
Reference in New Issue
Block a user