Douglas Gregor | 9e8c92a | 2012-02-20 19:44:39 +0000 | [diff] [blame] | 1 | //===--- 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 | //===----------------------------------------------------------------------===// |
Benjamin Kramer | 478851c | 2012-07-04 17:04:04 +0000 | [diff] [blame] | 14 | |
Douglas Gregor | 9e8c92a | 2012-02-20 19:44:39 +0000 | [diff] [blame] | 15 | #include "clang/AST/LambdaMangleContext.h" |
Benjamin Kramer | 478851c | 2012-07-04 17:04:04 +0000 | [diff] [blame] | 16 | #include "clang/AST/ASTContext.h" |
Douglas Gregor | 9e8c92a | 2012-02-20 19:44:39 +0000 | [diff] [blame] | 17 | #include "clang/AST/DeclCXX.h" |
| 18 | |
| 19 | using namespace clang; |
| 20 | |
| 21 | unsigned LambdaMangleContext::getManglingNumber(CXXMethodDecl *CallOperator) { |
| 22 | const FunctionProtoType *Proto |
| 23 | = CallOperator->getType()->getAs<FunctionProtoType>(); |
| 24 | ASTContext &Context = CallOperator->getASTContext(); |
| 25 | |
Jordan Rose | bea522f | 2013-03-08 21:51:21 +0000 | [diff] [blame] | 26 | QualType Key = |
| 27 | Context.getFunctionType(Context.VoidTy, |
| 28 | ArrayRef<QualType>(Proto->arg_type_begin(), |
| 29 | Proto->getNumArgs()), |
| 30 | FunctionProtoType::ExtProtoInfo()); |
Douglas Gregor | 9e8c92a | 2012-02-20 19:44:39 +0000 | [diff] [blame] | 31 | Key = Context.getCanonicalType(Key); |
| 32 | return ++ManglingNumbers[Key->castAs<FunctionProtoType>()]; |
| 33 | } |