Skip to content

Commit 94cafc3

Browse files
committed
[sil] Add an implicit operator bool conversion to SILDebugLocation.
The reason to do this is that one can now do: ``` if (auto debugLoc = i.getDebugLocation()) { // do something with debug loc. } ``` I also cleaned up the style a little bit by renaming the internal ivars to be camelCase.
1 parent 0c7894f commit 94cafc3

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

include/swift/SIL/SILLocation.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -755,17 +755,18 @@ class SILDebugScope;
755755

756756
/// A SILLocation paired with a SILDebugScope.
757757
class SILDebugLocation {
758-
const SILDebugScope *Scope = nullptr;
759-
SILLocation Location;
758+
const SILDebugScope *debugScope;
759+
SILLocation location;
760760

761761
public:
762762
SILDebugLocation()
763-
: Scope(nullptr),
764-
Location(RegularLocation::getAutoGeneratedLocation()) {}
765-
SILDebugLocation(SILLocation Loc, const SILDebugScope *DS)
766-
: Scope(DS), Location(Loc) {}
767-
SILLocation getLocation() const { return Location; }
768-
const SILDebugScope *getScope() const { return Scope; }
763+
: debugScope(nullptr),
764+
location(RegularLocation::getAutoGeneratedLocation()) {}
765+
SILDebugLocation(SILLocation location, const SILDebugScope *debugScope)
766+
: debugScope(debugScope), location(location) {}
767+
SILLocation getLocation() const { return location; }
768+
const SILDebugScope *getScope() const { return debugScope; }
769+
operator bool() const { return bool(location) && debugScope; }
769770
};
770771

771772
} // end swift namespace

0 commit comments

Comments
 (0)