diff options
| author | Alp Toker <alp@nuanti.com> | 2014-01-25 14:38:41 +0000 |
|---|---|---|
| committer | Alp Toker <alp@nuanti.com> | 2014-01-25 14:38:41 +0000 |
| commit | 48047f5d75b02ef14c48fa2d6ed63faf5c299f74 (patch) | |
| tree | 6592aaac9c5dc823b69bcd0d7a07744d8405e2db /clang/lib/StaticAnalyzer | |
| parent | 65dfc8ce09987f7e6c50467292a3f8ae2b2fc7a4 (diff) | |
| download | bcm5719-llvm-48047f5d75b02ef14c48fa2d6ed63faf5c299f74.tar.gz bcm5719-llvm-48047f5d75b02ef14c48fa2d6ed63faf5c299f74.zip | |
PlistSupport: Eliminate duplicated EmitLocation() and EmitRange() functions
llvm-svn: 200077
Diffstat (limited to 'clang/lib/StaticAnalyzer')
| -rw-r--r-- | clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp b/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp index 1a40f5e5827..f10ce203823 100644 --- a/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp +++ b/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp @@ -24,6 +24,7 @@ #include "llvm/Support/Casting.h" using namespace clang; using namespace ento; +using namespace markup; namespace { class PlistDiagnostics : public PathDiagnosticConsumer { @@ -77,23 +78,6 @@ void ento::createPlistMultiFileDiagnosticConsumer(AnalyzerOptions &AnalyzerOpts, PP.getLangOpts(), true)); } -static void EmitLocation(raw_ostream &o, const SourceManager &SM, - const LangOptions &LangOpts, - const PathDiagnosticLocation &L, const FIDMap& FM, - unsigned indent, bool extend = false) { - EmitLocation(o, SM, LangOpts, L.asLocation(), FM, indent, extend); -} - -static void EmitRange(raw_ostream &o, const SourceManager &SM, - const LangOptions &LangOpts, - PathDiagnosticRange R, const FIDMap &FM, - unsigned indent) { - Indent(o, indent) << "<array>\n"; - EmitLocation(o, SM, LangOpts, R.getBegin(), FM, indent+1); - EmitLocation(o, SM, LangOpts, R.getEnd(), FM, indent+1, !R.isPoint); - Indent(o, indent) << "</array>\n"; -} - static void ReportControlFlow(raw_ostream &o, const PathDiagnosticControlFlowPiece& P, const FIDMap& FM, @@ -121,11 +105,13 @@ static void ReportControlFlow(raw_ostream &o, // logic for clients. Indent(o, indent) << "<key>start</key>\n"; SourceLocation StartEdge = I->getStart().asRange().getBegin(); - EmitRange(o, SM, LangOpts, SourceRange(StartEdge, StartEdge), FM, indent+1); + EmitRange(o, SM, LangOpts, CharSourceRange::getTokenRange(StartEdge), FM, + indent + 1); Indent(o, indent) << "<key>end</key>\n"; SourceLocation EndEdge = I->getEnd().asRange().getBegin(); - EmitRange(o, SM, LangOpts, SourceRange(EndEdge, EndEdge), FM, indent+1); + EmitRange(o, SM, LangOpts, CharSourceRange::getTokenRange(EndEdge), FM, + indent + 1); --indent; Indent(o, indent) << "</dict>\n"; @@ -177,7 +163,8 @@ static void ReportEvent(raw_ostream &o, const PathDiagnosticPiece& P, ++indent; for (ArrayRef<SourceRange>::iterator I = Ranges.begin(), E = Ranges.end(); I != E; ++I) { - EmitRange(o, SM, LangOpts, *I, FM, indent+1); + EmitRange(o, SM, LangOpts, CharSourceRange::getTokenRange(*I), FM, + indent + 1); } --indent; Indent(o, indent) << "</array>\n"; @@ -468,7 +455,7 @@ void PlistDiagnostics::FlushDiagnosticsImpl( // Output the location of the bug. o << " <key>location</key>\n"; - EmitLocation(o, *SM, LangOpts, D->getLocation(), FM, 2); + EmitLocation(o, *SM, LangOpts, D->getLocation().asLocation(), FM, 2); // Output the diagnostic to the sub-diagnostic client, if any. if (!filesMade->empty()) { |

