//===------- ItaniumCXXABI.cpp - AST support for the Itanium C++ ABI ------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This provides C++ AST support targeting the Itanium C++ ABI, which is // documented at: // http://www.codesourcery.com/public/cxx-abi/abi.html // http://www.codesourcery.com/public/cxx-abi/abi-eh.html // // It also supports the closely-related ARM C++ ABI, documented at: // http://infocenter.arm.com/help/topic/com.arm.doc.ihi0041c/IHI0041C_cppabi.pdf // //===----------------------------------------------------------------------===// #include "CXXABI.h" #include "clang/AST/ASTContext.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/Mangle.h" #include "clang/AST/MangleNumberingContext.h" #include "clang/AST/RecordLayout.h" #include "clang/AST/Type.h" #include "clang/Basic/TargetInfo.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/iterator.h" #include <optional> usingnamespaceclang; namespace { /// According to Itanium C++ ABI 5.1.2: /// the name of an anonymous union is considered to be /// the name of the first named data member found by a pre-order, /// depth-first, declaration-order walk of the data members of /// the anonymous union. /// If there is no such data member (i.e., if all of the data members /// in the union are unnamed), then there is no way for a program to /// refer to the anonymous union, and there is therefore no need to mangle its name. /// /// Returns the name of anonymous union VarDecl or nullptr if it is not found. static const IdentifierInfo *findAnonymousUnionVarDeclName(const VarDecl& VD) { … } /// The name of a decomposition declaration. struct DecompositionDeclName { … }; } namespace llvm { template<typename T> bool isDenseMapKeyEmpty(T V) { … } template<typename T> bool isDenseMapKeyTombstone(T V) { … } template <typename T> std::optional<bool> areDenseMapKeysEqualSpecialValues(T LHS, T RHS) { … } template<> struct DenseMapInfo<DecompositionDeclName> { … }; } namespace { /// Keeps track of the mangled names of lambda expressions and block /// literals within a particular context. class ItaniumNumberingContext : public MangleNumberingContext { … }; // A version of this for SYCL that makes sure that 'device' mangling context // matches the lambda mangling number, so that __builtin_sycl_unique_stable_name // can be consistently generated between a MS and Itanium host by just referring // to the device mangling number. class ItaniumSYCLNumberingContext : public ItaniumNumberingContext { … }; class ItaniumCXXABI : public CXXABI { … }; } CXXABI *clang::CreateItaniumCXXABI(ASTContext &Ctx) { … } std::unique_ptr<MangleNumberingContext> clang::createItaniumNumberingContext(MangleContext *Mangler) { … }