#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"
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);
}
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,
/// 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)
/// 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,
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);
/// 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)
/// 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);
// 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())