From: Ted Kremenek Date: Sun, 5 Apr 2009 02:08:28 +0000 (+0000) Subject: Fix output of ranges in analyzer plist files. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f076339c679a889f751873a9cf8e5ad4a8686a03;p=clang Fix output of ranges in analyzer plist files. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68437 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Frontend/PlistDiagnostics.cpp b/lib/Frontend/PlistDiagnostics.cpp index 575c3f3bfc..d87a8f189f 100644 --- a/lib/Frontend/PlistDiagnostics.cpp +++ b/lib/Frontend/PlistDiagnostics.cpp @@ -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 llvm::raw_ostream& Indent(llvm::raw_ostream& o, const unsigned indent) { 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(*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) << "\n"; Indent(o, indent) << " line" - << SM->getInstantiationLineNumber(L) << "\n"; + << Loc.getInstantiationLineNumber() << "\n"; Indent(o, indent) << " col" - << SM->getInstantiationColumnNumber(L) << "\n"; + << Loc.getInstantiationColumnNumber() + offset << "\n"; Indent(o, indent) << " file" - << GetFID(FM, SM, L) << "\n"; + << GetFID(FM, SM, Loc) << "\n"; Indent(o, indent) << "\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 @@ static void EmitRange(llvm::raw_ostream& o, const SourceManager* SM, const unsigned indent) { Indent(o, indent) << "\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) << "\n"; }