SourceLocation SourceManager::normalize(const SourceLocation &aLoc) { SourceLocation loc = aLoc; while (loc.isInMacro()) { size_t loc_index; if (!findLocation(loc, &loc_index)) return SourceLocation(); loc = locations_[loc_index].getParent(); } return loc; }
void SourceManager::getTokenHistory(const SourceLocation &aLoc, TokenHistory *history) { SourceLocation loc = aLoc; while (loc.isSet()) { size_t loc_index; if (!findLocation(loc, &loc_index)) return; const LREntry &range = locations_[loc_index]; if (loc.isInMacro()) { history->macros.append(FullMacroRef(range.getMacro(), loc.offset() - range.id)); } else { history->files.append(fullSourceRef(range, loc)); } loc = range.getParent(); } }