From 25a80bf9b6a4c01eb50dacac5007262c09eca6e0 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Tue, 8 Sep 2015 23:01:30 +0000 Subject: CodeGen: Introduce CodeGenModule::CreateMetadataIdentifierForType. This function can be used to create a metadata identifier for a specific type. No functionality change, but this will be used by D11857 and D12026. Differential Revision: http://reviews.llvm.org/D12038 llvm-svn: 247098 --- clang/lib/CodeGen/CodeGenModule.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index e76ee12..a2d554b 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -3803,6 +3803,25 @@ void CodeGenModule::EmitOMPThreadPrivateDecl(const OMPThreadPrivateDecl *D) { } } +llvm::Metadata *CodeGenModule::CreateMetadataIdentifierForType(QualType T) { + llvm::Metadata *&InternalId = MetadataIdMap[T.getCanonicalType()]; + if (InternalId) + return InternalId; + + if (isExternallyVisible(T->getLinkage())) { + std::string OutName; + llvm::raw_string_ostream Out(OutName); + getCXXABI().getMangleContext().mangleTypeName(T, Out); + + InternalId = llvm::MDString::get(getLLVMContext(), Out.str()); + } else { + InternalId = llvm::MDNode::getDistinct(getLLVMContext(), + llvm::ArrayRef()); + } + + return InternalId; +} + llvm::MDTuple *CodeGenModule::CreateVTableBitSetEntry( llvm::GlobalVariable *VTable, CharUnits Offset, const CXXRecordDecl *RD) { std::string OutName; -- cgit v1.1