r301597 - [Modules] Improve diagnostics for incomplete umbrella

Bruno Cardoso Lopes via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 27 17:48:32 PDT 2017


This is breaking a non related test in some windows bots.

Takumi & other with windows access, can you help me figure why?

For instance:
http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/3846
http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/4379

On Thu, Apr 27, 2017 at 3:29 PM, Bruno Cardoso Lopes via cfe-commits
<cfe-commits at lists.llvm.org> wrote:
> Author: bruno
> Date: Thu Apr 27 17:29:14 2017
> New Revision: 301597
>
> URL: http://llvm.org/viewvc/llvm-project?rev=301597&view=rev
> Log:
> [Modules] Improve diagnostics for incomplete umbrella
>
> One of the -Wincomplete-umbrella warnings diagnoses when a header is present in
> the directory but it's not present in the umbrella header. Currently, this
> warning only happens on top level modules; any submodule using an umbrella
> header does not get this warning. Fix that by also considering the submodules.
>
> Differential Revision: https://reviews.llvm.org/D32576
>
> rdar://problem/22623686
>
> Added:
>     cfe/trunk/test/Modules/Inputs/incomplete-umbrella/
>     cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/
>     cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/
>     cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h
>     cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h
>     cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/
>     cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.modulemap
>     cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.private.modulemap
>     cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/
>     cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Baz.h
>     cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Foo.h
>     cfe/trunk/test/Modules/incomplete-umbrella.m
> Modified:
>     cfe/trunk/lib/Lex/PPLexerChange.cpp
>
> Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=301597&r1=301596&r2=301597&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)
> +++ cfe/trunk/lib/Lex/PPLexerChange.cpp Thu Apr 27 17:29:14 2017
> @@ -287,6 +287,14 @@ const char *Preprocessor::getCurLexerEnd
>    return EndPos;
>  }
>
> +static void collectAllSubModulesWithUmbrellaHeader(
> +    const Module &Mod, SmallVectorImpl<const Module *> &SubMods) {
> +  if (Mod.getUmbrellaHeader())
> +    SubMods.push_back(&Mod);
> +  for (auto *M : Mod.submodules())
> +    collectAllSubModulesWithUmbrellaHeader(*M, SubMods);
> +}
> +
>  void Preprocessor::diagnoseMissingHeaderInUmbrellaDir(const Module &Mod) {
>    assert(Mod.getUmbrellaHeader() && "Module must use umbrella header");
>    SourceLocation StartLoc =
> @@ -507,10 +515,15 @@ bool Preprocessor::HandleEndOfFile(Token
>    }
>
>    // If we are building a module that has an umbrella header, make sure that
> -  // each of the headers within the directory covered by the umbrella header
> -  // was actually included by the umbrella header.
> -  if (Module *Mod = getCurrentModule())
> -    diagnoseMissingHeaderInUmbrellaDir(*Mod);
> +  // each of the headers within the directory, including all submodules, is
> +  // covered by the umbrella header was actually included by the umbrella
> +  // header.
> +  if (Module *Mod = getCurrentModule()) {
> +    llvm::SmallVector<const Module *, 4> AllMods;
> +    collectAllSubModulesWithUmbrellaHeader(*Mod, AllMods);
> +    for (auto *M : AllMods)
> +      diagnoseMissingHeaderInUmbrellaDir(*M);
> +  }
>
>    return true;
>  }
>
> Added: cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h?rev=301597&view=auto
> ==============================================================================
> --- cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h (added)
> +++ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h Thu Apr 27 17:29:14 2017
> @@ -0,0 +1 @@
> +#define BAR_PUBLIC 1
>
> Added: cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h?rev=301597&view=auto
> ==============================================================================
> --- cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h (added)
> +++ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h Thu Apr 27 17:29:14 2017
> @@ -0,0 +1 @@
> +// FooPublic.h
>
> Added: cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.modulemap
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.modulemap?rev=301597&view=auto
> ==============================================================================
> --- cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.modulemap (added)
> +++ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.modulemap Thu Apr 27 17:29:14 2017
> @@ -0,0 +1,5 @@
> +framework module Foo {
> +    umbrella header "FooPublic.h"
> +    requires objc
> +    export *
> +}
>
> Added: cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.private.modulemap
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.private.modulemap?rev=301597&view=auto
> ==============================================================================
> --- cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.private.modulemap (added)
> +++ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.private.modulemap Thu Apr 27 17:29:14 2017
> @@ -0,0 +1,5 @@
> +explicit module Foo.Private {
> +    umbrella header "Foo.h"
> +    requires objc
> +    export *
> +}
>
> Added: cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Baz.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Baz.h?rev=301597&view=auto
> ==============================================================================
> --- cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Baz.h (added)
> +++ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Baz.h Thu Apr 27 17:29:14 2017
> @@ -0,0 +1 @@
> +#define BAZ_PRIVATE 1
>
> Added: cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Foo.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Foo.h?rev=301597&view=auto
> ==============================================================================
> --- cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Foo.h (added)
> +++ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Foo.h Thu Apr 27 17:29:14 2017
> @@ -0,0 +1 @@
> +// Foo.h
>
> Added: cfe/trunk/test/Modules/incomplete-umbrella.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/incomplete-umbrella.m?rev=301597&view=auto
> ==============================================================================
> --- cfe/trunk/test/Modules/incomplete-umbrella.m (added)
> +++ cfe/trunk/test/Modules/incomplete-umbrella.m Thu Apr 27 17:29:14 2017
> @@ -0,0 +1,15 @@
> +// RUN: rm -rf %t
> +// RUN: not %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -F%S/Inputs/incomplete-umbrella -fsyntax-only %s 2>&1 | FileCheck %s
> +
> +#import <Foo/Foo.h>
> +#import <Foo/Bar.h>
> +#import <Foo/Baz.h>
> + at import Foo.Private;
> +
> +// CHECK: warning: umbrella header for module 'Foo' does not include header 'Bar.h'
> +// CHECK: warning: umbrella header for module 'Foo.Private' does not include header 'Baz.h'
> +int foo() {
> +  int a = BAR_PUBLIC;
> +  int b = BAZ_PRIVATE;
> +  return 0;
> +}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits



-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc


More information about the cfe-commits mailing list