From: Douglas Gregor Date: Tue, 17 Jul 2012 23:07:44 +0000 (+0000) Subject: Eliminating the GCC_CAST hack, take two. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d47bc514d49e3707063dc30b166d28e954b338f1;p=clang Eliminating the GCC_CAST hack, take two. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160404 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h index 2e56a486f3..b30b178807 100644 --- a/include/clang/AST/RecursiveASTVisitor.h +++ b/include/clang/AST/RecursiveASTVisitor.h @@ -464,19 +464,12 @@ template bool RecursiveASTVisitor::dataTraverseNode(Stmt *S, bool &EnqueueChildren) { -// The cast for DISPATCH_WALK is needed for older versions of g++, but causes -// problems for MSVC. So we'll skip the cast entirely for MSVC. -#if defined(_MSC_VER) - #define GCC_CAST(CLASS) -#else - #define GCC_CAST(CLASS) (bool (RecursiveASTVisitor::*)(CLASS*)) -#endif - // Dispatch to the corresponding WalkUpFrom* function only if the derived // class didn't override Traverse* (and thus the traversal is trivial). #define DISPATCH_WALK(NAME, CLASS, VAR) \ - if (&RecursiveASTVisitor::Traverse##NAME == \ - GCC_CAST(CLASS)&Derived::Traverse##NAME) \ + if (bool (Derived::*DerivedFn)(CLASS*) = &Derived::Traverse##NAME) \ + if (bool (Derived::*BaseFn)(CLASS*) = &RecursiveASTVisitor::Traverse##NAME)\ + if (DerivedFn == BaseFn) \ return getDerived().WalkUpFrom##NAME(static_cast(VAR)); \ EnqueueChildren = false; \ return getDerived().Traverse##NAME(static_cast(VAR)); @@ -516,7 +509,6 @@ bool RecursiveASTVisitor::dataTraverseNode(Stmt *S, } #undef DISPATCH_WALK -#undef GCC_CAST return true; }