[cfe-commits] r68437 - /cfe/trunk/lib/Frontend/PlistDiagnostics.cpp
Ted Kremenek
kremenek at apple.com
Sat Apr 4 19:08:28 PDT 2009
Author: kremenek
Date: Sat Apr 4 21:08:28 2009
New Revision: 68437
URL: http://llvm.org/viewvc/llvm-project?rev=68437&view=rev
Log:
Fix output of ranges in analyzer plist files.
Modified:
cfe/trunk/lib/Frontend/PlistDiagnostics.cpp
Modified: cfe/trunk/lib/Frontend/PlistDiagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PlistDiagnostics.cpp?rev=68437&r1=68436&r2=68437&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PlistDiagnostics.cpp (original)
+++ cfe/trunk/lib/Frontend/PlistDiagnostics.cpp Sat Apr 4 21:08:28 2009
@@ -15,6 +15,7 @@
#include "clang/Analysis/PathDiagnostic.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/FileManager.h"
+#include "clang/Lex/Lexer.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Casting.h"
@@ -80,22 +81,27 @@
static void EmitLocation(llvm::raw_ostream& o, const SourceManager* SM,
SourceLocation L, const FIDMap& FM,
- const unsigned indent) {
+ const unsigned indent, bool extend = false) {
+ FullSourceLoc Loc(SM->getInstantiationLoc(L), const_cast<SourceManager&>(*SM));
+
+ // Add in the length of the token, so that we cover multi-char tokens.
+ unsigned offset = extend ? Lexer::MeasureTokenLength(Loc, *SM) - 1 : 0;
+
Indent(o, indent) << "<dict>\n";
Indent(o, indent) << " <key>line</key><integer>"
- << SM->getInstantiationLineNumber(L) << "</integer>\n";
+ << Loc.getInstantiationLineNumber() << "</integer>\n";
Indent(o, indent) << " <key>col</key><integer>"
- << SM->getInstantiationColumnNumber(L) << "</integer>\n";
+ << Loc.getInstantiationColumnNumber() + offset << "</integer>\n";
Indent(o, indent) << " <key>file</key><integer>"
- << GetFID(FM, SM, L) << "</integer>\n";
+ << GetFID(FM, SM, Loc) << "</integer>\n";
Indent(o, indent) << "</dict>\n";
}
static void EmitLocation(llvm::raw_ostream& o, const SourceManager* SM,
const PathDiagnosticLocation &L, const FIDMap& FM,
- const unsigned indent) {
- EmitLocation(o, SM, L.asLocation(), FM, indent);
+ const unsigned indent, bool extend = false) {
+ EmitLocation(o, SM, L.asLocation(), FM, indent, extend);
}
static void EmitRange(llvm::raw_ostream& o, const SourceManager* SM,
@@ -103,8 +109,8 @@
const unsigned indent) {
Indent(o, indent) << "<array>\n";
- EmitLocation(o, SM, R.getBegin(), FM, indent+1);
- EmitLocation(o, SM, R.getEnd(), FM, indent+1);
+ EmitLocation(o, SM, R.getBegin(), FM, indent+1);
+ EmitLocation(o, SM, R.getEnd(), FM, indent+1, true);
Indent(o, indent) << "</array>\n";
}
More information about the cfe-commits
mailing list