summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2011-08-27 20:50:59 +0000
committerFariborz Jahanian <fjahanian@apple.com>2011-08-27 20:50:59 +0000
commit3a039e339f1fc8a134b1d55cd6c4c6d387a81967 (patch)
treeabcdea7eb4975061cca240f4a8b44364018babc7 /clang/lib/Sema
parente83797c3aa94201e89873a5108ebeb6c31d118e5 (diff)
downloadbcm5719-llvm-3a039e339f1fc8a134b1d55cd6c4c6d387a81967.tar.gz
bcm5719-llvm-3a039e339f1fc8a134b1d55cd6c4c6d387a81967.zip
objective-c: Treat top-level objective-c declarations
, such as list of forward @class decls, in a DeclGroup node. Deal with its consequence throught clang. This is in preparation for more Sema work ahead. // rdar://8843851. Feel free to reverse if it breaks something important and I am unavailable. llvm-svn: 138709
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaCodeComplete.cpp11
-rw-r--r--clang/lib/Sema/SemaDeclObjC.cpp22
-rw-r--r--clang/lib/Sema/SemaLookup.cpp5
3 files changed, 15 insertions, 23 deletions
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp
index ef54fbcad88..5e19148c38d 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -5405,12 +5405,11 @@ static void AddInterfaceResults(DeclContext *Ctx, DeclContext *CurContext,
// Record any forward-declared interfaces we find.
if (ObjCClassDecl *Forward = dyn_cast<ObjCClassDecl>(*D)) {
- for (ObjCClassDecl::iterator C = Forward->begin(), CEnd = Forward->end();
- C != CEnd; ++C)
- if ((!OnlyForwardDeclarations || C->getInterface()->isForwardDecl()) &&
- (!OnlyUnimplemented || !C->getInterface()->getImplementation()))
- Results.AddResult(Result(C->getInterface(), 0), CurContext,
- 0, false);
+ ObjCInterfaceDecl *IDecl = Forward->getForwardInterfaceDecl();
+ if ((!OnlyForwardDeclarations || IDecl->isForwardDecl()) &&
+ (!OnlyUnimplemented || !IDecl->getImplementation()))
+ Results.AddResult(Result(IDecl, 0), CurContext,
+ 0, false);
}
}
}
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp
index af14aa4f84f..c7d3590fb85 100644
--- a/clang/lib/Sema/SemaDeclObjC.cpp
+++ b/clang/lib/Sema/SemaDeclObjC.cpp
@@ -1657,13 +1657,12 @@ void Sema::ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl* IMPDecl,
}
/// ActOnForwardClassDeclaration -
-Decl *
+Sema::DeclGroupPtrTy
Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
IdentifierInfo **IdentList,
SourceLocation *IdentLocs,
unsigned NumElts) {
- SmallVector<ObjCInterfaceDecl*, 32> Interfaces;
-
+ SmallVector<Decl *, 8> DeclsInGroup;
for (unsigned i = 0; i != NumElts; ++i) {
// Check for another declaration kind with the same name.
NamedDecl *PrevDecl
@@ -1708,17 +1707,14 @@ Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
PushOnScopeChains(IDecl, TUScope, false);
CurContext->makeDeclVisibleInContext(IDecl, true);
}
-
- Interfaces.push_back(IDecl);
+ ObjCClassDecl *CDecl = ObjCClassDecl::Create(Context, CurContext, AtClassLoc,
+ IDecl, IdentLocs[i]);
+ CurContext->addDecl(CDecl);
+ CheckObjCDeclScope(CDecl);
+ DeclsInGroup.push_back(CDecl);
}
-
- assert(Interfaces.size() == NumElts);
- ObjCClassDecl *CDecl = ObjCClassDecl::Create(Context, CurContext, AtClassLoc,
- Interfaces.data(), IdentLocs,
- Interfaces.size());
- CurContext->addDecl(CDecl);
- CheckObjCDeclScope(CDecl);
- return CDecl;
+
+ return BuildDeclaratorGroup(DeclsInGroup.data(), DeclsInGroup.size(), false);
}
static bool tryMatchRecordTypes(ASTContext &Context,
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index 240eb5f1bf7..7df049815a5 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -2670,14 +2670,11 @@ static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result,
}
}
} else if (ObjCClassDecl *Class = dyn_cast<ObjCClassDecl>(*D)) {
- for (ObjCClassDecl::iterator I = Class->begin(), IEnd = Class->end();
- I != IEnd; ++I) {
- ObjCInterfaceDecl *IFace = I->getInterface();
+ ObjCInterfaceDecl *IFace = Class->getForwardInterfaceDecl();
if (Result.isAcceptableDecl(IFace)) {
Consumer.FoundDecl(IFace, Visited.checkHidden(IFace), InBaseClass);
Visited.add(IFace);
}
- }
}
// Visit transparent contexts and inline namespaces inside this context.
OpenPOWER on IntegriCloud