blob: f5272a7fdbce2a2315a710598104f78c2a2b1fe4 [file] [log] [blame]
Douglas Gregor9e8c92a2012-02-20 19:44:39 +00001//===--- LambdaMangleContext.cpp - Context for mangling lambdas -*- C++ -*-===//
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#include "clang/AST/LambdaMangleContext.h"
15#include "clang/AST/DeclCXX.h"
16
17using namespace clang;
18
19unsigned LambdaMangleContext::getManglingNumber(CXXMethodDecl *CallOperator) {
20 const FunctionProtoType *Proto
21 = CallOperator->getType()->getAs<FunctionProtoType>();
22 ASTContext &Context = CallOperator->getASTContext();
23
24 QualType Key = Context.getFunctionType(Context.VoidTy,
25 Proto->arg_type_begin(),
26 Proto->getNumArgs(),
27 FunctionProtoType::ExtProtoInfo());
28 Key = Context.getCanonicalType(Key);
29 return ++ManglingNumbers[Key->castAs<FunctionProtoType>()];
30}