Support `CCC_OVERRIDE_OPTIONS`
Now that we've better separated effective and canonical options (#39), we can better model one of Clang's escape hatches CCC_OVERRIDE_OPTIONS.
Source: https://github.com/llvm/llvm-project/blob/93a1fc2e18b452216be70f534da42f7702adbe1d/clang/tools/driver/driver.cpp#L79-L105
In summary: CCC_OVERRIDE_OPTIONS can be specified in the environment, and takes precedence over all other option transformations (like response files). The transforms (that we care about) are:
-
^FOO: PrependFOOto the arguments (e.g.^-Werror) -
+FOO: AppendFOOto the arguments (e.g.+-Werror) -
s/FOO/BAR/: Replace allFOOwithBARin the arguments (e.g.s/-Werror/-Wno-error/) -
xFOO: Remove all instances ofFOOfrom the arguments -
XFOO: Remove all instances ofFOO optfrom the arguments- Does this include
FOO=opt? The Clang code doesn't seem to handle that, but it may be normalized toFOO optprior to override handling.
- Does this include
-
Ox: Remove all optimization arguments, append-Ox(e.g.,-O2)
The settings in CCC_OVERRIDE_OPTIONS are space separated. The comments in Clang's driver say that they're comma separated, but the code actually splits on spaces.
In summary:
CCC_OVERRIDE_OPTIONScan be specified in the environment, and takes precedence over all other option transformations (like response files).
To clarify: this means that CCC_OVERRIDE_OPTIONS happens after all response files and other sources have been expanded. It's the very last phase in the clang driver's argument construction process.