Skip to content

Commit 088a5f2

Browse files
ojhuntahmedbougacha
authored andcommitted
Address review comments
1 parent 208a547 commit 088a5f2

File tree

10 files changed

+54
-43
lines changed

10 files changed

+54
-43
lines changed

clang/include/clang/Basic/Thunk.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,20 +169,17 @@ struct ThunkInfo {
169169
/// CAUTION: In the unlikely event you need to sort ThunkInfos, consider using
170170
/// an ABI-specific comparator.
171171
const CXXMethodDecl *Method;
172-
const Type *ThisType { nullptr };
172+
const Type *ThisType{nullptr};
173173

174174
ThunkInfo() : Method(nullptr) {}
175175

176176
ThunkInfo(const ThisAdjustment &This, const ReturnAdjustment &Return,
177-
const Type *thisType,
178-
const CXXMethodDecl *Method = nullptr)
179-
: This(This), Return(Return), Method(Method),
180-
ThisType(thisType) {}
177+
const Type *thisType, const CXXMethodDecl *Method = nullptr)
178+
: This(This), Return(Return), Method(Method), ThisType(thisType) {}
181179

182180
friend bool operator==(const ThunkInfo &LHS, const ThunkInfo &RHS) {
183181
return LHS.This == RHS.This && LHS.Return == RHS.Return &&
184-
LHS.Method == RHS.Method &&
185-
LHS.ThisType == RHS.ThisType;
182+
LHS.Method == RHS.Method && LHS.ThisType == RHS.ThisType;
186183
}
187184

