int getLineCount(clang::SourceRange sourceRange, const clang::SourceManager& sourceManager) { clang::SourceLocation startLocation = sourceRange.getBegin(); clang::SourceLocation endLocation = sourceRange.getEnd(); unsigned startLineNumber = sourceManager.getPresumedLineNumber(startLocation); unsigned endLineNumber = sourceManager.getPresumedLineNumber(endLocation); return endLineNumber - startLineNumber + 1; }
bool VisitDecl(clang::Decl *decl) { if (markedAsSuppress(decl, _rule)) { clang::SourceLocation startLocation = decl->getLocStart(); clang::SourceLocation endLocation = decl->getLocEnd(); unsigned startLineNumber = _sourceManager->getPresumedLineNumber(startLocation); unsigned endLineNumber = _sourceManager->getPresumedLineNumber(endLocation); _range.insert(std::make_pair(startLineNumber, endLineNumber)); } return true; }