[cfe-commits] r39641 - in /cfe/cfe/trunk: Basic/Diagnostic.cpp Driver/TextDiagnosticPrinter.cpp Driver/TextDiagnosticPrinter.h include/clang/Basic/Diagnostic.h

bwendlin at cs.uiuc.edu bwendlin at cs.uiuc.edu
Wed Jul 11 09:46:33 PDT 2007


Author: bwendlin
Date: Wed Jul 11 11:46:33 2007
New Revision: 39641

URL: http://llvm.org/viewvc/llvm-project?rev=39641&view=rev
Log:
Submitted by: Bill Wendling
Reviewed by: Chris Lattner

- Added a method "IgnoreDiagnostic" so that the diagnostic client can
  tell the diagnostic object that it doesn't want to handle a particular
  diagnostic message. In which case, it won't be counted as either a
  diagnostic or error.

Modified:
    cfe/cfe/trunk/Basic/Diagnostic.cpp
    cfe/cfe/trunk/Driver/TextDiagnosticPrinter.cpp
    cfe/cfe/trunk/Driver/TextDiagnosticPrinter.h
    cfe/cfe/trunk/include/clang/Basic/Diagnostic.h

Modified: cfe/cfe/trunk/Basic/Diagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Basic/Diagnostic.cpp?rev=39641&r1=39640&r2=39641&view=diff

==============================================================================
--- cfe/cfe/trunk/Basic/Diagnostic.cpp (original)
+++ cfe/cfe/trunk/Basic/Diagnostic.cpp Wed Jul 11 11:46:33 2007
@@ -135,6 +135,10 @@
     ++NumErrors;
   }
 
+  // Are we going to ignore this diagnosic?
+  if (Client.IgnoreDiagnostic(DiagLevel, Pos))
+    return;
+
   // Finally, report it.
   Client.HandleDiagnostic(DiagLevel, Pos, (diag::kind)DiagID, Strs, NumStrs,
                           Ranges, NumRanges);

Modified: cfe/cfe/trunk/Driver/TextDiagnosticPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Driver/TextDiagnosticPrinter.cpp?rev=39641&r1=39640&r2=39641&view=diff

==============================================================================
--- cfe/cfe/trunk/Driver/TextDiagnosticPrinter.cpp (original)
+++ cfe/cfe/trunk/Driver/TextDiagnosticPrinter.cpp Wed Jul 11 11:46:33 2007
@@ -121,6 +121,27 @@
   return TheTok.getLength();
 }
 
+bool TextDiagnosticPrinter::IgnoreDiagnostic(Diagnostic::Level Level, 
+                                             SourceLocation Pos) {
+  if (Pos.isValid()) {
+    // If this is a warning or note, and if it a system header, suppress the
+    // diagnostic.
+    if (Level == Diagnostic::Warning ||
+        Level == Diagnostic::Note) {
+      SourceLocation PhysLoc = SourceMgr.getPhysicalLoc(Pos);
+      const FileEntry *F = SourceMgr.getFileEntryForFileID(PhysLoc.getFileID());
+      if (F) {
+        DirectoryLookup::DirType DirInfo = TheHeaderSearch->getFileDirFlavor(F);
+        if (DirInfo == DirectoryLookup::SystemHeaderDir ||
+            DirInfo == DirectoryLookup::ExternCSystemHeaderDir)
+          return true;
+      }
+    }
+  }
+
+  return false;
+}
+
 void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level, 
                                              SourceLocation Pos,
                                              diag::kind ID,
@@ -136,20 +157,6 @@
     LineNo = SourceMgr.getLineNumber(Pos);
     FileID  = SourceMgr.getLogicalLoc(Pos).getFileID();
     
-    // If this is a warning or note, and if it a system header, suppress the
-    // diagnostic.
-    if (Level == Diagnostic::Warning ||
-        Level == Diagnostic::Note) {
-      SourceLocation PhysLoc = SourceMgr.getPhysicalLoc(Pos);
-      const FileEntry *F = SourceMgr.getFileEntryForFileID(PhysLoc.getFileID());
-      if (F) {
-        DirectoryLookup::DirType DirInfo = TheHeaderSearch->getFileDirFlavor(F);
-        if (DirInfo == DirectoryLookup::SystemHeaderDir ||
-            DirInfo == DirectoryLookup::ExternCSystemHeaderDir)
-          return;
-      }
-    }
-    
     // First, if this diagnostic is not in the main file, print out the
     // "included from" lines.
     if (LastWarningLoc != SourceMgr.getIncludeLoc(FileID)) {

Modified: cfe/cfe/trunk/Driver/TextDiagnosticPrinter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Driver/TextDiagnosticPrinter.h?rev=39641&r1=39640&r2=39641&view=diff

==============================================================================
--- cfe/cfe/trunk/Driver/TextDiagnosticPrinter.h (original)
+++ cfe/cfe/trunk/Driver/TextDiagnosticPrinter.h Wed Jul 11 11:46:33 2007
@@ -42,6 +42,8 @@
                           const std::string &SourceLine);
       unsigned GetTokenLength(SourceLocation Loc);
 
+      virtual bool IgnoreDiagnostic(Diagnostic::Level Level,
+                                    SourceLocation Pos);
       virtual void HandleDiagnostic(Diagnostic::Level DiagLevel,
                                     SourceLocation Pos,
                                     diag::kind ID, const std::string *Strs,

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

==============================================================================
--- cfe/cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/cfe/trunk/include/clang/Basic/Diagnostic.h Wed Jul 11 11:46:33 2007
@@ -140,6 +140,11 @@
 public:
   virtual ~DiagnosticClient();
 
+  /// IgnoreDiagnostic - If the client wants to ignore this diagnostic, then
+  /// return true.
+  virtual bool IgnoreDiagnostic(Diagnostic::Level DiagLevel,
+                                SourceLocation Pos) = 0;
+
   /// HandleDiagnostic - Handle this diagnostic, reporting it to the user or
   /// capturing it to a log as needed.
   virtual void HandleDiagnostic(Diagnostic::Level DiagLevel, SourceLocation Pos,





More information about the cfe-commits mailing list