From: Douglas Gregor Date: Fri, 19 Jun 2015 23:17:55 +0000 (+0000) Subject: Make -Wnullability-completeness work with -Wsystem-headers. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5c5a8ceac8e2b0477814f0dfcc4d33bcb079eb67;p=clang Make -Wnullability-completeness work with -Wsystem-headers. rdar://problem/21134250 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240187 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index d950d329b4..b7f5ca058c 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -2791,9 +2791,12 @@ static FileID getNullabilityCompletenessCheckFileID(Sema &S, // We don't want to perform completeness checks on the main file or in // system headers. const SrcMgr::FileInfo &fileInfo = sloc.getFile(); - if (fileInfo.getIncludeLoc().isInvalid() || - fileInfo.getFileCharacteristic() != SrcMgr::C_User) + if (fileInfo.getIncludeLoc().isInvalid()) return FileID(); + if (fileInfo.getFileCharacteristic() != SrcMgr::C_User && + S.Diags.getSuppressSystemWarnings()) { + return FileID(); + } return file; } diff --git a/test/SemaObjCXX/Inputs/nullability-consistency-system/nullability-consistency-system.h b/test/SemaObjCXX/Inputs/nullability-consistency-system/nullability-consistency-system.h new file mode 100644 index 0000000000..6dbca1663d --- /dev/null +++ b/test/SemaObjCXX/Inputs/nullability-consistency-system/nullability-consistency-system.h @@ -0,0 +1,8 @@ +// Simply marking this as "#pragma clang system_header" didn't tickle the bug, rdar://problem/21134250. + +void system1(int *ptr); +#if WARN_IN_SYSTEM_HEADERS +// expected-warning@-2{{pointer is missing a nullability type specifier}} +#endif + +void system2(int * __nonnull); diff --git a/test/SemaObjCXX/nullability-consistency.mm b/test/SemaObjCXX/nullability-consistency.mm index 7497e84a36..acb972da0b 100644 --- a/test/SemaObjCXX/nullability-consistency.mm +++ b/test/SemaObjCXX/nullability-consistency.mm @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -fsyntax-only -fblocks -I %S/Inputs %s -verify +// RUN: %clang_cc1 -fsyntax-only -fblocks -I %S/Inputs -isystem %S/Inputs/nullability-consistency-system %s -verify +// RUN: %clang_cc1 -fsyntax-only -fblocks -I %S/Inputs -isystem %S/Inputs/nullability-consistency-system %s -Wsystem-headers -DWARN_IN_SYSTEM_HEADERS -verify #include "nullability-consistency-1.h" #include "nullability-consistency-3.h" @@ -8,6 +9,7 @@ #include "nullability-consistency-6.h" #include "nullability-consistency-7.h" #include "nullability-consistency-8.h" +#include "nullability-consistency-system.h" void h1(int *ptr) { } // don't warn