[cfe-dev] default instance variable visibility

Emerson Murphy-Hill emerson at apple.com
Tue Apr 29 11:23:49 PDT 2008


I noticed when clang parses objective-c interfaces, the default  
visibility for instance variables is private.  For example, in this code

@interface Bloo {
     int somevar;
}

somevar is reportedly private visibility, by getAccessControl on  
ObjCIvarDecl.  I believe that default visibility is supposed to be  
protected:

http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/ObjC.pdf

Here's a patch:

Index: ParseObjc.cpp
===================================================================
--- ParseObjc.cpp	(revision 50182)
+++ ParseObjc.cpp	(working copy)
@@ -758,7 +758,7 @@

    SourceLocation LBraceLoc = ConsumeBrace(); // the "{"

-  tok::ObjCKeywordKind visibility = tok::objc_private;
+  tok::ObjCKeywordKind visibility = tok::objc_protected;
    // While we still have something to read, read the instance  
variables.
    while (Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof)) {
      // Each iteration of this loop reads one objc-instance-variable- 
decl.

Cheers,

e
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20080429/240ddf8b/attachment.html>


More information about the cfe-dev mailing list