diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-03-19 23:55:53 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-03-19 23:55:53 +0000 |
commit | bc249625668c52592e7d9946748dd8bdbb3a5700 (patch) | |
tree | 2fa857feaad5d65e7f1e33a0b2da46c00524e24f /clang/Driver/HTMLPrint.cpp | |
parent | 157c403cb83dd6aead597a5cfc9d38d300ff32b0 (diff) | |
download | bcm5719-llvm-bc249625668c52592e7d9946748dd8bdbb3a5700.tar.gz bcm5719-llvm-bc249625668c52592e7d9946748dd8bdbb3a5700.zip |
Added HTML highlighting for ranges.
llvm-svn: 48572
Diffstat (limited to 'clang/Driver/HTMLPrint.cpp')
-rw-r--r-- | clang/Driver/HTMLPrint.cpp | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/clang/Driver/HTMLPrint.cpp b/clang/Driver/HTMLPrint.cpp index a6b90fafdff..b30f1e80ef2 100644 --- a/clang/Driver/HTMLPrint.cpp +++ b/clang/Driver/HTMLPrint.cpp @@ -154,10 +154,16 @@ void HTMLDiagnostic::HandleDiagnostic(Diagnostic &Diags, if (!Pos.isValid()) return; + SourceManager& SM = R.getSourceMgr(); + FullSourceLoc LPos = Pos.getLogicalLoc(); unsigned FileID = LPos.getLocation().getFileID(); - if (FileID != LPos.getManager().getMainFileID()) + assert (&LPos.getManager() == &SM && "SourceManagers are different!"); + + unsigned MainFileID = SM.getMainFileID(); + + if (FileID != MainFileID) return; @@ -202,9 +208,33 @@ void HTMLDiagnostic::HandleDiagnostic(Diagnostic &Diags, // Insert the new html. - const llvm::MemoryBuffer *Buf = R.getSourceMgr().getBuffer(FileID); + const llvm::MemoryBuffer *Buf = SM.getBuffer(FileID); const char* FileStart = Buf->getBufferStart(); R.InsertStrBefore(SourceLocation::getFileLoc(FileID, LineStart - FileStart), os.str()); + + // Now highlight the ranges. + + for (unsigned i = 0; i < NumRanges; ++i) { + + SourceLocation B = SM.getLogicalLoc(Ranges->getBegin()); + SourceLocation E = SM.getLogicalLoc(Ranges->getEnd()); + + // We do this because the position seems to point to the beginning of + // the last character. FIXME: Is this what is suppose to happen? + std::pair<unsigned,unsigned> X = SM.getDecomposedFileLoc(E); + E = SourceLocation::getFileLoc(X.first, X.second+1); + + ++Ranges; + + if (B.getFileID() != MainFileID || E.getFileID() != MainFileID) + continue; + + // Highlight the range. Make the span tag the outermost tag for the + // selected range. + R.InsertCStrBefore(B, "<span class=\"mrange\">"); + R.InsertCStrAfter(E, "</span>"); + } + } |