Split the single monolithic DiagnosticKinds.def file into one

.def file for each library.  This means that adding a diagnostic
to sema doesn't require all the other libraries to be rebuilt.

Patch by Anders Johnsen!

llvm-svn: 63111
This commit is contained in:
Chris Lattner 2009-01-27 18:30:58 +00:00
parent 422d81dcd4
commit 7368d581c1
45 changed files with 150 additions and 1826 deletions

View File

@ -40,6 +40,7 @@
#include "clang/Basic/FileManager.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/DiagnosticDriver.h"
#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/StringExtras.h"

View File

@ -18,6 +18,13 @@
#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;
}
@ -34,12 +41,8 @@ namespace clang {
class CustomDiagInfo;
/// diag::kind - All of the diagnostics that can be emitted by the frontend.
enum kind {
#define DIAG(ENUM,FLAGS,DESC) ENUM,
#include "DiagnosticKinds.def"
NUM_BUILTIN_DIAGNOSTICS
};
typedef unsigned kind;
/// 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).
@ -82,7 +85,7 @@ private:
/// DiagMappings - Mapping information for diagnostics. Mapping info is
/// packed into two bits per diagnostic.
unsigned char DiagMappings[(diag::NUM_BUILTIN_DIAGNOSTICS+3)/4];
unsigned char DiagMappings[DIAG_UPPER_LIMIT/4];
/// ErrorOccurred - This is set to true when an error is emitted, and is
/// sticky.
@ -144,7 +147,7 @@ public:
/// 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::NUM_BUILTIN_DIAGNOSTICS &&
assert(Diag < DIAG_UPPER_LIMIT &&
"Can only map builtin diagnostics");
assert(isBuiltinNoteWarningOrExtension(Diag) && "Cannot map errors!");
unsigned char &Slot = DiagMappings[Diag/4];

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@
#include "clang/AST/ASTContext.h"
#include "clang/AST/RecordLayout.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticAST.h"
#include "clang/Basic/TargetInfo.h"
#include "llvm/Support/Compiler.h"
using namespace clang;

View File

@ -14,7 +14,7 @@
#include "clang/Analysis/Analyses/UninitializedValues.h"
#include "clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h"
#include "clang/Analysis/LocalCheckers.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticAnalysis.h"
#include "clang/AST/ASTContext.h"
#include "clang/Analysis/FlowSensitive/DataflowSolver.h"
#include "llvm/Support/Compiler.h"

View File

@ -36,29 +36,99 @@ enum {
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.
static unsigned char DiagnosticFlags[] = {
#define DIAG(ENUM,FLAGS,DESC) FLAGS,
#include "clang/Basic/DiagnosticKinds.def"
static unsigned char DiagnosticFlagsCommon[] = {
#include "clang/Basic/DiagnosticCommonKinds.def"
0
};
static unsigned char DiagnosticFlagsLex[] = {
#include "clang/Basic/DiagnosticLexKinds.def"
0
};
static unsigned char DiagnosticFlagsParse[] = {
#include "clang/Basic/DiagnosticParseKinds.def"
0
};
static unsigned char DiagnosticFlagsAST[] = {
#include "clang/Basic/DiagnosticASTKinds.def"
0
};
static unsigned char DiagnosticFlagsSema[] = {
#include "clang/Basic/DiagnosticSemaKinds.def"
0
};
static unsigned char DiagnosticFlagsAnalysis[] = {
#include "clang/Basic/DiagnosticAnalysisKinds.def"
0
};
#undef DIAG
/// getDiagClass - Return the class field of the diagnostic.
///
static unsigned getBuiltinDiagClass(unsigned DiagID) {
assert(DiagID < diag::NUM_BUILTIN_DIAGNOSTICS &&
"Diagnostic ID out of range!");
return DiagnosticFlags[DiagID] & class_mask;
unsigned res;
if (DiagID < 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
res = DiagnosticFlagsAnalysis[DiagID - DIAG_START_ANALYSIS - 1];
return res & class_mask;
}
/// DiagnosticText - An english message to print for the diagnostic. These
/// should be localized.
static const char * const DiagnosticText[] = {
#define DIAG(ENUM,FLAGS,DESC) DESC,
#include "clang/Basic/DiagnosticKinds.def"
static const char * const DiagnosticTextCommon[] = {
#include "clang/Basic/DiagnosticCommonKinds.def"
0
};
static const char * const DiagnosticTextLex[] = {
#include "clang/Basic/DiagnosticLexKinds.def"
0
};
static const char * const DiagnosticTextParse[] = {
#include "clang/Basic/DiagnosticParseKinds.def"
0
};
static const char * const DiagnosticTextAST[] = {
#include "clang/Basic/DiagnosticASTKinds.def"
0
};
static const char * const DiagnosticTextSema[] = {
#include "clang/Basic/DiagnosticSemaKinds.def"
0
};
static const char * const DiagnosticTextAnalysis[] = {
#include "clang/Basic/DiagnosticAnalysisKinds.def"
0
};
#undef DIAG
//===----------------------------------------------------------------------===//
// Custom Diagnostic information
@ -170,9 +240,22 @@ bool Diagnostic::isBuiltinNoteWarningOrExtension(unsigned DiagID) {
/// issue.
const char *Diagnostic::getDescription(unsigned DiagID) const {
if (DiagID < diag::NUM_BUILTIN_DIAGNOSTICS)
return DiagnosticText[DiagID];
else
return CustomDiagInfo->getDescription(DiagID);
{
if (DiagID < 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];
}
return CustomDiagInfo->getDescription(DiagID);
}
/// getDiagnosticLevel - Based on the way the client configured the Diagnostic

View File

@ -26,7 +26,7 @@
#include "clang/Lex/Lexer.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticLex.h"
#include "clang/Basic/SourceManager.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/MemoryBuffer.h"

View File

@ -14,7 +14,7 @@
#include "clang/Lex/LiteralSupport.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticLex.h"
#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/StringExtras.h"
using namespace clang;

View File

@ -14,7 +14,7 @@
#include "MacroArgs.h"
#include "clang/Lex/MacroInfo.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticLex.h"
using namespace clang;
/// MacroArgs ctor function - This destroys the vector passed in.

View File

@ -15,7 +15,7 @@
#include "clang/Lex/LiteralSupport.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/MacroInfo.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticLex.h"
#include "clang/Basic/SourceManager.h"
#include "llvm/ADT/APInt.h"
using namespace clang;

View File

@ -20,7 +20,7 @@
#include "clang/Lex/MacroInfo.h"
#include "clang/Lex/LiteralSupport.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticLex.h"
#include "llvm/ADT/APSInt.h"
using namespace clang;

View File

@ -15,7 +15,7 @@
#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/MacroInfo.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticLex.h"
#include "clang/Basic/SourceManager.h"
#include "llvm/Support/MemoryBuffer.h"

View File

@ -17,7 +17,7 @@
#include "clang/Lex/MacroInfo.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticLex.h"
#include <ctime>
using namespace clang;

View File

@ -16,7 +16,7 @@
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/LiteralSupport.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticLex.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/SourceManager.h"
using namespace clang;

View File

@ -30,7 +30,7 @@
#include "clang/Lex/MacroInfo.h"
#include "clang/Lex/Pragma.h"
#include "clang/Lex/ScratchBuffer.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticLex.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/APFloat.h"

View File

@ -13,7 +13,7 @@
#include "clang/Lex/PreprocessorLexer.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticLex.h"
#include "clang/Basic/SourceManager.h"
using namespace clang;

View File

@ -16,7 +16,7 @@
#include "clang/Lex/MacroInfo.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticLex.h"
#include "llvm/ADT/SmallVector.h"
using namespace clang;

View File

@ -12,7 +12,7 @@
//===----------------------------------------------------------------------===//
#include "clang/Parse/DeclSpec.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticParse.h"
#include "clang/Basic/LangOptions.h"
#include "llvm/ADT/STLExtras.h"
using namespace clang;

View File

@ -14,7 +14,7 @@
#ifndef LLVM_CLANG_PARSE_EXTENSION_RAII_OBJECT_H
#define LLVM_CLANG_PARSE_EXTENSION_RAII_OBJECT_H
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticParse.h"
namespace clang {

View File

@ -11,7 +11,7 @@
//
//===----------------------------------------------------------------------===//
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticParse.h"
#include "clang/Parse/Parser.h"
#include "clang/Parse/DeclSpec.h"
#include "clang/Parse/Scope.h"

View File

@ -12,7 +12,7 @@
//===----------------------------------------------------------------------===//
#include "clang/Parse/Parser.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticParse.h"
#include "clang/Parse/Scope.h"
#include "ExtensionRAIIObject.h"
#include "AstGuard.h"

View File

@ -12,7 +12,7 @@
//===----------------------------------------------------------------------===//
#include "clang/Parse/Parser.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticParse.h"
#include "clang/Parse/DeclSpec.h"
#include "clang/Parse/Scope.h"
#include "AstGuard.h"

View File

@ -11,7 +11,7 @@
//
//===----------------------------------------------------------------------===//
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticParse.h"
#include "clang/Parse/Parser.h"
#include "clang/Parse/DeclSpec.h"
#include "AstGuard.h"

View File

@ -14,7 +14,7 @@
#include "clang/Parse/Designator.h"
#include "clang/Parse/Parser.h"
#include "AstGuard.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticParse.h"
#include "llvm/ADT/SmallString.h"
using namespace clang;

View File

@ -15,7 +15,7 @@
#include "clang/Parse/DeclSpec.h"
#include "clang/Parse/Scope.h"
#include "AstGuard.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticParse.h"
#include "llvm/ADT/SmallVector.h"
using namespace clang;

View File

@ -12,7 +12,7 @@
//===----------------------------------------------------------------------===//
#include "ParsePragma.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticParse.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Parse/Action.h"
using namespace clang;

View File

@ -12,7 +12,7 @@
//===----------------------------------------------------------------------===//
#include "clang/Parse/Parser.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticParse.h"
#include "clang/Parse/DeclSpec.h"
#include "clang/Parse/Scope.h"

View File

@ -13,7 +13,7 @@
//===----------------------------------------------------------------------===//
#include "clang/Parse/Parser.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticParse.h"
using namespace clang;
/// isCXXDeclarationStatement - C++-specialized function that disambiguates

View File

@ -12,7 +12,7 @@
//===----------------------------------------------------------------------===//
#include "clang/Parse/Parser.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticParse.h"
#include "clang/Parse/DeclSpec.h"
#include "clang/Parse/Scope.h"
#include "ExtensionRAIIObject.h"

View File

@ -17,7 +17,7 @@
#include "clang/AST/DeclObjC.h"
#include "clang/AST/Expr.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticSema.h"
using namespace clang;
/// ConvertQualTypeToStringFn - This function is used to pretty print the

View File

@ -21,7 +21,7 @@
#include "clang/AST/DeclBase.h"
#include "clang/AST/Expr.h"
#include "clang/Parse/Action.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticSema.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/SmallPtrSet.h"

View File

@ -14,7 +14,7 @@
#include "Sema.h"
#include "clang/AST/ASTContext.h"
#include "clang/Parse/DeclSpec.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticSema.h"
#include "llvm/ADT/STLExtras.h"
using namespace clang;

View File

@ -18,7 +18,7 @@
#include "clang/AST/ExprCXX.h"
#include "clang/AST/ExprObjC.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticSema.h"
#include "SemaUtil.h"
using namespace clang;

View File

@ -18,7 +18,7 @@
#include "clang/AST/DeclObjC.h"
#include "clang/AST/ExprCXX.h"
#include "clang/Parse/DeclSpec.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticSema.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/SourceManager.h"
// FIXME: layering (ideally, Sema shouldn't be dependent on Lex API's)

View File

@ -15,7 +15,7 @@
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/Expr.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticSema.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Parse/DeclSpec.h"
#include <llvm/ADT/StringExtras.h>

View File

@ -18,7 +18,7 @@
#include "clang/AST/TypeOrdering.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticSema.h"
#include "clang/Parse/DeclSpec.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Compiler.h"

View File

@ -14,7 +14,7 @@
#include "Sema.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclObjC.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticSema.h"
#include "clang/Parse/DeclSpec.h"
using namespace clang;

View File

@ -18,7 +18,7 @@
#include "clang/AST/ExprObjC.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/LiteralSupport.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticSema.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Parse/DeclSpec.h"

View File

@ -16,7 +16,7 @@
#include "clang/AST/ASTContext.h"
#include "clang/Parse/DeclSpec.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticSema.h"
#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/STLExtras.h"
using namespace clang;

View File

@ -15,7 +15,7 @@
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/ExprObjC.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticSema.h"
using namespace clang;
Sema::ExprResult Sema::ParseObjCStringLiteral(SourceLocation *AtLocs,

View File

@ -19,7 +19,7 @@
#include "clang/AST/DeclCXX.h"
#include "clang/AST/Type.h"
#include "clang/AST/TypeOrdering.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticSema.h"
#include <algorithm>
#include <memory>
#include <set>

View File

@ -15,7 +15,7 @@
#include "clang/Parse/Designator.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Expr.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticSema.h"
#include <algorithm> // for std::count_if
#include <functional> // for std::mem_fun

View File

@ -15,7 +15,7 @@
#include "SemaInherit.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/ASTContext.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticSema.h"
#include "llvm/ADT/SmallVector.h"
#include <set>
using namespace clang;

View File

@ -17,7 +17,7 @@
#include "clang/AST/DeclObjC.h"
#include "clang/AST/Expr.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticSema.h"
using namespace clang;
Sema::OwningStmtResult Sema::ActOnExprStmt(ExprArg expr) {

View File

@ -15,7 +15,7 @@
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/Expr.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticSema.h"
#include "clang/Parse/DeclSpec.h"
using namespace clang;