Remove unneeded EncodingRecordTypes argument to getObjCEncodingForType.

llvm-svn: 57716
This commit is contained in:
Daniel Dunbar 2008-10-17 20:21:44 +00:00
parent aadf7414b2
commit fc1066db81
6 changed files with 16 additions and 44 deletions

View File

@ -57,7 +57,6 @@ namespace {
llvm::DenseMap<ObjCMethodDecl*, std::string> MethodInternalNames;
llvm::SmallVector<Stmt *, 32> Stmts;
llvm::SmallVector<int, 8> ObjCBcLabelNo;
llvm::SmallVector<const RecordType *, 8> EncodingRecordTypes;
unsigned NumObjCStringLiterals;
@ -1564,8 +1563,7 @@ Stmt *RewriteObjC::RewriteAtEncode(ObjCEncodeExpr *Exp) {
// Create a new string expression.
QualType StrType = Context->getPointerType(Context->CharTy);
std::string StrEncoding;
Context->getObjCEncodingForType(Exp->getEncodedType(), StrEncoding,
EncodingRecordTypes);
Context->getObjCEncodingForType(Exp->getEncodedType(), StrEncoding);
Expr *Replacement = new StringLiteral(StrEncoding.c_str(),
StrEncoding.length(), false, StrType,
SourceLocation(), SourceLocation());
@ -2962,8 +2960,7 @@ void RewriteObjC::RewriteObjCClassMetaData(ObjCImplementationDecl *IDecl,
Result += (*IVI)->getName();
Result += "\", \"";
std::string StrEncoding;
Context->getObjCEncodingForType((*IVI)->getType(), StrEncoding,
EncodingRecordTypes);
Context->getObjCEncodingForType((*IVI)->getType(), StrEncoding);
Result += StrEncoding;
Result += "\", ";
SynthesizeIvarOffsetComputation(IDecl, *IVI, Result);
@ -2973,8 +2970,7 @@ void RewriteObjC::RewriteObjCClassMetaData(ObjCImplementationDecl *IDecl,
Result += (*IVI)->getName();
Result += "\", \"";
std::string StrEncoding;
Context->getObjCEncodingForType((*IVI)->getType(), StrEncoding,
EncodingRecordTypes);
Context->getObjCEncodingForType((*IVI)->getType(), StrEncoding);
Result += StrEncoding;
Result += "\", ";
SynthesizeIvarOffsetComputation(IDecl, (*IVI), Result);

View File

@ -68,8 +68,6 @@ class ASTContext {
llvm::DenseMap<const ObjCInterfaceDecl*,
const ASTRecordLayout*> ASTObjCInterfaces;
llvm::SmallVector<const RecordType *, 8> EncodingRecordTypes;
/// BuiltinVaListType - built-in va list type.
/// This is initially null and set by Sema::LazilyCreateBuiltin when
/// a builtin that takes a valist is encountered.
@ -277,7 +275,6 @@ public:
/// given type into \arg S. If \arg NameFields is specified then
/// record field names are also encoded.
void getObjCEncodingForType(QualType t, std::string &S,
llvm::SmallVector<const RecordType*,8> &RT,
bool NameFields=false) const;
// Put the string version of type qualifiers into S.
@ -481,7 +478,6 @@ private:
void getObjCEncodingForTypeImpl(QualType t, std::string &S,
bool ExpandPointedToStructures,
bool ExpandStructures,
llvm::SmallVector<const RecordType*,8> &RT,
bool NameFields) const;
};

View File

@ -1474,7 +1474,7 @@ void ASTContext::getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl,
// Encode type qualifer, 'in', 'inout', etc. for the return type.
getObjCEncodingForTypeQualifier(Decl->getObjCDeclQualifier(), S);
// Encode result type.
getObjCEncodingForType(Decl->getResultType(), S, EncodingRecordTypes);
getObjCEncodingForType(Decl->getResultType(), S);
// Compute size of all parameters.
// Start with computing size of a pointer in number of bytes.
// FIXME: There might(should) be a better way of doing this computation!
@ -1502,7 +1502,7 @@ void ASTContext::getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl,
// 'in', 'inout', etc.
getObjCEncodingForTypeQualifier(
Decl->getParamDecl(i)->getObjCDeclQualifier(), S);
getObjCEncodingForType(PType, S, EncodingRecordTypes);
getObjCEncodingForType(PType, S);
S += llvm::utostr(ParmOffset);
ParmOffset += getObjCEncodingTypeSize(PType);
}
@ -1557,7 +1557,7 @@ void ASTContext::getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD,
// Encode result type.
// FIXME: GCC uses a generating_property_type_encoding mode during
// this part. Investigate.
getObjCEncodingForType(PD->getType(), S, EncodingRecordTypes);
getObjCEncodingForType(PD->getType(), S);
if (PD->isReadOnly()) {
S += ",R";
@ -1594,19 +1594,17 @@ void ASTContext::getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD,
}
void ASTContext::getObjCEncodingForType(QualType T, std::string& S,
llvm::SmallVector<const RecordType*,8> &ERType,
bool NameFields) const {
// We follow the behavior of gcc, expanding structures which are
// directly pointed to, and expanding embedded structures. Note that
// these rules are sufficient to prevent recursive encoding of the
// same type.
getObjCEncodingForTypeImpl(T, S, true, true, ERType, NameFields);
getObjCEncodingForTypeImpl(T, S, true, true, NameFields);
}
void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
bool ExpandPointedToStructures,
bool ExpandStructures,
llvm::SmallVector<const RecordType*,8> &ERType,
bool NameFields) const {
if (const BuiltinType *BT = T->getAsBuiltinType()) {
char encoding;
@ -1637,7 +1635,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
// Treat id<P...> same as 'id' for encoding purposes.
return getObjCEncodingForTypeImpl(getObjCIdType(), S,
ExpandPointedToStructures,
ExpandStructures, ERType, NameFields);
ExpandStructures, NameFields);
}
else if (const PointerType *PT = T->getAsPointerType()) {
QualType PointeeTy = PT->getPointeeType();
@ -1664,7 +1662,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
S += '^';
getObjCEncodingForTypeImpl(PT->getPointeeType(), S,
false, ExpandPointedToStructures,
ERType, NameFields);
NameFields);
} else if (const ArrayType *AT =
// Ignore type qualifiers etc.
dyn_cast<ArrayType>(T->getCanonicalTypeInternal())) {
@ -1676,7 +1674,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
assert(0 && "Unhandled array type!");
getObjCEncodingForTypeImpl(AT->getElementType(), S,
false, ExpandStructures, ERType, NameFields);
false, ExpandStructures, NameFields);
S += ']';
} else if (T->getAsFunctionType()) {
S += '?';
@ -1689,14 +1687,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
} else {
S += '?';
}
bool found = false;
for (unsigned i = 0, e = ERType.size(); i != e; ++i)
if (ERType[i] == RTy) {
found = true;
break;
}
if (!found && ExpandStructures) {
ERType.push_back(RTy);
if (ExpandStructures) {
S += '=';
for (int i = 0; i < RDecl->getNumMembers(); i++) {
FieldDecl *FD = RDecl->getMember(i);
@ -1716,12 +1707,9 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
S += 'b';
S += llvm::utostr(N);
} else {
getObjCEncodingForTypeImpl(FD->getType(), S, false, true,
ERType, NameFields);
getObjCEncodingForTypeImpl(FD->getType(), S, false, true, NameFields);
}
}
assert(ERType.back() == RTy && "Record Type stack mismatch.");
ERType.pop_back();
}
S += RDecl->isUnion() ? ')' : '}';
} else if (T->isEnumeralType()) {

View File

@ -1148,9 +1148,7 @@ Value *ScalarExprEmitter::VisitVAArgExpr(VAArgExpr *VE) {
Value *ScalarExprEmitter::VisitObjCEncodeExpr(const ObjCEncodeExpr *E) {
std::string str;
llvm::SmallVector<const RecordType *, 8> EncodingRecordTypes;
CGF.getContext().getObjCEncodingForType(E->getEncodedType(), str,
EncodingRecordTypes);
CGF.getContext().getObjCEncodingForType(E->getEncodedType(), str);
llvm::Constant *C = llvm::ConstantArray::get(str);
C = new llvm::GlobalVariable(C->getType(), true,

View File

@ -707,9 +707,7 @@ void CGObjCGNU::GenerateClass(const ObjCImplementationDecl *OID) {
IvarNames.push_back(CGM.GetAddrOfConstantCString((*iter)->getName()));
// Get the type encoding for this ivar
std::string TypeStr;
llvm::SmallVector<const RecordType *, 8> EncodingRecordTypes;
Context.getObjCEncodingForType((*iter)->getType(), TypeStr,
EncodingRecordTypes);
Context.getObjCEncodingForType((*iter)->getType(), TypeStr);
IvarTypes.push_back(CGM.GetAddrOfConstantCString(TypeStr));
// Get the offset
int offset =

View File

@ -1268,15 +1268,11 @@ llvm::Constant *CGObjCMac::EmitIvarList(const ObjCImplementationDecl *ID,
unsigned Offset =
Layout->getElementOffset(CGM.getTypes().getLLVMFieldNo(V));
std::string TypeStr;
llvm::SmallVector<const RecordType *, 8> EncodingRecordTypes;
Ivar[0] = GetMethodVarName(V->getIdentifier());
CGM.getContext().getObjCEncodingForType(V->getType(), TypeStr,
EncodingRecordTypes,
true);
CGM.getContext().getObjCEncodingForType(V->getType(), TypeStr, true);
Ivar[1] = GetMethodVarType(TypeStr);
Ivar[2] = llvm::ConstantInt::get(ObjCTypes.IntTy, Offset);
Ivars.push_back(llvm::ConstantStruct::get(ObjCTypes.IvarTy,
Ivar));
Ivars.push_back(llvm::ConstantStruct::get(ObjCTypes.IvarTy, Ivar));
}
// Return null for empty list.