[cfe-commits] r63318 - in /cfe/trunk: Driver/clang.cpp include/clang/AST/ASTDiagnostic.h include/clang/Analysis/AnalysisDiagnostic.h include/clang/Basic/Diagnostic.h include/clang/Basic/DiagnosticCommonKinds.def include/clang/Basic/DiagnosticKinds.def include/clang/Basic/DiagnosticLexKinds.def include/clang/Basic/DiagnosticSemaKinds.def include/clang/Driver/DriverDiagnostic.h include/clang/Lex/LexDiagnostic.h include/clang/Parse/ParseDiagnostic.h lib/Basic/Diagnostic.cpp

Chris Lattner sabre at nondot.org
Thu Jan 29 09:46:13 PST 2009


Author: lattner
Date: Thu Jan 29 11:46:13 2009
New Revision: 63318

URL: http://llvm.org/viewvc/llvm-project?rev=63318&view=rev
Log:
next round of diagnostics cleanups, moving some 
diags around, eliminating #defines, etc.  Patch by
Anders Johnsen!


Modified:
    cfe/trunk/Driver/clang.cpp
    cfe/trunk/include/clang/AST/ASTDiagnostic.h
    cfe/trunk/include/clang/Analysis/AnalysisDiagnostic.h
    cfe/trunk/include/clang/Basic/Diagnostic.h
    cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.def
    cfe/trunk/include/clang/Basic/DiagnosticKinds.def
    cfe/trunk/include/clang/Basic/DiagnosticLexKinds.def
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def
    cfe/trunk/include/clang/Driver/DriverDiagnostic.h
    cfe/trunk/include/clang/Lex/LexDiagnostic.h
    cfe/trunk/include/clang/Parse/ParseDiagnostic.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=63318&r1=63317&r2=63318&view=diff

==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Thu Jan 29 11:46:13 2009
@@ -29,7 +29,6 @@
 #include "clang/Driver/InitHeaderSearch.h"
 #include "clang/Driver/TextDiagnosticBuffer.h"
 #include "clang/Driver/TextDiagnosticPrinter.h"
-#include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Analysis/PathDiagnostic.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/TranslationUnit.h"

Modified: cfe/trunk/include/clang/AST/ASTDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTDiagnostic.h?rev=63318&r1=63317&r2=63318&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/ASTDiagnostic.h (original)
+++ cfe/trunk/include/clang/AST/ASTDiagnostic.h Thu Jan 29 11:46:13 2009
@@ -18,6 +18,7 @@
 #define DIAG(ENUM,FLAGS,DESC) ENUM,
 #define ASTSTART
 #include "clang/Basic/DiagnosticASTKinds.def"
+#undef DIAG
       NUM_BUILTIN_AST_DIAGNOSTICS
     };
   }  // end namespace diag

Modified: cfe/trunk/include/clang/Analysis/AnalysisDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/AnalysisDiagnostic.h?rev=63318&r1=63317&r2=63318&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/AnalysisDiagnostic.h (original)
+++ cfe/trunk/include/clang/Analysis/AnalysisDiagnostic.h Thu Jan 29 11:46:13 2009
@@ -18,6 +18,7 @@
 #define DIAG(ENUM,FLAGS,DESC) ENUM,
 #define ANALYSISSTART
 #include "clang/Basic/DiagnosticAnalysisKinds.def"
+#undef DIAG
       NUM_BUILTIN_ANALYSIS_DIAGNOSTICS
     };
   }  // end namespace diag

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

==============================================================================
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Thu Jan 29 11:46:13 2009
@@ -18,13 +18,6 @@
 #include <string>
 #include <cassert>
 
-#define DIAG_START_LEX                              300
-#define DIAG_START_PARSE    (DIAG_START_LEX      +  300)
-#define DIAG_START_AST      (DIAG_START_PARSE    +  300)
-#define DIAG_START_SEMA     (DIAG_START_AST      +  100)
-#define DIAG_START_ANALYSIS (DIAG_START_SEMA     + 1000)
-#define DIAG_UPPER_LIMIT    (DIAG_START_ANALYSIS +  100)
-
 namespace llvm {
   template <typename T> class SmallVectorImpl;
 }