188185
bool isEmpty() const {

clang/lib/AST/ItaniumMangle.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7043,6 +7043,21 @@ void ItaniumMangleContextImpl::mangleCXXDtorComdat(const CXXDestructorDecl *D,
70437043
Mangler.mangle(GlobalDecl(D, Dtor_Comdat));
70447044
}
70457045

7046+
/// Mangles the pointer authentication override attribute for classes
7047+
/// that have explicit overrides for the vtable authentication schema.
7048+
///
7049+
/// The override is mangled as a parameterized vendor extension as follows
7050+
///
7051+
/// <type> ::= U "__vtptrauth" I
7052+
/// <key>
7053+
/// <addressDiscriminated>
7054+
/// <extraDiscriminator>
7055+
/// E
7056+
///
7057+
/// The extra discriminator encodes the explicit value derived from the
7058+
/// override schema, e.g. if the override has specified type based
7059+
/// discrimination the encoded value will be the discriminator derived from the
7060+
/// type name.
70467061
static void mangleOverrideDiscrimination(CXXNameMangler &mangler,
70477062
ASTContext &context,
70487063
const ThunkInfo &thunk) {

clang/lib/AST/VTableBuilder.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3190,8 +3190,7 @@ void VFTableBuilder::AddMethods(BaseSubobject Base, unsigned BaseDepth,
31903190
}
31913191
auto ThisType = (OverriddenMD ? OverriddenMD : MD)->getThisType().getTypePtr();
31923192
AddMethod(FinalOverriderMD,
3193-
ThunkInfo(ThisAdjustmentOffset, ReturnAdjustment,
3194-
thisType,
3193+
ThunkInfo(ThisAdjustmentOffset, ReturnAdjustment, ThisType,
31953194
ForceReturnAdjustmentMangling ? MD : nullptr));
31963195
}
31973196
}

clang/lib/CodeGen/CGClass.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2588,10 +2588,10 @@ void CodeGenFunction::InitializeVTablePointer(const VPtr &Vptr) {
25882588
// the same addr space. Note that this might not be LLVM address space 0.
25892589
VTableField = VTableField.withElementType(PtrTy);
25902590

2591-
if (auto authenticationInfo = CGM.getVTablePointerAuthInfo(
2591+
if (auto AuthenticationInfo = CGM.getVTablePointerAuthInfo(
25922592
this, Vptr.Base.getBase(), VTableField.emitRawPointer(*this))) {
25932593
VTableAddressPoint =
2594-
EmitPointerAuthSign(*authenticationInfo, VTableAddressPoint);
2594+
EmitPointerAuthSign(*AuthenticationInfo, VTableAddressPoint);
25952595
}
25962596

25972597
llvm::StoreInst *Store = Builder.CreateStore(VTableAddressPoint, VTableField);
@@ -2688,18 +2688,18 @@ void CodeGenFunction::InitializeVTablePointers(const CXXRecordDecl *RD) {
26882688
llvm::Value *CodeGenFunction::GetVTablePtr(Address This,
26892689
llvm::Type *VTableTy,
26902690
const CXXRecordDecl *RD,
2691-
VTableAuthMode authMode) {
2691+
VTableAuthMode AuthMode) {
26922692
Address VTablePtrSrc = This.withElementType(VTableTy);
26932693
llvm::Instruction *VTable = Builder.CreateLoad(VTablePtrSrc, "vtable");
26942694
TBAAAccessInfo TBAAInfo = CGM.getTBAAVTablePtrAccessInfo(VTableTy);
26952695
CGM.DecorateInstructionWithTBAA(VTable, TBAAInfo);
26962696

2697-
if (auto authenticationInfo =
2697+
if (auto AuthenticationInfo =
26982698
CGM.getVTablePointerAuthInfo(this, RD, This.emitRawPointer(*this))) {
2699-
if (authMode != VTableAuthMode::UnsafeUbsanStrip) {
2699+
if (AuthMode != VTableAuthMode::UnsafeUbsanStrip) {
27002700
VTable = cast<llvm::Instruction>(
2701-
EmitPointerAuthAuth(*authenticationInfo, VTable));
2702-
if (authMode == VTableAuthMode::MustTrap) {
2701+
EmitPointerAuthAuth(*AuthenticationInfo, VTable));
2702+
if (AuthMode == VTableAuthMode::MustTrap) {
27032703
// This is clearly suboptimal but until we have an ability
27042704
// to rely on the authentication intrinsic trapping and force
27052705
// an authentication to occur we don't really have a choice.

clang/lib/CodeGen/CGExprConstant.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -803,10 +803,10 @@ bool ConstStructBuilder::Build(const APValue &Val, const RecordDecl *RD,
803803
llvm::Constant *VTableAddressPoint =
804804
CGM.getCXXABI().getVTableAddressPoint(BaseSubobject(CD, Offset),
805805
VTableClass);
806-
if (auto authentication =
806+
if (auto Authentication =
807807
CGM.getVTablePointerAuthentication(VTableClass)) {
808808
VTableAddressPoint = Emitter.tryEmitConstantSignedPointer(
809-
VTableAddressPoint, *authentication);
809+
VTableAddressPoint, *Authentication);
810810
if (!VTableAddressPoint) {
811811
return false;
812812
}

clang/lib/CodeGen/CGVTT.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ CodeGenVTables::EmitVTTDefinition(llvm::GlobalVariable *VTT,
9090
llvm::Constant *Init = llvm::ConstantExpr::getGetElementPtr(
9191
VTable->getValueType(), VTable, Idxs, /*InBounds=*/true, InRange);
9292

93-
if (auto &schema =
93+
if (const auto &Schema =
9494
CGM.getCodeGenOpts().PointerAuth.CXXVTTVTablePointers)
95-
Init = CGM.getConstantSignedPointer(Init, schema, nullptr, GlobalDecl(),
95+
Init = CGM.getConstantSignedPointer(Init, Schema, nullptr, GlobalDecl(),
9696
QualType());
9797

9898
VTTComponents.push_back(Init);

clang/lib/CodeGen/CGVTables.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,9 @@ CodeGenFunction::GenerateVarArgsThunk(llvm::Function *Fn,
220220
// Adjust "this", if necessary.
221221
Builder.SetInsertPoint(&*ThisStore);
222222

223-
const CXXRecordDecl *thisValueClass = Thunk.ThisType->getPointeeCXXRecordDecl();
223+
const CXXRecordDecl *ThisValueClass = Thunk.ThisType->getPointeeCXXRecordDecl();
224224
llvm::Value *AdjustedThisPtr = CGM.getCXXABI().performThisAdjustment(
225-
*this, ThisPtr, thisValueClass, Thunk);
225+
*this, ThisPtr, ThisValueClass, Thunk);
226226
AdjustedThisPtr = Builder.CreateBitCast(AdjustedThisPtr,
227227
ThisStore->getOperand(0)->getType());
228228
ThisStore->setOperand(0, AdjustedThisPtr);
@@ -309,14 +309,14 @@ void CodeGenFunction::EmitCallAndReturnForThunk(llvm::FunctionCallee Callee,
309309
const CXXMethodDecl *MD = cast<CXXMethodDecl>(CurGD.getDecl());
310310

311311
// Adjust the 'this' pointer if necessary
312-
const CXXRecordDecl *thisValueClass =
312+
const CXXRecordDecl *ThisValueClass =
313313
MD->getThisType()->getPointeeCXXRecordDecl();
314314
if (Thunk)
315-
thisValueClass = Thunk->ThisType->getPointeeCXXRecordDecl();
315+
ThisValueClass = Thunk->ThisType->getPointeeCXXRecordDecl();
316316

317317
llvm::Value *AdjustedThisPtr =
318318
Thunk ? CGM.getCXXABI().performThisAdjustment(*this, LoadCXXThisAddress(),
319-
thisValueClass, *Thunk)
319+
ThisValueClass, *Thunk)
320320
: LoadCXXThis();
321321

322322
// If perfect forwarding is required a variadic method, a method using
@@ -866,9 +866,9 @@ void CodeGenVTables::addVTableComponent(ConstantArrayBuilder &builder,
866866
if (FnAS != GVAS)
867867
fnPtr =
868868
llvm::ConstantExpr::getAddrSpaceCast(fnPtr, CGM.GlobalsInt8PtrTy);
869-
if (auto &schema =
869+
if (const auto &Schema =
870870
CGM.getCodeGenOpts().PointerAuth.CXXVirtualFunctionPointers)
871-
return builder.addSignedPointer(fnPtr, schema, GD, QualType());
871+
return builder.addSignedPointer(fnPtr, Schema, GD, QualType());
872872
return builder.add(fnPtr);
873873
}
874874
}

clang/lib/CodeGen/CodeGenFunction.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2466,7 +2466,7 @@ class CodeGenFunction : public CodeGenTypeCache {
24662466
llvm::Value *
24672467
GetVTablePtr(Address This, llvm::Type *VTableTy,
24682468
const CXXRecordDecl *VTableClass,
2469-
VTableAuthMode authMode = VTableAuthMode::Authenticate);
2469+
VTableAuthMode AuthMode = VTableAuthMode::Authenticate);
24702470

24712471
enum CFITypeCheckKind {
24722472
CFITCK_VCall,
@@ -4428,17 +4428,17 @@ class CodeGenFunction : public CodeGenTypeCache {
44284428
bool isPointerKnownNonNull(const Expr *E);
44294429

44304430
/// Create the discriminator from the storage address and the entity hash.
4431-
llvm::Value *EmitPointerAuthBlendDiscriminator(llvm::Value *storageAddress,
4432-
llvm::Value *discriminator);
4431+
llvm::Value *EmitPointerAuthBlendDiscriminator(llvm::Value *StorageAddress,
4432+
llvm::Value *Discriminator);
44334433
CGPointerAuthInfo EmitPointerAuthInfo(const PointerAuthSchema &schema,
44344434
llvm::Value *storageAddress,
44354435
GlobalDecl calleeDecl,
44364436
QualType calleeType);
4437-
llvm::Value *EmitPointerAuthSign(QualType pointeeType, llvm::Value *pointer);
4438-
llvm::Value *EmitPointerAuthSign(const CGPointerAuthInfo &info,
4439-
llvm::Value *pointer);
4440-
llvm::Value *EmitPointerAuthAuth(const CGPointerAuthInfo &info,
4441-
llvm::Value *pointer);
4437+
llvm::Value *EmitPointerAuthSign(QualType PointeeType, llvm::Value *Pointer);
4438+
llvm::Value *EmitPointerAuthSign(const CGPointerAuthInfo &Info,
4439+
llvm::Value *Pointer);
4440+
llvm::Value *EmitPointerAuthAuth(const CGPointerAuthInfo &Info,
4441+
llvm::Value *Pointer);
44424442

44434443
void EmitPointerAuthOperandBundle(
44444444
const CGPointerAuthInfo &Info,

clang/lib/CodeGen/CodeGenModule.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ class CodeGenModule : public CodeGenTypeCache {
614614
llvm::DenseMap<const CXXRecordDecl *, std::optional<PointerAuthQualifier>>
615615
VTablePtrAuthInfos;
616616
std::optional<PointerAuthQualifier>
617-
computeVTPointerAuthentication(const CXXRecordDecl *thisClass);
617+
computeVTPointerAuthentication(const CXXRecordDecl *ThisClass);
618618

619619
public:
620620
CodeGenModule(ASTContext &C, IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS,
@@ -970,14 +970,14 @@ class CodeGenModule : public CodeGenTypeCache {
970970
llvm::ConstantInt *OtherDiscriminator);
971971

972972
llvm::ConstantInt *
973-
getPointerAuthOtherDiscriminator(const PointerAuthSchema &schema,
974-
GlobalDecl schemaDecl, QualType schemaType);
973+
getPointerAuthOtherDiscriminator(const PointerAuthSchema &Schema,
974+
GlobalDecl SchemaDecl, QualType SchemaType);
975975

976976
uint16_t getPointerAuthDeclDiscriminator(GlobalDecl GD);
977977
std::optional<CGPointerAuthInfo>
978-
getVTablePointerAuthInfo(CodeGenFunction *context,
979-
const CXXRecordDecl *record,
980-
llvm::Value *storageAddress);
978+
getVTablePointerAuthInfo(CodeGenFunction *Context,
979+
const CXXRecordDecl *Record,
980+
llvm::Value *StorageAddress);
981981

982982
std::optional<PointerAuthQualifier>
983983
getVTablePointerAuthentication(const CXXRecordDecl *thisClass);

clang/lib/CodeGen/ConstantEmitter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ class ConstantEmitter {
113113
llvm::Constant *tryEmitAbstract(const APValue &value, QualType T);
114114
llvm::Constant *tryEmitAbstractForMemory(const APValue &value, QualType T);
115115

116-
llvm::Constant *tryEmitConstantSignedPointer(llvm::Constant *ptr,
117-
PointerAuthQualifier auth);
116+
llvm::Constant *tryEmitConstantSignedPointer(llvm::Constant *Ptr,
117+
PointerAuthQualifier Auth);
118118

119119
llvm::Constant *tryEmitConstantExpr(const ConstantExpr *CE);
120120

0 commit comments

Comments
 (0)