add a virtual method to DiagnosticClient to get rid of some fragile

casting in clang-cc.

llvm-svn: 69377
This commit is contained in:
Chris Lattner 2009-04-17 20:16:08 +00:00
parent 5ceb1a2dd9
commit c6b5613460
3 changed files with 13 additions and 8 deletions

View File

@ -27,6 +27,7 @@ namespace clang {
class SourceRange; class SourceRange;
class DiagnosticBuilder; class DiagnosticBuilder;
class IdentifierInfo; class IdentifierInfo;
class LangOptions;
// Import the diagnostic enums themselves. // Import the diagnostic enums themselves.
namespace diag { namespace diag {
@ -667,6 +668,13 @@ class DiagnosticClient {
public: public:
virtual ~DiagnosticClient(); virtual ~DiagnosticClient();
/// setLangOptions - This is set by clients of diagnostics when they know the
/// language parameters of the diagnostics that may be sent through. Note
/// that this can change over time if a DiagClient has multiple languages sent
/// through it. It may also be set to null (e.g. when processing command line
/// options).
virtual void setLangOptions(const LangOptions *LO) {}
/// IncludeInDiagnosticCounts - This method (whose default implementation /// IncludeInDiagnosticCounts - This method (whose default implementation
/// returns true) indicates whether the diagnostics handled by this /// returns true) indicates whether the diagnostics handled by this
/// DiagnosticClient should be included in the number of diagnostics /// DiagnosticClient should be included in the number of diagnostics

View File

@ -50,8 +50,8 @@ public:
PrintRangeInfo(printRangeInfo), PrintRangeInfo(printRangeInfo),
PrintDiagnosticOption(printDiagnosticOption) {} PrintDiagnosticOption(printDiagnosticOption) {}
void SetLangOpts(const LangOptions &LO) { void setLangOptions(const LangOptions *LO) {
LangOpts = &LO; LangOpts = LO;
} }
void PrintIncludeStack(SourceLocation Loc, const SourceManager &SM); void PrintIncludeStack(SourceLocation Loc, const SourceManager &SM);

View File

@ -2301,11 +2301,7 @@ int main(int argc, char **argv) {
// Initialize language options, inferring file types from input filenames. // Initialize language options, inferring file types from input filenames.
LangOptions LangInfo; LangOptions LangInfo;
TextDiagClient->setLangOptions(&LangInfo);
if (!VerifyDiagnostics)
static_cast<TextDiagnosticPrinter*>(TextDiagClient)
->SetLangOpts(LangInfo);
InitializeBaseLanguage(); InitializeBaseLanguage();
LangKind LK = GetLanguage(InFile); LangKind LK = GetLanguage(InFile);
@ -2346,7 +2342,8 @@ int main(int argc, char **argv) {
// Process the source file. // Process the source file.
ProcessInputFile(*PP, PPFactory, InFile, ProgAction); ProcessInputFile(*PP, PPFactory, InFile, ProgAction);
HeaderInfo.ClearFileInfo(); HeaderInfo.ClearFileInfo();
TextDiagClient->setLangOptions(0);
} }
if (Verbose) if (Verbose)