r240187 - Make -Wnullability-completeness work with -Wsystem-headers.

Aaron Ballman aaron at aaronballman.com
Sat Jun 20 12:57:15 PDT 2015


On Fri, Jun 19, 2015 at 7:17 PM, Douglas Gregor <dgregor at apple.com> wrote:
> Author: dgregor
> Date: Fri Jun 19 18:17:55 2015
> New Revision: 240187
>
> URL: http://llvm.org/viewvc/llvm-project?rev=240187&view=rev
> Log:
> Make -Wnullability-completeness work with -Wsystem-headers.
>
> rdar://problem/21134250
>
> Added:
>     cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-system/
>     cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-system/nullability-consistency-system.h   (with props)
> Modified:
>     cfe/trunk/lib/Sema/SemaType.cpp
>     cfe/trunk/test/SemaObjCXX/nullability-consistency.mm
>
> Modified: cfe/trunk/lib/Sema/SemaType.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=240187&r1=240186&r2=240187&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaType.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaType.cpp Fri Jun 19 18:17:55 2015
> @@ -2791,9 +2791,12 @@ static FileID getNullabilityCompleteness
>    // 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;
>  }
>
> Added: cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-system/nullability-consistency-system.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-system/nullability-consistency-system.h?rev=240187&view=auto
> ==============================================================================
> --- cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-system/nullability-consistency-system.h (added)
> +++ cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-system/nullability-consistency-system.h Fri Jun 19 18:17:55 2015
> @@ -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 at -2{{pointer is missing a nullability type specifier}}
> +#endif
> +
> +void system2(int * __nonnull);
>
> Propchange: cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-system/nullability-consistency-system.h
> ------------------------------------------------------------------------------
>     svn:eol-style = native
>
> Propchange: cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-system/nullability-consistency-system.h
> ------------------------------------------------------------------------------
>     svn:keywords = Id
>
> Propchange: cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-system/nullability-consistency-system.h
> ------------------------------------------------------------------------------
>     svn:mime-type = text/plain

Unintentional svn prop changes?

>
> Modified: cfe/trunk/test/SemaObjCXX/nullability-consistency.mm
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/nullability-consistency.mm?rev=240187&r1=240186&r2=240187&view=diff
> ==============================================================================
> --- cfe/trunk/test/SemaObjCXX/nullability-consistency.mm (original)
> +++ cfe/trunk/test/SemaObjCXX/nullability-consistency.mm Fri Jun 19 18:17:55 2015
> @@ -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
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

~Aaron



More information about the cfe-commits mailing list