Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions clang/lib/CodeGen/CodeGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3041,9 +3041,12 @@ void CodeGenModule::createFunctionTypeMetadataForIcall(const FunctionDecl *FD,
if (isa<CXXMethodDecl>(FD) && !cast<CXXMethodDecl>(FD)->isStatic())
return;

llvm::Metadata *MD = CreateMetadataIdentifierForType(FD->getType());
QualType FnType = FD->getType();
llvm::Metadata *MD = CreateMetadataIdentifierForType(FnType);
F->addTypeMetadata(0, MD);
F->addTypeMetadata(0, CreateMetadataIdentifierGeneralized(FD->getType()));

QualType GenPtrFnType = GeneralizeFunctionType(getContext(), FD->getType());
F->addTypeMetadata(0, CreateMetadataIdentifierGeneralized(GenPtrFnType));

// Emit a hash-based bit set entry for cross-DSO calls.
if (CodeGenOpts.SanitizeCfiCrossDso)
Expand Down Expand Up @@ -7936,8 +7939,10 @@ CodeGenModule::CreateMetadataIdentifierImpl(QualType T, MetadataTypeMap &Map,

llvm::Metadata *CodeGenModule::CreateMetadataIdentifierForFnType(QualType T) {
assert(isa<FunctionType>(T));
if (getCodeGenOpts().SanitizeCfiICallGeneralizePointers)
if (getCodeGenOpts().SanitizeCfiICallGeneralizePointers) {
T = GeneralizeFunctionType(getContext(), T);
return CreateMetadataIdentifierGeneralized(T);
}
return CreateMetadataIdentifierForType(T);
}

Expand All @@ -7951,8 +7956,8 @@ CodeGenModule::CreateMetadataIdentifierForVirtualMemPtrType(QualType T) {
}

llvm::Metadata *CodeGenModule::CreateMetadataIdentifierGeneralized(QualType T) {
return CreateMetadataIdentifierImpl(GeneralizeFunctionType(getContext(), T),
GeneralizedMetadataIdMap, ".generalized");
return CreateMetadataIdentifierImpl(T, GeneralizedMetadataIdMap,
".generalized");
}

/// Returns whether this module needs the "all-vtables" type identifier.
Expand Down
Loading