1 //===--- TextPathDiagnostics.cpp - Text Diagnostics for Paths ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the TextPathDiagnostics object.
12 //===----------------------------------------------------------------------===//
14 #include "clang/StaticAnalyzer/PathDiagnosticClients.h"
15 #include "clang/StaticAnalyzer/BugReporter/PathDiagnostic.h"
16 #include "clang/Lex/Preprocessor.h"
17 #include "llvm/Support/raw_ostream.h"
18 using namespace clang
;
24 /// \brief Simple path diagnostic client used for outputting as diagnostic notes
25 /// the sequence of events.
26 class TextPathDiagnostics
: public PathDiagnosticClient
{
27 const std::string OutputFile
;
31 TextPathDiagnostics(const std::string
& output
, Diagnostic
&diag
)
32 : OutputFile(output
), Diag(diag
) {}
34 void HandlePathDiagnostic(const PathDiagnostic
* D
);
36 void FlushDiagnostics(llvm::SmallVectorImpl
<std::string
> *FilesMade
) { }
38 virtual llvm::StringRef
getName() const {
39 return "TextPathDiagnostics";
42 PathGenerationScheme
getGenerationScheme() const { return Minimal
; }
43 bool supportsLogicalOpControlFlow() const { return true; }
44 bool supportsAllBlockEdges() const { return true; }
45 virtual bool useVerboseDescription() const { return true; }
48 } // end anonymous namespace
51 ento::createTextPathDiagnosticClient(const std::string
& out
,
52 const Preprocessor
&PP
) {
53 return new TextPathDiagnostics(out
, PP
.getDiagnostics());
56 void TextPathDiagnostics::HandlePathDiagnostic(const PathDiagnostic
* D
) {
65 for (PathDiagnostic::const_iterator I
=D
->begin(), E
=D
->end(); I
!= E
; ++I
) {
66 unsigned diagID
= Diag
.getDiagnosticIDs()->getCustomDiagID(
67 DiagnosticIDs::Note
, I
->getString());
68 Diag
.Report(I
->getLocation().asLocation(), diagID
);