@@ -38,6 +31,16 @@
   
   // Import the diagnostic enums themselves.
   namespace diag {
+    // Start position for diagnostics.
+    enum {
+      DIAG_START_LEX      =                        300,
+      DIAG_START_PARSE    = DIAG_START_LEX      +  300,
+      DIAG_START_AST      = DIAG_START_PARSE    +  300,
+      DIAG_START_SEMA     = DIAG_START_AST      +  100,
+      DIAG_START_ANALYSIS = DIAG_START_SEMA     + 1000,
+      DIAG_UPPER_LIMIT    = DIAG_START_ANALYSIS +  100
+    };
+
     class CustomDiagInfo;
     
     /// diag::kind - All of the diagnostics that can be emitted by the frontend.
@@ -93,7 +96,7 @@
 
   /// DiagMappings - Mapping information for diagnostics.  Mapping info is
   /// packed into two bits per diagnostic.
-  unsigned char DiagMappings[DIAG_UPPER_LIMIT/4];
+  unsigned char DiagMappings[diag::DIAG_UPPER_LIMIT/4];
   
   /// ErrorOccurred - This is set to true when an error is emitted, and is
   /// sticky.
@@ -155,7 +158,7 @@
   /// setDiagnosticMapping - This allows the client to specify that certain
   /// warnings are ignored.  Only NOTEs, WARNINGs, and EXTENSIONs can be mapped.
   void setDiagnosticMapping(diag::kind Diag, diag::Mapping Map) {
-    assert(Diag < DIAG_UPPER_LIMIT &&
+    assert(Diag < diag::DIAG_UPPER_LIMIT &&
            "Can only map builtin diagnostics");
     assert(isBuiltinNoteWarningOrExtension(Diag) && "Cannot map errors!");
     unsigned char &Slot = DiagMappings[Diag/4];

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.def?rev=63318&r1=63317&r2=63318&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.def Thu Jan 29 11:46:13 2009
@@ -65,19 +65,7 @@
 // Driver
 DIAG(pp_macro_not_used, WARNING,    // -Wunused-macros
      "macro is not used")
-DIAG(warn_floatingpoint_eq, WARNING,
-  "comparing floating point with == or != is unsafe")
-DIAG(warn_objc_property_attr_mutually_exclusive, WARNING,
-     "property attributes '%0' and '%1' are mutually exclusive")
-DIAG(warn_printf_not_string_constant, WARNING,
-     "format string is not a string literal (potentially insecure)")
-DIAG(warn_implicit_function_decl, WARNING,
-     "implicit declaration of function %0")
 DIAG(err_pp_I_dash_not_supported, ERROR,
      "-I- not supported, please use -iquote instead")
-DIAG(warn_octal_escape_too_large, EXTWARN,
-     "octal escape sequence out of range")
-DIAG(warn_hex_escape_too_large, EXTWARN,
-     "hex escape sequence out of range")
 DIAG(warn_pp_undef_identifier, WARNING,
      "%0 is not defined, evaluates to 0")

Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=63318&r1=63317&r2=63318&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Thu Jan 29 11:46:13 2009
@@ -1,33 +0,0 @@
-//===-- DiagnosticKinds.def - C Family Diagnostic Kind Database -*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-//  This file defines the DiagnosticKind database.
-//
-//===----------------------------------------------------------------------===//
-
-// Flags for diagnostic:
-//
-//   DIAG_TYPE - Allows one of:
-//     NOTE      - Informational message.
-//     WARNING   - Warning.
-//     EXTENSION - Notification that an extension to the language is being used.
-//     EXTWARN   - Warning for behaviour that is supported as an extension. This 
-//                 differs from EXTENSION in that the warning is always emitted
-//                 by default.
-//     ERROR     - Error, compilation will stop after parsing completes.
-
-
-#include "clang/Basic/DiagnosticCommonKinds.def"
-#include "clang/Basic/DiagnosticLexKinds.def"
-#include "clang/Basic/DiagnosticParseKinds.def"
-#include "clang/Basic/DiagnosticASTKinds.def"
-#include "clang/Basic/DiagnosticSemaKinds.def"
-#include "clang/Basic/DiagnosticAnalysisKinds.def"
-
-#undef DIAG

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.def?rev=63318&r1=63317&r2=63318&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.def Thu Jan 29 11:46:13 2009
@@ -98,6 +98,10 @@
      "binary integer literals are an extension")
 DIAG(err_pascal_string_too_long, ERROR,
     "Pascal string is too long")
+DIAG(warn_octal_escape_too_large, EXTWARN,
+     "octal escape sequence out of range")
+DIAG(warn_hex_escape_too_large, EXTWARN,
+     "hex escape sequence out of range")
 
 //===----------------------------------------------------------------------===//
 // Preprocessor Diagnostics

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def?rev=63318&r1=63317&r2=63318&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def Thu Jan 29 11:46:13 2009
@@ -74,6 +74,8 @@
      "parameter name omitted")
 DIAG(warn_decl_in_param_list, WARNING,
      "declaration of %0 will not be visible outside of this function")
+DIAG(warn_implicit_function_decl, WARNING,
+     "implicit declaration of function %0")
 
 DIAG(err_declarator_need_ident, ERROR,
      "declarator requires an identifier")
@@ -196,6 +198,8 @@
      "synthesized properties %0 and %1 both claim ivar %2")
 DIAG(error_property_implemented, ERROR,
      "property %0 is already implemented")
