[cfe-commits] r96479 - in /cfe/trunk: lib/Sema/SemaDeclObjC.cpp test/SemaObjC/stand-alone-implementation.m
Douglas Gregor
dgregor at apple.com
Wed Feb 17 09:21:22 PST 2010
On Feb 17, 2010, at 9:00 AM, Fariborz Jahanian wrote:
> Author: fjahanian
> Date: Wed Feb 17 11:00:07 2010
> New Revision: 96479
>
> URL: http://llvm.org/viewvc/llvm-project?rev=96479&view=rev
> Log:
> Allow for declaration and use of ivars in a stand-alone
> implementation (toward radar 7547942).
>
>
> Added:
> cfe/trunk/test/SemaObjC/stand-alone-implementation.m
> Modified:
> cfe/trunk/lib/Sema/SemaDeclObjC.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=96479&r1=96478&r2=96479&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Wed Feb 17 11:00:07 2010
> @@ -823,6 +823,12 @@
> if (IDecl->isImplicitInterfaceDecl()) {
> IDecl->setIVarList(ivars, numIvars, Context);
> IDecl->setLocEnd(RBrace);
> + // Add ivar's to class's DeclContext.
> + for (unsigned i = 0, e = numIvars; i != e; ++i) {
> + ivars[i]->setLexicalDeclContext(IDecl);
> + IDecl->addDecl(ivars[i]);
> + }
By doing this, we lose track of whether the ivars came from the @implementation or the @interface. An alternative approach would be for the ivars to go into the @implementation's context (that's its lexical context), then to use
IDecl->makeDeclVisibleInContext(ivars[i], false);
so that name lookup will find those ivars when it searches in the interface. That way, we maintain source fidelity and still get the semantics we want.
- Doug
More information about the cfe-commits
mailing list