Skip to content

Commit e0fb8f3

Browse files
committed
Debug Info: Mark variables without source location as artificial.
rdar://problem/50349713 (cherry picked from commit e63caa4)
1 parent 5e36f55 commit e0fb8f3

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2123,10 +2123,6 @@ void IRGenDebugInfoImpl::emitVariableDeclaration(
21232123
IRBuilder &Builder, ArrayRef<llvm::Value *> Storage, DebugTypeInfo DbgTy,
21242124
const SILDebugScope *DS, ValueDecl *VarDecl, StringRef Name, unsigned ArgNo,
21252125
IndirectionKind Indirection, ArtificialKind Artificial) {
2126-
// Self is always an artificial argument.
2127-
if (ArgNo > 0 && Name == IGM.Context.Id_self.str())
2128-
Artificial = ArtificialValue;
2129-
21302126
// FIXME: Make this an assertion.
21312127
// assert(DS && "variable has no scope");
21322128
if (!DS)
@@ -2158,10 +2154,15 @@ void IRGenDebugInfoImpl::emitVariableDeclaration(
21582154
assert(DITy && "could not determine debug type of variable");
21592155

21602156
unsigned Line = Loc.Line;
2157+
2158+
// Self is always an artificial argument, so are variables without location.
2159+
if (!Line || (ArgNo > 0 && Name == IGM.Context.Id_self.str()))
2160+
Artificial = ArtificialValue;
2161+
21612162
llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
21622163
if (Artificial || DITy->isArtificial() || DITy == InternalType)
21632164
Flags |= llvm::DINode::FlagArtificial;
2164-
2165+
21652166
// This could be Opts.Optimize if we would also unique DIVariables here.
21662167
bool Optimized = false;
21672168
// Create the descriptor for the variable.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %target-swift-frontend %s -emit-ir -g -o - | %FileCheck %s
2+
func markUsed<T>(_ t: T) {}
3+
4+
public func f() {
5+
// CHECK: !DILocalVariable(name: "$interpolation",
6+
// CHECK-SAME: flags: DIFlagArtificial)
7+
let world = "World"
8+
var s = "Hello \(world)!"
9+
markUsed(s)
10+
}
11+
f()

0 commit comments

Comments
 (0)