#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"
#define DIAG(ENUM,FLAGS,DESC) ENUM,
#define ASTSTART
#include "clang/Basic/DiagnosticASTKinds.def"
+#undef DIAG
NUM_BUILTIN_AST_DIAGNOSTICS
};
} // end namespace diag
#define DIAG(ENUM,FLAGS,DESC) ENUM,
#define ANALYSISSTART
#include "clang/Basic/DiagnosticAnalysisKinds.def"
+#undef DIAG
NUM_BUILTIN_ANALYSIS_DIAGNOSTICS
};
} // end namespace diag
#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;
}
// 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.
/// 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.
/// 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];
// 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")
-//===-- 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
"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
"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")
"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,
"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")
"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")
-//===--- 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
-
#define DIAG(ENUM,FLAGS,DESC) ENUM,
#define LEXSTART
#include "clang/Basic/DiagnosticLexKinds.def"
+#undef DIAG
NUM_BUILTIN_LEX_DIAGNOSTICS
};
} // end namespace diag
#define DIAG(ENUM,FLAGS,DESC) ENUM,
#define PARSESTART
#include "clang/Basic/DiagnosticParseKinds.def"
+#undef DIAG
NUM_BUILTIN_PARSE_DIAGNOSTICS
};
} // end namespace diag
/// 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;
}
/// 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);
/// 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);
// 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())