diff options
author | Chris Lattner <sabre@nondot.org> | 2009-03-28 19:18:32 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-03-28 19:18:32 +0000 |
commit | b28317a8e5e0e2953d1e5406d753d6c3c7f1e7d2 (patch) | |
tree | de590dbcd3bf708b1f203f27df4eccef59f0235a /lib/Sema/SemaLookup.cpp | |
parent | 8054e25b5116e331a2ee4203f5fae2bee1c3cc46 (diff) |
Introduce a new OpaquePtr<N> struct type, which is a simple POD wrapper for a
pointer. Its purpose in life is to be a glorified void*, but which does not
implicitly convert to void* or other OpaquePtr's with a different UID.
Introduce Action::DeclPtrTy which is a typedef for OpaquePtr<0>. Change the
entire parser/sema interface to use DeclPtrTy instead of DeclTy*. This
makes the C++ compiler enforce that these aren't convertible to other opaque
types.
We should also convert ExprTy, StmtTy, TypeTy, AttrTy, BaseTy, etc,
but I don't plan to do that in the short term.
The one outstanding known problem with this patch is that we lose the
bitmangling optimization where ActionResult<DeclPtrTy> doesn't know how to
bitmangle the success bit into the low bit of DeclPtrTy. I will rectify
this with a subsequent patch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67952 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaLookup.cpp')
-rw-r--r-- | lib/Sema/SemaLookup.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index 770f9301e6..69bd5602d3 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -84,12 +84,11 @@ static void AddScopeUsingDirectives(Scope *S, UsingDirectivesTy &UDirs) { AddNamespaceUsingDirectives(Ctx, UDirs, /*ref*/ VisitedNS); } else { - Scope::udir_iterator - I = S->using_directives_begin(), - End = S->using_directives_end(); + Scope::udir_iterator I = S->using_directives_begin(), + End = S->using_directives_end(); for (; I != End; ++I) { - UsingDirectiveDecl * UD = static_cast<UsingDirectiveDecl*>(*I); + UsingDirectiveDecl *UD = I->getAs<UsingDirectiveDecl>(); UDirs.push_back(UD); std::push_heap(UDirs.begin(), UDirs.end(), UsingDirAncestorCompare()); @@ -575,7 +574,7 @@ Sema::CppLookupName(Scope *S, DeclarationName Name, // for (; S && !isNamespaceOrTranslationUnitScope(S); S = S->getParent()) { // Check whether the IdResolver has anything in this scope. - for (; I != IEnd && S->isDeclScope(*I); ++I) { + for (; I != IEnd && S->isDeclScope(DeclPtrTy::make(*I)); ++I) { if (isAcceptableLookupResult(*I, NameKind, IDNS)) { // We found something. Look for anything else in our scope // with this same name and in an acceptable identifier @@ -583,7 +582,7 @@ Sema::CppLookupName(Scope *S, DeclarationName Name, // need to. IdentifierResolver::iterator LastI = I; for (++LastI; LastI != IEnd; ++LastI) { - if (!S->isDeclScope(*LastI)) + if (!S->isDeclScope(DeclPtrTy::make(*LastI))) break; } LookupResult Result = @@ -666,7 +665,7 @@ Sema::CppLookupName(Scope *S, DeclarationName Name, "We should have been looking only at file context here already."); // Check whether the IdResolver has anything in this scope. - for (; I != IEnd && S->isDeclScope(*I); ++I) { + for (; I != IEnd && S->isDeclScope(DeclPtrTy::make(*I)); ++I) { if (isAcceptableLookupResult(*I, NameKind, IDNS)) { // We found something. Look for anything else in our scope // with this same name and in an acceptable identifier @@ -674,7 +673,7 @@ Sema::CppLookupName(Scope *S, DeclarationName Name, // need to. IdentifierResolver::iterator LastI = I; for (++LastI; LastI != IEnd; ++LastI) { - if (!S->isDeclScope(*LastI)) + if (!S->isDeclScope(DeclPtrTy::make(*LastI))) break; } @@ -790,7 +789,7 @@ Sema::LookupName(Scope *S, DeclarationName Name, LookupNameKind NameKind, if (NameKind == LookupRedeclarationWithLinkage) { // Determine whether this (or a previous) declaration is // out-of-scope. - if (!LeftStartingScope && !S->isDeclScope(*I)) + if (!LeftStartingScope && !S->isDeclScope(DeclPtrTy::make(*I))) LeftStartingScope = true; // If we found something outside of our starting scope that @@ -804,14 +803,15 @@ Sema::LookupName(Scope *S, DeclarationName Name, LookupNameKind NameKind, // might have a set of overloaded functions. // Figure out what scope the identifier is in. - while (!(S->getFlags() & Scope::DeclScope) || !S->isDeclScope(*I)) + while (!(S->getFlags() & Scope::DeclScope) || + !S->isDeclScope(DeclPtrTy::make(*I))) S = S->getParent(); // Find the last declaration in this scope (with the same // name, naturally). IdentifierResolver::iterator LastI = I; for (++LastI; LastI != IEnd; ++LastI) { - if (!S->isDeclScope(*LastI)) + if (!S->isDeclScope(DeclPtrTy::make(*LastI))) break; } |