From: Anna Zaks Date: Thu, 27 Sep 2012 19:45:11 +0000 (+0000) Subject: Make getDefaultSynthIvarName() a member of ObjCPropertyDecl. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ad0ce53c8219456938405b84c5d13341a47e3d94;p=clang Make getDefaultSynthIvarName() a member of ObjCPropertyDecl. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164789 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index 9e0130ad16..a1a287118e 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -1882,6 +1882,9 @@ public: virtual SourceRange getSourceRange() const LLVM_READONLY { 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. static ObjCPropertyDecl *findPropertyDecl(const DeclContext *DC, diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index 4d48ad8e4f..d28a910d0a 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -16,6 +16,7 @@ #include "clang/AST/Stmt.h" #include "clang/AST/ASTMutationListener.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/SmallString.h" using namespace clang; //===----------------------------------------------------------------------===// @@ -93,6 +94,16 @@ ObjCPropertyDecl::findPropertyDecl(const DeclContext *DC, 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 /// in 'PropertyId' and returns it. It returns 0, if not found. ObjCPropertyDecl * diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index f51ec72399..f32376c516 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -1617,16 +1617,6 @@ ObjCPropertyDecl *Sema::PropertyIfSetterOrGetter(NamedDecl *D) { 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 /// in class's \@implementation. void Sema::DefaultSynthesizeProperties(Scope *S, ObjCImplDecl* IMPDecl, @@ -1675,7 +1665,7 @@ void Sema::DefaultSynthesizeProperties(Scope *S, ObjCImplDecl* IMPDecl, ActOnPropertyImplDecl(S, SourceLocation(), SourceLocation(), true, /* property = */ Prop->getIdentifier(), - /* ivar = */ getDefaultSynthIvarName(Prop, Context), + /* ivar = */ Prop->getDefaultSynthIvarName(Context), Prop->getLocation())); if (PIDecl) { Diag(Prop->getLocation(), diag::warn_missing_explicit_synthesis);