| 819 | } |
| 820 | |
| 821 | void Annotator::annotateSourceRange(clang::SourceRange range, std::string tag, std::string attributes) |
| 822 | { |
| 823 | clang::SourceManager &sm = getSourceMgr(); |
| 824 | if (!range.getBegin().isFileID()) { |
| 825 | range = sm.getSpellingLoc(range.getBegin()); |
| 826 | if(!range.getBegin().isFileID()) |
| 827 | return; |
| 828 | } |
| 829 | |
| 830 | clang::FileID FID = sm.getFileID(range.getBegin()); |
| 831 | if (FID != sm.getFileID(range.getEnd())) { |
| 832 | return; |
| 833 | } |
| 834 | if (!shouldProcess(FID)) |
| 835 | return; |
| 836 | |
| 837 | |
| 838 | clang::SourceLocation B = range.getBegin(); |
| 839 | clang::SourceLocation E = range.getEnd(); |
| 840 | |
| 841 | uint pos = sm.getFileOffset(B); |
| 842 | int len = sm.getFileOffset(E) - pos; |
| 843 | |
| 844 | // Include the whole end token in the range. |
| 845 | len += clang::Lexer::MeasureTokenLength(E, sm, getLangOpts()); |
| 846 | |
| 847 | generator(FID).addTag(std::move(tag), std::move(attributes), pos, len); |
| 848 | } |
| 849 | |
| 850 | void Annotator::reportDiagnostic(clang::SourceRange range, const std::string& msg, const std::string &clas) |
| 851 | { |