Clang driver

I have noticed that clang silently ignores unknown flags:

clang -finvalidflag some_file.cpp

The above does not produce any error or warning, and adding "-v" shows
that the invalid flag does not make it out of the driver.

I looked through bug reports, and I did not see any on this. Is it an
intentional design? I have only seen this behavior for flags (starting
with "-f"), so I want to make sure that there is no rationale behind
this behavior.

Thanks,
Marcin

The rationale is that it makes swapping projects to clang a little easier in that we're not going to support every random flag, but also don't want to worry about some project not compiling if we don't support -finline-limit=

-eric

OK. But should the driver totally ignore unknown flags, or should it
pass them to the tool it calls?

clang -cc1 -finvalidflag some_file.cpp

The above command gives the following error:

error: unknown argument: '-finvalidflag'

What happened to me was that I added a flag to cc1. Everything was
working correctly until I actually tried to use the driver. It was
silently eating up my flag. Only after examining the output of "-v" I
notice that my flag disappears, and then I added proper support for
the flag in the driver. In case of some other options (not flags), I
at least get a warning:

clang -auao testt.cpp
clang: warning: argument unused during compilation: '-auao'

but

clang -invalidoption testt.cpp

gives no warning. As an "outsider," I was confused by some options
giving warnings and some not.

Thanks,
Marcin

OK. But should the driver totally ignore unknown flags, or should it
pass them to the tool it calls?

clang -cc1 -finvalidflag some_file.cpp

The above command gives the following error:

error: unknown argument: '-finvalidflag'

What happened to me was that I added a flag to cc1. Everything was
working correctly until I actually tried to use the driver. It was
silently eating up my flag. Only after examining the output of "-v" I
notice that my flag disappears, and then I added proper support for
the flag in the driver. In case of some other options (not flags), I
at least get a warning:

Yes. You need to add it to the driver as well.

clang -auao testt.cpp
clang: warning: argument unused during compilation: '-auao'

but

clang -invalidoption testt.cpp

gives no warning. As an "outsider," I was confused by some options
giving warnings and some not.

Yes. Some options missing will give warnings, others won't. Largely based
on the character they start with :slight_smile:

Again, this is to make transitioning easier - unfortunately it makes
adding options more painful at the moment.

-eric