blob: 4e9006ec24a89a5ca7c39e320de7e948ad663580 [file] [log] [blame]
Eli Friedman7e346a82013-07-01 20:22:57 +00001//===--- MangleNumberingContext.cpp - Context for mangling numbers --------===//
Douglas Gregor63798542012-02-20 19:44:39 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines the LambdaMangleContext class, which keeps track of
11// the Itanium C++ ABI mangling numbers for lambda expressions.
12//
13//===----------------------------------------------------------------------===//
Benjamin Kramer1ea8e092012-07-04 17:04:04 +000014
Eli Friedman7e346a82013-07-01 20:22:57 +000015#include "clang/AST/MangleNumberingContext.h"
Benjamin Kramer1ea8e092012-07-04 17:04:04 +000016#include "clang/AST/ASTContext.h"
Douglas Gregor63798542012-02-20 19:44:39 +000017#include "clang/AST/DeclCXX.h"
18
19using namespace clang;
20
Eli Friedman7e346a82013-07-01 20:22:57 +000021unsigned
Eli Friedman3b7d46c2013-07-10 00:30:46 +000022MangleNumberingContext::getManglingNumber(const CXXMethodDecl *CallOperator) {
Douglas Gregor63798542012-02-20 19:44:39 +000023 const FunctionProtoType *Proto
24 = CallOperator->getType()->getAs<FunctionProtoType>();
25 ASTContext &Context = CallOperator->getASTContext();
Reid Kleckner896b32f2013-06-10 20:51:09 +000026
27 QualType Key = Context.getFunctionType(Context.VoidTy, Proto->getArgTypes(),
28 FunctionProtoType::ExtProtoInfo());
Douglas Gregor63798542012-02-20 19:44:39 +000029 Key = Context.getCanonicalType(Key);
30 return ++ManglingNumbers[Key->castAs<FunctionProtoType>()];
31}
Eli Friedman7e346a82013-07-01 20:22:57 +000032
33unsigned
Eli Friedman3b7d46c2013-07-10 00:30:46 +000034MangleNumberingContext::getManglingNumber(const BlockDecl *BD) {
Eli Friedman7e346a82013-07-01 20:22:57 +000035 // FIXME: Compute a BlockPointerType? Not obvious how.
36 const Type *Ty = 0;
37 return ++ManglingNumbers[Ty];
38}
Eli Friedman3b7d46c2013-07-10 00:30:46 +000039
40unsigned
41MangleNumberingContext::getManglingNumber(const VarDecl *VD) {
42 return ++VarManglingNumbers[VD->getIdentifier()];
43}
44
45unsigned
46MangleNumberingContext::getManglingNumber(const TagDecl *TD) {
47 return ++TagManglingNumbers[TD->getIdentifier()];
48}