+DIAG(warn_objc_property_attr_mutually_exclusive, WARNING,
+     "property attributes '%0' and '%1' are mutually exclusive")
 
 // C++ class members
 DIAG(err_storageclass_invalid_for_member, ERROR,
@@ -624,6 +628,8 @@
      "offsetof requires array type, %0 invalid")
 DIAG(ext_offsetof_extended_field_designator, EXTENSION,
      "using extended field designator is an extension")
+DIAG(warn_floatingpoint_eq, WARNING,
+  "comparing floating point with == or != is unsafe")
      
 DIAG(err_typecheck_subscript_value, ERROR,
      "subscripted value is neither array nor pointer")
@@ -721,6 +727,8 @@
      "initializer of a builtin type can only take one argument")
 DIAG(err_value_init_for_array_type, ERROR,
      "array types cannot be value-initialized")
+DIAG(warn_printf_not_string_constant, WARNING,
+     "format string is not a string literal (potentially insecure)")
 
 DIAG(err_unexpected_interface, ERROR,
      "unexpected interface name %0: expected expression")

Modified: cfe/trunk/include/clang/Driver/DriverDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/DriverDiagnostic.h?rev=63318&r1=63317&r2=63318&view=diff

==============================================================================
--- cfe/trunk/include/clang/Driver/DriverDiagnostic.h (original)
+++ cfe/trunk/include/clang/Driver/DriverDiagnostic.h Thu Jan 29 11:46:13 2009
@@ -1,25 +0,0 @@
-//===--- DiagnosticDriver.h - Diagnostics for the driver --------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_DIAGNOSTICDRIVER_H
-#define LLVM_CLANG_DIAGNOSTICDRIVER_H
-
-#include "clang/Basic/Diagnostic.h"
-
-namespace clang {
-  namespace diag { 
-    enum {
-// FIXME: REMOVE??
-      NUM_BUILTIN_DRIVER_DIAGNOSTICS
-    };
-  }  // end namespace diag
-}  // end namespace clang
-
-#endif
-

Modified: cfe/trunk/include/clang/Lex/LexDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/LexDiagnostic.h?rev=63318&r1=63317&r2=63318&view=diff

==============================================================================
--- cfe/trunk/include/clang/Lex/LexDiagnostic.h (original)
+++ cfe/trunk/include/clang/Lex/LexDiagnostic.h Thu Jan 29 11:46:13 2009
@@ -18,6 +18,7 @@
 #define DIAG(ENUM,FLAGS,DESC) ENUM,
 #define LEXSTART
 #include "clang/Basic/DiagnosticLexKinds.def"
+#undef DIAG
       NUM_BUILTIN_LEX_DIAGNOSTICS
     };
   }  // end namespace diag

Modified: cfe/trunk/include/clang/Parse/ParseDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/ParseDiagnostic.h?rev=63318&r1=63317&r2=63318&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/ParseDiagnostic.h (original)
+++ cfe/trunk/include/clang/Parse/ParseDiagnostic.h Thu Jan 29 11:46:13 2009
@@ -18,6 +18,7 @@
 #define DIAG(ENUM,FLAGS,DESC) ENUM,
 #define PARSESTART
 #include "clang/Basic/DiagnosticParseKinds.def"
+#undef DIAG
       NUM_BUILTIN_PARSE_DIAGNOSTICS
     };
   }  // end namespace diag

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

