Pass AnalyzerOptions to PathDiagnosticConsumer to make analyzer options accessible there.

This is plumbing needed for later functionality changes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170488 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ted Kremenek 2012-12-19 01:35:35 +00:00
Родитель 6ee225c8d4
Коммит 9fcc2ab2ec
5 изменённых файлов: 39 добавлений и 27 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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));

Просмотреть файл

@ -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,

Просмотреть файл

@ -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()));

Просмотреть файл

@ -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.