summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-07-23 18:04:17 +0000
committerTed Kremenek <kremenek@apple.com>2008-07-23 18:04:17 +0000
commit73295fab89d1b9756992abd5a054dc854911063c (patch)
tree19073ddda9f303161b5240ed2b7a6d5cb1b93667 /clang/lib
parent7de7fd030586bfa7ec4e6c3252c767e2b212fb86 (diff)
downloadbcm5719-llvm-73295fab89d1b9756992abd5a054dc854911063c.tar.gz
bcm5719-llvm-73295fab89d1b9756992abd5a054dc854911063c.zip
When constructing an ObjCIvarDecl object in Sema, provide its visibility up front instead of setting it afterwards.
This change also fixes a subtle bug where the access control of an ivar would be initialized to garbage if we didn't have an explicit visibility specifier (e.g., @private). llvm-svn: 53955
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/DeclObjC.cpp5
-rw-r--r--clang/lib/Sema/SemaDecl.cpp13
2 files changed, 12 insertions, 6 deletions
diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp
index 4b798474f62..9ba6e86cf09 100644
--- a/clang/lib/AST/DeclObjC.cpp
+++ b/clang/lib/AST/DeclObjC.cpp
@@ -87,9 +87,10 @@ void ObjCInterfaceDecl::Destroy(ASTContext& C) {
ObjCIvarDecl *ObjCIvarDecl::Create(ASTContext &C, SourceLocation L,
- IdentifierInfo *Id, QualType T, Expr *BW) {
+ IdentifierInfo *Id, QualType T,
+ AccessControl ac, Expr *BW) {
void *Mem = C.getAllocator().Allocate<ObjCIvarDecl>();
- return new (Mem) ObjCIvarDecl(L, Id, T, BW);
+ return new (Mem) ObjCIvarDecl(L, Id, T, ac, BW);
}
ObjCProtocolDecl *ObjCProtocolDecl::Create(ASTContext &C,
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 7753a757961..25d4ad5751b 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -1947,16 +1947,21 @@ Sema::DeclTy *Sema::ActOnIvar(Scope *S,
InvalidDecl = true;
}
- ObjCIvarDecl *NewID = ObjCIvarDecl::Create(Context, Loc, II, T,
+ // Get the visibility (access control) for this ivar.
+ ObjCIvarDecl::AccessControl ac =
+ Visibility != tok::objc_not_keyword ? TranslateIvarVisibility(Visibility)
+ : ObjCIvarDecl::None;
+
+ // Construct the decl.
+ ObjCIvarDecl *NewID = ObjCIvarDecl::Create(Context, Loc, II, T, ac,
(Expr *)BitfieldWidth);
+ // Process attributes attached to the ivar.
ProcessDeclAttributes(NewID, D);
if (D.getInvalidType() || InvalidDecl)
NewID->setInvalidDecl();
- // If we have visibility info, make sure the AST is set accordingly.
- if (Visibility != tok::objc_not_keyword)
- NewID->setAccessControl(TranslateIvarVisibility(Visibility));
+
return NewID;
}
OpenPOWER on IntegriCloud