Eli Friedman | 7e346a8 | 2013-07-01 20:22:57 +0000 | [diff] [blame] | 1 | //===--- MangleNumberingContext.cpp - Context for mangling numbers --------===// |
Douglas Gregor | 6379854 | 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 | 1ea8e09 | 2012-07-04 17:04:04 +0000 | [diff] [blame] | 14 | |
Eli Friedman | 7e346a8 | 2013-07-01 20:22:57 +0000 | [diff] [blame] | 15 | #include "clang/AST/MangleNumberingContext.h" |
Benjamin Kramer | 1ea8e09 | 2012-07-04 17:04:04 +0000 | [diff] [blame] | 16 | #include "clang/AST/ASTContext.h" |
Douglas Gregor | 6379854 | 2012-02-20 19:44:39 +0000 | [diff] [blame] | 17 | #include "clang/AST/DeclCXX.h" |
| 18 | |
| 19 | using namespace clang; |
| 20 | |
Eli Friedman | 7e346a8 | 2013-07-01 20:22:57 +0000 | [diff] [blame] | 21 | unsigned |
Eli Friedman | 3b7d46c | 2013-07-10 00:30:46 +0000 | [diff] [blame] | 22 | MangleNumberingContext::getManglingNumber(const CXXMethodDecl *CallOperator) { |
Douglas Gregor | 6379854 | 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 | 896b32f | 2013-06-10 20:51:09 +0000 | [diff] [blame] | 26 | |
| 27 | QualType Key = Context.getFunctionType(Context.VoidTy, Proto->getArgTypes(), |
| 28 | FunctionProtoType::ExtProtoInfo()); |
Douglas Gregor | 6379854 | 2012-02-20 19:44:39 +0000 | [diff] [blame] | 29 | Key = Context.getCanonicalType(Key); |
| 30 | return ++ManglingNumbers[Key->castAs<FunctionProtoType>()]; |
| 31 | } |
Eli Friedman | 7e346a8 | 2013-07-01 20:22:57 +0000 | [diff] [blame] | 32 | |
| 33 | unsigned |
Eli Friedman | 3b7d46c | 2013-07-10 00:30:46 +0000 | [diff] [blame] | 34 | MangleNumberingContext::getManglingNumber(const BlockDecl *BD) { |
Eli Friedman | 7e346a8 | 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 | 3b7d46c | 2013-07-10 00:30:46 +0000 | [diff] [blame] | 39 | |
| 40 | unsigned |
| 41 | MangleNumberingContext::getManglingNumber(const VarDecl *VD) { |
| 42 | return ++VarManglingNumbers[VD->getIdentifier()]; |
| 43 | } |
| 44 | |
| 45 | unsigned |
| 46 | MangleNumberingContext::getManglingNumber(const TagDecl *TD) { |
| 47 | return ++TagManglingNumbers[TD->getIdentifier()]; |
| 48 | } |