[cfe-commits] r54472 - in /cfe/trunk: Driver/clang.cpp include/clang/Basic/Diagnostic.h lib/Basic/Diagnostic.cpp
Ted Kremenek
kremenek at apple.com
Thu Aug 7 10:49:58 PDT 2008
Author: kremenek
Date: Thu Aug 7 12:49:57 2008
New Revision: 54472
URL: http://llvm.org/viewvc/llvm-project?rev=54472&view=rev
Log:
Fix --html-diags in driver by delaying the construction of an HTMLDiagnosticClient until after we have created the Preprocessor object.
Modified:
cfe/trunk/Driver/clang.cpp
cfe/trunk/include/clang/Basic/Diagnostic.h
cfe/trunk/lib/Basic/Diagnostic.cpp
Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=54472&r1=54471&r2=54472&view=diff
==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Thu Aug 7 12:49:57 2008
@@ -1389,38 +1389,26 @@
// 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 @@
// 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 @@
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();
Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=54472&r1=54471&r2=54472&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Thu Aug 7 12:49:57 2008
@@ -61,7 +61,7 @@
bool WarningsAsErrors; // Treat warnings like errors:
bool WarnOnExtensions; // Enables warnings for gcc extensions: -pedantic.
bool ErrorOnExtensions; // Error on extensions: -pedantic-errors.
- DiagnosticClient &Client;
+ DiagnosticClient *Client;
/// DiagMappings - Mapping information for diagnostics. Mapping info is
/// packed into two bits per diagnostic.
@@ -77,16 +77,17 @@
/// CustomDiagInfo - Information for uniquing and looking up custom diags.
diag::CustomDiagInfo *CustomDiagInfo;
public:
- explicit Diagnostic(DiagnosticClient &client);
+ explicit Diagnostic(DiagnosticClient *client);
~Diagnostic();
//===--------------------------------------------------------------------===//
// Diagnostic characterization methods, used by a client to customize how
//
- DiagnosticClient &getClient() { return Client; };
-
- const DiagnosticClient &getClient() const { return Client; };
+ DiagnosticClient &getClient() { return *Client; };
+ const DiagnosticClient &getClient() const { return *Client; };
+
+ void setClient(DiagnosticClient* client) { Client = client; }
/// setIgnoreAllWarnings - When set to true, any unmapped warnings are
/// ignored. If this and WarningsAsErrors are both set, then this one wins.
Modified: cfe/trunk/lib/Basic/Diagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=54472&r1=54471&r2=54472&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Thu Aug 7 12:49:57 2008
@@ -108,7 +108,7 @@
// Common Diagnostic implementation
//===----------------------------------------------------------------------===//
-Diagnostic::Diagnostic(DiagnosticClient &client) : Client(client) {
+Diagnostic::Diagnostic(DiagnosticClient *client) : Client(client) {
IgnoreAllWarnings = false;
WarningsAsErrors = false;
WarnOnExtensions = false;
@@ -219,7 +219,7 @@
return;
// Set the diagnostic client if it isn't set already.
- if (!C) C = &Client;
+ if (!C) C = Client;
// If this is not an error and we are in a system header, ignore it. We have
// to check on the original class here, because we also want to ignore
@@ -227,13 +227,13 @@
// warnings/extensions to errors.
if (DiagID < diag::NUM_BUILTIN_DIAGNOSTICS &&
getBuiltinDiagClass(DiagID) != ERROR &&
- Client.isInSystemHeader(Pos))
+ Client->isInSystemHeader(Pos))
return;
if (DiagLevel >= Diagnostic::Error) {
ErrorOccurred = true;
- if (C == &Client)
+ if (C == Client)
++NumErrors;
}
@@ -242,7 +242,7 @@
C->HandleDiagnostic(*this, DiagLevel, Pos, (diag::kind)DiagID,
Strs, NumStrs, Ranges, NumRanges);
- if (C == &Client)
+ if (C == Client)
++NumDiagnostics;
}
More information about the cfe-commits
mailing list