[all-commits] [llvm/llvm-project] 84c475: [clang] Add -fc++-abi= flag for specifying which C...

Leonard Chan via All-commits all-commits at lists.llvm.org
Tue May 4 10:52:52 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 84c475437267e7fffedc40029ce274b099d8f8f3
      https://github.com/llvm/llvm-project/commit/84c475437267e7fffedc40029ce274b099d8f8f3
  Author: Leonard Chan <leonardchan at google.com>
  Date:   2021-05-04 (Tue, 04 May 2021)

  Changed paths:
    M clang/include/clang/AST/ASTContext.h
    M clang/include/clang/Basic/DiagnosticDriverKinds.td
    M clang/include/clang/Basic/LangOptions.h
    A clang/include/clang/Basic/TargetCXXABI.def
    M clang/include/clang/Basic/TargetCXXABI.h
    M clang/include/clang/Driver/Options.td
    M clang/lib/AST/ASTContext.cpp
    M clang/lib/CodeGen/CodeGenModule.cpp
    M clang/lib/CodeGen/ItaniumCXXABI.cpp
    M clang/lib/Driver/ToolChains/Clang.cpp
    M clang/lib/Frontend/CompilerInvocation.cpp
    A clang/test/CodeGenCXX/cxx-abi-switch.cpp
    A clang/test/Frontend/invalid-cxx-abi.cpp

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

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.

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




More information about the All-commits mailing list