Submitted by:
Reviewed by:
Fix a bozo bug in HandleDeclAttribute...only install a new type when appropriate.
Also changed setType/setUnderlyingType to return void.

llvm-svn: 39716
This commit is contained in:
Steve Naroff 2007-07-09 18:55:26 +00:00
parent 4ae0ac6a06
commit 4dddb6194b
2 changed files with 6 additions and 16 deletions

View File

@ -942,16 +942,14 @@ void Sema::HandleDeclAttribute(Decl *New, AttributeList *rawAttr) {
if (strcmp(rawAttr->getAttributeName()->getName(), "vector_size") == 0) {
if (ValueDecl *vDecl = dyn_cast<ValueDecl>(New)) {
QualType newType = HandleVectorTypeAttribute(vDecl->getType(), rawAttr);
// install the new vector type into the decl
QualType oldType = vDecl->setType(newType);
// FIXME: deal with memory management for oldType!
if (!newType.isNull()) // install the new vector type into the decl
vDecl->setType(newType);
}
if (TypedefDecl *tDecl = dyn_cast<TypedefDecl>(New)) {
QualType newType = HandleVectorTypeAttribute(tDecl->getUnderlyingType(),
rawAttr);
// install the new vector type into the decl
QualType oldType = tDecl->setUnderlyingType(newType);
// FIXME: deal with memory management for oldType!
if (!newType.isNull()) // install the new vector type into the decl
tDecl->setUnderlyingType(newType);
}
}
// FIXME: add other attributes...

View File

@ -128,11 +128,7 @@ protected:
Decl *PrevDecl) : Decl(DK, L, Id, PrevDecl), DeclType(T) {}
public:
QualType getType() const { return DeclType; }
QualType setType(QualType newType) {
QualType oldType = DeclType;
DeclType = newType;
return oldType;
}
void setType(QualType newType) { DeclType = newType; }
QualType getCanonicalType() const { return DeclType.getCanonicalType(); }
// Implement isa/cast/dyncast/etc.
@ -330,11 +326,7 @@ public:
: TypeDecl(Typedef, L, Id, PrevDecl), UnderlyingType(T) {}
QualType getUnderlyingType() const { return UnderlyingType; }
QualType setUnderlyingType(QualType newType) {
QualType oldType = UnderlyingType;
UnderlyingType = newType;
return oldType;
}
void setUnderlyingType(QualType newType) { UnderlyingType = newType; }
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return D->getKind() == Typedef; }