2009-02-19 07:53:56 +08:00
|
|
|
//===--- Mangle.h - Mangle C++ Names ----------------------------*- C++ -*-===//
|
2009-02-13 08:10:09 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Implements C++ name mangling according to the Itanium C++ ABI,
|
|
|
|
// which is used in GCC 3.2 and newer (and many compilers that are
|
|
|
|
// ABI-compatible with GCC):
|
|
|
|
//
|
|
|
|
// http://www.codesourcery.com/public/cxx-abi/abi.html
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2009-03-21 16:24:40 +08:00
|
|
|
|
2009-02-13 08:10:09 +08:00
|
|
|
#ifndef LLVM_CLANG_CODEGEN_MANGLE_H
|
|
|
|
#define LLVM_CLANG_CODEGEN_MANGLE_H
|
|
|
|
|
2009-04-15 13:36:58 +08:00
|
|
|
#include "CGCXX.h"
|
2009-08-01 02:25:34 +08:00
|
|
|
#include "clang/AST/Type.h"
|
2009-10-07 09:45:02 +08:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
2009-04-15 13:36:58 +08:00
|
|
|
|
2009-02-13 08:10:09 +08:00
|
|
|
namespace llvm {
|
2009-11-21 17:06:22 +08:00
|
|
|
template<typename T>
|
|
|
|
class SmallVectorImpl;
|
2009-02-13 08:10:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace clang {
|
2009-11-21 17:06:10 +08:00
|
|
|
class ASTContext;
|
|
|
|
class CXXConstructorDecl;
|
|
|
|
class CXXDestructorDecl;
|
|
|
|
class FunctionDecl;
|
|
|
|
class NamedDecl;
|
|
|
|
class VarDecl;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-11-21 17:06:10 +08:00
|
|
|
/// MangleContext - Context for tracking state which persists across multiple
|
|
|
|
/// calls to the C++ name mangler.
|
|
|
|
class MangleContext {
|
|
|
|
ASTContext &Context;
|
2009-10-07 09:45:02 +08:00
|
|
|
|
2009-11-21 17:06:10 +08:00
|
|
|
llvm::DenseMap<const TagDecl *, uint64_t> AnonStructIds;
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit MangleContext(ASTContext &Context)
|
2009-10-07 09:06:45 +08:00
|
|
|
: Context(Context) { }
|
2009-11-21 17:06:10 +08:00
|
|
|
|
|
|
|
ASTContext &getASTContext() const { return Context; }
|
|
|
|
|
|
|
|
uint64_t getAnonymousStructId(const TagDecl *TD) {
|
|
|
|
std::pair<llvm::DenseMap<const TagDecl *,
|
|
|
|
uint64_t>::iterator, bool> Result =
|
2009-10-07 09:45:02 +08:00
|
|
|
AnonStructIds.insert(std::make_pair(TD, AnonStructIds.size()));
|
2009-11-21 17:06:10 +08:00
|
|
|
return Result.first->second;
|
|
|
|
}
|
2009-10-07 09:06:45 +08:00
|
|
|
|
2009-11-21 17:06:10 +08:00
|
|
|
/// @name Mangler Entry Points
|
|
|
|
/// @{
|
|
|
|
|
2009-11-21 17:06:22 +08:00
|
|
|
bool mangleName(const NamedDecl *D, llvm::SmallVectorImpl<char> &);
|
2009-11-21 17:06:10 +08:00
|
|
|
void mangleThunk(const FunctionDecl *FD, int64_t n, int64_t vn,
|
2009-11-21 17:06:22 +08:00
|
|
|
llvm::SmallVectorImpl<char> &);
|
2009-11-21 17:06:10 +08:00
|
|
|
void mangleCovariantThunk(const FunctionDecl *FD, int64_t nv_t, int64_t v_t,
|
2009-11-21 17:06:22 +08:00
|
|
|
int64_t nv_r, int64_t v_r,
|
|
|
|
llvm::SmallVectorImpl<char> &);
|
|
|
|
void mangleGuardVariable(const VarDecl *D, llvm::SmallVectorImpl<char> &);
|
|
|
|
void mangleCXXVtable(const CXXRecordDecl *RD, llvm::SmallVectorImpl<char> &);
|
|
|
|
void mangleCXXVTT(const CXXRecordDecl *RD, llvm::SmallVectorImpl<char> &);
|
2009-11-21 17:06:10 +08:00
|
|
|
void mangleCXXCtorVtable(const CXXRecordDecl *RD, int64_t Offset,
|
2009-11-21 17:06:22 +08:00
|
|
|
const CXXRecordDecl *Type,
|
|
|
|
llvm::SmallVectorImpl<char> &);
|
|
|
|
void mangleCXXRtti(QualType T, llvm::SmallVectorImpl<char> &);
|
|
|
|
void mangleCXXRttiName(QualType T, llvm::SmallVectorImpl<char> &);
|
2009-11-21 17:06:10 +08:00
|
|
|
void mangleCXXCtor(const CXXConstructorDecl *D, CXXCtorType Type,
|
2009-11-21 17:06:22 +08:00
|
|
|
llvm::SmallVectorImpl<char> &);
|
2009-11-21 17:06:10 +08:00
|
|
|
void mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type,
|
2009-11-21 17:06:22 +08:00
|
|
|
llvm::SmallVectorImpl<char> &);
|
2009-11-21 17:06:10 +08:00
|
|
|
|
|
|
|
/// @}
|
|
|
|
};
|
2009-02-13 08:10:09 +08:00
|
|
|
}
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
#endif
|