[PATCH] D118311: [Clang][ModuleMap] Add conditional parsing via requires block declaration

Michael Spencer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 1 17:14:39 PST 2022


Bigcheese added a comment.

> Is it possible to reference external module map from requires block? I mean that in one context the module has some extra requirements but in a different context doesn't have them.

Can you provide an example where this would cause issues?

> It would be nice to have some mechanism to notify developers that includes are still performed regardless of requires.

This would be nice, but is rather complicated to do given how the module map parser works right now. We would need to actually record what gets skipped by a requires block without including it in the `Module`. With the current design that's not easy to do.



================
Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:722
+def err_mmap_expected_lbrace_requires : Error<
+  "expected '{' to start rquires block">;
 def err_mmap_expected_rbrace : Error<"expected '}'">;
----------------
vsapsai wrote:
> s/rquires/requires/
> 
> Would it be useful to put `requires` into some quotation marks to show it's not a part of the sentence but used verbatim?
Possibly, but I don't think we do that anywhere else. '' is always used to refer to user identifiers, "" is only used when referring to headers or strings, and I don't see any usage of ``. I have added a note so it shows up now as:

```
requires-block-errors.m.tmp/missing-opening-brace/module.modulemap:3:1: error: expected '{' to start requires block
module Pony {
^
requires-block-errors.m.tmp/missing-opening-brace/module.modulemap:2:1: note: for requires block declared here
requires !cplusplus
^
```

Which makes it clear.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118311/new/

https://reviews.llvm.org/D118311



More information about the llvm-commits mailing list