Best way to disable warnings by using a compile option


I'm messing around creating a compiler option for a specialised hardware
target that I'm working on. It involves changing the behaviour of the
compiler in small ways but one thing that I'd particularly like to be able to
do is disable certain compiler warnings when this flag is in use. I've got all
the relevant warnings grouped together in, but I'm trying
to find the best way to bring this under the control of the single compiler

My approach so far has been to push the -Wno-... flag early in the
Clang::ConstructJob function in lib/Driver/Tools.cpp:

  // Invoke ourselves in -cc1 mode.
  // FIXME: Implement custom jobs for internal actions.

  // Add the "effective" target triple.

  // -my-special-hardware option.
  if (Args.hasArg(options::OPT_my_special_hardware)) {

This actually works quite well: it disables the warnings by default even if I
invoke the compiler with -Wall or similar, and very usefully it can be
overridden at the command line, by...

clang ... -my-special-hardware -Wirrelevant-warnings

or, for a specific warning in the group, by...

clang ... -my-special-hardware -Wspecific-irrelevant-warning

However, I can't help thinking this is not the most intelligent approach and
that there must be a much better way. I'm also not 100% sure that my approach
is necessarily valid, given that it relies on the compiler spawning itself
again -- or, apart from using the -cc1 flag explicitly from the command line,
will the compiler always do this?

It would be wonderful if someone could give me a pointer, please. :o)