]> granicus.if.org Git - clang/commitdiff
Fixing an MSVC warning -- the compiler did not like the cast added to work around...
authorAaron Ballman <aaron@aaronballman.com>
Mon, 16 Jul 2012 15:45:33 +0000 (15:45 +0000)
committerAaron Ballman <aaron@aaronballman.com>
Mon, 16 Jul 2012 15:45:33 +0000 (15:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160281 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/RecursiveASTVisitor.h

index 1a61255f04744677f5f8c63fe0c5dc4e7227879f..2e56a486f3d0bb2432b21fa04ddb5296d54a12cc 100644 (file)
@@ -464,12 +464,19 @@ template<typename Derived>
 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).
-  // The cast here is necessary to work around a bug in old versions of g++.
 #define DISPATCH_WALK(NAME, CLASS, VAR) \
   if (&RecursiveASTVisitor::Traverse##NAME == \
-      (bool (RecursiveASTVisitor::*)(CLASS*))&Derived::Traverse##NAME) \
+      GCC_CAST(CLASS)&Derived::Traverse##NAME) \
     return getDerived().WalkUpFrom##NAME(static_cast<CLASS*>(VAR)); \
   EnqueueChildren = false; \
   return getDerived().Traverse##NAME(static_cast<CLASS*>(VAR));
@@ -509,6 +516,7 @@ bool RecursiveASTVisitor<Derived>::dataTraverseNode(Stmt *S,
   }
 
 #undef DISPATCH_WALK
+#undef GCC_CAST
 
   return true;
 }