[cfe-commits] r168295 - /cfe/trunk/include/clang/AST/RecursiveASTVisitor.h

NAKAMURA Takumi geek4civic at gmail.com
Sun Nov 18 16:51:37 PST 2012


Author: chapuni
Date: Sun Nov 18 18:51:37 2012
New Revision: 168295

URL: http://llvm.org/viewvc/llvm-project?rev=168295&view=rev
Log:
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.

Modified:
    cfe/trunk/include/clang/AST/RecursiveASTVisitor.h

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=168295&r1=168294&r2=168295&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Sun Nov 18 18:51:37 2012
@@ -464,20 +464,15 @@
 bool RecursiveASTVisitor<Derived>::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<CLASS*>(VAR)); \
+  { \
+    bool (Derived::*DerivedFn)(CLASS*) = &Derived::Traverse##NAME; \
+    bool (Derived::*BaseFn)(CLASS*) = &RecursiveASTVisitor::Traverse##NAME; \
+    if (DerivedFn == BaseFn) \
+      return getDerived().WalkUpFrom##NAME(static_cast<CLASS*>(VAR)); \
+  } \
   EnqueueChildren = false; \
   return getDerived().Traverse##NAME(static_cast<CLASS*>(VAR));
 
@@ -516,7 +511,6 @@
   }
 
 #undef DISPATCH_WALK
-#undef GCC_CAST
 
   return true;
 }





More information about the cfe-commits mailing list