[clang] Add -fc++-abi= flag for specifying which C++ ABI to use

Authored by leonardchan on Apr 21 2021, 3:09 PM.


[clang] Add -fc++-abi= flag for specifying which C++ ABI to use

This implements the flag proposed in RFC

The goal is to add a way to override the default target C++ ABI through a
compiler flag. This makes it easier to test and transition between different
C++ ABIs through compile flags rather than build flags.

In this patch:

  • Store -fc++-abi= in a LangOpt. This isn't stored in a CodeGenOpt because there are instances outside of codegen where Clang needs to know what the ABI is (particularly through ASTContext::createCXXABI), and we should be able to override the target default if the flag is provided at that point.
  • Expose the existing ABIs in TargetCXXABI as values that can be passed through this flag.
    • Create a .def file for these ABIs to make it easier to check flag values.
    • Add an error for diagnosing bad ABI flag values.

Differential Revision: https://reviews.llvm.org/D85802