aboutsummaryrefslogtreecommitdiff
path: root/Driver/clang.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-08-07 17:49:57 +0000
committerTed Kremenek <kremenek@apple.com>2008-08-07 17:49:57 +0000
commitb4398aa27da4d6919c3ae448d1ae66ba6cafc048 (patch)
tree6f34a5c54a19240c6517e50fd6d51524ce7009fe /Driver/clang.cpp
parent45e52e137702abbfa44852979a5717dfdc09c9bc (diff)
Fix --html-diags in driver by delaying the construction of an HTMLDiagnosticClient until after we have created the Preprocessor object.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54472 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver/clang.cpp')
-rw-r--r--Driver/clang.cpp64
1 files changed, 33 insertions, 31 deletions
diff --git a/Driver/clang.cpp b/Driver/clang.cpp
index 1aa7651aa6..7721e83aff 100644
--- a/Driver/clang.cpp
+++ b/Driver/clang.cpp
@@ -1389,38 +1389,26 @@ int main(int argc, char **argv) {
// Create the diagnostic client for reporting errors or for
// implementing -verify.
- std::auto_ptr<DiagnosticClient> DiagClient;
- TextDiagnostics* TextDiagClient = NULL;
+ TextDiagnostics* TextDiagClient = 0;
- if (!HTMLDiag.empty()) {
-
- // FIXME: The HTMLDiagnosticClient uses the Preprocessor for
- // (optional) syntax highlighting, but we don't have a preprocessor yet.
- // Fix this dependency later.
- DiagClient.reset(CreateHTMLDiagnosticClient(HTMLDiag, 0, 0));
- }
- else { // Use Text diagnostics.
- if (!VerifyDiagnostics) {
- // Print diagnostics to stderr by default.
- TextDiagClient = new TextDiagnosticPrinter(!NoShowColumn,
- !NoCaretDiagnostics);
- } 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;
- }
+ if (!VerifyDiagnostics) {
+ // Print diagnostics to stderr by default.
+ TextDiagClient = new TextDiagnosticPrinter(!NoShowColumn,
+ !NoCaretDiagnostics);
+ } 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;
}
-
- assert (TextDiagClient);
- DiagClient.reset(TextDiagClient);
}
-
+
// Configure our handling of diagnostics.
- Diagnostic Diags(*DiagClient);
+ llvm::OwningPtr<DiagnosticClient> DiagClient(TextDiagClient);
+ Diagnostic Diags(DiagClient.get());
InitializeDiagnostics(Diags);
// -I- is a deprecated GCC feature, scan for it and reject it.
@@ -1445,15 +1433,16 @@ int main(int argc, char **argv) {
// Are we invoking one or more source analyses?
if (!AnalysisList.empty() && ProgAction == ParseSyntaxOnly)
ProgAction = RunAnalysis;
-
-
+
llvm::OwningPtr<SourceManager> SourceMgr;
for (unsigned i = 0, e = InputFilenames.size(); i != e; ++i) {
const std::string &InFile = InputFilenames[i];
- if (isSerializedFile(InFile))
+ if (isSerializedFile(InFile)) {
+ Diags.setClient(TextDiagClient);
ProcessSerializedFile(InFile,Diags,FileMgr);
+ }
else {
/// Create a SourceManager object. This tracks and owns all the file
/// buffers allocated to a translation unit.
@@ -1489,7 +1478,20 @@ int main(int argc, char **argv) {
if (!PP)
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);
+
+ // Process the source file.
ProcessInputFile(*PP, PPFactory, InFile);
HeaderInfo.ClearFileInfo();