Eli Friedman | 07369dd | 2013-07-01 20:22:57 +0000 | [diff] [blame] | 1 | //===--- MangleNumberingContext.cpp - Context for mangling numbers --------===// |
Douglas Gregor | 9e8c92a | 2012-02-20 19:44:39 +0000 | [diff] [blame] | 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 | |
Eli Friedman | 07369dd | 2013-07-01 20:22:57 +0000 | [diff] [blame] | 15 | #include "clang/AST/MangleNumberingContext.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 | |
Eli Friedman | 07369dd | 2013-07-01 20:22:57 +0000 | [diff] [blame] | 21 | unsigned |
Eli Friedman | 5e867c8 | 2013-07-10 00:30:46 +0000 | [diff] [blame] | 22 | MangleNumberingContext::getManglingNumber(const CXXMethodDecl *CallOperator) { |
Douglas Gregor | 9e8c92a | 2012-02-20 19:44:39 +0000 | [diff] [blame] | 23 | const FunctionProtoType *Proto |
| 24 | = CallOperator->getType()->getAs<FunctionProtoType>(); |
| 25 | ASTContext &Context = CallOperator->getASTContext(); |
Reid Kleckner | 0567a79 | 2013-06-10 20:51:09 +0000 | [diff] [blame] | 26 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame^] | 27 | QualType Key = Context.getFunctionType(Context.VoidTy, Proto->getParamTypes(), |
Reid Kleckner | 0567a79 | 2013-06-10 20:51:09 +0000 | [diff] [blame] | 28 | FunctionProtoType::ExtProtoInfo()); |
Douglas Gregor | 9e8c92a | 2012-02-20 19:44:39 +0000 | [diff] [blame] | 29 | Key = Context.getCanonicalType(Key); |
| 30 | return ++ManglingNumbers[Key->castAs<FunctionProtoType>()]; |
| 31 | } |
Eli Friedman | 07369dd | 2013-07-01 20:22:57 +0000 | [diff] [blame] | 32 | |
| 33 | unsigned |
Eli Friedman | 5e867c8 | 2013-07-10 00:30:46 +0000 | [diff] [blame] | 34 | MangleNumberingContext::getManglingNumber(const BlockDecl *BD) { |
Eli Friedman | 07369dd | 2013-07-01 20:22:57 +0000 | [diff] [blame] | 35 | // FIXME: Compute a BlockPointerType? Not obvious how. |
| 36 | const Type *Ty = 0; |
| 37 | return ++ManglingNumbers[Ty]; |
| 38 | } |
Eli Friedman | 5e867c8 | 2013-07-10 00:30:46 +0000 | [diff] [blame] | 39 | |
| 40 | unsigned |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame^] | 41 | MangleNumberingContext::getStaticLocalNumber(const VarDecl *VD) { |
| 42 | // FIXME: Compute a BlockPointerType? Not obvious how. |
| 43 | const Type *Ty = 0; |
| 44 | return ++ManglingNumbers[Ty]; |
Eli Friedman | 5e867c8 | 2013-07-10 00:30:46 +0000 | [diff] [blame] | 45 | } |