==============================================================================
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Thu Jan 29 11:46:13 2009
@@ -68,21 +68,21 @@
 /// getDiagClass - Return the class field of the diagnostic.
 ///
 static unsigned getBuiltinDiagClass(unsigned DiagID) {
-  assert(DiagID < DIAG_UPPER_LIMIT &&
+  assert(DiagID < diag::DIAG_UPPER_LIMIT &&
          "Diagnostic ID out of range!");
   unsigned res;
-  if (DiagID < DIAG_START_LEX)
+  if (DiagID < diag::DIAG_START_LEX)
     res = DiagnosticFlagsCommon[DiagID];
-  else if (DiagID < DIAG_START_PARSE)
-    res = DiagnosticFlagsLex[DiagID - DIAG_START_LEX - 1];
-  else if (DiagID < DIAG_START_AST)
-    res = DiagnosticFlagsParse[DiagID - DIAG_START_PARSE - 1];
-  else if (DiagID < DIAG_START_SEMA)
-    res = DiagnosticFlagsAST[DiagID - DIAG_START_AST - 1];
-  else if (DiagID < DIAG_START_ANALYSIS)
-    res = DiagnosticFlagsSema[DiagID - DIAG_START_SEMA - 1];
+  else if (DiagID < diag::DIAG_START_PARSE)
+    res = DiagnosticFlagsLex[DiagID - diag::DIAG_START_LEX - 1];
+  else if (DiagID < diag::DIAG_START_AST)
+    res = DiagnosticFlagsParse[DiagID - diag::DIAG_START_PARSE - 1];
+  else if (DiagID < diag::DIAG_START_SEMA)
+    res = DiagnosticFlagsAST[DiagID - diag::DIAG_START_AST - 1];
+  else if (DiagID < diag::DIAG_START_ANALYSIS)
+    res = DiagnosticFlagsSema[DiagID - diag::DIAG_START_SEMA - 1];
   else
-    res = DiagnosticFlagsAnalysis[DiagID - DIAG_START_ANALYSIS - 1];
+    res = DiagnosticFlagsAnalysis[DiagID - diag::DIAG_START_ANALYSIS - 1];
   return res & class_mask;
 }
 
@@ -216,26 +216,26 @@
 /// level of the specified diagnostic ID is a Note, Warning, or Extension.
 /// Note that this only works on builtin diagnostics, not custom ones.
 bool Diagnostic::isBuiltinNoteWarningOrExtension(unsigned DiagID) {
-  return DiagID < DIAG_UPPER_LIMIT && getBuiltinDiagClass(DiagID) < ERROR;
+  return DiagID < diag::DIAG_UPPER_LIMIT && getBuiltinDiagClass(DiagID) < ERROR;
 }
 
 
 /// getDescription - Given a diagnostic ID, return a description of the
 /// issue.
 const char *Diagnostic::getDescription(unsigned DiagID) const {
-  if (DiagID < DIAG_UPPER_LIMIT) {
-    if (DiagID < DIAG_START_LEX)
+  if (DiagID < diag::DIAG_UPPER_LIMIT) {
+    if (DiagID < diag::DIAG_START_LEX)
       return DiagnosticTextCommon[DiagID];
-    else if (DiagID < DIAG_START_PARSE)
-      return DiagnosticTextLex[DiagID - DIAG_START_LEX - 1];
-    else if (DiagID < DIAG_START_AST)
-      return DiagnosticTextParse[DiagID - DIAG_START_PARSE - 1];
-    else if (DiagID < DIAG_START_SEMA)
-      return DiagnosticTextAST[DiagID - DIAG_START_AST - 1];
-    else if (DiagID < DIAG_START_ANALYSIS)
-      return DiagnosticTextSema[DiagID - DIAG_START_SEMA - 1];
-    else if (DiagID < DIAG_UPPER_LIMIT)
-      return DiagnosticTextAnalysis[DiagID - DIAG_START_ANALYSIS - 1];
+    else if (DiagID < diag::DIAG_START_PARSE)
+      return DiagnosticTextLex[DiagID - diag::DIAG_START_LEX - 1];
+    else if (DiagID < diag::DIAG_START_AST)
+      return DiagnosticTextParse[DiagID - diag::DIAG_START_PARSE - 1];
+    else if (DiagID < diag::DIAG_START_SEMA)
+      return DiagnosticTextAST[DiagID - diag::DIAG_START_AST - 1];
+    else if (DiagID < diag::DIAG_START_ANALYSIS)
+      return DiagnosticTextSema[DiagID - diag::DIAG_START_SEMA - 1];
+    else if (DiagID < diag::DIAG_UPPER_LIMIT)
+      return DiagnosticTextAnalysis[DiagID - diag::DIAG_START_ANALYSIS - 1];
   }
    
   return CustomDiagInfo->getDescription(DiagID);
@@ -246,7 +246,7 @@
 /// the DiagnosticClient.
 Diagnostic::Level Diagnostic::getDiagnosticLevel(unsigned DiagID) const {
   // Handle custom diagnostics, which cannot be mapped.
-  if (DiagID >= DIAG_UPPER_LIMIT)
+  if (DiagID >= diag::DIAG_UPPER_LIMIT)
     return CustomDiagInfo->getLevel(DiagID);
   
   unsigned DiagClass = getBuiltinDiagClass(DiagID);
@@ -307,7 +307,7 @@
   // ignore extensions and warnings in -Werror and -pedantic-errors modes,
   // which *map* warnings/extensions to errors.
   if (SuppressSystemWarnings &&
-      Info.getID() < DIAG_UPPER_LIMIT &&
+      Info.getID() < diag::DIAG_UPPER_LIMIT &&
       getBuiltinDiagClass(Info.getID()) != ERROR &&
       Info.getLocation().isValid() &&
       Info.getLocation().getSpellingLoc().isInSystemHeader())





More information about the cfe-commits mailing list