r242055 - [Modules] Allow missing header before a missing requirement

Sean Silva chisophugis at gmail.com
Wed Jul 15 14:56:41 PDT 2015


Thanks for looking into this! I've been a bit swamped this week but I
promise I'll circle back around to that patch (hopefully next week).

-- Sean Silva

On Mon, Jul 13, 2015 at 12:48 PM, Ben Langmuir <blangmuir at apple.com> wrote:

> Author: benlangmuir
> Date: Mon Jul 13 14:48:52 2015
> New Revision: 242055
>
> URL: http://llvm.org/viewvc/llvm-project?rev=242055&view=rev
> Log:
> [Modules] Allow missing header before a missing requirement
>
> And make the module unavailable without breaking any parent modules.
>
> If there's a missing requirement after we've already seen a missing
> header, still update the IsMissingRequiement bit correctly.  Also,
> diagnose missing requirements before missing headers, since the
> existence of the header is moot if there are missing requirements.
>
> Modified:
>     cfe/trunk/lib/Basic/Module.cpp
>     cfe/trunk/test/Modules/Inputs/module.map
>     cfe/trunk/test/Modules/requires.m
>
> Modified: cfe/trunk/lib/Basic/Module.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Module.cpp?rev=242055&r1=242054&r2=242055&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Basic/Module.cpp (original)
> +++ cfe/trunk/lib/Basic/Module.cpp Mon Jul 13 14:48:52 2015
> @@ -82,10 +82,6 @@ bool Module::isAvailable(const LangOptio
>      return true;
>
>    for (const Module *Current = this; Current; Current = Current->Parent) {
> -    if (!Current->MissingHeaders.empty()) {
> -      MissingHeader = Current->MissingHeaders.front();
> -      return false;
> -    }
>      for (unsigned I = 0, N = Current->Requirements.size(); I != N; ++I) {
>        if (hasFeature(Current->Requirements[I].first, LangOpts, Target) !=
>                Current->Requirements[I].second) {
> @@ -93,6 +89,10 @@ bool Module::isAvailable(const LangOptio
>          return false;
>        }
>      }
> +    if (!Current->MissingHeaders.empty()) {
> +      MissingHeader = Current->MissingHeaders.front();
> +      return false;
> +    }
>    }
>
>    llvm_unreachable("could not find a reason why module is unavailable");
> @@ -184,7 +184,11 @@ void Module::addRequirement(StringRef Fe
>  }
>
>  void Module::markUnavailable(bool MissingRequirement) {
> -  if (!IsAvailable)
> +  auto needUpdate = [MissingRequirement](Module *M) {
> +    return M->IsAvailable || (!M->IsMissingRequirement &&
> MissingRequirement);
> +  };
> +
> +  if (!needUpdate(this))
>      return;
>
>    SmallVector<Module *, 2> Stack;
> @@ -193,7 +197,7 @@ void Module::markUnavailable(bool Missin
>      Module *Current = Stack.back();
>      Stack.pop_back();
>
> -    if (!Current->IsAvailable)
> +    if (!needUpdate(Current))
>        continue;
>
>      Current->IsAvailable = false;
> @@ -201,7 +205,7 @@ void Module::markUnavailable(bool Missin
>      for (submodule_iterator Sub = Current->submodule_begin(),
>                           SubEnd = Current->submodule_end();
>           Sub != SubEnd; ++Sub) {
> -      if ((*Sub)->IsAvailable)
> +      if (needUpdate(*Sub))
>          Stack.push_back(*Sub);
>      }
>    }
>
> Modified: cfe/trunk/test/Modules/Inputs/module.map
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module.map?rev=242055&r1=242054&r2=242055&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/Modules/Inputs/module.map (original)
> +++ cfe/trunk/test/Modules/Inputs/module.map Mon Jul 13 14:48:52 2015
> @@ -336,3 +336,14 @@ module ImportNameInDir {
>    header "ImportNameInDir.h"
>    export *
>  }
> +
> +module RequiresWithMissingHeader {
> +  module HeaderBefore {
> +    header "RequiresWithMissingHeader-Missing1.h"
> +    requires missing
> +  }
> +  module HeaderAfter {
> +    requires missing
> +    header "RequiresWithMissingHeader-Missing2.h"
> +  }
> +}
>
> Modified: cfe/trunk/test/Modules/requires.m
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/requires.m?rev=242055&r1=242054&r2=242055&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/Modules/requires.m (original)
> +++ cfe/trunk/test/Modules/requires.m Mon Jul 13 14:48:52 2015
> @@ -6,3 +6,7 @@
>  @import DependsOnModule.NotObjC; // expected-error{{module
> 'DependsOnModule.NotObjC' is incompatible with feature 'objc'}}
>  @import DependsOnModule.CustomReq1; // OK
>  @import DependsOnModule.CustomReq2; // expected-error{{module
> 'DependsOnModule.CustomReq2' requires feature 'custom_req2'}}
> +
> + at import RequiresWithMissingHeader; // OK
> + at import RequiresWithMissingHeader.HeaderBefore; // expected-error{{module
> 'RequiresWithMissingHeader.HeaderBefore' requires feature 'missing'}}
> + at import RequiresWithMissingHeader.HeaderAfter; // expected-error{{module
> 'RequiresWithMissingHeader.HeaderAfter' requires feature 'missing'}}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150715/29246cef/attachment.html>


More information about the cfe-commits mailing list