}
//===----------------------------------------------------------------------===//
-// CheckeRConsumer - Generic Driver for running intra-procedural path-sensitive
+// CheckerConsumer - Generic Driver for running intra-procedural path-sensitive
// analyses.
namespace {
protected:
Diagnostic &Diags;
ASTContext* Ctx;
+ Preprocessor* PP;
const std::string& HTMLDir;
bool Visualize;
bool TrimGraph;
llvm::OwningPtr<PathDiagnosticClient> PD;
bool AnalyzeAll;
public:
- CheckerConsumer(Diagnostic &diags, const std::string& fname,
- const std::string& htmldir,
- bool visualize, bool trim, bool analyzeAll)
- : CFGVisitor(fname), Diags(diags), HTMLDir(htmldir),
+ CheckerConsumer(Diagnostic &diags, Preprocessor* pp,
+ const std::string& fname,
+ const std::string& htmldir,
+ bool visualize, bool trim, bool analyzeAll)
+ : CFGVisitor(fname), Diags(diags), PP(pp), HTMLDir(htmldir),
Visualize(visualize), TrimGraph(trim), AnalyzeAll(analyzeAll) {}
virtual void Initialize(ASTContext &Context) { Ctx = &Context; }
// Lazily create the diagnostic client.
if (!HTMLDir.empty() && PD.get() == NULL)
- PD.reset(CreateHTMLDiagnosticClient(HTMLDir));
+ PD.reset(CreateHTMLDiagnosticClient(HTMLDir, PP));
if (!Visualize) {
namespace {
class GRSimpleValsVisitor : public CheckerConsumer {
public:
- GRSimpleValsVisitor(Diagnostic &diags, const std::string& fname,
- const std::string& htmldir,
+ GRSimpleValsVisitor(Diagnostic &diags, Preprocessor* pp,
+ const std::string& fname, const std::string& htmldir,
bool visualize, bool trim, bool analyzeAll)
- : CheckerConsumer(diags, fname, htmldir, visualize, trim, analyzeAll) {}
+ : CheckerConsumer(diags, pp, fname, htmldir, visualize, trim, analyzeAll) {}
virtual const char* getCheckerName() { return "GRSimpleVals"; }
} // end anonymous namespace
ASTConsumer* clang::CreateGRSimpleVals(Diagnostic &Diags,
+ Preprocessor* PP,
const std::string& FunctionName,
const std::string& HTMLDir,
bool Visualize, bool TrimGraph,
bool AnalyzeAll) {
- return new GRSimpleValsVisitor(Diags, FunctionName, HTMLDir,
+ return new GRSimpleValsVisitor(Diags, PP, FunctionName, HTMLDir,
Visualize, TrimGraph, AnalyzeAll);
}
namespace {
class CFRefCountCheckerVisitor : public CheckerConsumer {
public:
- CFRefCountCheckerVisitor(Diagnostic &diags, const std::string& fname,
- const std::string& htmldir,
- bool visualize, bool trim, bool analyzeAll)
- : CheckerConsumer(diags, fname, htmldir, visualize, trim, analyzeAll) {}
+ CFRefCountCheckerVisitor(Diagnostic &diags, Preprocessor* pp,
+ const std::string& fname,
+ const std::string& htmldir,
+ bool visualize, bool trim, bool analyzeAll)
+ : CheckerConsumer(diags, pp, fname, htmldir, visualize, trim, analyzeAll) {}
virtual const char* getCheckerName() { return "CFRefCountChecker"; }
} // end anonymous namespace
ASTConsumer* clang::CreateCFRefChecker(Diagnostic &Diags,
+ Preprocessor* PP,
const std::string& FunctionName,
const std::string& HTMLDir,
bool Visualize, bool TrimGraph,
bool AnalyzeAll) {
- return new CFRefCountCheckerVisitor(Diags, FunctionName, HTMLDir,
+ return new CFRefCountCheckerVisitor(Diags, PP, FunctionName, HTMLDir,
Visualize, TrimGraph, AnalyzeAll);
}
class VISIBILITY_HIDDEN HTMLDiagnostics : public PathDiagnosticClient {
llvm::sys::Path Directory, FilePrefix;
bool createdDir, noDir;
+ Preprocessor* PP;
public:
- HTMLDiagnostics(const std::string& prefix);
+ HTMLDiagnostics(const std::string& prefix, Preprocessor* pp = NULL);
virtual ~HTMLDiagnostics() {}
} // end anonymous namespace
-HTMLDiagnostics::HTMLDiagnostics(const std::string& prefix)
- : Directory(prefix), FilePrefix(prefix), createdDir(false), noDir(false) {
+HTMLDiagnostics::HTMLDiagnostics(const std::string& prefix, Preprocessor* pp)
+ : Directory(prefix), FilePrefix(prefix), createdDir(false), noDir(false),
+ PP(pp) {
// All html files begin with "report"
FilePrefix.appendComponent("report");
}
PathDiagnosticClient*
-clang::CreateHTMLDiagnosticClient(const std::string& prefix) {
+clang::CreateHTMLDiagnosticClient(const std::string& prefix, Preprocessor* PP) {
- return new HTMLDiagnostics(prefix);
+ return new HTMLDiagnostics(prefix, PP);
}
//===----------------------------------------------------------------------===//
html::EscapeText(R, FileID);
html::AddLineNumbers(R, FileID);
+ // If we have a preprocessor, relex the file and syntax highlight.
+ // We might not have a preprocessor if we come from a deserialized AST file,
+ // for example.
+
+ if (PP) {
+ html::SyntaxHighlight(R, FileID, *PP);
+ html::HighlightMacros(R, FileID, *PP);
+ }
+
// Get the full directory name of the analyzed file.
const FileEntry* Entry = SMgr.getFileEntryForID(FileID);
return CreateUnitValsChecker(Diag);
case AnalysisGRSimpleVals:
- return CreateGRSimpleVals(Diag, AnalyzeSpecificFunction, OutputFile,
+ return CreateGRSimpleVals(Diag, PP, AnalyzeSpecificFunction, OutputFile,
VisualizeEG, TrimGraph, AnalyzeAll);
case CheckerCFRef:
- return CreateCFRefChecker(Diag, AnalyzeSpecificFunction, OutputFile,
+ return CreateCFRefChecker(Diag, PP, AnalyzeSpecificFunction, OutputFile,
VisualizeEG, TrimGraph, AnalyzeAll);
case TestSerialization:
TextDiagnostics* TextDiagClient = NULL;
if (!HTMLDiag.empty()) {
- DiagClient.reset(CreateHTMLDiagnosticClient(HTMLDiag));
+ DiagClient.reset(CreateHTMLDiagnosticClient(HTMLDiag, NULL));
}
else { // Use Text diagnostics.
if (!VerifyDiagnostics) {