diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-02-08 22:30:36 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-02-08 22:30:36 +0000 |
commit | 811d75ee35b8b061a9b10a4e7b81e0c0eaf739c3 (patch) | |
tree | 76064238268b854e8698c225b3eb44eefedd6559 /lib/StaticAnalyzer/Core/TextPathDiagnostics.cpp | |
parent | a12a51701794a5ce96d47513ed186922e41eadd5 (diff) |
[analyzer] Move the files in lib/StaticAnalyzer to lib/StaticAnalyzer/Core.
Eventually there will also be a lib/StaticAnalyzer/Frontend that will handle initialization and checker registration.
Yet another library to avoid cyclic dependencies between Core and Checkers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125124 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/TextPathDiagnostics.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Core/TextPathDiagnostics.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/lib/StaticAnalyzer/Core/TextPathDiagnostics.cpp b/lib/StaticAnalyzer/Core/TextPathDiagnostics.cpp new file mode 100644 index 0000000000..9ca378f2d4 --- /dev/null +++ b/lib/StaticAnalyzer/Core/TextPathDiagnostics.cpp @@ -0,0 +1,70 @@ +//===--- TextPathDiagnostics.cpp - Text Diagnostics for Paths ---*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the TextPathDiagnostics object. +// +//===----------------------------------------------------------------------===// + +#include "clang/StaticAnalyzer/PathDiagnosticClients.h" +#include "clang/StaticAnalyzer/BugReporter/PathDiagnostic.h" +#include "clang/Lex/Preprocessor.h" +#include "llvm/Support/raw_ostream.h" +using namespace clang; +using namespace ento; +using namespace llvm; + +namespace { + +/// \brief Simple path diagnostic client used for outputting as diagnostic notes +/// the sequence of events. +class TextPathDiagnostics : public PathDiagnosticClient { + const std::string OutputFile; + Diagnostic &Diag; + +public: + TextPathDiagnostics(const std::string& output, Diagnostic &diag) + : OutputFile(output), Diag(diag) {} + + void HandlePathDiagnostic(const PathDiagnostic* D); + + void FlushDiagnostics(llvm::SmallVectorImpl<std::string> *FilesMade) { } + + virtual llvm::StringRef getName() const { + return "TextPathDiagnostics"; + } + + PathGenerationScheme getGenerationScheme() const { return Minimal; } + bool supportsLogicalOpControlFlow() const { return true; } + bool supportsAllBlockEdges() const { return true; } + virtual bool useVerboseDescription() const { return true; } +}; + +} // end anonymous namespace + +PathDiagnosticClient* +ento::createTextPathDiagnosticClient(const std::string& out, + const Preprocessor &PP) { + return new TextPathDiagnostics(out, PP.getDiagnostics()); +} + +void TextPathDiagnostics::HandlePathDiagnostic(const PathDiagnostic* D) { + if (!D) + return; + + if (D->empty()) { + delete D; + return; + } + + for (PathDiagnostic::const_iterator I=D->begin(), E=D->end(); I != E; ++I) { + unsigned diagID = Diag.getDiagnosticIDs()->getCustomDiagID( + DiagnosticIDs::Note, I->getString()); + Diag.Report(I->getLocation().asLocation(), diagID); + } +} |