Skip to content
Open
Show file tree
Hide file tree
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
12 changes: 11 additions & 1 deletion clang/lib/CodeGen/CodeGenFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,17 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
// fast register allocator would be happier...
CXXThisValue = CXXABIThisValue;
}

if (CGM.getCodeGenOpts().StrictVTablePointers) {
const CXXRecordDecl *ThisRecordDecl = MD->getParent();
bool IsPolymorphicObject = ThisRecordDecl->isPolymorphic();
bool IsStructor = isa<CXXDestructorDecl, CXXConstructorDecl>(MD);
bool IsFinal = ThisRecordDecl->isEffectivelyFinal();
// We do not care about whether this is a virtual method, because even
// if the current method is not virtual, it may be calling another method
// that calls a virtual function.
if (IsPolymorphicObject && !IsStructor && IsFinal)
EmitVTableAssumptionLoads(ThisRecordDecl, LoadCXXThisAddress());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we use EmitVTableAssumptionLoads, we should add test for cases it has multiple virtual tables.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call, will do, and virtual inheritance

}
// Check the 'this' pointer once per function, if it's available.
if (CXXABIThisValue) {
SanitizerSet SkippedChecks;
Expand Down
Loading
Loading