Skip to content

Commit dadc2b6

Browse files
committed
DebugInfo: Prepare for deletion of DIDescriptor subclasses
An upcoming LLVM commit will delete all the remaining subclasses of (the already deleted) `DIDescriptor`. Stop using them. llvm-svn: 235403
1 parent ec0bff9 commit dadc2b6

File tree

2 files changed

+47
-59
lines changed

2 files changed

+47
-59
lines changed

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 41 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,17 +1245,14 @@ CGDebugInfo::CollectTemplateParams(const TemplateParameterList *TPList,
12451245
switch (TA.getKind()) {
12461246
case TemplateArgument::Type: {
12471247
llvm::MDType *TTy = getOrCreateType(TA.getAsType(), Unit);
1248-
llvm::DITemplateTypeParameter TTP =
1249-
DBuilder.createTemplateTypeParameter(TheCU, Name, TTy);
1250-
TemplateParams.push_back(TTP);
1248+
TemplateParams.push_back(
1249+
DBuilder.createTemplateTypeParameter(TheCU, Name, TTy));
12511250
} break;
12521251
case TemplateArgument::Integral: {
12531252
llvm::MDType *TTy = getOrCreateType(TA.getIntegralType(), Unit);
1254-
llvm::DITemplateValueParameter TVP =
1255-
DBuilder.createTemplateValueParameter(
1256-
TheCU, Name, TTy,
1257-
llvm::ConstantInt::get(CGM.getLLVMContext(), TA.getAsIntegral()));
1258-
TemplateParams.push_back(TVP);
1253+
TemplateParams.push_back(DBuilder.createTemplateValueParameter(
1254+
TheCU, Name, TTy,
1255+
llvm::ConstantInt::get(CGM.getLLVMContext(), TA.getAsIntegral())));
12591256
} break;
12601257
case TemplateArgument::Declaration: {
12611258
const ValueDecl *D = TA.getAsDecl();
@@ -1284,11 +1281,9 @@ CGDebugInfo::CollectTemplateParams(const TemplateParameterList *TPList,
12841281
CGM.getContext().toCharUnitsFromBits((int64_t)fieldOffset);
12851282
V = CGM.getCXXABI().EmitMemberDataPointer(MPT, chars);
12861283
}
1287-
llvm::DITemplateValueParameter TVP =
1288-
DBuilder.createTemplateValueParameter(
1289-
TheCU, Name, TTy,
1290-
cast_or_null<llvm::Constant>(V->stripPointerCasts()));
1291-
TemplateParams.push_back(TVP);
1284+
TemplateParams.push_back(DBuilder.createTemplateValueParameter(
1285+
TheCU, Name, TTy,
1286+
cast_or_null<llvm::Constant>(V->stripPointerCasts())));
12921287
} break;
12931288
case TemplateArgument::NullPtr: {
12941289
QualType T = TA.getNullPtrType();
@@ -1307,25 +1302,19 @@ CGDebugInfo::CollectTemplateParams(const TemplateParameterList *TPList,
13071302
V = CGM.getCXXABI().EmitNullMemberPointer(MPT);
13081303
if (!V)
13091304
V = llvm::ConstantInt::get(CGM.Int8Ty, 0);
1310-
llvm::DITemplateValueParameter TVP =
1311-
DBuilder.createTemplateValueParameter(TheCU, Name, TTy,
1312-
cast<llvm::Constant>(V));
1313-
TemplateParams.push_back(TVP);
1305+
TemplateParams.push_back(DBuilder.createTemplateValueParameter(
1306+
TheCU, Name, TTy, cast<llvm::Constant>(V)));
13141307
} break;
1315-
case TemplateArgument::Template: {
1316-
llvm::DITemplateValueParameter TVP =
1317-
DBuilder.createTemplateTemplateParameter(
1318-
TheCU, Name, nullptr, TA.getAsTemplate()
1319-
.getAsTemplateDecl()
1320-
->getQualifiedNameAsString());
1321-
TemplateParams.push_back(TVP);
1322-
} break;
1323-
case TemplateArgument::Pack: {
1324-
llvm::DITemplateValueParameter TVP = DBuilder.createTemplateParameterPack(
1308+
case TemplateArgument::Template:
1309+
TemplateParams.push_back(DBuilder.createTemplateTemplateParameter(
13251310
TheCU, Name, nullptr,
1326-
CollectTemplateParams(nullptr, TA.getPackAsArray(), Unit));
1327-
TemplateParams.push_back(TVP);
1328-
} break;
1311+
TA.getAsTemplate().getAsTemplateDecl()->getQualifiedNameAsString()));
1312+
break;
1313+
case TemplateArgument::Pack:
1314+
TemplateParams.push_back(DBuilder.createTemplateParameterPack(
1315+
TheCU, Name, nullptr,
1316+
CollectTemplateParams(nullptr, TA.getPackAsArray(), Unit)));
1317+
break;
13291318
case TemplateArgument::Expression: {
13301319
const Expr *E = TA.getAsExpr();
13311320
QualType T = E->getType();
@@ -1334,10 +1323,8 @@ CGDebugInfo::CollectTemplateParams(const TemplateParameterList *TPList,
13341323
llvm::Constant *V = CGM.EmitConstantExpr(E, T);
13351324
assert(V && "Expression in template argument isn't constant");
13361325
llvm::MDType *TTy = getOrCreateType(T, Unit);
1337-
llvm::DITemplateValueParameter TVP =
1338-
DBuilder.createTemplateValueParameter(
1339-
TheCU, Name, TTy, cast<llvm::Constant>(V->stripPointerCasts()));
1340-
TemplateParams.push_back(TVP);
1326+
TemplateParams.push_back(DBuilder.createTemplateValueParameter(
1327+
TheCU, Name, TTy, cast<llvm::Constant>(V->stripPointerCasts())));
13411328
} break;
13421329
// And the following should never occur:
13431330
case TemplateArgument::TemplateExpansion:
@@ -1953,7 +1940,7 @@ llvm::MDType *CGDebugInfo::CreateTypeDefinition(const EnumType *Ty) {
19531940

19541941
SmallString<256> FullName = getUniqueTagTypeName(Ty, CGM, TheCU);
19551942

1956-
// Create DIEnumerator elements for each enumerator.
1943+
// Create elements for each enumerator.
19571944
SmallVector<llvm::Metadata *, 16> Enumerators;
19581945
ED = ED->getDefinition();
19591946
for (const auto *Enum : ED->enumerators()) {
@@ -2401,7 +2388,7 @@ CGDebugInfo::getFunctionForwardDeclaration(const FunctionDecl *FD) {
24012388
return SP;
24022389
}
24032390

2404-
llvm::DIGlobalVariable
2391+
llvm::MDGlobalVariable *
24052392
CGDebugInfo::getGlobalVariableForwardDeclaration(const VarDecl *VD) {
24062393
QualType T;
24072394
StringRef Name, LinkageName;
@@ -2411,11 +2398,9 @@ CGDebugInfo::getGlobalVariableForwardDeclaration(const VarDecl *VD) {
24112398
unsigned Line = getLineNumber(Loc);
24122399

24132400
collectVarDeclProps(VD, Unit, Line, T, Name, LinkageName, DContext);
2414-
llvm::DIGlobalVariable GV =
2415-
DBuilder.createTempGlobalVariableFwdDecl(DContext, Name, LinkageName, Unit,
2416-
Line, getOrCreateType(T, Unit),
2417-
!VD->isExternallyVisible(),
2418-
nullptr, nullptr);
2401+
auto *GV = DBuilder.createTempGlobalVariableFwdDecl(
2402+
DContext, Name, LinkageName, Unit, Line, getOrCreateType(T, Unit),
2403+
!VD->isExternallyVisible(), nullptr, nullptr);
24192404
FwdDeclReplaceMap.emplace_back(
24202405
std::piecewise_construct,
24212406
std::make_tuple(cast<VarDecl>(VD->getCanonicalDecl())),
@@ -2835,8 +2820,8 @@ void CGDebugInfo::EmitDeclare(const VarDecl *VD, llvm::dwarf::Tag Tag,
28352820
Expr.push_back(offset.getQuantity());
28362821

28372822
// Create the descriptor for the variable.
2838-
llvm::DIVariable D = DBuilder.createLocalVariable(
2839-
Tag, Scope, VD->getName(), Unit, Line, Ty, ArgNo);
2823+
auto *D = DBuilder.createLocalVariable(Tag, Scope, VD->getName(), Unit,
2824+
Line, Ty, ArgNo);
28402825

28412826
// Insert an llvm.dbg.declare into the current block.
28422827
DBuilder.insertDeclare(Storage, D, DBuilder.createExpression(Expr),
@@ -2859,7 +2844,7 @@ void CGDebugInfo::EmitDeclare(const VarDecl *VD, llvm::dwarf::Tag Tag,
28592844
continue;
28602845

28612846
// Use VarDecl's Tag, Scope and Line number.
2862-
llvm::DIVariable D = DBuilder.createLocalVariable(
2847+
auto *D = DBuilder.createLocalVariable(
28632848
Tag, Scope, FieldName, Unit, Line, FieldTy,
28642849
CGM.getLangOpts().Optimize, Flags, ArgNo);
28652850

@@ -2873,7 +2858,7 @@ void CGDebugInfo::EmitDeclare(const VarDecl *VD, llvm::dwarf::Tag Tag,
28732858
}
28742859

28752860
// Create the descriptor for the variable.
2876-
llvm::DIVariable D =
2861+
auto *D =
28772862
DBuilder.createLocalVariable(Tag, Scope, Name, Unit, Line, Ty,
28782863
CGM.getLangOpts().Optimize, Flags, ArgNo);
28792864

@@ -2958,7 +2943,7 @@ void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(
29582943
}
29592944

29602945
// Create the descriptor for the variable.
2961-
llvm::DIVariable D = DBuilder.createLocalVariable(
2946+
auto *D = DBuilder.createLocalVariable(
29622947
llvm::dwarf::DW_TAG_auto_variable,
29632948
cast<llvm::MDLocalScope>(LexicalBlockStack.back()), VD->getName(), Unit,
29642949
Line, Ty);
@@ -3121,7 +3106,7 @@ void CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block,
31213106
auto *scope = cast<llvm::MDLocalScope>(LexicalBlockStack.back());
31223107

31233108
// Create the descriptor for the parameter.
3124-
llvm::DIVariable debugVar = DBuilder.createLocalVariable(
3109+
auto *debugVar = DBuilder.createLocalVariable(
31253110
llvm::dwarf::DW_TAG_arg_variable, scope, Arg->getName(), tunit, line,
31263111
type, CGM.getLangOpts().Optimize, flags, ArgNo);
31273112

@@ -3162,10 +3147,10 @@ CGDebugInfo::getOrCreateStaticDataMemberDeclarationOrNull(const VarDecl *D) {
31623147
/// Recursively collect all of the member fields of a global anonymous decl and
31633148
/// create static variables for them. The first time this is called it needs
31643149
/// to be on a union and then from there we can have additional unnamed fields.
3165-
llvm::DIGlobalVariable CGDebugInfo::CollectAnonRecordDecls(
3150+
llvm::MDGlobalVariable *CGDebugInfo::CollectAnonRecordDecls(
31663151
const RecordDecl *RD, llvm::MDFile *Unit, unsigned LineNo,
31673152
StringRef LinkageName, llvm::GlobalVariable *Var, llvm::MDScope *DContext) {
3168-
llvm::DIGlobalVariable GV;
3153+
llvm::MDGlobalVariable *GV = nullptr;
31693154

31703155
for (const auto *Field : RD->fields()) {
31713156
llvm::MDType *FieldTy = getOrCreateType(Field->getType(), Unit);
@@ -3201,7 +3186,7 @@ void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
32013186

32023187
// Attempt to store one global variable for the declaration - even if we
32033188
// emit a lot of fields.
3204-
llvm::DIGlobalVariable GV;
3189+
llvm::MDGlobalVariable *GV = nullptr;
32053190

32063191
// If this is an anonymous union then we'll want to emit a global
32073192
// variable for each member of the anonymous union so that it's possible
@@ -3233,7 +3218,9 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD,
32333218
assert(isa<EnumType>(ED->getTypeForDecl()) && "Enum without EnumType?");
32343219
Ty = getOrCreateType(QualType(ED->getTypeForDecl(), 0), Unit);
32353220
}
3236-
// Do not use DIGlobalVariable for enums.
3221+
// Do not use global variables for enums.
3222+
//
3223+
// FIXME: why not?
32373224
if (Ty->getTag() == llvm::dwarf::DW_TAG_enumeration_type)
32383225
return;
32393226
// Do not emit separate definitions for function local const/statics.
@@ -3291,14 +3278,14 @@ void CGDebugInfo::EmitUsingDecl(const UsingDecl &UD) {
32913278
getLineNumber(USD.getLocation()));
32923279
}
32933280

3294-
llvm::DIImportedEntity
3281+
llvm::MDImportedEntity *
32953282
CGDebugInfo::EmitNamespaceAlias(const NamespaceAliasDecl &NA) {
32963283
if (CGM.getCodeGenOpts().getDebugInfo() < CodeGenOptions::LimitedDebugInfo)
3297-
return llvm::DIImportedEntity();
3284+
return nullptr;
32983285
auto &VH = NamespaceAliasCache[&NA];
32993286
if (VH)
33003287
return cast<llvm::MDImportedEntity>(VH);
3301-
llvm::DIImportedEntity R;
3288+
llvm::MDImportedEntity *R;
33023289
if (const NamespaceAliasDecl *Underlying =
33033290
dyn_cast<NamespaceAliasDecl>(NA.getAliasedNamespace()))
33043291
// This could cache & dedup here rather than relying on metadata deduping.

clang/lib/CodeGen/CGDebugInfo.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ class CGDebugInfo {
290290
void EmitUsingDecl(const UsingDecl &UD);
291291

292292
/// \brief Emit C++ namespace alias.
293-
llvm::DIImportedEntity EmitNamespaceAlias(const NamespaceAliasDecl &NA);
293+
llvm::MDImportedEntity *EmitNamespaceAlias(const NamespaceAliasDecl &NA);
294294

295295
/// \brief Emit record type's standalone debug info.
296296
llvm::MDType *getOrCreateRecordType(QualType Ty, SourceLocation L);
@@ -376,13 +376,14 @@ class CGDebugInfo {
376376
/// decalration represented in the given FunctionDecl.
377377
llvm::MDSubprogram *getFunctionForwardDeclaration(const FunctionDecl *FD);
378378

379-
/// \brief Create a DIGlobalVariable describing the forward
380-
/// decalration represented in the given VarDecl.
381-
llvm::DIGlobalVariable getGlobalVariableForwardDeclaration(const VarDecl *VD);
379+
/// \brief Create a global variable describing the forward decalration
380+
/// represented in the given VarDecl.
381+
llvm::MDGlobalVariable *
382+
getGlobalVariableForwardDeclaration(const VarDecl *VD);
382383

383384
/// Return a global variable that represents one of the collection of
384385
/// global variables created for an anonmyous union.
385-
llvm::DIGlobalVariable
386+
llvm::MDGlobalVariable *
386387
CollectAnonRecordDecls(const RecordDecl *RD, llvm::MDFile *Unit,
387388
unsigned LineNo, StringRef LinkageName,
388389
llvm::GlobalVariable *Var, llvm::MDScope *DContext);

0 commit comments

Comments
 (0)