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

Leonard Chan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 11 18:23:09 PDT 2020


leonardchan created this revision.
leonardchan added reviewers: phosek, mcgrathr, rjmccall, rsmith, pcc, hansec.
leonardchan added a project: clang.
Herald added subscribers: dang, dschuff.
leonardchan requested review of this revision.
Herald added a subscriber: aheejin.

This implements the flag proposed in RFC http://lists.llvm.org/pipermail/cfe-dev/2020-August/066437.html.

      

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.
- Use the relative VTables ABI for fuchsia if `-fc++-abi=Fuchsia` is provided.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85802

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/TargetCXXABI.def
  clang/include/clang/Basic/TargetCXXABI.h
  clang/include/clang/Driver/Options.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/fuchsia.cpp
  clang/test/Frontend/invalid-cxx-abi.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85802.284944.patch
Type: text/x-patch
Size: 19922 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200812/667addcb/attachment-0001.bin>


More information about the cfe-commits mailing list