static inline void allImpl(const SymbolMap &map, const Location &loc, const CursorInfo &info, SymbolMap &out, Mode mode, CXCursorKind kind) { if (out.contains(loc)) return; out[loc] = info; typedef SymbolMap (CursorInfo::*Function)(const SymbolMap &map) const; const SymbolMap targets = info.targetInfos(map); for (SymbolMap::const_iterator t = targets.begin(); t != targets.end(); ++t) { bool ok = false; switch (mode) { case VirtualRefs: case NormalRefs: ok = (t->second.kind == kind); break; case ClassRefs: ok = (t->second.isClass() || t->second.kind == CXCursor_Destructor || t->second.kind == CXCursor_Constructor); break; } if (ok) allImpl(map, t->first, t->second, out, mode, kind); } const SymbolMap refs = info.referenceInfos(map); for (SymbolMap::const_iterator r = refs.begin(); r != refs.end(); ++r) { switch (mode) { case NormalRefs: out[r->first] = r->second; break; case VirtualRefs: if (r->second.kind == kind) { allImpl(map, r->first, r->second, out, mode, kind); } else { out[r->first] = r->second; } break; case ClassRefs: if (info.isClass()) // for class/struct we want the references inserted directly regardless and also recursed out[r->first] = r->second; if (r->second.isClass() || r->second.kind == CXCursor_Destructor || r->second.kind == CXCursor_Constructor) { // if is a constructor/destructor/class reference we want to recurse it allImpl(map, r->first, r->second, out, mode, kind); } } } }
static inline void allImpl(const SymbolMap &map, const Location &loc, const std::shared_ptr<CursorInfo> &info, SymbolMap &out, Mode mode, unsigned kind) { if (out.contains(loc)) return; out[loc] = info; const SymbolMap targets = info->targetInfos(map); for (auto t = targets.begin(); t != targets.end(); ++t) { bool ok = false; switch (mode) { case VirtualRefs: case NormalRefs: ok = (t->second->kind == kind); break; case ClassRefs: ok = (t->second->isClass() || t->second->kind == CXCursor_Destructor || t->second->kind == CXCursor_Constructor); break; } if (ok) allImpl(map, t->first, t->second, out, mode, kind); } const SymbolMap refs = info->referenceInfos(map); for (auto r = refs.begin(); r != refs.end(); ++r) { switch (mode) { case NormalRefs: out[r->first] = r->second; break; case VirtualRefs: if (r->second->kind == kind) { allImpl(map, r->first, r->second, out, mode, kind); } else { out[r->first] = r->second; } break; case ClassRefs: if (info->isClass()) // for class/struct we want the references inserted directly regardless and also recursed out[r->first] = r->second; if (r->second->isClass() || r->second->kind == CXCursor_Destructor || r->second->kind == CXCursor_Constructor) { // if is a constructor/destructor/class reference we want to recurse it allImpl(map, r->first, r->second, out, mode, kind); } } } }