From 53992adde3eda3ccf9da63bc7e45673f043de18f Mon Sep 17 00:00:00 2001 From: rdivacky Date: Thu, 27 May 2010 15:17:06 +0000 Subject: Update clang to r104832. --- lib/CodeGen/Mangle.h | 76 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 21 deletions(-) (limited to 'lib/CodeGen/Mangle.h') diff --git a/lib/CodeGen/Mangle.h b/lib/CodeGen/Mangle.h index da3626f..f1c5358 100644 --- a/lib/CodeGen/Mangle.h +++ b/lib/CodeGen/Mangle.h @@ -23,14 +23,17 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/SmallString.h" +#include "llvm/Support/raw_ostream.h" namespace clang { class ASTContext; + class BlockDecl; class CXXConstructorDecl; class CXXDestructorDecl; class CXXMethodDecl; class FunctionDecl; class NamedDecl; + class ObjCMethodDecl; class VarDecl; namespace CodeGen { @@ -63,7 +66,7 @@ private: llvm::StringRef String; llvm::SmallString<256> Buffer; }; - + /// MangleContext - Context for tracking state which persists across multiple /// calls to the C++ name mangler. class MangleContext { @@ -73,6 +76,8 @@ class MangleContext { llvm::DenseMap AnonStructIds; unsigned Discriminator; llvm::DenseMap Uniquifier; + llvm::DenseMap GlobalBlockIds; + llvm::DenseMap LocalBlockIds; public: explicit MangleContext(ASTContext &Context, @@ -83,6 +88,8 @@ public: Diagnostic &getDiags() const { return Diags; } + void startNewFunction() { LocalBlockIds.clear(); } + uint64_t getAnonymousStructId(const TagDecl *TD) { std::pair::iterator, bool> Result = @@ -90,31 +97,42 @@ public: return Result.first->second; } + unsigned getBlockId(const BlockDecl *BD, bool Local) { + llvm::DenseMap &BlockIds + = Local? LocalBlockIds : GlobalBlockIds; + std::pair::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 &); - void mangleThunk(const CXXMethodDecl *MD, - const ThunkInfo &Thunk, - llvm::SmallVectorImpl &); - void mangleCXXDtorThunk(const CXXDestructorDecl *DD, CXXDtorType Type, - const ThisAdjustment &ThisAdjustment, + virtual void mangleName(const NamedDecl *D, llvm::SmallVectorImpl &); + virtual void mangleThunk(const CXXMethodDecl *MD, + const ThunkInfo &Thunk, llvm::SmallVectorImpl &); - void mangleGuardVariable(const VarDecl *D, llvm::SmallVectorImpl &); - void mangleCXXVTable(const CXXRecordDecl *RD, llvm::SmallVectorImpl &); - void mangleCXXVTT(const CXXRecordDecl *RD, llvm::SmallVectorImpl &); - void mangleCXXCtorVTable(const CXXRecordDecl *RD, int64_t Offset, - const CXXRecordDecl *Type, - llvm::SmallVectorImpl &); - void mangleCXXRTTI(QualType T, llvm::SmallVectorImpl &); - void mangleCXXRTTIName(QualType T, llvm::SmallVectorImpl &); - void mangleCXXCtor(const CXXConstructorDecl *D, CXXCtorType Type, - llvm::SmallVectorImpl &); - void mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type, - llvm::SmallVectorImpl &); - + virtual void mangleCXXDtorThunk(const CXXDestructorDecl *DD, CXXDtorType Type, + const ThisAdjustment &ThisAdjustment, + llvm::SmallVectorImpl &); + virtual void mangleGuardVariable(const VarDecl *D, + llvm::SmallVectorImpl &); + virtual void mangleCXXVTable(const CXXRecordDecl *RD, + llvm::SmallVectorImpl &); + virtual void mangleCXXVTT(const CXXRecordDecl *RD, + llvm::SmallVectorImpl &); + virtual void mangleCXXCtorVTable(const CXXRecordDecl *RD, int64_t Offset, + const CXXRecordDecl *Type, + llvm::SmallVectorImpl &); + virtual void mangleCXXRTTI(QualType T, llvm::SmallVectorImpl &); + virtual void mangleCXXRTTIName(QualType T, llvm::SmallVectorImpl &); + virtual void mangleCXXCtor(const CXXConstructorDecl *D, CXXCtorType Type, + llvm::SmallVectorImpl &); + virtual void mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type, + llvm::SmallVectorImpl &); + void mangleBlock(const BlockDecl *BD, llvm::SmallVectorImpl &); + void mangleInitDiscriminator() { Discriminator = 0; } @@ -130,7 +148,23 @@ public: } /// @} }; + +/// MiscNameMangler - Mangles Objective-C method names and blocks. +class MiscNameMangler { + MangleContext &Context; + llvm::raw_svector_ostream Out; + ASTContext &getASTContext() const { return Context.getASTContext(); } + +public: + MiscNameMangler(MangleContext &C, llvm::SmallVectorImpl &Res); + + llvm::raw_svector_ostream &getStream() { return Out; } + + void mangleBlock(const BlockDecl *BD); + void mangleObjCMethodName(const ObjCMethodDecl *MD); +}; + } } -- cgit v1.1