How to add a -W flag?

I’m adding a warning to the end of the “Modules Issues” category in DiagnosticSemaKinds.td:

def warn_need_module_import : Warning<

“Use of identifier ‘%0’ requires import/inclusion of the module ‘%1’”>;

This makes test/Misc/warning-flags.c fail.

A comment in that test file says:

If you add a new warning without a flag, this test will fail. To fix

this test, simply add a warning group to that warning.

I don’t know what that means. How do I add a warning group to the warning?

Thanks.

-John

John,
You need to put it under some type of grouping. What grouping, I don't know?

As an example, see:
http://llvm.org/viewvc/llvm-project?view=revision&revision=159966

Chad

I believe you need to add your warning to a group like so:

def warn_need_module_import : Warning<
“Use of identifier ‘%0’ requires import/inclusion of the module ‘%1’”>;

becomes →

def warn_need_module_import : Warning<
“Use of identifier ‘%0’ requires import/inclusion of the module ‘%1’”>,
InGroup;

where “SomeGroup” is taken from DiagnosticGroups.td .

You can add you own group as well, the format is like:

def SomeGroup : DiagGroup<“some-group”>;

and then you should be able to use -Wsome-group

Thank you both, Zach and Chad!

-John

You should start your diagnostic text with a lowercase letter. I’m also curious what you’re diagnosing here! (Missing import of macros, maybe?)

Richard,

I’m working on a fixit such that when a type or other symbol can’t be found, it will search all the modules, and if the missing identifier is found, it will implicitly import the module, display a fixit warning, and continue. This is something Doug Gregor suggested to me at the last conference when I asked for ideas of some things I might do to help the modules effort.

I’ll post on Phabricator very shortly (hopefully this afternoon) a rough preview patch soon which just handles one case of a missing type, along with some questions, as there’s some more work needed that I’m not sure how to do yet, and the process I came up with of getting the global module index to cover all the modules is kind of iffy, so I wanted to have someone with more knowledge of the module system look at it. Can I put you as a reviewer, or can you suggest someone?

Thanks.

-John

Richard,

I'm working on a fixit such that when a type or other symbol can't be
found, it will search all the modules, and if the missing identifier is
found, it will implicitly import the module, display a fixit warning, and
continue. This is something Doug Gregor suggested to me at the last
conference when I asked for ideas of some things I might do to help the
modules effort.

By "search all the modules" I assume you mean search the global module
index? (We already do this in the case where the name is found in a
non-visible submodule of a loaded module.)

It seems a bit weird for our diagnostics to depend on what happens to be in
the global module index, but I don't have any alternative suggestion.

I'll post on Phabricator very shortly (hopefully this afternoon) a rough

preview patch soon which just handles one case of a missing type, along
with some questions, as there's some more work needed that I'm not sure how
to do yet, and the process I came up with of getting the global module
index to cover all the modules is kind of iffy, so I wanted to have someone
with more knowledge of the module system look at it. Can I put you as a
reviewer, or can you suggest someone?

I don't think there's anyone better than Doug or myself.