llvm::sys::Path Directory, FilePrefix;
bool createdDir, noDir;
Preprocessor* PP;
- PreprocessorFactory* PPF;
std::vector<const PathDiagnostic*> BatchedDiags;
public:
- HTMLDiagnostics(const std::string& prefix, Preprocessor* pp,
- PreprocessorFactory* ppf);
+ HTMLDiagnostics(const std::string& prefix, Preprocessor* pp);
virtual ~HTMLDiagnostics();
+ virtual void SetPreprocessor(Preprocessor *pp) { PP = pp; }
+
virtual void HandlePathDiagnostic(const PathDiagnostic* D);
unsigned ProcessMacroPiece(llvm::raw_ostream& os,
} // end anonymous namespace
-HTMLDiagnostics::HTMLDiagnostics(const std::string& prefix, Preprocessor* pp,
- PreprocessorFactory* ppf)
+HTMLDiagnostics::HTMLDiagnostics(const std::string& prefix, Preprocessor* pp)
: Directory(prefix), FilePrefix(prefix), createdDir(false), noDir(false),
- PP(pp), PPF(ppf) {
+ PP(pp) {
// All html files begin with "report"
FilePrefix.appendComponent("report");
PathDiagnosticClient*
clang::CreateHTMLDiagnosticClient(const std::string& prefix, Preprocessor* PP,
- PreprocessorFactory* PPF) {
-
- return new HTMLDiagnostics(prefix, PP, PPF);
+ PreprocessorFactory*) {
+ return new HTMLDiagnostics(prefix, PP);
}
//===----------------------------------------------------------------------===//
}
HTMLDiagnostics::~HTMLDiagnostics() {
-
while (!BatchedDiags.empty()) {
const PathDiagnostic* D = BatchedDiags.back();
BatchedDiags.pop_back();
}
void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D) {
-
// Create the HTML directory if it is missing.
-
if (!createdDir) {
createdDir = true;
std::string ErrorMsg;
unsigned max = n;
for (PathDiagnostic::const_reverse_iterator I=D.rbegin(), E=D.rend();
- I!=E; ++I, --n) {
-
+ I!=E; ++I, --n)
HandlePiece(R, FID, *I, n, max);
- }
// Add line numbers, header, footer, etc.
// Create the diagnostic client for reporting errors or for
// implementing -verify.
- DiagnosticClient* TextDiagClient = 0;
-
- if (!VerifyDiagnostics) {
+ llvm::OwningPtr<DiagnosticClient> DiagClient;
+ if (VerifyDiagnostics) {
+ // When checking diagnostics, just buffer them up.
+ DiagClient.reset(new TextDiagnosticBuffer());
+ if (InputFilenames.size() != 1) {
+ fprintf(stderr, "-verify only works on single input files for now.\n");
+ return 1;
+ }
+ if (!HTMLDiag.empty()) {
+ fprintf(stderr, "-verify and -html-diags don't work together\n");
+ return 1;
+ }
+ } else if (HTMLDiag.empty()) {
// Print diagnostics to stderr by default.
- TextDiagClient = new TextDiagnosticPrinter(llvm::errs(),
+ DiagClient.reset(new TextDiagnosticPrinter(llvm::errs(),
!NoShowColumn,
!NoCaretDiagnostics,
!NoShowLocation,
PrintSourceRangeInfo,
- PrintDiagnosticOption);
+ PrintDiagnosticOption));
} else {
- // When checking diagnostics, just buffer them up.
- TextDiagClient = new TextDiagnosticBuffer();
-
- if (InputFilenames.size() != 1) {
- fprintf(stderr,
- "-verify only works on single input files for now.\n");
- return 1;
- }
+ DiagClient.reset(CreateHTMLDiagnosticClient(HTMLDiag));
}
// Configure our handling of diagnostics.
- llvm::OwningPtr<DiagnosticClient> DiagClient(TextDiagClient);
Diagnostic Diags(DiagClient.get());
if (ProcessWarningOptions(Diags))
return 1;
const std::string &InFile = InputFilenames[i];
if (isSerializedFile(InFile)) {
- Diags.setClient(TextDiagClient);
ProcessSerializedFile(InFile,Diags,FileMgr);
continue;
}
// Initialize language options, inferring file types from input filenames.
LangOptions LangInfo;
- TextDiagClient->setLangOptions(&LangInfo);
+ DiagClient->setLangOptions(&LangInfo);
InitializeBaseLanguage();
LangKind LK = GetLanguage(InFile);
InitializeSourceManager(*PP.get(), InFile))
continue;
- // Create the HTMLDiagnosticsClient if we are using one. Otherwise,
- // always reset to using TextDiagClient.
- llvm::OwningPtr<DiagnosticClient> TmpClient;
-
- if (!HTMLDiag.empty()) {
- TmpClient.reset(CreateHTMLDiagnosticClient(HTMLDiag, PP.get(),
- &PPFactory));
- Diags.setClient(TmpClient.get());
- }
- else
- Diags.setClient(TextDiagClient);
+ if (!HTMLDiag.empty())
+ ((PathDiagnosticClient*)DiagClient.get())->SetPreprocessor(PP.get());
// Process the source file.
ProcessInputFile(*PP, PPFactory, InFile, ProgAction);
HeaderInfo.ClearFileInfo();
- TextDiagClient->setLangOptions(0);
+ DiagClient->setLangOptions(0);
}
if (Verbose)