blob: a4c8a27da5c55c0f03c1d5b4f18f13b96ad84e55 [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
22MangleNumberingContext::getManglingNumber(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
34MangleNumberingContext::getManglingNumber(BlockDecl *BD) {
35 // FIXME: Compute a BlockPointerType? Not obvious how.
36 const Type *Ty = 0;
37 return ++ManglingNumbers[Ty];
38}