Skip to content

Commit a23c990

Browse files
committed
Merge SILFunction::Location into SILFunction::DebugScope::Loc.
NFC intended.
1 parent cf3fdff commit a23c990

File tree

4 files changed

+5
-22
lines changed

4 files changed

+5
-22
lines changed

include/swift/SIL/SILFunction.h

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,6 @@ class SILFunction
9898
/// function references.
9999
BlockListType BlockList;
100100

101-
/// The SIL location of the function, which provides a link back to the AST.
102-
/// The function only gets a location after it's been emitted.
103-
Optional<SILLocation> Location;
104-
105101
/// The declcontext of this function.
106102
DeclContext *DeclCtx;
107103

@@ -437,20 +433,17 @@ class SILFunction
437433
/// or is raw SIL (so that the mandatory passes still run).
438434
bool shouldOptimize() const;
439435

440-
/// Initialize the source location of the function.
441-
void setLocation(SILLocation L) { Location = L; }
442-
443436
/// Check if the function has a location.
444437
/// FIXME: All functions should have locations, so this method should not be
445438
/// necessary.
446439
bool hasLocation() const {
447-
return Location.hasValue();
440+
return DebugScope && !DebugScope->Loc.isNull();
448441
}
449442

450443
/// Get the source location of the function.
451444
SILLocation getLocation() const {
452-
assert(Location.hasValue());
453-
return Location.getValue();
445+
assert(DebugScope && "no scope/location");
446+
return getDebugScope()->Loc;
454447
}
455448

456449
/// Initialize the debug scope of the function.

lib/SIL/SILFunction.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ SILFunction::SILFunction(SILModule &Module, SILLinkage Linkage,
8989
LoweredType(LoweredType),
9090
// FIXME: Context params should be independent of the function type.
9191
ContextGenericParams(contextGenericParams),
92-
Location(Loc),
9392
DeclCtx(DC),
9493
DebugScope(DebugScope),
9594
Bare(isBareSILFunction),

lib/SILGen/SILGen.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -488,10 +488,7 @@ void SILGenModule::preEmitFunction(SILDeclRef constant,
488488
Types.getConstantInfo(constant).ContextGenericParams);
489489

490490
// Create a debug scope for the function using astNode as source location.
491-
F->setDebugScope(new (M) SILDebugScope(RegularLocation(astNode), F));
492-
493-
F->setLocation(Loc);
494-
491+
F->setDebugScope(new (M) SILDebugScope(Loc, F));
495492
F->setDeclContext(astNode);
496493

497494
DEBUG(llvm::dbgs() << "lowering ";
@@ -881,12 +878,8 @@ SILFunction *SILGenModule::emitLazyGlobalInitializer(StringRef funcName,
881878
makeModuleFragile
882879
? IsFragile
883880
: IsNotFragile);
884-
f->setDebugScope(
885-
new (M) SILDebugScope(RegularLocation(binding->getInit(pbdEntry)), f));
886-
f->setLocation(binding);
887-
881+
f->setDebugScope(new (M) SILDebugScope(RegularLocation(binding), f));
888882
SILGenFunction(*this, *f).emitLazyGlobalInitializer(binding, pbdEntry);
889-
890883
f->verify();
891884

892885
return f;

lib/Serialization/DeserializeSIL.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,6 @@ SILFunction *SILDeserializer::readSILFunction(DeclID FID,
461461
"SILFunction to be deserialized starts being empty.");
462462

463463
fn->setBare(IsBare);
464-
if (!fn->hasLocation()) fn->setLocation(loc);
465-
466464
const SILDebugScope *DS = fn->getDebugScope();
467465
if (!DS) {
468466
DS = new (SILMod) SILDebugScope(loc, fn);

0 commit comments

Comments
 (0)