Skip to content

Commit f8f7139

Browse files
authored
Merge pull request #24416 from adrian-prantl/50349713
2 parents 20dd808 + e63caa4 commit f8f7139

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
@@ -2134,10 +2134,6 @@ void IRGenDebugInfoImpl::emitVariableDeclaration(
21342134
IRBuilder &Builder, ArrayRef<llvm::Value *> Storage, DebugTypeInfo DbgTy,
21352135
const SILDebugScope *DS, ValueDecl *VarDecl, StringRef Name, unsigned ArgNo,
21362136
IndirectionKind Indirection, ArtificialKind Artificial) {
2137-
// Self is always an artificial argument.
2138-
if (ArgNo > 0 && Name == IGM.Context.Id_self.str())
2139-
Artificial = ArtificialValue;
2140-
21412137
// FIXME: Make this an assertion.
21422138
// assert(DS && "variable has no scope");
21432139
if (!DS)
@@ -2169,10 +2165,15 @@ void IRGenDebugInfoImpl::emitVariableDeclaration(
21692165
assert(DITy && "could not determine debug type of variable");
21702166

21712167
unsigned Line = Loc.Line;
2168+
2169+
// Self is always an artificial argument, so are variables without location.
2170+
if (!Line || (ArgNo > 0 && Name == IGM.Context.Id_self.str()))
2171+
Artificial = ArtificialValue;
2172+
21722173
llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
21732174
if (Artificial || DITy->isArtificial() || DITy == InternalType)
21742175
Flags |= llvm::DINode::FlagArtificial;
2175-
2176+
21762177
// This could be Opts.Optimize if we would also unique DIVariables here.
21772178
bool Optimized = false;
21782179
// 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)