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
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index 9662c43..7e72a84 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -231,10 +231,10 @@
     // Note: we traverse the scope's list of declarations rather than
     // the DeclContext's list, because we only want to see the most
     // recent declaration of each identifier.
-    for (Scope::decl_iterator I = TUScope->decl_begin(), 
-                           IEnd = TUScope->decl_end();
+    for (Scope::decl_iterator I = TUScope->decl_begin(),
+         IEnd = TUScope->decl_end();
          I != IEnd; ++I) {
-      Decl *D = static_cast<Decl *>(*I);
+      Decl *D = (*I).getAs<Decl>();
       if (D->isInvalidDecl())
         continue;