Make getDefaultSynthIvarName() a member of ObjCPropertyDecl.

llvm-svn: 164789
This commit is contained in:
Anna Zaks 2012-09-27 19:45:11 +00:00
parent 8c0dd36ede
commit 454477cd07
3 changed files with 15 additions and 11 deletions

View File

@ -1882,6 +1882,9 @@ public:
virtual SourceRange getSourceRange() const LLVM_READONLY { virtual SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(AtLoc, getLocation()); return SourceRange(AtLoc, getLocation());
} }
/// Get the default name of the synthesized ivar.
IdentifierInfo *getDefaultSynthIvarName(ASTContext &Ctx) const;
/// Lookup a property by name in the specified DeclContext. /// Lookup a property by name in the specified DeclContext.
static ObjCPropertyDecl *findPropertyDecl(const DeclContext *DC, static ObjCPropertyDecl *findPropertyDecl(const DeclContext *DC,

View File

@ -16,6 +16,7 @@
#include "clang/AST/Stmt.h" #include "clang/AST/Stmt.h"
#include "clang/AST/ASTMutationListener.h" #include "clang/AST/ASTMutationListener.h"
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
using namespace clang; using namespace clang;
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -93,6 +94,16 @@ ObjCPropertyDecl::findPropertyDecl(const DeclContext *DC,
return 0; return 0;
} }
IdentifierInfo *
ObjCPropertyDecl::getDefaultSynthIvarName(ASTContext &Ctx) const {
SmallString<128> ivarName;
{
llvm::raw_svector_ostream os(ivarName);
os << '_' << getIdentifier()->getName();
}
return &Ctx.Idents.get(ivarName.str());
}
/// FindPropertyDeclaration - Finds declaration of the property given its name /// FindPropertyDeclaration - Finds declaration of the property given its name
/// in 'PropertyId' and returns it. It returns 0, if not found. /// in 'PropertyId' and returns it. It returns 0, if not found.
ObjCPropertyDecl * ObjCPropertyDecl *

View File

@ -1617,16 +1617,6 @@ ObjCPropertyDecl *Sema::PropertyIfSetterOrGetter(NamedDecl *D) {
return 0; return 0;
} }
static IdentifierInfo * getDefaultSynthIvarName(ObjCPropertyDecl *Prop,
ASTContext &Ctx) {
SmallString<128> ivarName;
{
llvm::raw_svector_ostream os(ivarName);
os << '_' << Prop->getIdentifier()->getName();
}
return &Ctx.Idents.get(ivarName.str());
}
/// \brief Default synthesizes all properties which must be synthesized /// \brief Default synthesizes all properties which must be synthesized
/// in class's \@implementation. /// in class's \@implementation.
void Sema::DefaultSynthesizeProperties(Scope *S, ObjCImplDecl* IMPDecl, void Sema::DefaultSynthesizeProperties(Scope *S, ObjCImplDecl* IMPDecl,
@ -1675,7 +1665,7 @@ void Sema::DefaultSynthesizeProperties(Scope *S, ObjCImplDecl* IMPDecl,
ActOnPropertyImplDecl(S, SourceLocation(), SourceLocation(), ActOnPropertyImplDecl(S, SourceLocation(), SourceLocation(),
true, true,
/* property = */ Prop->getIdentifier(), /* property = */ Prop->getIdentifier(),
/* ivar = */ getDefaultSynthIvarName(Prop, Context), /* ivar = */ Prop->getDefaultSynthIvarName(Context),
Prop->getLocation())); Prop->getLocation()));
if (PIDecl) { if (PIDecl) {
Diag(Prop->getLocation(), diag::warn_missing_explicit_synthesis); Diag(Prop->getLocation(), diag::warn_missing_explicit_synthesis);