diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-05-25 17:04:15 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-05-25 17:04:15 +0000 |
commit | 35415f5132f70ad5097a3514ab84251e10db3664 (patch) | |
tree | 43c52ced8c327cc5d16c565af87722a3a3a1e435 /lib/CodeGen/Mangle.h | |
parent | 1f90622e9d24064164df1608ea125d0ed451ac68 (diff) |
Improve name mangling for blocks and support mangling of static local
variables within blocks. We loosely follow GCC's mangling, but since
these are always internal symbols the names don't really matter. I
intend to revisit block mangling later, because GCC's mangling is
rather verbose. <rdar://problem/8015719>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104610 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/Mangle.h')
-rw-r--r-- | lib/CodeGen/Mangle.h | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/CodeGen/Mangle.h b/lib/CodeGen/Mangle.h index da3626fc5d..04f5dd6b21 100644 --- a/lib/CodeGen/Mangle.h +++ b/lib/CodeGen/Mangle.h @@ -26,6 +26,7 @@ namespace clang { class ASTContext; + class BlockDecl; class CXXConstructorDecl; class CXXDestructorDecl; class CXXMethodDecl; @@ -73,6 +74,8 @@ class MangleContext { llvm::DenseMap<const TagDecl *, uint64_t> AnonStructIds; unsigned Discriminator; llvm::DenseMap<const NamedDecl*, unsigned> Uniquifier; + llvm::DenseMap<const BlockDecl*, unsigned> GlobalBlockIds; + llvm::DenseMap<const BlockDecl*, unsigned> LocalBlockIds; public: explicit MangleContext(ASTContext &Context, @@ -83,6 +86,8 @@ public: Diagnostic &getDiags() const { return Diags; } + void startNewFunction() { LocalBlockIds.clear(); } + uint64_t getAnonymousStructId(const TagDecl *TD) { std::pair<llvm::DenseMap<const TagDecl *, uint64_t>::iterator, bool> Result = @@ -90,11 +95,18 @@ public: return Result.first->second; } + unsigned getBlockId(const BlockDecl *BD, bool Local) { + llvm::DenseMap<const BlockDecl *, unsigned> &BlockIds + = Local? LocalBlockIds : GlobalBlockIds; + std::pair<llvm::DenseMap<const BlockDecl *, unsigned>::iterator, bool> + Result = BlockIds.insert(std::make_pair(BD, BlockIds.size())); + return Result.first->second; + } + /// @name Mangler Entry Points /// @{ bool shouldMangleDeclName(const NamedDecl *D); - void mangleName(const NamedDecl *D, llvm::SmallVectorImpl<char> &); void mangleThunk(const CXXMethodDecl *MD, const ThunkInfo &Thunk, @@ -114,7 +126,8 @@ public: llvm::SmallVectorImpl<char> &); void mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type, llvm::SmallVectorImpl<char> &); - + void mangleBlock(const BlockDecl *BD, llvm::SmallVectorImpl<char> &); + void mangleInitDiscriminator() { Discriminator = 0; } |