diff options
author | Chris Lattner <sabre@nondot.org> | 2009-04-17 20:16:08 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-04-17 20:16:08 +0000 |
commit | 40469651a3f8379dc0f32df69e9bade06a2aad36 (patch) | |
tree | d9f93e24bbaf837b12e6532e70503c8fa42904c3 | |
parent | f7dac085f82d2cf395950db137f0bbf00fb305a8 (diff) |
add a virtual method to DiagnosticClient to get rid of some fragile
casting in clang-cc.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69377 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Basic/Diagnostic.h | 8 | ||||
-rw-r--r-- | include/clang/Frontend/TextDiagnosticPrinter.h | 4 | ||||
-rw-r--r-- | tools/clang-cc/clang-cc.cpp | 9 |
3 files changed, 13 insertions, 8 deletions
diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h index 87489257cc..9c0a02ca87 100644 --- a/include/clang/Basic/Diagnostic.h +++ b/include/clang/Basic/Diagnostic.h @@ -27,6 +27,7 @@ namespace clang { class SourceRange; class DiagnosticBuilder; class IdentifierInfo; + class LangOptions; // Import the diagnostic enums themselves. namespace diag { @@ -667,6 +668,13 @@ class DiagnosticClient { public: 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 /// returns true) indicates whether the diagnostics handled by this /// DiagnosticClient should be included in the number of diagnostics diff --git a/include/clang/Frontend/TextDiagnosticPrinter.h b/include/clang/Frontend/TextDiagnosticPrinter.h index 9341b89f56..afdafb2b34 100644 --- a/include/clang/Frontend/TextDiagnosticPrinter.h +++ b/include/clang/Frontend/TextDiagnosticPrinter.h @@ -50,8 +50,8 @@ public: PrintRangeInfo(printRangeInfo), PrintDiagnosticOption(printDiagnosticOption) {} - void SetLangOpts(const LangOptions &LO) { - LangOpts = &LO; + void setLangOptions(const LangOptions *LO) { + LangOpts = LO; } void PrintIncludeStack(SourceLocation Loc, const SourceManager &SM); diff --git a/tools/clang-cc/clang-cc.cpp b/tools/clang-cc/clang-cc.cpp index e9e5c3744a..81d1e39790 100644 --- a/tools/clang-cc/clang-cc.cpp +++ b/tools/clang-cc/clang-cc.cpp @@ -2301,11 +2301,7 @@ int main(int argc, char **argv) { // Initialize language options, inferring file types from input filenames. LangOptions LangInfo; - - if (!VerifyDiagnostics) - static_cast<TextDiagnosticPrinter*>(TextDiagClient) - ->SetLangOpts(LangInfo); - + TextDiagClient->setLangOptions(&LangInfo); InitializeBaseLanguage(); LangKind LK = GetLanguage(InFile); @@ -2346,7 +2342,8 @@ int main(int argc, char **argv) { // Process the source file. ProcessInputFile(*PP, PPFactory, InFile, ProgAction); - HeaderInfo.ClearFileInfo(); + HeaderInfo.ClearFileInfo(); + TextDiagClient->setLangOptions(0); } if (Verbose) |