Skip to content

Commit d4be529

Browse files
smanna12Fznamznon
authored andcommitted
Address review commnets
1 parent 733b225 commit d4be529

File tree

4 files changed

+21
-54
lines changed

4 files changed

+21
-54
lines changed

clang/include/clang/Basic/ABI.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ enum CXXCtorType {
3131

3232
/// C++ destructor types.
3333
enum CXXDtorType {
34-
Dtor_Deleting, ///< Deleting dtor
35-
Dtor_Complete, ///< Complete object dtor
36-
Dtor_Base, ///< Base object dtor
37-
Dtor_Comdat, ///< The COMDAT used for dtors
34+
Dtor_Deleting, ///< Deleting dtor
35+
Dtor_Complete, ///< Complete object dtor
36+
Dtor_Base, ///< Base object dtor
37+
Dtor_Comdat, ///< The COMDAT used for dtors
3838
Dtor_VectorDeleting ///< Vector deleting dtor
3939
};
4040

clang/lib/AST/MicrosoftMangle.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,9 +1484,7 @@ void MicrosoftCXXNameMangler::mangleCXXDtorType(CXXDtorType T) {
14841484
// <operator-name> ::= ?_G # scalar deleting destructor
14851485
case Dtor_Deleting: Out << "?_G"; return;
14861486
// <operator-name> ::= ?_E # vector deleting destructor
1487-
case Dtor_VectorDeleting:
1488-
Out << "?_E";
1489-
return;
1487+
case Dtor_VectorDeleting: Out << "?_E"; return;
14901488
case Dtor_Comdat:
14911489
llvm_unreachable("not expecting a COMDAT");
14921490
}
@@ -2918,11 +2916,12 @@ void MicrosoftCXXNameMangler::mangleFunctionType(const FunctionType *T,
29182916
// ::= @ # structors (they have no declared return type)
29192917
if (IsStructor) {
29202918
if (isa<CXXDestructorDecl>(D) && isStructorDecl(D)) {
2921-
// The scalar deleting destructor takes an extra int argument which is not
2919+
// The deleting destructors take an extra argument of type int that indicates
2920+
// whether the storage for the object should be deleted and whether a single
2921+
// object or an array of objects is being destroyed. This extra argument is not
29222922
// reflected in the AST.
29232923
if (StructorType == Dtor_Deleting ||
29242924
StructorType == Dtor_VectorDeleting) {
2925-
// The deleting destructors take an extra int arguments.
29262925
Out << (PointersAre64Bit ? "PEAXI@Z" : "PAXI@Z");
29272926
return;
29282927
}

clang/lib/AST/VTableBuilder.cpp

Lines changed: 13 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,14 +1341,9 @@ void ItaniumVTableBuilder::AddMethod(const CXXMethodDecl *MD,
13411341
if (const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(MD)) {
13421342
assert(ReturnAdjustment.isEmpty() &&
13431343
"Destructor can't have return adjustment!");
1344-
if (!Context.getTargetInfo().getCXXABI().isMicrosoft()) {
1345-
// Add both the complete destructor and the deleting destructor.
1346-
Components.push_back(VTableComponent::MakeCompleteDtor(DD));
1347-
Components.push_back(VTableComponent::MakeDeletingDtor(DD));
1348-
} else {
1349-
// Add the vector deleting destructor.
1350-
Components.push_back(VTableComponent::MakeDeletingDtor(DD));
1351-
}
1344+
// Add both the complete destructor and the deleting destructor.
1345+
Components.push_back(VTableComponent::MakeCompleteDtor(DD));
1346+
Components.push_back(VTableComponent::MakeDeletingDtor(DD));
13521347
} else {
13531348
// Add the return adjustment if necessary.
13541349
if (!ReturnAdjustment.isEmpty())
@@ -1737,15 +1732,10 @@ void ItaniumVTableBuilder::LayoutPrimaryAndSecondaryVTables(
17371732
const CXXMethodDecl *MD = I.first;
17381733
const MethodInfo &MI = I.second;
17391734
if (const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(MD)) {
1740-
if (!Context.getTargetInfo().getCXXABI().isMicrosoft()) {
1741-
MethodVTableIndices[GlobalDecl(DD, Dtor_Complete)] =
1742-
MI.VTableIndex - AddressPoint;
1743-
MethodVTableIndices[GlobalDecl(DD, Dtor_Deleting)] =
1744-
MI.VTableIndex + 1 - AddressPoint;
1745-
} else {
1746-
MethodVTableIndices[GlobalDecl(DD, Dtor_VectorDeleting)] =
1747-
MI.VTableIndex + 1 - AddressPoint;
1748-
}
1735+
MethodVTableIndices[GlobalDecl(DD, Dtor_Complete)]
1736+
= MI.VTableIndex - AddressPoint;
1737+
MethodVTableIndices[GlobalDecl(DD, Dtor_Deleting)]
1738+
= MI.VTableIndex + 1 - AddressPoint;
17491739
} else {
17501740
MethodVTableIndices[MD] = MI.VTableIndex - AddressPoint;
17511741
}
@@ -2080,8 +2070,6 @@ void ItaniumVTableBuilder::dumpLayout(raw_ostream &Out) {
20802070
DD->printQualifiedName(Out);
20812071
if (IsComplete)
20822072
Out << "() [complete]";
2083-
else if (Context.getTargetInfo().getCXXABI().isMicrosoft())
2084-
Out << "() [vector deleting]";
20852073
else
20862074
Out << "() [deleting]";
20872075

@@ -2257,28 +2245,12 @@ void ItaniumVTableBuilder::dumpLayout(raw_ostream &Out) {
22572245
PredefinedIdentKind::PrettyFunctionNoVirtual, MD);
22582246

22592247
if (const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(MD)) {
2260-
if (!Context.getTargetInfo().getCXXABI().isMicrosoft()) {
2261-
// For Itanium ABI, add entries for both complete and deleting
2262-
// destructors.
2263-
GlobalDecl CompleteGD(DD, Dtor_Complete);
2264-
assert(MethodVTableIndices.count(CompleteGD));
2265-
uint64_t CompleteIndex = MethodVTableIndices[CompleteGD];
2266-
IndicesMap[CompleteIndex] = MethodName + " [complete]";
2267-
2268-
GlobalDecl DeletingGD(DD, Dtor_Deleting);
2269-
assert(MethodVTableIndices.count(DeletingGD));
2270-
uint64_t DeletingIndex = MethodVTableIndices[DeletingGD];
2271-
IndicesMap[DeletingIndex] = MethodName + " [deleting]";
2272-
} else {
2273-
// For Microsoft ABI, add an entry for the vector deleting destructor.
2274-
// Ensure that the index calculation is correct for the Microsoft ABI.
2275-
GlobalDecl VectorDeletingGD(DD, Dtor_VectorDeleting);
2276-
assert(MethodVTableIndices.count(VectorDeletingGD));
2277-
uint64_t VectorDeletingIndex = MethodVTableIndices[VectorDeletingGD];
2278-
IndicesMap[VectorDeletingIndex] = MethodName + " [vector deleting]";
2279-
}
2248+
GlobalDecl GD(DD, Dtor_Complete);
2249+
assert(MethodVTableIndices.count(GD));
2250+
uint64_t VTableIndex = MethodVTableIndices[GD];
2251+
IndicesMap[VTableIndex] = MethodName + " [complete]";
2252+
IndicesMap[VTableIndex + 1] = MethodName + " [deleting]";
22802253
} else {
2281-
// For other virtual member functions, add an entry with the method name.
22822254
assert(MethodVTableIndices.count(MD));
22832255
IndicesMap[MethodVTableIndices[MD]] = MethodName;
22842256
}
@@ -3790,7 +3762,7 @@ void MicrosoftVTableContext::dumpMethodLocations(
37903762
PredefinedIdentKind::PrettyFunctionNoVirtual, MD);
37913763

37923764
if (isa<CXXDestructorDecl>(MD)) {
3793-
IndicesMap[I.second] = MethodName + " [vector deleting]";
3765+
IndicesMap[I.second] = MethodName + " [deleting]";
37943766
} else {
37953767
IndicesMap[I.second] = MethodName;
37963768
}

clang/lib/CodeGen/CGCXX.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,6 @@ bool CodeGenModule::TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D) {
175175
// requires explicit comdat support in the IL.
176176
if (llvm::GlobalValue::isWeakForLinker(TargetLinkage))
177177
return true;
178-
/*
179-
EmitDefinitionAsAlias(AliasDecl, TargetDecl);
180-
return false;
181-
*/
182178
// Create the alias with no name.
183179
auto *Alias = llvm::GlobalAlias::create(AliasValueType, 0, Linkage, "",
184180
Aliasee, &getModule());

0 commit comments

Comments
 (0)