diff --git a/clang/Sema/SemaDecl.cpp b/clang/Sema/SemaDecl.cpp index c86175dbaceb96c301d32c6945a9be8b273083de..bef5c674296d95eb000f4d7ca08f84d8d5618547 100644 --- a/clang/Sema/SemaDecl.cpp +++ b/clang/Sema/SemaDecl.cpp @@ -942,16 +942,14 @@ void Sema::HandleDeclAttribute(Decl *New, AttributeList *rawAttr) { if (strcmp(rawAttr->getAttributeName()->getName(), "vector_size") == 0) { if (ValueDecl *vDecl = dyn_cast(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(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... diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index 063f98347723676f906e0232e3fec604ba230459..2d3b01d3ced04915f2ff36e501da5d80c0bb5dfc 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -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; }