aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNAKAMURA Takumi <geek4civic@gmail.com>2012-11-19 00:51:37 +0000
committerNAKAMURA Takumi <geek4civic@gmail.com>2012-11-19 00:51:37 +0000
commit86256af6c8515077278d0a78f183fb6d322518ac (patch)
treeedce31094e0a65c3de9344e6e029551dbbe60179
parent898a7a298185c53a36e923f86fe3f938ebfea67f (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168295 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/RecursiveASTVisitor.h18
1 files changed, 6 insertions, 12 deletions
diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h
index f96e067978..cc622783a5 100644
--- a/include/clang/AST/RecursiveASTVisitor.h
+++ b/include/clang/AST/RecursiveASTVisitor.h
@@ -464,20 +464,15 @@ 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).
#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 @@ bool RecursiveASTVisitor<Derived>::dataTraverseNode(Stmt *S,
}
#undef DISPATCH_WALK
-#undef GCC_CAST
return true;
}