summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-02-03 09:00:04 +0000
committerChris Lattner <sabre@nondot.org>2008-02-03 09:00:04 +0000
commit3ac9699c44da272bd60c01a534aa10cc78e898ac (patch)
treec0c2b63e0f16ced27e32b7cc5cdc9400e3fd9082
parent15e4ad81c3331c5355446642b060259ff51e5d36 (diff)
downloadbcm5719-llvm-3ac9699c44da272bd60c01a534aa10cc78e898ac.tar.gz
bcm5719-llvm-3ac9699c44da272bd60c01a534aa10cc78e898ac.zip
Fix PR1966 by ignoring non-error diagnostics from system headers even if they are
*mapped* onto errors. llvm-svn: 46686
-rw-r--r--clang/Basic/Diagnostic.cpp14
-rw-r--r--clang/Driver/TextDiagnostics.cpp21
-rw-r--r--clang/Driver/TextDiagnostics.h3
-rw-r--r--clang/include/clang/Basic/Diagnostic.h5
4 files changed, 21 insertions, 22 deletions
diff --git a/clang/Basic/Diagnostic.cpp b/clang/Basic/Diagnostic.cpp
index 158e8ff33f4..de311a44880 100644
--- a/clang/Basic/Diagnostic.cpp
+++ b/clang/Basic/Diagnostic.cpp
@@ -200,22 +200,28 @@ Diagnostic::Level Diagnostic::getDiagnosticLevel(unsigned DiagID) const {
void Diagnostic::Report(FullSourceLoc Pos, unsigned DiagID,
const std::string *Strs, unsigned NumStrs,
const SourceRange *Ranges, unsigned NumRanges) {
+
// Figure out the diagnostic level of this message.
Diagnostic::Level DiagLevel = getDiagnosticLevel(DiagID);
// If the client doesn't care about this message, don't issue it.
if (DiagLevel == Diagnostic::Ignored)
return;
+
+ // If this is not an error and we are in a system header, ignore it. We have
+ // to check on the original class here, because we also want to ignore
+ // extensions and warnings in -Werror and -pedantic-errors modes, which *map*
+ // warnings/extensions to errors.
+ if (DiagID < diag::NUM_BUILTIN_DIAGNOSTICS &&
+ getBuiltinDiagClass(DiagID) != ERROR &&
+ Client.isInSystemHeader(Pos))
+ return;
if (DiagLevel >= Diagnostic::Error) {
ErrorOccurred = true;
++NumErrors;
}
- // Are we going to ignore this diagnosic?
- if (Client.IgnoreDiagnostic(DiagLevel, Pos))
- return;
-
// Finally, report it.
Client.HandleDiagnostic(*this, DiagLevel, Pos, (diag::kind)DiagID,
Strs, NumStrs, Ranges, NumRanges);
diff --git a/clang/Driver/TextDiagnostics.cpp b/clang/Driver/TextDiagnostics.cpp
index 01484e0fc49..7a78e947833 100644
--- a/clang/Driver/TextDiagnostics.cpp
+++ b/clang/Driver/TextDiagnostics.cpp
@@ -39,19 +39,14 @@ std::string TextDiagnostics::FormatDiagnostic(Diagnostic &Diags,
return Msg;
}
-bool TextDiagnostics::IgnoreDiagnostic(Diagnostic::Level Level,
- FullSourceLoc Pos) {
- if (Pos.isValid()) {
- // If this is a warning or note, and if it a system header, suppress the
- // diagnostic.
- if (Level == Diagnostic::Warning || Level == Diagnostic::Note) {
- if (const FileEntry *F = Pos.getFileEntryForLoc()) {
- DirectoryLookup::DirType DirInfo = TheHeaderSearch->getFileDirFlavor(F);
- if (DirInfo == DirectoryLookup::SystemHeaderDir ||
- DirInfo == DirectoryLookup::ExternCSystemHeaderDir)
- return true;
- }
- }
+bool TextDiagnostics::isInSystemHeader(FullSourceLoc Pos) const {
+ if (!Pos.isValid()) return false;
+
+ if (const FileEntry *F = Pos.getFileEntryForLoc()) {
+ DirectoryLookup::DirType DirInfo = TheHeaderSearch->getFileDirFlavor(F);
+ if (DirInfo == DirectoryLookup::SystemHeaderDir ||
+ DirInfo == DirectoryLookup::ExternCSystemHeaderDir)
+ return true;
}
return false;
diff --git a/clang/Driver/TextDiagnostics.h b/clang/Driver/TextDiagnostics.h
index 82ea11661f0..9b8d9fb27db 100644
--- a/clang/Driver/TextDiagnostics.h
+++ b/clang/Driver/TextDiagnostics.h
@@ -34,8 +34,7 @@ public:
void setHeaderSearch(HeaderSearch &HS) { TheHeaderSearch = &HS; }
- virtual bool IgnoreDiagnostic(Diagnostic::Level Level,
- FullSourceLoc Pos);
+ virtual bool isInSystemHeader(FullSourceLoc Pos) const;
virtual void HandleDiagnostic(Diagnostic &Diags, Diagnostic::Level DiagLevel,
FullSourceLoc Pos,
diff --git a/clang/include/clang/Basic/Diagnostic.h b/clang/include/clang/Basic/Diagnostic.h
index 9f18de305ee..35a32660931 100644
--- a/clang/include/clang/Basic/Diagnostic.h
+++ b/clang/include/clang/Basic/Diagnostic.h
@@ -166,10 +166,9 @@ class DiagnosticClient {
public:
virtual ~DiagnosticClient();
- /// IgnoreDiagnostic - If the client wants to ignore this diagnostic, then
+ /// isInSystemHeader - If the client can tell that this is a system header,
/// return true.
- virtual bool IgnoreDiagnostic(Diagnostic::Level DiagLevel,
- FullSourceLoc Pos) = 0;
+ virtual bool isInSystemHeader(FullSourceLoc Pos) const { return false; }
/// HandleDiagnostic - Handle this diagnostic, reporting it to the user or
/// capturing it to a log as needed.
OpenPOWER on IntegriCloud