1//===--- MangleNumberingContext.cpp - Context for mangling numbers --------===//
2//
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//===----------------------------------------------------------------------===//
14
15#include "clang/AST/MangleNumberingContext.h"
16#include "clang/AST/ASTContext.h"
17#include "clang/AST/DeclCXX.h"
18
19using namespace clang;
20
21unsigned
22MangleNumberingContext::getManglingNumber(const CXXMethodDecl *CallOperator) {
23  const FunctionProtoType *Proto
24    = CallOperator->getType()->getAs<FunctionProtoType>();
25  ASTContext &Context = CallOperator->getASTContext();
26
27  QualType Key = Context.getFunctionType(Context.VoidTy, Proto->getParamTypes(),
28                                         FunctionProtoType::ExtProtoInfo());
29  Key = Context.getCanonicalType(Key);
30  return ++ManglingNumbers[Key->castAs<FunctionProtoType>()];
31}
32
33unsigned
34MangleNumberingContext::getManglingNumber(const BlockDecl *BD) {
35  // FIXME: Compute a BlockPointerType?  Not obvious how.
36  const Type *Ty = nullptr;
37  return ++ManglingNumbers[Ty];
38}
39
40unsigned
41MangleNumberingContext::getStaticLocalNumber(const VarDecl *VD) {
42  // FIXME: Compute a BlockPointerType?  Not obvious how.
43  const Type *Ty = nullptr;
44  return ++ManglingNumbers[Ty];
45}
46