File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -327,6 +327,34 @@ struct DebugVarCarryingInst {
327
327
}
328
328
};
329
329
330
+ // / Attempt to discover a StringRef varName for the value \p value. If we fail,
331
+ // / we return the name "unknown".
332
+ inline StringRef getDebugVarName (SILValue value) {
333
+ if (auto *asi = dyn_cast<AllocStackInst>(value)) {
334
+ DebugVarCarryingInst debugVar (asi);
335
+ if (auto varInfo = debugVar.getVarInfo ()) {
336
+ return varInfo->Name ;
337
+ } else {
338
+ if (auto *decl = debugVar.getDecl ()) {
339
+ return decl->getBaseName ().userFacingName ();
340
+ }
341
+ }
342
+ }
343
+
344
+ StringRef varName = " unknown" ;
345
+ if (auto *use = getSingleDebugUse (value)) {
346
+ DebugVarCarryingInst debugVar (use->getUser ());
347
+ if (auto varInfo = debugVar.getVarInfo ()) {
348
+ varName = varInfo->Name ;
349
+ } else {
350
+ if (auto *decl = debugVar.getDecl ()) {
351
+ varName = decl->getBaseName ().userFacingName ();
352
+ }
353
+ }
354
+ }
355
+ return varName;
356
+ }
357
+
330
358
} // end namespace swift
331
359
332
360
#endif // SWIFT_SIL_DEBUGUTILS_H
You can’t perform that action at this time.
0 commit comments