зеркало из https://github.com/microsoft/clang-1.git
Fix some const_cast issues. This is the beginning of the rabbit hole.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78393 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
d0439688fe
Коммит
e607ed0683
|
@ -444,7 +444,7 @@ public:
|
||||||
|
|
||||||
/// getTagDeclType - Return the unique reference to the type for the
|
/// getTagDeclType - Return the unique reference to the type for the
|
||||||
/// specified TagDecl (struct/union/class/enum) decl.
|
/// specified TagDecl (struct/union/class/enum) decl.
|
||||||
QualType getTagDeclType(TagDecl *Decl);
|
QualType getTagDeclType(const TagDecl *Decl);
|
||||||
|
|
||||||
/// getSizeType - Return the unique type for "size_t" (C99 7.17), defined
|
/// getSizeType - Return the unique type for "size_t" (C99 7.17), defined
|
||||||
/// in <stddef.h>. The sizeof operator requires this (C99 6.5.3.4p4).
|
/// in <stddef.h>. The sizeof operator requires this (C99 6.5.3.4p4).
|
||||||
|
|
|
@ -2029,9 +2029,11 @@ QualType ASTContext::getDecltypeType(Expr *e) {
|
||||||
|
|
||||||
/// getTagDeclType - Return the unique reference to the type for the
|
/// getTagDeclType - Return the unique reference to the type for the
|
||||||
/// specified TagDecl (struct/union/class/enum) decl.
|
/// specified TagDecl (struct/union/class/enum) decl.
|
||||||
QualType ASTContext::getTagDeclType(TagDecl *Decl) {
|
QualType ASTContext::getTagDeclType(const TagDecl *Decl) {
|
||||||
assert (Decl);
|
assert (Decl);
|
||||||
return getTypeDeclType(Decl);
|
// FIXME: What is the design on getTagDeclType when it requires casting
|
||||||
|
// away const? mutable?
|
||||||
|
return getTypeDeclType(const_cast<TagDecl*>(Decl));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getSizeType - Return the unique type for "size_t" (C99 7.17), the result
|
/// getSizeType - Return the unique type for "size_t" (C99 7.17), the result
|
||||||
|
|
|
@ -379,9 +379,7 @@ QualType CXXMethodDecl::getThisType(ASTContext &C) const {
|
||||||
if (ClassTemplateDecl *TD = getParent()->getDescribedClassTemplate())
|
if (ClassTemplateDecl *TD = getParent()->getDescribedClassTemplate())
|
||||||
ClassTy = TD->getInjectedClassNameType(C);
|
ClassTy = TD->getInjectedClassNameType(C);
|
||||||
else
|
else
|
||||||
// FIXME: What is the design on getTagDeclType when it requires casting
|
ClassTy = C.getTagDeclType(getParent());
|
||||||
// away const? mutable?
|
|
||||||
ClassTy = C.getTagDeclType(const_cast<CXXRecordDecl*>(getParent()));
|
|
||||||
ClassTy = ClassTy.getWithAdditionalQualifiers(getTypeQualifiers());
|
ClassTy = ClassTy.getWithAdditionalQualifiers(getTypeQualifiers());
|
||||||
return C.getPointerType(ClassTy);
|
return C.getPointerType(ClassTy);
|
||||||
}
|
}
|
||||||
|
@ -466,10 +464,9 @@ CXXConstructorDecl::isCopyConstructor(ASTContext &Context,
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Is it a reference to our class type?
|
// Is it a reference to our class type?
|
||||||
QualType PointeeType
|
QualType PointeeType
|
||||||
= Context.getCanonicalType(ParamRefType->getPointeeType());
|
= Context.getCanonicalType(ParamRefType->getPointeeType());
|
||||||
QualType ClassTy
|
QualType ClassTy = Context.getTagDeclType(getParent());
|
||||||
= Context.getTagDeclType(const_cast<CXXRecordDecl*>(getParent()));
|
|
||||||
if (PointeeType.getUnqualifiedType() != ClassTy)
|
if (PointeeType.getUnqualifiedType() != ClassTy)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -506,9 +506,7 @@ llvm::Constant *CodeGenFunction::GenerateRtti(const CXXRecordDecl *RD) {
|
||||||
llvm::SmallString<256> OutName;
|
llvm::SmallString<256> OutName;
|
||||||
llvm::raw_svector_ostream Out(OutName);
|
llvm::raw_svector_ostream Out(OutName);
|
||||||
QualType ClassTy;
|
QualType ClassTy;
|
||||||
// FIXME: What is the design on getTagDeclType when it requires casting
|
ClassTy = getContext().getTagDeclType(RD);
|
||||||
// away const? mutable?
|
|
||||||
ClassTy = getContext().getTagDeclType(const_cast<CXXRecordDecl*>(RD));
|
|
||||||
mangleCXXRtti(ClassTy, getContext(), Out);
|
mangleCXXRtti(ClassTy, getContext(), Out);
|
||||||
const char *Name = OutName.c_str();
|
const char *Name = OutName.c_str();
|
||||||
llvm::GlobalVariable::LinkageTypes linktype;
|
llvm::GlobalVariable::LinkageTypes linktype;
|
||||||
|
@ -599,9 +597,7 @@ llvm::Value *CodeGenFunction::GenerateVtable(const CXXRecordDecl *RD) {
|
||||||
llvm::SmallString<256> OutName;
|
llvm::SmallString<256> OutName;
|
||||||
llvm::raw_svector_ostream Out(OutName);
|
llvm::raw_svector_ostream Out(OutName);
|
||||||
QualType ClassTy;
|
QualType ClassTy;
|
||||||
// FIXME: What is the design on getTagDeclType when it requires casting
|
ClassTy = getContext().getTagDeclType(RD);
|
||||||
// away const? mutable?
|
|
||||||
ClassTy = getContext().getTagDeclType(const_cast<CXXRecordDecl*>(RD));
|
|
||||||
mangleCXXVtable(ClassTy, getContext(), Out);
|
mangleCXXVtable(ClassTy, getContext(), Out);
|
||||||
const char *Name = OutName.c_str();
|
const char *Name = OutName.c_str();
|
||||||
llvm::GlobalVariable::LinkageTypes linktype;
|
llvm::GlobalVariable::LinkageTypes linktype;
|
||||||
|
|
|
@ -121,8 +121,7 @@ static const TagType *VerifyFuncTypeComplete(const Type* T) {
|
||||||
/// UpdateCompletedType - When we find the full definition for a TagDecl,
|
/// UpdateCompletedType - When we find the full definition for a TagDecl,
|
||||||
/// replace the 'opaque' type we previously made for it if applicable.
|
/// replace the 'opaque' type we previously made for it if applicable.
|
||||||
void CodeGenTypes::UpdateCompletedType(const TagDecl *TD) {
|
void CodeGenTypes::UpdateCompletedType(const TagDecl *TD) {
|
||||||
const Type *Key =
|
const Type *Key = Context.getTagDeclType(TD).getTypePtr();
|
||||||
Context.getTagDeclType(const_cast<TagDecl*>(TD)).getTypePtr();
|
|
||||||
llvm::DenseMap<const Type*, llvm::PATypeHolder>::iterator TDTI =
|
llvm::DenseMap<const Type*, llvm::PATypeHolder>::iterator TDTI =
|
||||||
TagDeclTypes.find(Key);
|
TagDeclTypes.find(Key);
|
||||||
if (TDTI == TagDeclTypes.end()) return;
|
if (TDTI == TagDeclTypes.end()) return;
|
||||||
|
@ -395,7 +394,7 @@ const llvm::Type *CodeGenTypes::ConvertTagDeclType(const TagDecl *TD) {
|
||||||
// TagDecl's are not necessarily unique, instead use the (clang)
|
// TagDecl's are not necessarily unique, instead use the (clang)
|
||||||
// type connected to the decl.
|
// type connected to the decl.
|
||||||
const Type *Key =
|
const Type *Key =
|
||||||
Context.getTagDeclType(const_cast<TagDecl*>(TD)).getTypePtr();
|
Context.getTagDeclType(TD).getTypePtr();
|
||||||
llvm::DenseMap<const Type*, llvm::PATypeHolder>::iterator TDTI =
|
llvm::DenseMap<const Type*, llvm::PATypeHolder>::iterator TDTI =
|
||||||
TagDeclTypes.find(Key);
|
TagDeclTypes.find(Key);
|
||||||
|
|
||||||
|
@ -478,7 +477,7 @@ void CodeGenTypes::addBitFieldInfo(const FieldDecl *FD, unsigned FieldNo,
|
||||||
const CGRecordLayout *
|
const CGRecordLayout *
|
||||||
CodeGenTypes::getCGRecordLayout(const TagDecl *TD) const {
|
CodeGenTypes::getCGRecordLayout(const TagDecl *TD) const {
|
||||||
const Type *Key =
|
const Type *Key =
|
||||||
Context.getTagDeclType(const_cast<TagDecl*>(TD)).getTypePtr();
|
Context.getTagDeclType(TD).getTypePtr();
|
||||||
llvm::DenseMap<const Type*, CGRecordLayout *>::iterator I
|
llvm::DenseMap<const Type*, CGRecordLayout *>::iterator I
|
||||||
= CGRecordLayouts.find(Key);
|
= CGRecordLayouts.find(Key);
|
||||||
assert (I != CGRecordLayouts.end()
|
assert (I != CGRecordLayouts.end()
|
||||||
|
|
Загрузка…
Ссылка в новой задаче