diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2010-08-09 21:55:28 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2010-08-09 21:55:28 +0000 |
commit | 74c730ad1f6818b676b0bad46d806a9176950328 (patch) | |
tree | 5c18340b3ff50d40bbb77954d0b75ebd34550eb0 /lib/Sema/SemaCodeComplete.cpp | |
parent | 35cc9627340b15232139b3c43fcde5973e7fad30 (diff) |
- Make ObjCInterfaceDecl redeclarable, and create separate decl nodes for forward declarations and the definition.
- Eagerly create ObjCInterfaceTypes for declarations.
- The two above changes lead to a 0.5% increase in memory use and no speed regression when parsing Cocoa.h. On the other hand, now chained PCH works when there's a forward declaration in one PCH and the interface definition in another.
- Add HandleInterestingDecl to ASTConsumer. PCHReader passes the "interesting" decls it finds to this function instead of HandleTopLevelDecl. The default implementation forwards to HandleTopLevelDecl, but ASTUnit's handler for example ignores them. This fixes a potential crash when lazy loading of PCH data would cause ASTUnit's "top level" declaration collection to change while being iterated.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110610 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCodeComplete.cpp')
-rw-r--r-- | lib/Sema/SemaCodeComplete.cpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index 52ac8dd649..f12e1839e5 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/lib/Sema/SemaCodeComplete.cpp @@ -3748,20 +3748,28 @@ static void AddInterfaceResults(DeclContext *Ctx, DeclContext *CurContext, for (DeclContext::decl_iterator D = Ctx->decls_begin(), DEnd = Ctx->decls_end(); D != DEnd; ++D) { - // Record any interfaces we find. - if (ObjCInterfaceDecl *Class = dyn_cast<ObjCInterfaceDecl>(*D)) - if ((!OnlyForwardDeclarations || Class->isForwardDecl()) && - (!OnlyUnimplemented || !Class->getImplementation())) - Results.AddResult(Result(Class, 0), CurContext, 0, false); + // Record any interfaces we find. Forward declarations are never registered + // in the lexical contest, so if we're only looking for those, don't bother. + if (!OnlyForwardDeclarations) + if (ObjCInterfaceDecl *Class = dyn_cast<ObjCInterfaceDecl>(*D)) + if (!OnlyUnimplemented || !Class->getImplementation()) + Results.AddResult(Result(Class, 0), CurContext, 0, false); // 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, + C != CEnd; ++C) { + ObjCInterfaceDecl *IDecl = C->getInterface(); + ObjCInterfaceDecl *IDef = IDecl->getDefinition(); + // If there's a definition, and we're looking for everything, then we + // already added the decl in question above. + if (!OnlyForwardDeclarations && !OnlyUnimplemented && IDef) + continue; + if ((!OnlyForwardDeclarations || !IDef) && + (!OnlyUnimplemented || !IDef || !IDef->getImplementation())) + Results.AddResult(Result(IDecl, 0), CurContext, 0, false); + } } } } |