[cfe-commits] r69377 - in /cfe/trunk: include/clang/Basic/Diagnostic.h include/clang/Frontend/TextDiagnosticPrinter.h tools/clang-cc/clang-cc.cpp

Chris Lattner sabre at nondot.org
Fri Apr 17 13:16:08 PDT 2009


Author: lattner
Date: Fri Apr 17 15:16:08 2009
New Revision: 69377

URL: http://llvm.org/viewvc/llvm-project?rev=69377&view=rev
Log:
add a virtual method to DiagnosticClient to get rid of some fragile
casting in clang-cc.

Modified:
    cfe/trunk/include/clang/Basic/Diagnostic.h
    cfe/trunk/include/clang/Frontend/TextDiagnosticPrinter.h
    cfe/trunk/tools/clang-cc/clang-cc.cpp

Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=69377&r1=69376&r2=69377&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Fri Apr 17 15:16:08 2009
@@ -27,6 +27,7 @@
   class SourceRange;
   class DiagnosticBuilder;
   class IdentifierInfo;
+  class LangOptions;
   
   // Import the diagnostic enums themselves.
   namespace diag {
@@ -667,6 +668,13 @@
 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

Modified: cfe/trunk/include/clang/Frontend/TextDiagnosticPrinter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/TextDiagnosticPrinter.h?rev=69377&r1=69376&r2=69377&view=diff

==============================================================================
--- cfe/trunk/include/clang/Frontend/TextDiagnosticPrinter.h (original)
+++ cfe/trunk/include/clang/Frontend/TextDiagnosticPrinter.h Fri Apr 17 15:16:08 2009
@@ -50,8 +50,8 @@
       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);

Modified: cfe/trunk/tools/clang-cc/clang-cc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/clang-cc.cpp?rev=69377&r1=69376&r2=69377&view=diff

==============================================================================
--- cfe/trunk/tools/clang-cc/clang-cc.cpp (original)
+++ cfe/trunk/tools/clang-cc/clang-cc.cpp Fri Apr 17 15:16:08 2009
@@ -2301,11 +2301,7 @@
     
     // 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 @@
     // Process the source file.
     ProcessInputFile(*PP, PPFactory, InFile, ProgAction);
     
-    HeaderInfo.ClearFileInfo();      
+    HeaderInfo.ClearFileInfo();
+    TextDiagClient->setLangOptions(0);
   }
 
   if (Verbose)





More information about the cfe-commits mailing list