diff options
| author | Ted Kremenek <kremenek@apple.com> | 2012-12-19 01:35:35 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2012-12-19 01:35:35 +0000 |
| commit | 3a081a033926da9cdd68ccb8705ad882704f68b5 (patch) | |
| tree | f93ae66ce658d27b1b3326deb9abaa9fcfa3ad09 | |
| parent | 372735f3423bbaacccda99e61805d6d8644487cc (diff) | |
| download | bcm5719-llvm-3a081a033926da9cdd68ccb8705ad882704f68b5.tar.gz bcm5719-llvm-3a081a033926da9cdd68ccb8705ad882704f68b5.zip | |
Pass AnalyzerOptions to PathDiagnosticConsumer to make analyzer options accessible there.
This is plumbing needed for later functionality changes.
llvm-svn: 170488
5 files changed, 39 insertions, 27 deletions
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h b/clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h index 3aab648dc57..b856de7dc61 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h @@ -19,6 +19,7 @@ namespace clang { +class AnalyzerOptions; class Preprocessor; namespace ento { @@ -26,21 +27,18 @@ namespace ento { class PathDiagnosticConsumer; typedef std::vector<PathDiagnosticConsumer*> PathDiagnosticConsumers; -void createHTMLDiagnosticConsumer(PathDiagnosticConsumers &C, - const std::string& prefix, - const Preprocessor &PP); +#define CREATE_CONSUMER(NAME)\ +void create ## NAME ## DiagnosticConsumer(AnalyzerOptions &AnalyzerOpts,\ + PathDiagnosticConsumers &C,\ + const std::string& prefix,\ + const Preprocessor &PP); -void createPlistDiagnosticConsumer(PathDiagnosticConsumers &C, - const std::string& prefix, - const Preprocessor &PP); +CREATE_CONSUMER(HTML) +CREATE_CONSUMER(Plist) +CREATE_CONSUMER(PlistMultiFile) +CREATE_CONSUMER(TextPath) -void createPlistMultiFileDiagnosticConsumer(PathDiagnosticConsumers &C, - const std::string& prefix, - const Preprocessor &PP); - -void createTextPathDiagnosticConsumer(PathDiagnosticConsumers &C, - const std::string& prefix, - const Preprocessor &PP); +#undef CREATE_CONSUMER } // end 'ento' namespace } // end 'clang' namespace diff --git a/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp b/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp index bd6898379ff..73426da2b4d 100644 --- a/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp +++ b/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp @@ -76,7 +76,8 @@ HTMLDiagnostics::HTMLDiagnostics(const std::string& prefix, FilePrefix.appendComponent("report"); } -void ento::createHTMLDiagnosticConsumer(PathDiagnosticConsumers &C, +void ento::createHTMLDiagnosticConsumer(AnalyzerOptions &AnalyzerOpts, + PathDiagnosticConsumers &C, const std::string& prefix, const Preprocessor &PP) { C.push_back(new HTMLDiagnostics(prefix, PP)); diff --git a/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp b/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp index 4472a48d27c..28266728a18 100644 --- a/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp +++ b/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp @@ -11,6 +11,7 @@ // //===----------------------------------------------------------------------===// +#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h" #include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h" #include "clang/Basic/FileManager.h" #include "clang/Basic/SourceManager.h" @@ -33,7 +34,9 @@ namespace { const LangOptions &LangOpts; const bool SupportsCrossFileDiagnostics; public: - PlistDiagnostics(const std::string& prefix, const LangOptions &LangOpts, + PlistDiagnostics(AnalyzerOptions &AnalyzerOpts, + const std::string& prefix, + const LangOptions &LangOpts, bool supportsMultipleFiles); virtual ~PlistDiagnostics() {} @@ -54,22 +57,28 @@ namespace { }; } // end anonymous namespace -PlistDiagnostics::PlistDiagnostics(const std::string& output, +PlistDiagnostics::PlistDiagnostics(AnalyzerOptions &AnalyzerOpts, + const std::string& output, const LangOptions &LO, bool supportsMultipleFiles) - : OutputFile(output), LangOpts(LO), + : OutputFile(output), + LangOpts(LO), SupportsCrossFileDiagnostics(supportsMultipleFiles) {} -void ento::createPlistDiagnosticConsumer(PathDiagnosticConsumers &C, +void ento::createPlistDiagnosticConsumer(AnalyzerOptions &AnalyzerOpts, + PathDiagnosticConsumers &C, const std::string& s, const Preprocessor &PP) { - C.push_back(new PlistDiagnostics(s, PP.getLangOpts(), false)); + C.push_back(new PlistDiagnostics(AnalyzerOpts, s, + PP.getLangOpts(), false)); } -void ento::createPlistMultiFileDiagnosticConsumer(PathDiagnosticConsumers &C, +void ento::createPlistMultiFileDiagnosticConsumer(AnalyzerOptions &AnalyzerOpts, + PathDiagnosticConsumers &C, const std::string &s, const Preprocessor &PP) { - C.push_back(new PlistDiagnostics(s, PP.getLangOpts(), true)); + C.push_back(new PlistDiagnostics(AnalyzerOpts, s, + PP.getLangOpts(), true)); } static void AddFID(FIDMap &FIDs, SmallVectorImpl<FileID> &V, diff --git a/clang/lib/StaticAnalyzer/Core/TextPathDiagnostics.cpp b/clang/lib/StaticAnalyzer/Core/TextPathDiagnostics.cpp index ceb665326f1..d5706d6dbbe 100644 --- a/clang/lib/StaticAnalyzer/Core/TextPathDiagnostics.cpp +++ b/clang/lib/StaticAnalyzer/Core/TextPathDiagnostics.cpp @@ -46,7 +46,8 @@ public: } // end anonymous namespace -void ento::createTextPathDiagnosticConsumer(PathDiagnosticConsumers &C, +void ento::createTextPathDiagnosticConsumer(AnalyzerOptions &AnalyzerOpts, + PathDiagnosticConsumers &C, const std::string& out, const Preprocessor &PP) { C.push_back(new TextPathDiagnostics(out, PP.getDiagnostics())); diff --git a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp index 6133e168c42..47ca9b7ba40 100644 --- a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -64,11 +64,13 @@ STATISTIC(MaxCFGSize, "The maximum number of basic blocks in a function."); // Special PathDiagnosticConsumers. //===----------------------------------------------------------------------===// -static void createPlistHTMLDiagnosticConsumer(PathDiagnosticConsumers &C, +static void createPlistHTMLDiagnosticConsumer(AnalyzerOptions &AnalyzerOpts, + PathDiagnosticConsumers &C, const std::string &prefix, const Preprocessor &PP) { - createHTMLDiagnosticConsumer(C, llvm::sys::path::parent_path(prefix), PP); - createPlistDiagnosticConsumer(C, prefix, PP); + createHTMLDiagnosticConsumer(AnalyzerOpts, C, + llvm::sys::path::parent_path(prefix), PP); + createPlistDiagnosticConsumer(AnalyzerOpts, C, prefix, PP); } namespace { @@ -188,13 +190,14 @@ public: switch (Opts->AnalysisDiagOpt) { default: #define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN, AUTOCREATE) \ - case PD_##NAME: CREATEFN(PathConsumers, OutDir, PP); break; + case PD_##NAME: CREATEFN(*Opts.getPtr(), PathConsumers, OutDir, PP);\ + break; #include "clang/StaticAnalyzer/Core/Analyses.def" } } else if (Opts->AnalysisDiagOpt == PD_TEXT) { // Create the text client even without a specified output file since // it just uses diagnostic notes. - createTextPathDiagnosticConsumer(PathConsumers, "", PP); + createTextPathDiagnosticConsumer(*Opts.getPtr(), PathConsumers, "", PP); } // Create the analyzer component creators. |

