From c59776d1fe6cf3015bd6dc2d7a84e276cda1b5dd Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Mon, 19 Nov 2012 00:51:37 +0000 Subject: [PATCH] RecursiveASTVisitor.h: Rework Doug's r160404, "Eliminating the GCC_CAST hack, take two." With this, ARCMT tests would not crash on certain hosts with g++ -O2, eg. cygwin g++-4.5.3. r160404 crashed mingw32-g++-4.4.0. I guess method's pointer in conditional expression could not be handled. llvm-svn: 168295 --- clang/include/clang/AST/RecursiveASTVisitor.h | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h index f96e067..cc62278 100644 --- a/clang/include/clang/AST/RecursiveASTVisitor.h +++ b/clang/include/clang/AST/RecursiveASTVisitor.h @@ -464,20 +464,15 @@ 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) \ - return getDerived().WalkUpFrom##NAME(static_cast(VAR)); \ + { \ + bool (Derived::*DerivedFn)(CLASS*) = &Derived::Traverse##NAME; \ + 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 +511,6 @@ bool RecursiveASTVisitor::dataTraverseNode(Stmt *S, } #undef DISPATCH_WALK -#undef GCC_CAST return true; } -- 2.7.4