Rename 'VisitLocation' to 'visitLocation'.
[clang.git] / lib / Checker / TextPathDiagnostics.cpp
blob0ed03e426d516f5088c4f9a6764b363364b4c850
1 //===--- TextPathDiagnostics.cpp - Text Diagnostics for Paths ---*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the TextPathDiagnostics object.
12 //===----------------------------------------------------------------------===//
14 #include "clang/Checker/PathDiagnosticClients.h"
15 #include "clang/Checker/BugReporter/PathDiagnostic.h"
16 #include "clang/Lex/Preprocessor.h"
17 #include "llvm/Support/raw_ostream.h"
18 using namespace clang;
19 using namespace llvm;
21 namespace {
23 /// \brief Simple path diagnostic client used for outputting as diagnostic notes
24 /// the sequence of events.
25 class TextPathDiagnostics : public PathDiagnosticClient {
26 const std::string OutputFile;
27 Diagnostic &Diag;
29 public:
30 TextPathDiagnostics(const std::string& output, Diagnostic &diag)
31 : OutputFile(output), Diag(diag) {}
33 void HandlePathDiagnostic(const PathDiagnostic* D);
35 void FlushDiagnostics(llvm::SmallVectorImpl<std::string> *FilesMade) { }
37 virtual llvm::StringRef getName() const {
38 return "TextPathDiagnostics";
41 PathGenerationScheme getGenerationScheme() const { return Minimal; }
42 bool supportsLogicalOpControlFlow() const { return true; }
43 bool supportsAllBlockEdges() const { return true; }
44 virtual bool useVerboseDescription() const { return true; }
47 } // end anonymous namespace
49 PathDiagnosticClient*
50 clang::createTextPathDiagnosticClient(const std::string& out,
51 const Preprocessor &PP) {
52 return new TextPathDiagnostics(out, PP.getDiagnostics());
55 void TextPathDiagnostics::HandlePathDiagnostic(const PathDiagnostic* D) {
56 if (!D)
57 return;
59 if (D->empty()) {
60 delete D;
61 return;
64 for (PathDiagnostic::const_iterator I=D->begin(), E=D->end(); I != E; ++I) {
65 unsigned diagID = Diag.getDiagnosticIDs()->getCustomDiagID(
66 DiagnosticIDs::Note, I->getString());
67 Diag.Report(I->getLocation().asLocation(), diagID);