[cfe-commits] r63282 - in /cfe/trunk: Driver/clang.cpp include/clang/AST/ASTDiagnostic.h include/clang/Analysis/AnalysisDiagnostic.h include/clang/Basic/Diagnostic.h include/clang/Driver/DriverDiagnostic.h include/clang/Lex/LexDiagnostic.h include/clang/Parse/ParseDiagnostic.h include/clang/Sema/SemaDiagnostic.h lib/Basic/Diagnostic.cpp

Chris Lattner sabre at nondot.org
Wed Jan 28 22:55:47 PST 2009


Author: lattner
Date: Thu Jan 29 00:55:46 2009
New Revision: 63282

URL: http://llvm.org/viewvc/llvm-project?rev=63282&view=rev
Log:
Fix -Wimplicit-function-declaration, which required some refactoring and
changes in various diagnostics code.

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/Driver/DriverDiagnostic.h
    cfe/trunk/include/clang/Lex/LexDiagnostic.h
    cfe/trunk/include/clang/Parse/ParseDiagnostic.h
    cfe/trunk/include/clang/Sema/SemaDiagnostic.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=63282&r1=63281&r2=63282&view=diff

==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Thu Jan 29 00:55:46 2009
@@ -35,6 +35,7 @@
 #include "clang/AST/TranslationUnit.h"
 #include "clang/CodeGen/ModuleBuilder.h"
 #include "clang/Sema/ParseAST.h"
+#include "clang/Sema/SemaDiagnostic.h"
 #include "clang/AST/ASTConsumer.h"
 #include "clang/Parse/Parser.h"
 #include "clang/Lex/HeaderSearch.h"
@@ -727,7 +728,10 @@
   if (!WarnUndefMacros)
     Diags.setDiagnosticMapping(diag::warn_pp_undef_identifier,diag::MAP_IGNORE);
     
-  if (!WarnImplicitFunctionDeclaration)
+  if (WarnImplicitFunctionDeclaration)
+    Diags.setDiagnosticMapping(diag::ext_implicit_function_decl,
+                               diag::MAP_WARNING);
+  else
     Diags.setDiagnosticMapping(diag::warn_implicit_function_decl,
                                diag::MAP_IGNORE);
 }

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

