blob: b46a085dc9e1acf30deaa70981f4a7a64712c015 [file] [log] [blame]
Eli Friedman07369dd2013-07-01 20:22:57 +00001//===--- MangleNumberingContext.cpp - Context for mangling numbers --------===//
Douglas Gregor9e8c92a2012-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 Kramer478851c2012-07-04 17:04:04 +000014
Eli Friedman07369dd2013-07-01 20:22:57 +000015#include "clang/AST/MangleNumberingContext.h"
Benjamin Kramer478851c2012-07-04 17:04:04 +000016#include "clang/AST/ASTContext.h"
Douglas Gregor9e8c92a2012-02-20 19:44:39 +000017#include "clang/AST/DeclCXX.h"
18
19using namespace clang;
20
Eli Friedman07369dd2013-07-01 20:22:57 +000021unsigned
Eli Friedman5e867c82013-07-10 00:30:46 +000022MangleNumberingContext::getManglingNumber(const CXXMethodDecl *CallOperator) {
Douglas Gregor9e8c92a2012-02-20 19:44:39 +000023 const FunctionProtoType *Proto
24 = CallOperator->getType()->getAs<FunctionProtoType>();
25 ASTContext &Context = CallOperator->getASTContext();
Reid Kleckner0567a792013-06-10 20:51:09 +000026
Stephen Hines651f13c2014-04-23 16:59:28 -070027 QualType Key = Context.getFunctionType(Context.VoidTy, Proto->getParamTypes(),
Reid Kleckner0567a792013-06-10 20:51:09 +000028 FunctionProtoType::ExtProtoInfo());
Douglas Gregor9e8c92a2012-02-20 19:44:39 +000029 Key = Context.getCanonicalType(Key);
30 return ++ManglingNumbers[Key->castAs<FunctionProtoType>()];
31}
Eli Friedman07369dd2013-07-01 20:22:57 +000032
33unsigned
Eli Friedman5e867c82013-07-10 00:30:46 +000034MangleNumberingContext::getManglingNumber(const BlockDecl *BD) {
Eli Friedman07369dd2013-07-01 20:22:57 +000035 // FIXME: Compute a BlockPointerType? Not obvious how.
36 const Type *Ty = 0;
37 return ++ManglingNumbers[Ty];
38}
Eli Friedman5e867c82013-07-10 00:30:46 +000039
40unsigned
Stephen Hines651f13c2014-04-23 16:59:28 -070041MangleNumberingContext::getStaticLocalNumber(const VarDecl *VD) {
42 // FIXME: Compute a BlockPointerType? Not obvious how.
43 const Type *Ty = 0;
44 return ++ManglingNumbers[Ty];
Eli Friedman5e867c82013-07-10 00:30:46 +000045}