==============================================================================
--- cfe/trunk/include/clang/AST/ASTDiagnostic.h (original)
+++ cfe/trunk/include/clang/AST/ASTDiagnostic.h Thu Jan 29 00:55:46 2009
@@ -16,7 +16,6 @@
   namespace diag { 
     enum {
 #define DIAG(ENUM,FLAGS,DESC) ENUM,
-#include "clang/Basic/DiagnosticCommonKinds.def"
 #define ASTSTART
 #include "clang/Basic/DiagnosticASTKinds.def"
       NUM_BUILTIN_AST_DIAGNOSTICS

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

==============================================================================
--- cfe/trunk/include/clang/Analysis/AnalysisDiagnostic.h (original)
+++ cfe/trunk/include/clang/Analysis/AnalysisDiagnostic.h Thu Jan 29 00:55:46 2009
@@ -16,7 +16,6 @@
   namespace diag { 
     enum {
 #define DIAG(ENUM,FLAGS,DESC) ENUM,
-#include "clang/Basic/DiagnosticCommonKinds.def"
 #define ANALYSISSTART
 #include "clang/Basic/DiagnosticAnalysisKinds.def"
       NUM_BUILTIN_ANALYSIS_DIAGNOSTICS

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

==============================================================================
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Thu Jan 29 00:55:46 2009
@@ -43,6 +43,14 @@
     /// diag::kind - All of the diagnostics that can be emitted by the frontend.
     typedef unsigned kind;
 
+    // Get typedefs for common diagnostics.
+    enum {
+#define DIAG(ENUM,FLAGS,DESC) ENUM,
+#include "clang/Basic/DiagnosticCommonKinds.def"
+      NUM_BUILTIN_COMMON_DIAGNOSTICS
+#undef DIAG
+    };
+      
     /// Enum values that allow the client to map NOTEs, WARNINGs, and EXTENSIONs
     /// to either MAP_IGNORE (nothing), MAP_WARNING (emit a warning), MAP_ERROR
     /// (emit as an error), or MAP_DEFAULT (handle the default way).

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

==============================================================================
--- cfe/trunk/include/clang/Driver/DriverDiagnostic.h (original)
+++ cfe/trunk/include/clang/Driver/DriverDiagnostic.h Thu Jan 29 00:55:46 2009
@@ -15,8 +15,7 @@
 namespace clang {
   namespace diag { 
     enum {
-#define DIAG(ENUM,FLAGS,DESC) ENUM,
-#include "clang/Basic/DiagnosticCommonKinds.def"
+// FIXME: REMOVE??
       NUM_BUILTIN_DRIVER_DIAGNOSTICS
     };
   }  // end namespace diag

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

==============================================================================
--- cfe/trunk/include/clang/Lex/LexDiagnostic.h (original)
+++ cfe/trunk/include/clang/Lex/LexDiagnostic.h Thu Jan 29 00:55:46 2009
@@ -16,7 +16,6 @@
   namespace diag { 
     enum {
 #define DIAG(ENUM,FLAGS,DESC) ENUM,
-#include "clang/Basic/DiagnosticCommonKinds.def"
 #define LEXSTART
 #include "clang/Basic/DiagnosticLexKinds.def"
       NUM_BUILTIN_LEX_DIAGNOSTICS

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

==============================================================================
--- cfe/trunk/include/clang/Parse/ParseDiagnostic.h (original)
+++ cfe/trunk/include/clang/Parse/ParseDiagnostic.h Thu Jan 29 00:55:46 2009
@@ -16,7 +16,6 @@
   namespace diag { 
     enum {
 #define DIAG(ENUM,FLAGS,DESC) ENUM,
-#include "clang/Basic/DiagnosticCommonKinds.def"
 #define PARSESTART
 #include "clang/Basic/DiagnosticParseKinds.def"
       NUM_BUILTIN_PARSE_DIAGNOSTICS

Modified: cfe/trunk/include/clang/Sema/SemaDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/SemaDiagnostic.h?rev=63282&r1=63281&r2=63282&view=diff

==============================================================================
--- cfe/trunk/include/clang/Sema/SemaDiagnostic.h (original)
+++ cfe/trunk/include/clang/Sema/SemaDiagnostic.h Thu Jan 29 00:55:46 2009
@@ -16,9 +16,9 @@
   namespace diag { 
     enum {
 #define DIAG(ENUM,FLAGS,DESC) ENUM,
-#include "clang/Basic/DiagnosticCommonKinds.def"
 #define SEMASTART
 #include "clang/Basic/DiagnosticSemaKinds.def"
+#undef DIAG
       NUM_BUILTIN_SEMA_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=63282&r1=63281&r2=63282&view=diff

==============================================================================
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Thu Jan 29 00:55:46 2009
@@ -36,21 +36,6 @@
   class_mask = 0x07
 };
 
-namespace clang {
-  namespace diag {
-    enum _kind{
-#define DIAG(ENUM,FLAGS,DESC) ENUM,
-#define LEXSTART
-#define PARSESTART
-#define ASTSTART
-#define SEMASTART
-#define ANALYSISSTART
-#include "clang/Basic/DiagnosticKinds.def"
-      NUM_BUILTIN_DIAGNOSTICS = DIAG_UPPER_LIMIT
-    };
-  }
-}
-
 /// DiagnosticFlags - A set of flags, or'd together, that describe the
 /// diagnostic.
 #define DIAG(ENUM,FLAGS,DESC) FLAGS,
@@ -83,7 +68,7 @@
 /// getDiagClass - Return the class field of the diagnostic.
 ///
 static unsigned getBuiltinDiagClass(unsigned DiagID) {
-  assert(DiagID < diag::NUM_BUILTIN_DIAGNOSTICS &&
+  assert(DiagID < DIAG_UPPER_LIMIT &&
          "Diagnostic ID out of range!");
   unsigned res;
   if (DiagID < DIAG_START_LEX)
@@ -145,16 +130,16 @@
       /// getDescription - Return the description of the specified custom
       /// diagnostic.
       const char *getDescription(unsigned DiagID) const {
-        assert(this && DiagID-diag::NUM_BUILTIN_DIAGNOSTICS < DiagInfo.size() &&
+        assert(this && DiagID-DIAG_UPPER_LIMIT < DiagInfo.size() &&
                "Invalid diagnosic ID");
-        return DiagInfo[DiagID-diag::NUM_BUILTIN_DIAGNOSTICS].second.c_str();
+        return DiagInfo[DiagID-DIAG_UPPER_LIMIT].second.c_str();
       }
       
       /// getLevel - Return the level of the specified custom diagnostic.
       Diagnostic::Level getLevel(unsigned DiagID) const {
-        assert(this && DiagID-diag::NUM_BUILTIN_DIAGNOSTICS < DiagInfo.size() &&
+        assert(this && DiagID-DIAG_UPPER_LIMIT < DiagInfo.size() &&
                "Invalid diagnosic ID");
-        return DiagInfo[DiagID-diag::NUM_BUILTIN_DIAGNOSTICS].first;
+        return DiagInfo[DiagID-DIAG_UPPER_LIMIT].first;
       }
       
       unsigned getOrCreateDiagID(Diagnostic::Level L, const char *Message,
@@ -166,7 +151,7 @@
           return I->second;
         
         // If not, assign a new ID.
-        unsigned ID = DiagInfo.size()+diag::NUM_BUILTIN_DIAGNOSTICS;
+        unsigned ID = DiagInfo.size()+DIAG_UPPER_LIMIT;
         DiagIDs.insert(std::make_pair(D, ID));
         DiagInfo.push_back(D);
 
@@ -231,16 +216,14 @@
 /// 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::NUM_BUILTIN_DIAGNOSTICS && 
-         getBuiltinDiagClass(DiagID) < ERROR;
+  return DiagID < 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::NUM_BUILTIN_DIAGNOSTICS)
-  {
+  if (DiagID < DIAG_UPPER_LIMIT) {
     if (DiagID < DIAG_START_LEX)
       return DiagnosticTextCommon[DiagID];
     else if (DiagID < DIAG_START_PARSE)
@@ -263,7 +246,7 @@
 /// the DiagnosticClient.
 Diagnostic::Level Diagnostic::getDiagnosticLevel(unsigned DiagID) const {
   // Handle custom diagnostics, which cannot be mapped.
-  if (DiagID >= diag::NUM_BUILTIN_DIAGNOSTICS)
+  if (DiagID >= DIAG_UPPER_LIMIT)
     return CustomDiagInfo->getLevel(DiagID);
   
   unsigned DiagClass = getBuiltinDiagClass(DiagID);
@@ -324,7 +307,7 @@
   // ignore extensions and warnings in -Werror and -pedantic-errors modes,
   // which *map* warnings/extensions to errors.
   if (SuppressSystemWarnings &&
-      Info.getID() < diag::NUM_BUILTIN_DIAGNOSTICS &&
+      Info.getID() < DIAG_UPPER_LIMIT &&
       getBuiltinDiagClass(Info.getID()) != ERROR &&
       Info.getLocation().isValid() &&
       Info.getLocation().getSpellingLoc().isInSystemHeader())





More information about the cfe-commits mailing list